I'm using this really nice volt meter circuit/voltage divider for my project to check the voltage of the 18V lithium battery.
I'm using 2 resistors for the voltage divider, just like they do. 7.5K and 30K. You can see my schematic in the one photo attached, and the actual layout of my board in the other. I'm using 0603 resistors. I even removed them, and put new ones on, measuring them with my Fluke 117 meter before I installed them. The actual values were 29.93K & 7.49K. So I changed my code to match, as follows:
But it still gives me pretty much the same result. For a battery that's fully charged (19.11 Volt reading from my meter), the Arduino gives a value of 24.94 volts. I tried another battery that was run down (13.91 volts) and the Arduino says it is about 20.94 volts.
Is there something I'm doing wrong?
I made this test code, and it gives the same results. I'm using an Atmega328P-AU, 3.3V 8Mhz crystal. But everything else works on the chip -- delay() is correct time, Serial works, etc.
Hmm, I don't have those value and I hate to have to rework that SMD board again. It seems like there would be a way to make adjustments in the formula to make allowance for that?
Just a quick enter of 18V in, 30K on the upper and 7.5K on the lower resister gives me a Vout of 3.6V in Electrodroid app. Little much for a 3V setup. Shooting for a target of 3V @ 20Vinput shows about 5.23K on the lower resister.
tinman13kup:
Just a quick enter of 18V in, 30K on the upper and 7.5K on the lower resister gives me a Vout of 3.6V in Electrodroid app. Little much for a 3V setup. Shooting for a target of 3V @ 20Vinput shows about 5.23K on the lower resister.
And I could keep the 30K on the upper?
The fact that I've already had this circuit hooked up -- possibly giving over 3.3 volts to the analog pin -- will that have damaged the Atmega chip? Probably not since it could be running on 5 volts?
I'll swap out the lower resistor. I don't have any 1% tolerance type, but if I measure the actual resistor before installing it, I should be fine, if I change that value in the sketch, correct?
I thought the 5 in this line:
vout = (value * 5) / 1024.0;
was referring to the ratio of the divider. As in 30K & 7.5K, it IS a 5:1 ratio. But that was just coincidental. I figured out it needs to be 3.3, and I see why now that I think about it.
This is now showing 19.06, and my meter shows 19.11 :). Hurray.
Thanks everyone. And I learned better how it works which I like!
Cheers.
He has his code using 4.996 But he is using a 3.3 volt arduino so you change that to 3.3 volts or what your good meter reads and then the divider he has can read 0 to 16.5 volts.
But to get 25 volts it be better to make better divider 6.8 k and 1 k would work. 30 and 4.6k would work
but that's really to big if you want fast readings the 6.8 and 1 would be better.
According to my voltage divider calculator, using 30K & 5.1K (29.95K & 5.096K actual measured), with a 20 volt input, I would only read 2.91 volts on the analog pin, so I should be fine. I'm getting the correct reading now. only 0.05 volts off from my meter.
SouthernAtHeart:
Hmm, I don't have those value and I hate to have to rework that SMD board again. It seems like there would be a way to make adjustments in the formula to make allowance for that?
Just rework the SMD board, and make sure to know in advance (in future) what full-scale voltage is equal to for the particular board being used.
Normally I'd aim to make the lower resistor 10k (the maximum impedance recommended if using
more than one analog pin), and here an upper resistor of 56k. Easier to work out the ratios (6.6:1)
In micropower circuits much higher resistances can be used, so long as a capacitor is added across the
lower resistor to keep the impedance low enough for when switching analog inputs.