Analog Input Range
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.
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
And you might consider using ANALOGIN -- it's a lot faster that using the PWM/comparator 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
If you say it can do it that is good enough for me.
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
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
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.