PDA

View Full Version : Digital Pot



Scott
- 12th September 2005, 22:08
I am looking at building a test board that using a Digital potentiometer such as the Analog devices AD5160 or the Microchip MCP42XXX to simulate a 10k ohm thermistor via software.

Can someone give me some pointers?
Has anyone attempted anything like this?

Any help would be great,
Scott

mister_e
- 12th September 2005, 22:23
Digital pot is one option BUT there's probably cheaper way to do it depending on how the Thermistor is place in the circuit. Generating a coltage with PWM and a op-amp buffer could do the same job.

BTW do you have a schematic of the Thermistor section you want to simulate?

Scott
- 12th September 2005, 22:36
Voltage will be supplied by another I/O board. I want to vary the resistance to simulate the changing of the temperature with the digital potentiometer. Does this make sense? I would like to place the board that will be simulating the 10k ohm thermistor in the same location as the real 10k ohm thermistor.

I am trying to simulate earlier captured data.

I do not have a schematic for the sensor!

Thanks,
Scott

mister_e
- 12th September 2005, 22:53
Sure it make sense no problem. Yes you can use Digital pot for that but you'll be limited to their own position/taps limitation.

Good luck.

CocaColaKid
- 13th September 2005, 14:18
Here's the code I wrote to control 5 digital pots daisy chained together.



DEFINE LOADER_USED 1 ' Bootloader is being used
DEFINE OSC 16 ' Set oscillator frequency, 4MHz (HS_PLL x4)
DEFINE HSER_BAUD 9600 ' Baud rate for serial output
DEFINE HSER_CLROERR 1 ' Automatically clear over-run errors
DEFINE HSER_RCSTA 90h ' Enable USART receive
DEFINE HSER_TXSTA 24h ' TXSTA=%00100100. TX enable, BRGH=1 for high-speed

@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
' Oscillator Switch Disable
' Oscillator Type HS PLL

@ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
' Brown-Out Reset Enabled
' Power-Up Timer Enable
' Brown-Out Reset Voltage 4.5V

@ __CONFIG _CONFIG2H, _WDT_ON_2H
' Watch Dog Timer Enable

@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
' Stack Over/Underflow Reset Enable
' Low Voltage ICSP Programming Disabled
' Background Debugger Disabled

ADCON1 = %0111 ' Set porta to digital mode

si var porte.2
sclk var porte.1
cs var porte.0

pot_value_0 var byte
pot_value_1 var byte
pot_value_2 var byte
pot_value_3 var byte
pot_value_4 var byte
cmd var byte
position var byte

low sclk ' Set clock pin low
high cs ' Set chip select low

clear

start:
gosub pot_5
gosub pot_4
gosub pot_3
gosub pot_2
gosub pot_1
goto start

pot_5:
low cs
cmd = %00010001 : position = pot_value_4 : gosub shout
cmd = 0 : position = 0 : gosub shout
cmd = 0 : position = 0 : gosub shout
high cs
return

pot_4:
low cs
cmd = %00010010 : position = pot_value_3 : gosub shout
cmd = 0 : position = 0 : gosub shout
high cs
return

pot_3:
low cs
cmd = %00010001 : position = pot_value_2 : gosub shout
cmd = 0 : position = 0 : gosub shout
high cs
return

pot_2:
low cs
cmd = %00010010 : position = pot_value_1 : gosub shout
high cs
return

pot_1:
low cs
cmd = %00010001 : position = pot_value_0 : gosub shout
high cs
return

shout:
shiftout si,sclk,1,[cmd]
shiftout si,sclk,1,[position]
return


Just set the pot_value_x to whatever you want between 0-255.

Scott
- 14th September 2005, 01:08
Wow!

Thanks for the code I'll give it a try this week and let you know.

Scott

CocaColaKid
- 14th September 2005, 01:31
If you need any help with them just give me a shout.