Go Down

Topic: DC volt value not accurate using A0. (Read 144 times) previous topic - next topic

nautifan

I believe this is more of an electronics question rather than an Arduino question, but I thought I would post it here to see if anyone has experienced this issue.

Problem: DC volts into A0 are not measured accurately by Arduino. 

More detail:
I'm measuring AC volts from an audio power amp.  There is a voltage divider across the non-inductive load.  After the voltage divider, I'm using a precision AC RMS to DC converter with an op amp buffer on the output with a bit of gain to give a range of 0-5 DC Volts (to represent a scaled version of 0-50V AC rms).  This hardware side is linear all day long.  Meaning the scaled output through the RMS converter and buffer are spot on from less than one volt to 50 volts.

Post op amp buffer, the [DC] signal is fed directly into A0.  With A0 connected as my input, the 5 digit bench top meter reads XXX, the calculated Arduino output is always just a bit less than XXX from about 0-10V.  The Arduino is spot on from about 10-30V and then reads a bit high after 30V.  So not linear measurement.  Real examples:  2.00 Vdc from bench meter reads 1.86 via Arduino.  15.00 Vdc from bench meter is 15.00 via Arduino.  37.50 Vdc from bench meter reads 37.85 via Arduino.

I have this on a breadboard, which I know are sources for ground problems and noise.  I've worked through this.  All my grounds are at one point and my wires are short.  I looked for noise and oscillation with my scope.

I'm using a regulated 12V supply for the Arduino via the external power connector.
Vref is external with a regulated 5V supply.
I have bypass caps across all important areas.  Extra bypass caps didn't help when placed across A0 and other places.

As an experiment, I created a variable test voltage divider using my 5V regulated supply that is used for Vref and fed that directly to A0 to check the ADC and Arduino code.  INTERESTING, the direct DC value is spot on with the Arduino ADC and calculation through out the whole range.  So does this mean the Arduino and LM358 buffer IC are not compatible

I see no meter loading when A0 is connected and no oscillations with an oscilloscope. 

When I have a moment, I'm going to setup my voltage variable test divider and send it directly to A0 and then setup A1 to receive the same voltage but from the LM358 buffer (gain of zero) and see my results.  I know the LM358 is not a precision part, but it is what I had on hand. 

Again, more of an electronics question, but hoping someone with some prior experience can support this.

Thank you!

hammy

#1
Sep 20, 2017, 09:45 pm Last Edit: Sep 20, 2017, 09:55 pm by hammy
Have a look at the "map" instruction. This can be used to calibrate your analog input by mapping the measured voltage to a number - high and low range. 

If it's non linear you could make a look up array .

I'm suprised its non linear tho , I've not seen that problem , are you sure you don't have a problem elsewhere - is your reference voltage steady ? Has the processor a true 5v supply ( if it's 4.8 volts , then the analog input won't read correct with 5v on it).

You could try running with a lower v ref in case the A/D is running out of head room.  Bear in mind too that if you put 5v on Vin the processor will be running at a voltage less than this due to the drop across the regulator .

Wawa

Post a diagram. Some things are questionable, like using an LM358.
This is not a rail2rail opamp, and can only output ~0-3.5volt on a 5volt supply.
Using an external 5volt reference can also be dangerous for the Arduino.

Why didn't you use the internal 1.1volt Aref.
Leo..

MarkT

The LM358 is a shocking performer above a few kHz - it basically cannot handle large signals above
about about 3kHz at all and goes completely distorted.  Use it for DC perhaps, not audio...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

nautifan

#4
Sep 21, 2017, 04:31 pm Last Edit: Sep 21, 2017, 04:38 pm by nautifan
Thanks for the replies.  I'm not going to quote all the replies, but help answer some questions below.  Also, diagram attached.

The LM358 was used because it was a single supply opamp.  It only sees DC, not AC.
Vref external / internal is  5.0 / 4.999.  Internal or external, the issue is the same.
I found using the 1.1v internal off too and even more difficult to measure the low DC level input.

After some testing last night, it appears it is not the LM358.  I do have some Linear Tech devices on their way.  I created some test jigs using some precision potentiometers to create a direct DC 0-5V variable supply.  This was input to A0 and split into the zero gain setup on the LM358 into A1.  Both A0 and A1 measured the same value ADC wise.  So LM358 not the issue.

I spent about an hour moving grounds around and grounding all the grounds together on my Uno board.  This improved the measured with voltmeter to Arduino ADC and calculation results.  But it is not perfect.  From about 2 volts down to zero, there still is about a 100mV discrepancy.  Example: 1.90Vdc on bench meter reads 1.80Vdc via Arduino.  The ADC value for 1.80 when looking at the serial monitor is correct. 

I think I am going to move this setup to some perf board and solder everything into place.  I'm starting to lean towards ground issues with small signals.  Although, 2V is not considered small signal and I would think it would be accurate.

Most of the time the Uno is powered by 12V DC regulated power.  The only time the USB is connected is when I look at the ADC value. 

@ hammy, I'll look at the map instruction too.

Thanks.

Wawa

#5
Sep 21, 2017, 10:03 pm Last Edit: Sep 21, 2017, 10:28 pm by Wawa
That's a block diagram.
I already understood all of that from the text.

The sensible thing to do is to remove that buffer and the 5volt reference, and use 1.1volt Aref.
And connect the RMS converter output directly to the Arduino input.
Depending on RMS output impedance and voltage levels, you might need a voltage divider or buffer with divider.
Not possible to give you proper advice without seeing a real circuit diagram.
Leo..

Go Up