amp and Volt meter

Discussion in 'General Electronics Discussion' started by donkey, Oct 19, 2012.

1. donkey

1,301
57
Feb 26, 2011
hey guys the only reason I am posting here and not on the arduino forums is cos you guys actually respond.
the project is a simple amp and voltmeter setup using arduino to monitor it. I don't want it to shut it down or anything just to tell me the amount of power left in the batteries. the issue is I have NO idea how to do this.
the system will either be 12 or 24volts (still debating) and I need to hook up an arduino to monitor a few things like :
-charge from panels
-charge in batteries

the issue I am having is I don't understand how to hook a 5v pin to a 12volt system to read these levels without blowing the arduino.
any help is appreciated

2. donkey

1,301
57
Feb 26, 2011
doh just realised the stupid heading... its supposed to be amp and volt meter
anyway the best I have seen is going to 20v using something like this

using 50k as R1 and 4k3 as R2
this apparently measures up to 12volt
how can I get that to 30 or 40v just to be safe?

Last edited: Oct 19, 2012

242
9
Aug 9, 2012
4. wingnut

242
9
Aug 9, 2012
Suppose you have 40V

The formula for R2 is....

Vdrop across R2 =R2 x 40/(R1 + R2)

What it means in effect is that to get 5V from 40, R2 will be 1/8 of total resistance. If R2 = 1k then R1 = 7k and V across R2 = 5V.

Last edited: Oct 19, 2012
5. donkey

1,301
57
Feb 26, 2011
awesome. wingnut.
so using that I can use a quick scale to calculate the % of 5volt thus giving me the right voltage for 40 right? so if for example the voltage on the pin is at 75% of 5volt then it would also be at 75% of 40volts right?
also would I have to modify this circuit and if so how, if I wanted to measure current? cannot find anyone with any details on how to measure current in arduino

Last edited: Oct 19, 2012
6. wingnut

242
9
Aug 9, 2012
Correct.

If you have a known resistor, and you can read voltage across that resistor, then Ohm's law will give the current or I = V/R. Since Arduino can read V, translating this into I should not be difficult. You could use a small resistance so as not to significantly alter the current.

7. CocaCola

3,635
5
Apr 7, 2012
One word of advise if the 12V isn't regulated it's best to divide it down to worst case so you never exceed the 5.5 or so volts the AVR can tolerate happily, even if this scaling causes a loss of resolution and changes the simple percentage math...

Example assume 15V (good reference number for automotive use) max so you have a 1:3 ratio and 12V would only be 4V so you have a 0-4V resolution to read from vs a 0-5V but you have overhead so you don't fry the port if the voltage exceeds 12... Adjust the code appropriately for this induced error...

8. donkey

1,301
57
Feb 26, 2011
thanks for the advice. I was worried I would need to modify this circuit alot.
the only addition to this circuit will be a 2.4 ghz tranciever but if I can get this working I can then do the other side.

9. CDRIVEHauling 10' pipe on a Trek Shift3

4,960
653
May 8, 2012
Donkey, you didn't state what the expected min/max current will be. Keep in mind that the current sens resistor (Rs) should be typically a low resistance value, as to make it as insignificant as possible to the operation of the circuit. It also has to be connected from ground to the low side of the load because the Arduino's ADC is referenced to Gnd.

This brings up another point. Because Rs must be a very low value, probably 0.1Ω or 1Ω the voltage drop will be far below the ADC's 0 - 5V range. If Rs= 1Ω then the voltage drop will be direct @ 1V per Amp. I don't think this will be acceptable unless your current demands are <= 1A. If so the ADC would see a max swing of 0 to 1V. A 0.1Ω would be a better choice but Rs will produce only 100mV per Amp. A good low noise rail to rail OpAmp could cure this issue by amplifying the small voltage drop across Rs to produce a 0 - 5V swing for the ADC input.

Chris

10. BobK

7,682
1,689
Jan 5, 2010
And then there is the problem that the current used by the Arduino is not being counted (assuming it is running off the same battery). A high-side current sense IC would eliminate this problem and also provide the needed amplification.

http://www.maximintegrated.com/app-notes/index.mvp/id/746

Bob

11. CDRIVEHauling 10' pipe on a Trek Shift3

4,960
653
May 8, 2012
This probably a better Hi Side method than I was considering, which was an OpAmp with the inputs wired differentially across Rs.

Chris

12. BobK

7,682
1,689
Jan 5, 2010
Well, that is basically what it is, in a package designed for that purpose.

Bob