Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:53 14 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : oversampling to increase resolution

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 03:31am 23 Aug 2015
Copy link to clipboard 
Print this post

i've been reading a bit about a method of increasing the resolution of an A/D converter using oversampling for a non-micromite project. the method relies upon the random noise on each conversion being at least 1 bit (ie, the lowest bit appears random), and for every 4x increase in the number of samples one gets an additional single bit of resolution.

for example, if using a micromite, with its 10-bit onboard A/D converter, if the method works, one needs to take 256 samples, adding them together, and then divide by 16, to get a result with 14-bits of resolution. now, the micromite already scales analog reads to a decimal voltage, so in fact you would just need to add together 256 measurements and then divide by 256.0 to get the result in volts.

there is a penalty, that being increased time taken to make a number of A/D conversions. there are no free lunches, but when running basic the penalty may not matter.

the method also significantly improves the signal-to-noise ratio. on the net there are quite a few articles on the method, including this one:
https://www.silabs.com/Support%20Documents/TechnicalDocs/an118.pdf

my question(s):

1. does the micromite basic interpreter already do any oversampling when an analog pin is read?

2. if not, how much time overhead would be added by doing so? even taking just 4 samples may yield improved results, yet introduce a time-penalty that (on the face of it) would be a fraction of the processing time for a single basic statement.

i'm hoping some of the custom-function experts may jump in with some ideas, and perhaps even roll some test code to see if the method produces worthwhile results on the micromite. there is some suggestion in some articles that oversampling is best suited to 12-bit A/D converters, whereas the pic32 processors are only 10-bit, so there may be no useful gain.


cheers,
rob :-)
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 04:20am 23 Aug 2015
Copy link to clipboard 
Print this post

  Quote  1. does the micromite basic interpreter already do any oversampling when an analog pin is read?


Yes: it takes 10 samples and discards the lowest and highest before averaging the remaining 8
 
Lou

Senior Member

Joined: 01/02/2014
Location: United States
Posts: 229
Posted: 07:01am 23 Aug 2015
Copy link to clipboard 
Print this post

Rob,

On an old battery powered 68HC705 project (15+ years ago) I used a 12 bit A/D converter and to reduce uProc bus noise I took 8 samples added together then shifted back for an averaged result, worked very nicely.

Looks like what matherp quoted the uMite doing is even better.

If you do try oversampling the uMite's oversampling please post your results, it will be good info to have.

Lou
Microcontrollers - the other white meat
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 07:41am 23 Aug 2015
Copy link to clipboard 
Print this post

  matherp said  it takes 10 samples and discards the lowest and highest before averaging the remaining 8

Actually the current setting is to discard the top two and lowest two values and average the remaining six - but the effect is similar.Edited by Geoffg 2015-08-24
Geoff Graham - http://geoffg.net
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 02:29pm 23 Aug 2015
Copy link to clipboard 
Print this post

I think it is a good idea, certainly interesting.
My impression is, the processor generates significant non-random noise so
the limits are there eventually, the more grunt the processor the more noise.

I used the 12-bit A/D on the Microchip 16 bit '33 micros and it was excellent, right on the dot.
That translates to, 1 millivolt accuracy out of 4.095 volts (edit - I used 3 v) range. You have to keep digital signal lines separate from the analog inputs and of course a very clean power supply.
The biggest problem is, the measurements are only as precise as the reference, and even a 0.1 % in-circuit reference (one bit in 1024) is pushing up the cost.
The better voltage references usually have to be aged, calibrated, etc.
I guess it depends on the application, absolute measurements are finicky but for say, audio sampling there is probably more "go with the flow".

The new MZ...EF has a new 12 bit A/D now, don't know what it is like yet.

Whatever path, I would recommend actually testing the reported values against known input values ... [ ie chart the "transfer function" ] .
When I did this, it was quite an eye-opener... even the micro-amp drawn by a multimeter in a simple voltage test, caused several millivolts difference as it flowed through an analog filtering circuit.
(edit) Guess who found out, upmarket multimeter with good specifications...drew over ten times the quoted input leakage.
Edited by chronic 2015-08-25
 
SteveP
Newbie

