Inaccurate analog readings when powered via laptop PSU

I have a project requiring a lot of power, hence the laptop PSU part. I don't want to have to power the Arduino separately via USB so Ive stuck a 12v regulator (LM7812) between the 19v input and Arduino VIN.
Only problem is the analog voltage inaccuracies.

I've set the AREF to external (4.30v as I am measuring Li-ion cells) but when the laptop PSU is powering the Arduino, voltage readings drop by nearly a full volt but are incredibly accurate when its powered from USB only!

All voltages are solid and reliable

Is this caused from the lack of capacitors before/after the 12v regulator?
If not, I'm stumped.

Analog measurements are relative to whatever you are using for the ADC reference voltage.

It is not clear from your post what you are doing, but from the symptoms, the ADC reference voltage must be changing as you switch power sources.

Keep in mind that it is quite easy to destroy the ADC, and possibly also the entire MCU if you do not follow all the rules in the data sheet for how you connect and programmatically set up the ADC reference.

For informed help, post the code, using code tags, and a wiring diagram (not a Fritzing mess).

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How are you providing your 4.30V reference?

You NEED to have the capacitors that the datasheet shows to go around the 5V regulator.
Place them as close to the regulator pins as possible.

Is this post related to this?

Tom..

The aim of the project is to power x4 Li-ion chargers + Arduino Nano + other small bits from the laptop PSU. I only ever want to use the PSU so i should not be switching power sources.

I am getting my 4.30v ref from a potentiometer connected to 5v and GND
It was set to output 4.30v when laptop PSU was connected. When powered by USB its drops to 3.94v so adjustment is required.

As for the code, for example purposes it can just be a simple read and display:

void setup(){
    analogReference(EXTERNAL);
    analogRead(0);
    Serial.begin(115200);
}

void loop(){
    Serial.print(analogRead(A0) * 4.30 / 1023.0, 3);
    delay(100);
}

Testing a 3.923v cell with the above code (powered by just USB) yields a result of 3.919v
However, when the PSU is the power source the result is is around 3.012v

And yes, it is the same project.
So you think it is capacitor related then?

wiring.PNG

So you think it is capacitor related then?

No, but you MUST have a capacitor from AREF to ground. The analog reference voltage is changing, and in your circuit it depends on whatever Vcc happens to be.

What is the pot resistance?

I believe its a 10k trim pot.
It was just as bad when the aref was set to default 5v and ive not seen any diagram that has a capacitor for setting aref to external?

Serial.print(analogRead(A0) * 4.30 / 1023.0, 3); // three decimal places
Why? That's a 4300 count. A Nano only has a 10-bit A/D (1024 counts).
4300 is more than 12 bits.

In post#3 you mention a Nano.
A Nano has a schottky backflow protection diode between USB power and VCC.
That diode drops USB voltage by ~0.4volt.
That increases analogue readout by 5/4.6... = ~9% compared to the laptop supply.

External Aref derived from VCC is as instable as VCC.
If you want a stable readout independent of VCC, then use the internal 1.1volt Aref.
And drop battery voltage with a voltage divider to ~1volt.
Leo..

Wawa:
That increases analogue readout by 5/4.6… = ~9% compared to the laptop supply.

But my readings are about 30% different?

Wawa:
External Aref derived from VCC is as instable as VCC.
If you want a stable readout independent of VCC, then use the internal 1.1volt Aref.
And drop battery voltage with a voltage divider to ~1volt.

I understand that but I havent recorded any instability large enough to warrant this kind of change. Ive read that the internal ref has inaccuracies of its own. Would it make sense to tie the pot to 12v regulated output and GND instead

stephenryan2525:
Ive read that the internal ref has inaccuracies of its own.

Internal is stable, but not factory calibrated. So different between boards.
It's a far better option than VCC or an external voltage.
Leo..

stephenryan2525:
I am getting my 4.30v ref from a potentiometer connected to 5v and GND
It was set to output 4.30v when laptop PSU was connected. When powered by USB its drops to 3.94v so adjustment is required.

So your reference is at susceptible to your 5V supply variations.
Try a TL431 programmable ref IC setup as a constant voltage ref. this will keep your setup Vref constant no matter how your 5V fluctuates.
http://www.ti.com/lit/ds/symlink/tl432a.pdf
Tom... :slight_smile: