CraigR
11-18-2009, 04:11 AM
I am using an AD5220 digital potentiometer and want to display the position of the potentiometer's wiper at a given time (ADC position). I connected the potentiometer to a AD0831 analog to digital converter:
__________________________________________________ _______________________
counter VAR Word
ADCOutput VAR Word
Volts VAR Word
CS·············PIN···· 0······················ ' chip select
AData·········PIN···· 2······················ ' data pin
Clk············ PIN···· 1······················ ' clock pin
adcRes········VAR···· Byte················ ' ADC result
Setup:
· HIGH CS
Main:
DO
·
· LOW CS
· FOR counter = 0 TO 127
······ PULSOUT 5, 1
······ PAUSE 500
······ SHIFTIN AData, Clk, MSBPOST, [adcRes\9]
····· ·DEBUG "ADCRes is: ", DEC3 adcRes, CR
· NEXT
· HIGH CS····································
·····························
LOOP
_________________________________
The For loop is used to adjust the potentiometer from one end of its range to the other. When I run the program I get a single value of the wiper position·opposed to multiple values.·Inside the For loop I don't know which variable·associated with the SHIFTIN command·(i.e. AData, Clk, MSBPOST) can be replaced by "counter" to·display the value at each increment of the potentiometer wiper.
__________________________________________________ _______________________
counter VAR Word
ADCOutput VAR Word
Volts VAR Word
CS·············PIN···· 0······················ ' chip select
AData·········PIN···· 2······················ ' data pin
Clk············ PIN···· 1······················ ' clock pin
adcRes········VAR···· Byte················ ' ADC result
Setup:
· HIGH CS
Main:
DO
·
· LOW CS
· FOR counter = 0 TO 127
······ PULSOUT 5, 1
······ PAUSE 500
······ SHIFTIN AData, Clk, MSBPOST, [adcRes\9]
····· ·DEBUG "ADCRes is: ", DEC3 adcRes, CR
· NEXT
· HIGH CS····································
·····························
LOOP
_________________________________
The For loop is used to adjust the potentiometer from one end of its range to the other. When I run the program I get a single value of the wiper position·opposed to multiple values.·Inside the For loop I don't know which variable·associated with the SHIFTIN command·(i.e. AData, Clk, MSBPOST) can be replaced by "counter" to·display the value at each increment of the potentiometer wiper.