Electrical – Need help calibrating ADC input using a voltage divider

adccalibrationvoltage divider

I have been using Arduino Nano analog input to measure voltages, in the range between 22-30 Volts. The Nano's ADC expects a 0-5 volt range and has 0-1023 as its output.

Following the instructions found here:

Read Analog Voltage (www.arduino.cc)

Which basically states that all I need is this code:

int sensorValue = analogRead(A0);
float voltage= sensorValue * (5.0 / 1023.0);

5.0/1023 = 0.004888 volts per increment in analog readings. Turning that around, voltage input divided by this value should give me the sensor value.

My voltage divider is 1 Mohm (R1) between the voltage input and A2, then 200K (R2) from A2 to ground

30 Volts measures as 4.2 Volts. 22 Volts measures as 3.1 Volts.

I think the range between 22 volts and 30 Volts doesn't present enough variation to the ADC – every single-digit change in the analogRead really make a big difference.

The result is that it is giving me some crazy readings. It is definitely nonlinear, so I am having real trouble trying to get it to be accurate at both ends of my measurement range. Each slight ADC increment makes too much of a difference in the measured voltage because I am not using the full 0-5V input range.

So I have been taking 10 readings in a row, at 500 ms intervals, then averaging.

And yet it is not working well enough.

One thing that seems to really matter is the power supply. When I put 4.97 into the Vin it gets different readings than if I rely on getting power from the USB connection to the Raspberry Pi 3B.

Just yesterday I put it on the power supply for good – had been relying on the Pi all along. But it still is not giving accurate readings.

–EDIT from Answers (Thank you for showing me where to look)

Input impedance: I'm trying 147/23.5 for the next attempt. Getting 3.0-4.1 for the 22-30 range. Same as the 1M/100K, basically, but lower resistances.

The reference voltage issue: It measures 4.36 Volts on the 5V output from the Nano. Vin is 5V exactly.

Here is an article I found that says the 5/1023 formula should use that actual value:

Measuring DC Voltage using Arduino

And another that confirms it:

Analog to Digital Conversion

SO NOW the immediate problem is how can I map 22-30 volts to 0-4 or so, thus allowing the utilization of more than just a few % of the allowable values?

Cross-posted at How can I seriously calibrate ADC voltage readings with Arduino Nano?

Best Answer

The best way is offset and less attenuation.

Spec

  • yes convert 20~30 to 0 to 5V with 0.1% accuracy if poss.

Rev A

  • 22~30 converted to 0~4 becomes Vin * 0.5000 -11.00V = Vout
    • 11.000V = k* 4.380V using k= 2.5114
    • with a non-inv OpAmp of gain 1+Rf/Rin
  • one way: V+/2 - 11.00 V using precision Vref or programmable zener.
  • using R array with matched R to <0.1%
  • This will be 3x better resolution using 1/2 instead of 1/6 attenuation
  • ensure your connections are twisted pair and filtered with low ESR RF cap

What supplies are avail?

p.s. I grew up in awe of Aurora , chasing smoke trails that appeared to be at ground level, watching sky waves like the ocean for hours at night and the fiery colours in Churchill Mb at the NRC rocket research range for Plasma Physics.

Related Topic