adc0838
indigo2
Posts: 25
i have connected all the cables to my basic stamp 2.(correct)
i run this program to measure between channel 0 and channel 6, com connected to ground,
if i connect a 12 volt batterie the output is 50 50
if i put more resistance between the bat and channel 0 no effect.
am i doing something wrong here?
i want something like the experiment 28 in the stampworks, so i can calculate with numbers between 0 and 255.
s code:
'
[noparse][[/noparse] I/O Definitions ]
SE CON 5
CS CON 3
DIO CON 4
SAR CON 1
CLK CON 2
'
[noparse][[/noparse] Constants en variabelen]
adcBits VAR Byte
volt_ch0 VAR Word
volt_ch6 VAR Word
'
[noparse][[/noparse] Initialization ]
'
[noparse][[/noparse] Program Code ]
Main:
LOW CLK
LOW SE
HIGH SE
LOW CS
SHIFTOUT DIO, CLK, 1, [noparse][[/noparse]%11000\5]
SHIFTIN DIO, CLK, MSBPOST, [noparse][[/noparse]adcBits\8]
volt_ch0 = adcBits*50/255
DEBUG HOME, CR, CR, "Decimal value, 10x the voltage on chanel 0", DEC3 volt_ch0
LOW CLK
LOW SE
HIGH CS
LOW CS
SHIFTOUT DIO, CLK, 1, [noparse][[/noparse]%11011\5]
SHIFTIN DIO, CLK, MSBPOST, [noparse][[/noparse]adcBits\8]
volt_ch6=adcBits*50/255
DEBUG CR, CR, "Dec value 10 times voltage on chanel 0", DEC volt_ch6
GOTO main
thank you
·
i run this program to measure between channel 0 and channel 6, com connected to ground,
if i connect a 12 volt batterie the output is 50 50
if i put more resistance between the bat and channel 0 no effect.
am i doing something wrong here?
i want something like the experiment 28 in the stampworks, so i can calculate with numbers between 0 and 255.
s code:
'
[noparse][[/noparse] I/O Definitions ]
SE CON 5
CS CON 3
DIO CON 4
SAR CON 1
CLK CON 2
'
[noparse][[/noparse] Constants en variabelen]
adcBits VAR Byte
volt_ch0 VAR Word
volt_ch6 VAR Word
'
[noparse][[/noparse] Initialization ]
'
[noparse][[/noparse] Program Code ]
Main:
LOW CLK
LOW SE
HIGH SE
LOW CS
SHIFTOUT DIO, CLK, 1, [noparse][[/noparse]%11000\5]
SHIFTIN DIO, CLK, MSBPOST, [noparse][[/noparse]adcBits\8]
volt_ch0 = adcBits*50/255
DEBUG HOME, CR, CR, "Decimal value, 10x the voltage on chanel 0", DEC3 volt_ch0
LOW CLK
LOW SE
HIGH CS
LOW CS
SHIFTOUT DIO, CLK, 1, [noparse][[/noparse]%11011\5]
SHIFTIN DIO, CLK, MSBPOST, [noparse][[/noparse]adcBits\8]
volt_ch6=adcBits*50/255
DEBUG CR, CR, "Dec value 10 times voltage on chanel 0", DEC volt_ch6
GOTO main
thank you
·
Comments
all i want is to measure channel 0
output· between 0-255 for 0-5 Volts
i have this, but the stamp doesn't read anything, 0
Main:
LOW CLK
LOW SE
HIGH SE
LOW CS
SHIFTOUT DIO, CLK, 1, [noparse][[/noparse]%11000\5]
SHIFTIN DIO, CLK, MSBPOST, [noparse][[/noparse]adcBits\8]
DEBUG HOME, CR, CR,·DEC3 adcBits
goto main
low se
thank you for your time
Er, you connected a 12V battery? Unless you did something to divide the voltage, I think that's going to cause you some problems. The absolute max supply voltage (Vcc) for the ADC0838 is 6.5V, and the absolute analog input is Vcc + .3V (that is, 6.8V, if you're using 6.5V for Vcc, and 5.3V if you're using a 5V supply).
www.national.com/ds/DC/ADC0831.pdf
I think that if you want to measure a 12V supply you're going to need to set up a voltage divider before the input, and unless I'm terribly confused about these things, I think there's a strong chance that you've damaged the ADC0838 and possibly the Stamp input pin.
Now, later you said that you were trying to measure 0-5V, which of course should work just fine. Am I confused about what you were doing with the 12V battery?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering