Shop OBEX P1 Docs P2 Docs Learn Events
ADC not working — Parallax Forums

ADC not working

mrmaxmrmax Posts: 1
edited 2007-07-06 23:13 in General Discussion
Hey, im working on a robot that will follow people around.· Im using the Eltec pyroelectric sensor to detect people.· For the sensor, i have one pin hooked up to +5V, another hooked up to GND, and the third is the output, ranging from 0-5V, with it normanlly hovering around 2.5V.· When i just hooked the output up to a volt meter, it worked well, staying at around 2.5V, and then jumping up to 3V or down to 2V if i waved my hand in front of it.· However, i need to hook it up to my basic stamp 2, and when i plugged the output of the sensor in to the input of the ADC0831, the results were wierd.· While about half of the values read 120ish, which is right for right around 2.5V input, it would all of a sudden jump up to 255, then down to 30, and be all over the place, even though the output voltage from the sensor stayed within 2.48-2.53V.· the program i'm using for the ADC0831 is:
·DO
··· LOW CS····································· ' activate the ADC0831
··· SHIFTIN AData, Clk, MSBPOST, [noparse][[/noparse]adcRes\9]···· ' shift in the data
··· HIGH CS···································· ' deactivate ADC0831
··· DEBUG ? adcRes····························· ' show conversion result
··· PAUSE 500································· ' wait half of a second
· LOOP········································· ' repeat
· END
can anyone explain why the values the ADC is giving me·are all over the place?· And more helpful, could anyone help me get the ADC0831 to give more consistent readings?
thanks for any help,
max

Comments

  • metron9metron9 Posts: 1,100
    edited 2007-07-05 16:30
    From what little I read of the datasheet, (My pdf reader is screwed up and I can t make the window bigger on this stupid MAC) I t seems when you take the CS LOW the chip waits for a start bit and then a mux address before it will do a conversion. In your code i only see the shiftin without a start bit send. No time, have to work now but that is my initial impression.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-07-05 19:28
    Double check your connections, Max, I use the ADC0831 all the time and never have any problems with it. Make sure you have pin 5 (Vref) connected to a clean 5v supply.

    Metron: The extra clock bit in the SHIFTIN statement provides the start cycle for the ADC0831.
  • metron9metron9 Posts: 1,100
    edited 2007-07-06 19:55
    I was reading this (attached .png file) from page 13 of this datasheet. http://www.datasheetcatalog.com/datasheets_pdf/A/D/C/0/ADC0831.shtml

    I thought you had to send the start bit with the MUX data and then the conversion would begin. The SAR line would signal LOW at completion. Perhaps this is another mode but I thought I would post this link to the datasheet as it is different from the other datasheets.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!

    Post Edited (metron9) : 7/6/2007 8:02:05 PM GMT
    532 x 416 - 67K
    adc.png 66.7K
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-07-06 23:13
    According to the code sample he's using the single-channel ADC0831 -- since there is just one channel the interface is simpler than say the ADC0832 or ADC0834 which are in the same family and do require a few command bits for the MUX. On page 9 of this doc

    cache.national.com/ds/DC/ADC0831.pdf

    you'll find the timing for the ADC0831 and you can see that it just takes one extra clock bit (hence the \9) to get things rolling. As I stated before, I've used that code fragment being cited and I know it works (with the ADC0831 -- not with the others in that family).
Sign In or Register to comment.