Author Topic: Howto: Precision voltage measurement with an ADC & uC ??  (Read 7811 times)

Zhang

  • Newbie
  • *
  • Posts: 9
Howto: Precision voltage measurement with an ADC & uC ??
« on: May 20, 2014, 01:32:48 PM »
Hi there,

I'm stuck with my little project. I want to measure voltage in a range from 0 to 30 volts as accurately as possible. My plan, a voltage divider to 5 volts and then into a 12-bit ADC. I have read a little about the resolution of ADCs but I'm not sure whether a 12-bit ADC has a resolution of 0.01 volts. I think I need a 16-bit ADCs for this resolution.

Next point is the accuracy of the resistors. How exactly the precision need to be

I would appreciate if you could give me some tips. Maybe there is another solution to measure Voltage.

Please do not bash, I'm still a beginner ....  :-\

Regards

Zhang

Rick Law

  • Newbie
  • *
  • Posts: 6
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #1 on: May 20, 2014, 11:20:30 PM »
Hi there,

I'm stuck with my little project. I want to measure voltage in a range from 0 to 30 volts as accurately as possible. My plan, a voltage divider to 5 volts and then into a 12-bit ADC. I have read a little about the resolution of ADCs but I'm not sure whether a 12-bit ADC has a resolution of 0.01 volts. I think I need a 16-bit ADCs for this resolution.

Next point is the accuracy of the resistors. How exactly the precision need to be

I would appreciate if you could give me some tips. Maybe there is another solution to measure Voltage.

Please do not bash, I'm still a beginner ....  :-\

Regards

Zhang

Running a 12bit ADC at 5 volt will give you 5/(2^12) = 5/4096=0.001221
So, you have 0.001221 volt resolution, not 0.01V.

Typical good resistors are 1%, or .1%, but you can get some 10x better costing 100x more.  Precision costs money.  So, what is the precision you require?

Simplest way without extensive algebra, when you do voltage divide, V=R1/(R1+R2), do the eval with these in a spreadsheet:
1: use R1+1% and R2+1%
2: use R1-1% and R2+1%
3: use R1-1% and R2-1%
4: use R1+1% and R2-1%
Compare the 4 numbers, to the pure result (using just R1 and R2 without the 1%), the biggest  +delta is your +error range and the biggest -delta is your -error.

Now you have to worry about the ADC error.  My experience is, the lower the ADC reading, the bigger the error.  You have to work out a way to compensate for that.

I did some analysis of the Arduino's 10bit ADC.   At 4 to 5V, you are almost spot on.  At 1-2volt, the error start to exceed 1%.  Below 1V, it gets wild.  At 0.5 volt, you are looking at 5% error, at 0.25v, you are looking at 10% error.

You can see the graph here:
http://www.eevblog.com/forum/microcontrollers/atmega328-adc-accuracy-graph/

You can also see my suggestion here (last post on the page) using adc reading as a table index and then interpolate to gain accuracy:
http://www.eevblog.com/forum/beginners/current-shunt/
 
Good luck.  It should be a fun project.

Rick

Mr Eastwood

  • Sr. Member
  • ****
  • Posts: 271
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #2 on: May 22, 2014, 01:19:50 PM »
You can see the graph here:
http://www.eevblog.com/forum/microcontrollers/atmega328-adc-accuracy-graph/

Hi,  in your tests did you only try it with the USB power supply for the Arduino ADC?   It would be nice to see the same test with a really nice stable 5v to the ADC.
Hey! Frisbee! Far out!

Zhang

  • Newbie
  • *
  • Posts: 9
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #3 on: May 22, 2014, 01:26:31 PM »
Thanks for the detailed explanations.

My plan is like Martin to build a dummy load. My dummy load is controlled by a uC. The basic circuit for the load generators already works. Here I use a 12bit DAC with i2c. For the measurements, I would like to use a 12bit or 16bit ADC.

For the current a INA 225. For the voltages the voltage divider.
I'll experiment a bit. The circuit to be as accurate as possible, but not overdone.
I order a couple of precise resistors.

thank you for your help .... :)


Zhang

Rick Law

  • Newbie
  • *
  • Posts: 6
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #4 on: May 30, 2014, 12:54:37 AM »
You can see the graph here:
http://www.eevblog.com/forum/microcontrollers/atmega328-adc-accuracy-graph/

