Just accumulate 64, 10 bit readings in a row into the same word variable, then do a shift to the right by 4 places which will give you a 12 bit result. Here is an example:
'************************************************* ********************
READAD: 'READ SYSTEM A/D VOLTAGES (AVERAGE 64 READINGS) 18F2620
'************************************************* ********************
TMPCHAN = CHANNEL 'COPY CHANNEL DATA
IF CHANNEL = 3 THEN TMPCHAN = 4 'SKIP CHANNEL 3 AS IT IS USED AS REFERENCE
ADCON0 = $01 | (TMPCHAN << 2) ' Set A/D to Channel X, On
PAUSEUS 40
VOLTS(CHANNEL) = 0 'CLEAR A/D READINGS
SCRATCH = 0
WHILE SCRATCH < 64 'SUM 64 READINGS
ADCON0.1 = 1 ' START CONVERSION
WHILE ADCON0.1 = 1 'WAIT FOR A/D TO FINISH
WEND
VOLTS(CHANNEL) = VOLTS(CHANNEL) + (((ADRESH & $3) << 8) + ADRESL) 'BUILD SENSOR WORD
SCRATCH = SCRATCH + 1
WEND
VOLTS(CHANNEL) = VOLTS(CHANNEL) >> 4 'TURN INTO 12 BIT RESULT
RETURN
Dave Purola,
N8NTA
EN82fn
Hi;
Following what Dave has said, take a look at this link, by Darrel Taylor;
http://www.darreltaylor.com/DT_Analog/
By the way rasciodc, i'm Portuguese too, i'm from Maia.
Thanks and Regards;
Gadelhas
Thank you Dave, and Gadelhas! I am excited to try this!
Shawn
Thanks, gadelhas, for the link! very useful!! mainly for beginners like me!
And, actually I´m Brazilian! living in São Paulo at the time....
Dave, thanks for the explanation! How much time would this algorithm take to do this, any idea? (just wondering if I can use it in my altimeter...)Just accumulate 64, 10 bit readings in a row into the same word variable, then do a shift to the right by 4 places which will give you a 12 bit result.
Thanks!
Isn't the 12-14-16 bit reading just a guess about being between the 2- 10 bit readings which could be off the expanded factor bits ??
If the a/d values do not bounce in the 64 samples, the actual voltage could be up or down on that step but the guess would be middle.
Don
amgen
Yes, but in practice the numbers jump around enough so oversampling can extract more data from the result. The main drawback is speed, but it is very effective.
Here's some sources of info:
http://www.atmel.com/dyn/resources/p...ts/doc8003.pdf
http://ww1.microchip.com/downloads/e...otes/Achieving Higher ADC Resolution Using Oversampling 01152A.pdf
Last edited by ScaleRobotics; - 28th January 2012 at 20:35.
http://www.scalerobotics.com
Bookmarks