Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ADC resolution

Status
Not open for further replies.

ashfsk

New Member
Hi. I will be using a PIC 18f452/6722 for my project. AS you would be knowing it has a 10-bit ADC. However the required resolution for my project is 16-bit. One of the techniques to improve the resolution is to oversample and average. If I do that I will need approx. 47350 samples/sec. This is because my sampling rate would be 11.56Hz and oversampling rate 47350Hz. Also adding these many 10-bit values doesnt seem possible without overflow. Can someone help me with this please?? If you have different techniques please let me know.


Thank You.
 
Why do you need 16 bit resolution?, and are the rest of your components that accurate? - bear in mind 10 bit resolution gives more than 0.1% resolution, do you have resistors etc. more accurate than that?.
 
Sorry to interupt, but I'm curious: what's the sample rate of the ADC on something like a 16F88, anyway? Can anyone give me a ballpark (or better) figure? Thanks.
 
On a 16F88 the sample time is around 20uS which is equivalent to 50,000 S/S. The 18 series are about 50% faster.

Mike.
 
Sir, Im working on 3D Tracking and the required accuracy is 0.0057 degrees. I must be able to precisely determine the yaw, pitch & roll as small as 0.0057deg. With a 10-bit ADC I get to 0.057deg. With a 16-bit I can measure 0.0057deg. And Ive been asked not to go for a 16-bit external ADC. So have to figure out how to inc. the resolution of 10-bit ADC.
 
I don't see how averaging multiple samples is really going to help?, at best you might perhaps gain an extra bit? - but like I said, the accuracy of the support components isn't going to that good, and the resolution may well disappear in the noise levels.

I would suggest initially trying it as ten bit, then try averaging multiple samples and see if you can get any improvement?.
 
ashfsk said:
Also adding these many 10-bit values doesnt seem possible without overflow.

If you use a higher language such as PIC Basic, it does the work for you, I was interested at the sample rate, so I ran a few tests. It was comparing a 16F877 and a 18F452.

Both were running at maximum speed, i.e. the 16F877 was 20Mhz, and the 18F452 was 40Mhz (PLL enabled). Both programs were very similar,

16F877 Code;

Code:
Device = 16F877
XTAL = 20

Dim Result As Word
Dim X As Byte
Dim myarray1[100] As Byte

Declare ADIN_RES 8 		' 8-bit result required 
Declare ADIN_TAD 8_FOSC 	'
Declare ADIN_STIME 0 		' Allow 10us sample time 

Low PORTB.0          

Main:
     X = 0
     Repeat
         Inc X
         myarray1[X] = ADIn 0
     Until X = 100
    
    PORTB.0 = 1
    PORTB.0 = 0
    
    GoTo Main

18F452 Code;
Code:
Device = 18F452
XTAL = 10
Declare PLL_REQ = On    '40Mhz

Dim Result As Word
Dim X As Byte
Dim myarray1[100] As Byte

Declare ADIN_RES 8 		' 8-bit result required 
Declare ADIN_TAD 8_FOSC 	' 
Declare ADIN_STIME 0 		' Allow 10us sample time 

Low PORTB.0          

Main:
     X = 0                       ' start A/D run
     Repeat
         Inc X
         myarray1[X] = ADIn 0
     Until X = 100
    
    PORTB.0 = 1
    PORTB.0 = 0
    
    GoTo Main

As you can see, the program acquires 100 samples from ADC Channel 0 (PORTA.0). PORTB.0 is toggled so I can clock each time 100 samples has been taken, and see it on an external frequency counter

I experimented with both 10 Bit and 8 Bit resolution, here’s the 8 Bit results;

16F877 = 44600 Samples/Second
18F452 = 175300 Samples/Second

Now with a couple of changes for 10 Bit resolution;

Code:
Device = 18F452
XTAL = 10
Declare PLL_REQ = On    '40Mhz

Dim Result As Word
Dim X As Byte
Dim myarray1[100] As [COLOR="Red"][B]Word[/B][/COLOR]

Declare ADIN_RES [COLOR="Red"][B]10[/B][/COLOR] 		' 10-bit result required 
Declare ADIN_TAD 8_FOSC 	'  
Declare ADIN_STIME 0 		' Allow 10us sample time

And the sample rate afterwards;

16F877 = 30100 Samples/Second
18F452 = 153800 Samples/Second

Its clear that the 18F452 is by far the superior from these results, it would be a combination of a few things, but mainly because of its PLL ability, so that it can function at 40Mhz, and extended instruction set that all 18F's have

This is not specifically directed as an answer for your post, but could provide a quick guide on how to make efficient samples in PIC Basic.

After you have sampled, you can do what you please with the data
 
Last edited:
hi gramo,
Thanks for posting the results for 16F877 and 18F452, these are the devices I use most.

I saw that you used PIC Basic, do you have any results for the 18F452, using Swordfish Basic, its supposed to produce faster code.

Regards
 
hi gramo,
Many thanks.

Evaluated the LCD RW control mod that David sent me, [swordfish] works fine at 4MHz, arranging tests at 20/40MHz
 
Wow, examples of implementation.

Have we reached the consensus that we can indeed have 16-bit resolution using a 10-bit ADC by averaging the results?
 
A simple test would be to only use 8 bits of the ADC and average. If the value you get matches the 10 bit result then it works, if not then ...

My guess is that it doesn't work. If it did then we would see bit 2 (bit 0 in above example) changing when we had a fixed voltage and this just doesn't happen.

Mike.
 
Nigel, it's called decimation, AVR Appnote #121
https://www.electro-tech-online.com/custompdfs/2007/04/doc8003.pdf
Basically for every 4 times you oversample the signal you can get an extra bit of precision (asuming there is at least 1LSB worth of noise on the signal) You just add all the samples up and shift the result. Oversampling that much however may require a seperate capture and hold circuit for the original analog signal.
 
Oversampling will increase precision when you have a noisy or varying signal. The OP is asking about oversampling a steady signal. I don't see how you can increase resolution of a DC signal.

Mike.
 
The ADC itself usually has a noise floor high enough to use desimation, even on a DC signal. You can also introduce an external source of noise, as long as it's white noise.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top