Hi,  in your tests did you only try it with the USB power supply for the Arduino ADC?   It would be nice to see the same test with a really nice stable 5v to the ADC.

No, I did not use a stable 5V.  I used native USB.  That was to serve as base line against my improvement attempts.

To get a better voltage measurement, you have to use a separate power supply, and make sure that the USB power is NOT affecting the voltage.  In fact, whether RS232 is ON or OFF will cause a shift in the voltage.  AND...  Right after flashing, the adc measured voltage will differ a bit.

I was able to have a +- 0.5% when ADC>10 and voltage>5mV, and +-0.2% when voltage>30mV.

Search for "DinoMeter" in eevblog, I did a video on my learning project (4 channel voltage measurement/logging using the ATMega328, each channel with individual ranges from +-0.2V, +2.5V, +-5V, and +30V).   I still use that for logging occasionally.

bobcat

  • Newbie
  • *
  • Posts: 7
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #5 on: August 14, 2014, 04:30:14 PM »
You should also use an external analog reference to the Arduino. Using a 4.096 volt reference makes the math simpler in your sketch. Also you can try oversampling to help with noise/accuracy at the lower end of the scale.
Dev Circus -- Breakout boards, Arduino compatible products- Check Us Out! www.devcircus.com

Zhang

  • Newbie
  • *
  • Posts: 9
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #6 on: August 24, 2014, 04:34:58 AM »
Hi together,
My project is more advanced. Now i have a problem. I use a voltage divider to measure voltage on my constant current load.
Actually, the voltage should remain constant but it is not. If the load increases, the voltage drops. What confuses me: if i measure directly on the power supply it is constant.

What am I doing wrong? As a beginner, I am standing here in front of a riddle.  :o

I hope some experts my help me...

thx
Zhang

bobcat

  • Newbie
  • *
  • Posts: 7
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #7 on: August 24, 2014, 08:58:12 AM »
If you are measuring between TP13 and ground, then it should stay constant. But if the wires you are using to connect to the power supply have some resistance, the the voltage will drop. Try checking the voltage between LOAD IN and LOAD OUT, if it drops there, then you have a wiring problem.
Dev Circus -- Breakout boards, Arduino compatible products- Check Us Out! www.devcircus.com

Zhang

  • Newbie
  • *
  • Posts: 9
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #8 on: August 24, 2014, 11:34:45 AM »
If you are measuring between TP13 and ground, then it should stay constant. But if the wires you are using to connect to the power supply have some resistance, the the voltage will drop. Try checking the voltage between LOAD IN and LOAD OUT, if it drops there, then you have a wiring problem.

Hi Bobcat,
I've experimented a bit but without success.
I have measured the voltage between Load IN and Load OUT. It is not stable.
After that, i measured the voltage on Load IN and Ground direct on the PSU -> not stable. If i measure direct on the output and ground on the PSU it is stable..... That is want i did not understanding. I am very confused.
I have made two pictures. On the first picture, the DC-Load draws 1A current. The left down DMM measuring the voltage direct at the PSU. Fine stable 5V. The left upper DMM measuring the voltage between LOAD IN and LOAD OUT -> not stable.

OK, i understand, that there are some resitors between IN and OUT but how can i measure the stable voltage? Is there a ground Problem?

The second picture shows DC-Load Display. All works fine except the little offset in the current measurement.

thx
Zhang...

bobcat

  • Newbie
  • *
  • Posts: 7
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #9 on: August 24, 2014, 04:01:14 PM »
There is some resistance creating a voltage drop in the wiring between the power supply and the dummy load. About .05 ohms. Try using heavier wires and make sure the connections can handle the current.
I tested some of my test leads and jumpers, and their resistance are all in the .1 to .05 range.
« Last Edit: August 24, 2014, 04:25:06 PM by bobcat »
Dev Circus -- Breakout boards, Arduino compatible products- Check Us Out! www.devcircus.com

Zhang

  • Newbie
  • *
  • Posts: 9
Re: Howto: Precision voltage measurement with an ADC & uC ??
« Reply #10 on: August 29, 2014, 12:53:48 PM »
Hallo,
Next Episode troubleshooting of voltagedrop on my DummyLoad.
As Bob suggested, I have replaced all the cables from 0.22mm˛ to 1.5mm˛, without success.

But ....
Yesterday I had a look at the last video of Martin. He explained the same effect on his power meter. Three-point measurement .... Can it be?

Tomorrow I'll test.

Zh4ng