Shop OBEX P1 Docs P2 Docs Learn Events
analog to digital troubles — Parallax Forums

analog to digital troubles

erp1976erp1976 Posts: 3
edited 2007-10-08 22:48 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-10-08 19:09
    erp1976 -

    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

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • sumguy16sumguy16 Posts: 21
    edited 2007-10-08 22:48
    I would try testing with a DC signal. Any ADC can measure a sinusoidal voltage, but it might not be able to measure a negative voltage. Most ADCs will only measure from Gnd to Vdd. The reason I suggest a DC signal is that your ADC might not sample fast enough to show the 60Hz signal, check out what the Nyquist Rate is: You need to sample twice as fast as your incoming signal frequency or you will not be able to measure the signal properly. Also keep in mind that your monitor will refresh around 60-70Hz added with the delay of the BS2, serial comm to the PC, you will not be able to view the data in real-time with your current scheme.

    ATP
Sign In or Register to comment.