analog to digital troubles
erp1976
Posts: 3
I have an adc0831·hooked up to my test board. I am sending to the adc a 5vpp at 60Hz with no offset.Using my code the debug displays a few 0s followed by a few 255. It will cycle through this and occasionally display a different value. I was trying to use the adc differential with the outputs of function generator connected to vin+ and vin-. I have varied my duration on the pulseout function. I can't seem to get any different results. Does anyone have any suggestions? here is my code. thanks
' {$STAMP BS2p}
' {$PBASIC 2.5}
' Analog to Digital Conversion
adc VAR Byte
volt_array· VAR Byte(10)
idx VAR Nib
cs PIN 0
clk PIN 1
dataout PIN 2
DO
·FOR idx = 0 TO 9
·HIGH cs
·LOW cs
·LOW clk
·PULSOUT clk, 1
·SHIFTIN dataout,clk,LSBPOST, [noparse][[/noparse]adc\8]
·volt_array(idx) = adc
· NEXT
· FOR idx = 0 TO 9
·DEBUG ? volt_array(idx)
·NEXT
·'DEBUG "8its = ", BIN8 adc,CR
LOOP
' {$STAMP BS2p}
' {$PBASIC 2.5}
' Analog to Digital Conversion
adc VAR Byte
volt_array· VAR Byte(10)
idx VAR Nib
cs PIN 0
clk PIN 1
dataout PIN 2
DO
·FOR idx = 0 TO 9
·HIGH cs
·LOW cs
·LOW clk
·PULSOUT clk, 1
·SHIFTIN dataout,clk,LSBPOST, [noparse][[/noparse]adc\8]
·volt_array(idx) = adc
· NEXT
· FOR idx = 0 TO 9
·DEBUG ? volt_array(idx)
·NEXT
·'DEBUG "8its = ", BIN8 adc,CR
LOOP
Comments
Perhaps I'm wrong and someone will correct me, but it was my impression that ADC chips like the ADC0831 would only operate properly with a DC input voltage.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
ATP