PDA

View Full Version : ADCin and floating point values



niknaksbarbeque
- 15th May 2005, 16:21
Hello,

Firstly apologies if this is very thick question, pretty new to all this electronic malarkey, had a look on the forums and couldn't find an answer, any help really really really appreciated.

I am wanting to read a voltage value on the RA0 pin on the pic 18f452 using ADCin. However the values I want to read go from 0.0 to 0.5 V.

Am I correct in thinking that because the pic doesn't do floating point values, anything less than 0.5 will be scaled down to 0?

If so, does this mean that your ADC converter can only supply a range of values from 0 to 5?

Thanks very much
Mark
p.s. I come from a software background, embedded hardware programing so much harder than just pure software, don't know how you guys keep your patience :)

Luciano
- 15th May 2005, 17:13
Analog to Digital Converters (A/Ds)
http://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html

Melanie
- 15th May 2005, 18:08
Your ADC result will have NOTHING in common with floating point. Let me explain... assuming you have a 10-bit ADC, your minimum reading will be zero and your maximum reading will be 10-bits or 1024. This maximum reading is referenced to +VRef, and the minimum is referenced to -VRef.

If -VRef is 0v, and +VRef is 5v, then 0v will equal zero on the ADC and 5v will equal a count of 1024. It goes to assume that 2.5v will be half of 1024 ie a count of 512, and 0.5v will have a count around 102...so you will have a resolution of about 5mV or 100 points on the scale.

If you change your +VRef to 0.5v (keeping -VRef at 0v), then the scale will be between 0 and +VRef for your entire 10 bits... ie, a count of 0-1024 for a voltage range of 0-0.5v (here a resolution of 500uV).

So to summarise, your ADC range is a count between -Vref and +Vref in the 10-bit (or 8-bit is you set it that way) resolution of your ADC. Thereafter you can perform some math on your ADC reading and thrrow in a decimal point to give you an answer in volts, amps, coulombs, whatever....

Melanie

niknaksbarbeque
- 19th May 2005, 11:38
Yes I was being thick, thank's very much for the replies guys, you've let me keep my hair (was slowly being torn out in clumps).