Joined: 21/03/2013
Location: United States
Posts: 19
Posted: 03:05pm 25 Aug 2015
Copy link to clipboard 
Print this post

There is also the technique of intentionally adding at least +/- 1/2 LSB of noise to a perfectly clean signal (dithering) in order to determine where in between the two digital bits of a single-sampled conversion that signal is by increasing the resolution.
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 02:54pm 27 Aug 2015
Copy link to clipboard 
Print this post

Goeff, would you mind taking a second to explain how you came up with that algorithm? Was it through trial and error or did you figure that would be the least noisy part of the result set? It's interesting...Edited by akashh 2015-08-29
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 05:08pm 27 Aug 2015
Copy link to clipboard 
Print this post

  akashh said   Goeff, would you mind taking a second to explain how you came up with that algorithm? Was it through trial and error or did you figure that would be the least noisy part of the result set? It's interesting...

There was no real science to it, I was mostly concerned with getting the best reading with the minimum of samples (and time). The output of the ADC is so noisy that it would require the average of a 100 samples or more to get a reliable reading.
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 08:24pm 27 Aug 2015
Copy link to clipboard 
Print this post

I think Geoff's current method is probably as good as anything else without compromising the time required for a result. If better precision is wanted then multiple results can be taken and mathematically treated, as long as you're not worried about the time penalty.

I agree with @chronic though, variation in other 'things', notably the reference voltage and the test signal itself, will likely be the greater problem - they may not effect the precision but will effect the accuracy of the measurement and accuracy is likely to be more important than precision.

Greg
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 08:38pm 27 Aug 2015
Copy link to clipboard 
Print this post

i would be curious about the source of the noise. for instance, does adding a small inductor in series with AVcc and providing seperate decoupling help? if so, what value of inductance - microchip says one may be used, but offers no suggested value.


cheers,
rob :-)
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 09:06pm 27 Aug 2015
Copy link to clipboard 
Print this post

I guess an AVcc inductor and decoupling would help precision, depending on the frequency of the noise. It won't help accuracy though.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:10am 28 Aug 2015
Copy link to clipboard 
Print this post

I not used the ADC's that are controlled from I2C yet. They should offer a better resolution and can have less noise when mounted away from the mcu with maybe its own pcb/power/shielding/etc..

Microblocks. Build with logic.
 
HankR
Senior Member

Joined: 02/01/2015
Location: United States
Posts: 209
Posted: 06:24pm 28 Aug 2015
Copy link to clipboard 
Print this post

  Geoffg said   The output of the ADC is so noisy that it would require the average of a 100 samples or more to get a reliable reading.


I would also like to know something more about the source of noise of this
magnitude.

Geoff, could you please quantify just how serious this noise is with some
typical numbers?

Anyone else please chime in, especially if you have seen ADC noise (more than
just a few bits) and you feel you have a "controlled" situation (rock solid power supply, acceptably low source resistance, etc.)

HankEdited by HankR 2015-08-30
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 09:13pm 28 Aug 2015
Copy link to clipboard 
Print this post

The way to start looking at this is to do some frequency distributions over different time intervals. The time intervals need to encompass the sort of time intervals that your 'problem' occurs and by 'frequency' I mean statistically speaking, not Hz.

It should be pretty quick and easy to do this with a bit of programming.

1. Take a good sample of A/D readings and separate them into 'bands' across the target range, e.g. bands of 0.1v or 0.01v across the range.
2. Count the no. of readings you get in each band.
3. Plot the 'no. of readings in each band' on Y axis, Vs the 'band' in consecutive order on the X axis. Excel can do this easily for you if you write the raw A/D readings to the SD card then transfer them. If no SD card then maybe via TeraTerm and Excel.
4. Look at the resulting 'frequency distribution' plot. If it's a bell shaped curve, (i.e. Gaussian) it probably means you're dealing with normal 'noise'. If the bell is 'skewed' or there are bands with abnormal numbers of readings well off the Gaussian distribution, then 'special' causes are involved.

'Fiddling' with your circuit (tapping, loading up/down, switching things on/off, etc) while you do your 'sampling' will often then show you the source of 'special' causes. If you have a 'scope of course you can often circumvent the work above.

Greg
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024