Shop OBEX P1 Docs P2 Docs Learn Events
messed up analog/digital converter, reads pot, but not sensor — Parallax Forums

messed up analog/digital converter, reads pot, but not sensor

MatthewMatthew Posts: 200
edited 2005-02-08 23:17 in General Discussion
Hello.

I'm using an ADC0831 as my analog/digital converter. If I hook pin2 to my 10k pot, it reads it like a dream (from the debug menu, I can see all 256 values as I turn the pot). If I hook it up to my ultrasonic sensor, it reads eratic values even if I'm not moving the sensor. When I attach the ultasonic sensor to my voltmeter, it works perfectly and gives off an output voltage of 0.03-6.xx.

Could my problem be because the voltage goes over 5 volts? But shouldn't it still be able to read something like 3.xx or 2.xx volts?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-07 01:49
    Do the sensor and the ADC have a common/good ground when you're connected to it?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • MatthewMatthew Posts: 200
    edited 2005-02-07 02:18
    No, the sensor runs off of 9v, and the ADC runs on 5v (both from different sources). I'm guessing that's a problem?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-07 04:22
    Which sensor are you using? Can you post a link to tech docs -- that will help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MatthewMatthew Posts: 200
    edited 2005-02-07 05:43
    I'm using this one:
    www.mrrobot.com/usonic.html

    Pin1 is connected to the positive terminal of a 9v battery
    Pin2 is connected to the negative terminal of a 9v battery
    Pin6 is connected to Pin2 of my ADC0831

    Thanks,
    Matthew
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-07 17:09
    Curious why you got the 8-12v version instead of the 5V version? I suppose you wanted to save the $20. I personally would have opted for the digital output version since it would reduce chip count (no ADC needed) but thats just my druthers. Chris has a point that your ground may not be proper, you can try tying the negative terminal of your battery and the ground of your 5V supply together, but the safer option is to use a 9V supply and a 5V regulator to supply the 5V portions of your circuit. Also the specs are vague, they mention a 0-5V and 0-10V out but dont specify which versions do what and if there is a method of switching between the two, I would test the voltage range of the sensor before hooking it up to your ADC to make sure it not outputing 0-10V (unless your ADC can handle that high of an input) otherwize you could fry your ADC.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-07 20:42
    You might want to run the analog output through a divider (use a couple 1% resistors) to drop it down into the rnage of the ADC0831.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • David BDavid B Posts: 591
    edited 2005-02-07 23:29
    Maybe the signal is noisy. Maybe the ADC is really reading the correct instantaneous values of a noisy sensor. The voltmeter probably has a good amount of filtering built in; maybe your circuit could use a filter, too.

    Also, I don't know that particular ADC, but I was using an ADC recently that had a pretty low input impedance, and its internal clocking was yanking my signal all over the place until I used an op-amp buffer on my sensor to lower its output impedance. Maybe your circuit would be helped by a buffer of some kind.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-08 00:35
    Matthew said...
    No, the sensor runs off of 9v, and the ADC runs on 5v (both from different sources). I'm guessing that's a problem?
    If you don't have the negative terminals of the batteries tied together, then you don't have a common ground.· The ADC doesn't have a reference from ground as to what voltage your signal is at...You need a common ground.· And that's beside the issue of feeding too much voltage into the ADC input, which I think may have been answered from the looks of the replies.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • MatthewMatthew Posts: 200
    edited 2005-02-08 01:38
    Paul Baker said...
    Curious why you got the 8-12v version instead of the 5V version? I suppose you wanted to save the $20. I personally would have opted for the digital output version since it would reduce chip count (no ADC needed) but thats just my druthers.

    Mr. Robot didn't have any 5v sensors left, and they said they wouldn't be coming in for a few months.
  • MatthewMatthew Posts: 200
    edited 2005-02-08 01:39
    Okay, I'll try supplying the stamp (and thus the ADC) and the sensor with the same 9v battery. I'll let you guys know what happened.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-08 01:44
    Matthew,

    ·· You don't want to run the Stamp (And ADC) from 9V, you want them at 5 Volts!· What you want is a common-ground between the two power circuits.· All you need to do is connect the ground pin from the sensor to the ground·on the BASIC Stamp.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • MatthewMatthew Posts: 200
    edited 2005-02-08 01:46
    Even if the ground is from a 5v source, and not a 9v source? Are all grounds similar?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-08 01:50
    Yes...On one side you have your sensor with a 9V battery connected to it.· Ground, +9V and the output goes to the BASIC Stamp pin.· On the other side, you have the BASIC Stamp connected to an ADC.· It's running on 5V.· The single wire you have going between the two circuits doesn't provide a reference from ground so the ADC knows how high the level is.· You just need to connect the grounds from both circuits together.· So the sensor will have 2 wires going to the BASIC Stamp/ADC side.· One is the output, the other is ground.· Let me know if this fixes your problem.· It should!·

    smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • MatthewMatthew Posts: 200
    edited 2005-02-08 02:47
    Chris, I just tried it a second ago, but didn't have much time to play with it too much. The value are definetely more consistant (and not jumping all over the place), but the values don't seem to be correct. It probably need to recalibrate the thing again. I'll let you know if it works then.

    Thanks,
    Matthew
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-08 23:17
    Well at least you got the idea...I didn't want to see you fry your BS2/ADC...

    Make sure your connections, especially the common ground are solid.· I can't count how many times I got erratic readings from and ADC or other device just because a wire in the breadboard was making intermittent contact.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
Sign In or Register to comment.