Arduino Due ADC error

Hello

Why is it that the scan and the expected value (I measured the voltage that the arduino scans and calculated what value I should get) do not match?

I use Arduino Due. I calculated with this formula: (4095 / 3.3) * voltage.

I should have gotten this value from more than 2479.336364.
I got the following values:

2471
2471
2474
2471
2471
2470
2470
2473
2472
2466
2470
2466
2471
2469
2470
2470
2474
2469
2470
2471
2472
2468
2472
2472
2465
2472
2473
2469
2471
2470
2465
2469
2469
2466
2470
2471
2466
2472
2469
2474

Even if I average the values I get, I don't get the expected values. As if all values were shifted.
Why is this?

If I'm reading that correctly, you got something like a 0.2% error.

What's the problem?

I just want to know what's causing it.

How can we tell?
You haven't told us anything.

No you should not.
The ADC returns an integer

Those are 40 samples with an average of 2470.1
That is an error of 0.37%, the voltage is 7 mV too low.

I think you are right, it can be a little better.
I also think that the others are right, you have to tell us everything to be able to find it.
Can you show your sketch and show how everything is connected ?

A mistake of only 7mV is very easy to make. If you have a ledstrip connected, then there are GND currents. Perhaps your multimeter is not calibrated. Perhaps the 3.3V is not 3.30000V, and so on.

TheMemberFormerly...
If you want to know something else, write what.
That's the program code. It does not affect anything. I think the shift is caused by Due.

void setup()
{
  Serial.begin(9600); 
  analogReadResolution(12);
  }

void loop()
{
  Serial.println(analogRead(A0));
  delay(2000);
}

johnerrington
I know he returns an integer. I am not waiting for the calculated fraction either, but for the read values to bounce around the calculated value. However, this is not the case.

kupola
I can't attach a circuit diagram. I took 3.3V from descriptions and haven't looked at whether it's actually the maximum of the ADC.
The voltage based on which I calculated the above formula, 2479.336364, was measured between the Due GND and the analog foot.
Multimeter is calibrated.

I prefer (4096 / 3.3), but that still doesn't make up your error.

I can't see your schematic, I can't see your method, I can't see your problem.

I'm out.

For 4096, the expected value changes to 2479.941818. This is a negligible error (and so the expected value just doesn't come out).

I can't send a schematic.
What method do you think of?
The problem is that even if I average the values, I don't get the expected value. The problem is that the read values do not bounce around the expected value but around another value.

But is that level of inaccuracy actually going to cause a problem? It's less than 0.5%. What application requires it to be better than that?

The ADC measures ratiometrically to the 3.3V at the AVcc pin of the chip - that could easily be a few mV out from the Vcc you presumably measured?

If you are looking for high accuracy, an ADC built-in to a microcontroller is not the best approach, they are very compromized compared to a dedicated ADC laid out on a PCB with attention paid to ground loops, separating analog and digital grounds and so on. And IIRC the Due 3.3V power supply is switch-mode, not a linear regulator, so will be very noisy. Not what you need for sensitive analog work.

1 Like

Really? To what standard, and by whom?

I express surprise that the multimeter is calibrated - it's not a cheap procedure.

That <0.5% error could be in the multimeter.

Hi,
Can you please post a circuit diagram of your project?
Can you please post a picture(s) of your project?

Have you put a 0.1uF capacitor between the analog input pin and gnd?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

SteveThackery
I want to know the reason for this inaccuracy so yes it is causing the problem.

TomGeorge
I can't send a picture of such things like I said.
Yes, I put a capacitor.

One point on a graph is not much use.
Plot some more.

Nothing wrong with that, but I am confused, because"curiosity" is not the same thing as "a problem".

Answering questions in the spirit in which they are asked is important if you want to keep other forum members engaged; they are here voluntarily and it helps to know where you are coming from. Someone researching an intriguing mystery will receive a different set of answers than someone struggling with a system which is malfunctioning due to an unexplained offset on the ADC readings.

The default setting is VCC as analog reference. That means the Due does not measure a voltage. It really does not.

Scroll back and look for the words "ratiometrically" and "3.30000V".

We need to know exactly the voltage of your 3.3V and I would like to know which GND pin you use as GND reference. It is only 7mV, so all these things are important.

I don't have a Due board. It could have a design flaw that causes that 7mV.

From the point of view of the operation of the system, it is not really a problem for me (but this does not mean that there will be no one else who can help if we can find the answer here now).
In addition to my curiosity, my reason is even that if someone were to ask why the values that should be based on the equation do not come out, I could give a normal answer.

1 Like

I measured it and it was 3,312. This way I get a value close to the average.
Thanks for the help.

Most voltage regulators output a voltage that is a few percentage higher than specified, to compensate for some loss in wires.
When the reference voltage goes up, then the Arduino think that it measures a lower value at a analog input (the voltage at a analog input stays the same, but the Arduino does not know that).

However "close" is not good enough, let's get closer.
You can use the noise to get more resolution by calculating the average of many samples. Don't forget about the half bit.

The ADC advances to the next level if it reaches that level. However, the actual voltage at the input could be between those levels. If for example the ADC output is 500, then the input voltage is between the ADC levels 500 and 501. That is why 500.5 should be used to calculate the input voltage.
https://www.gammon.com.au/adc

You could try my averageRead.ino.