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 18F4431 - oversampling abnormal reading (fixed offset) occurring at random

Status
Not open for further replies.

atferrari

Well-Known Member
Most Helpful Member
18F4431 - Assembly - Xtal 4 MHz

2 inputs ADC conversion with Vref+ = Vdd /Vref- = ground - one shot mode (every 3 seconds) with simultaneous sampling - Tacq = 2 TAD as per datasheet.

10-bit values read sequentially from the ADRES buffer.

For testing, the inputs come from two resistive dividers (total R <5K ea). Noise is around 5 mV pk to pk in both.

I implemented oversampling (12-bits) to get 1,2 mV resolution. Maths for it and for scaling seem flawless and basically I am getting on the display, steady values with 1 to 3 mV difference with the inputs.

What puzzles me is that at a certain input values, I can start getting periods that could last up to several seconds where one of the channels jumps back and forth from the "correct" value to one that is, most of the time, some 7 to 9 mV above and fixed. Never anything in between. That variation, has not a timing pattern that I could say.

Examples:

Measured at the input: 2456 mV
Result on display: 2458 mV
Value occasionally offset to: 2465 mV

Measured at the input: 1639 mV
Result on display: 1641 mV
Value occasionally offset to: 1650 mV

I ruled out this as specific of a particular AN in the micro by swapping inputs / dividers and appears as occurring for some values. I swapped micros as well.

I am puzzled by the fixed offset that does not change.

My question: could this be an artifact of the oversampling? I do not see why but I ask simply because I do not know whom to blame.

What anyone would suggest to look at? Gracias.
 
Using 15 mV pk to pk noise, seems to to be all I needed for the oversampling to work OK.
 
What happens if you slow down the ADC?
We have seen several time when people switch from one channel to another and do not leave enough time.
Try a cap from input to ground. Even a small cap.
How are your power supply caps?
 
Here both inputs are connected permanently and sampled at the same time.
The acquisition time is above the minimum and applied once the software sets the GO bit. The micro does it, automatically.

What do you mean with slow down the ADC? Given the conditions above I have no reason to do. All as per manual.

Tomorrow I am reworking filters and a Vref ad hoc (forget Vdd).

Noted the small cap.
 
Last edited:
It seems a little coincidental that you read the value 4 times and the reading is over by 8mV. It does sound like it's something to do with the oversampling. If the anomaly appears on both channels then it could be the power supply.

Mike.
 
What do you mean with slow down the ADC? Given the conditions above I have no reason to do. All as per manual.
Give it a try. Cut the clock speed to the ADC. I know the manual said......
Is the number 8 bigger than it should be? (x+8) some times?
To trouble shoot you must change something and see what happens.
 
I find the best way to oversample is to take 24 summed readings and divide by 6.

If you simply take 4 readings you will lose resolution as you won't get much more that 10bit readings..

1639 mV with a 10 bit resolution over 5V is @5mV so 1644 to 1634 mV is about right!... If we assume 12bit is working out we still have 1.22mV resolution ( you lose 4 bits ) If your oversample is by 8 then the code may be your issue..

Can I see you code?
 
As I said already, it works.

Using 15 mV pk to pk noise, seems to to be all I needed for the oversampling to work OK.

Oversampling implemented strictly as per the attached AN, probably the best of all I could read up to now. Even the "offset" problem was clearly addressed there; my bad!

Now, on my display, I get figures with the last digit wobbling just +/- 1!!

Definitely, I need to provide a dedicated Vref to Vref+ and forget worrying about unexpected consumptions.
 

Attachments

  • AVR121 Enhancing ADC resolution by oversampling.pdf
    118 KB · Views: 208
Just for Information...

Lets assume a system that will read a sensor and display the sensors output!!

Read voltage... Convert scales.... Display output..

Load device:- 10 bit ADC:-
2.5mV amplified to 2.5V reads 512!!
conversion:-
513 * 5 / 1024 = 2.504
512 * 5 / 1024 = 2.500
511 * 5 / 1024 = 2.495​

Over sampled!! by 24
2.5mV amplified to 2.5V reads 12288
conversion:-
12289 * 5 / 24576 = 2.5002
12288 * 5 / 24576 = 2.5000
12286 * 5 / 24576 = 2.4995
I know that this is the ideal, but oversampling averages out the reading + dampens the displayed output!!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top