Shop OBEX P1 Docs P2 Docs Learn Events
Analog Input Range — Parallax Forums

Analog Input Range

Sparks-R-FunSparks-R-Fun Posts: 388
edited 2007-03-14 19:18 in General Discussion
I am using the analog input circuit and code from the SX/B help file for the 8-bit ADC example. Currently I am obtaining values of 0-255 between roughly 2.0 to 4.5 volts running at 4MHz. I wish to obtain near linear readings across the full 0-5V range.

I assume that since I am using the built in comparator I should be able to distinguish voltage changes rail to rail. If so, what things should I consider\examine to help spread the 0-255 input reading across the entire 0-5V range?

- Sparks



P.S. The real circuit will be measuring 0-10V. I am planning to use a voltage divider to lower it to the 0-5V range. Right now all testing is with 0-5V.

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-03-12 23:28
    Are you using the same RC values on the PWM pin as in the circuit? How are you getting voltage to the input pin?

    And you might consider using ANALOGIN -- it's a lot faster that using the PWM/comparator circuit.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-12 23:58
    Are you using the same RC values on the PWM pin as in the circuit?
    Yes.

    How are you getting voltage to the input pin?
    10k pot across the power rails, input voltage take from the wiper as shown in the example.

    And you might consider using ANALOGIN -- it's a lot faster that using the PWM/comparator circuit.
    I will consider that.

    I seek something straightforward and easy that can read the full range of 0-5V.

    - Sparks
  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-03-13 00:08
    I've used the PWM/ADC project in help file (uh... I created it) and have got results from 0 to 255; I can't explain why you're not. There's always the ADC0831 since you're willing to give up three pins. Since it's a synchronous device your code could use interrupts, too.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-13 00:24
    Ok, JonnyMac…

    If you say it can do it that is good enough for me. smile.gif
    I’ll figure out what is wrong.

    (And since tone is hard to read from text, I really am ok with that.) At least I am assured that it is MY problem. Since the example is sound and works for others, I am sure I can figure out what I am doing differently and correct it.

    Thanks for your comments, JonnyMac!

    - Sparks
  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-03-13 00:37
    Well, Sparks, I am human -- let me clear my PDB quickly and try again; maybe I fouled something getting that project into the help file....

    Update: Okay, I just ran it and it's fine, that is, I get 2 on the low side and 255 on the top. I was getting weird results at first but found I had a connections problem. Then I changed the 0.01 uF cap to a 0.1 uF cap and now I get the whole range, 0 to 255. You might try to change the cap; my resistors are still 10K.

    Post Edited (JonnyMac) : 3/13/2007 12:54:12 AM GMT
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-03-14 19:18
    JonnyMac

    Wow... You did not need to go so far as to actually rebuild the circuit for me! Though I appreciate the fact that you did. Thank you!

    I rebuilt the circuit on an SX Tech board and ran the example code (and only the example code) and am now seeing the results described with the values given.

    So the circuit is now working for me too! Thank you for all your help.

    - Sparks



    P.S. I will be posting again with additional analog questions. wink.gif
Sign In or Register to comment.