Go Down

Topic: 6v Battery Monitor (Read 811 times) previous topic - next topic

Microboard

Hi,

I'm a new to Arduino programming but managed with a little help online to get a bit of code running.

I have got the code to reading 5v off the board and light up 3 x LEDS at various voltages and works ok.

Now how do i get it to read a 6v 4amp battery and to convert this code to give me a battery monitor,
 
the arduino only can handle 5v ?

Shall i use a resister and a diode? or just a resister? What would be the calculation/ formula  for the values of these components?


Any help would be great thanks.









 

slipstick

Two resistors. Look up "Voltage divider".

And you will need to know the maximum voltage of your "6V" nominal battery...if it's lead-acid it can be around 7V, if it's 5 cell NiMH it will hit over 7V fully charged.

Steve

Microboard

Thank you slipstick,

I've looked on internet and found a voltage divider calculator, so i order resisters to give it a try..

Also stuck a multi-meter on my full charged 6v lead-acid and it reads 6.6v.

just need to work out half charged and flat battery.

Thanks again..

 








jremington

Quote
just need to work out half charged and flat battery.
Look up that information and gain additional invaluable information about proper battery handing at http://batteryuniversity.com/.

Due_unto

When the battery voltage is less than ten I use a simple 2:1 divider, specifically two 5.6K resistors that show equal resistance. Or, if you have one, a twenty-turn 10K trimpot adjusted so that both halves are equal. The ADC will show 1/2 of the battery voltage so just double it.
For example, on my UNO board 5 volts is actually 4.98 so I double that in the analog read statement;
Code: [Select]
Vin = analogRead(analogPin) * (9.96 / 1023);    // incorporates 2:1 voltage divider on ADC input

Here is a text drawing of my divider;
Code: [Select]
    voltage divider:

    V in------------------- 5.6K -------|--------------------- ADC0  (= 1/2 Vin)
                                        |
    Gnd-------------------- 5.6K -------|                  (protection diode drops 0.784 V)
                                        |
    Gnd-----------------------||--------|
                             .01uF

I added the .01 uF cap to help stabilize the ADC readings.
The reading I get always agrees with my meter when I put it across Vin and Gnd. I monitor Vin so I can see when the voltage to the regulator gets close to the twitchy area, somewhere around 6.8 Volts, I heard.
Do not look into laser with remaining good eye.

wvmarle

 Voltage divider: yes.
5k6 resistors: wasting your battery (about 0.5 mA constant leakage).
Cap: not needed with those low resistor values.

Also: bring down the voltage to <1.1V and use the internal reference, which is much more stable than the Vcc reference used by default. You'll have to calibrate it (the voltage is very stable at 1.1V nominal but it's +/- 10%!).

For measuring up to 7V, get an approx. 1:6 divider. 12k + 68k are standard values that would work well for this - the total 80k resistance brings the current down to <0.1 mA. For even less loss, you can increase those values further, 120k + 680k will work if you add a 10-100 nF cap to help the ADC charge up.

So wiring is then GND - 12k - A0 - 68k - battery. Do remember to connect battery ground (negative pole) to Arduino ground.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Kiwi_Bloke

Also stuck a multi-meter on my full charged 6v lead-acid and it reads 6.6v.

just need to work out half charged and flat battery.

Thanks again..
May I suggest you work on volts per cell (VPC) instead of block voltage? While I would normally use this to calculate Sealed Lead Acid (SLA) battery figures it should work for Ni-Cad and Lithium.

Most battery manufacturers will list VPC figures because it then doesn't matter how many blocks are in the string the result is the same.

As an example most SLA battery manufacturers would consider 2.25 - 2.27VPC to be correct float voltage at 25 degrees Celsius ambient temperature.

2.25VPC is 6.75volts for a 6 volt battery or 13.5 volts for a 12v block (each cell is nominally 2 volts)

Depending on a number of usage factors there are recommended maximum discharge figures, these factors include: intended cycles - will the battery discharge every day? once a week? only occasionally?
How long do you need the battery last? Months? years? or is it a short term project and you don't care?
What is the minimum voltage your load can operate at?

For a high cycle count I would recommend no less than 1.8VPC
For general standby type operations maybe 1.7VPC
For occasional high importance loads most "standard" batteries will go down to 1.65VPC

(just multiply the VPC by 3 for a 6 volt SLA battery, by 6 for a 12 Volt or 384 for the battery strings I used to design)


Due_unto

@wvmarle
I had thought that it was important to closely match the input impedance of the ADC input, which I believe is around 10K. Can I assume that is not necessary for very slowly changing levels? I did increase both resistors to 82K which reduced battery draw down to a little over 0.03 mA.
Do not look into laser with remaining good eye.

wvmarle

The input impedance of the pin is much higher than that - should be in the tune of a few GΩ.

This 10k is the recommended maximum output impedance of the signal connected to the pin (which in the case of the voltage divider is the value of the resistors). This to allow the small cap that is the ADC to charge quick enough for the ADC to follow any voltage. At that kind of signals you pretty much don't have to worry about anything but proper connections, it'll just work. You can get away with a MUCH higher output impedance on your signal. There are a few things to consider when you do this.
You can't do this with a fast changing signal (battery voltage changes slowly).
You may have to help the ADC with a little charge reservoir - that's that cap between the ADC and GND. It helps to get the ADC to the correct charge level quickly, and generally helps stabilising the signal.
When you go really high (MΩ kind of values or higher), you may get problems with EMF, as all wires act as little antennas, and external electrical fields (the 50/60Hz mains is notorious) can mess up your signal. You may start to see this signal on top of what you're trying to measure. A cap also helps stabilising the signal.
Adding a capacitor to your analog pin will delay reaction: the cap forms an RC circuit with output impedance. So a 680k resistor and 100 nF cap would make the signal take about 340 ms to go from 0 to maximum value. Not an issue for monitoring batteries, whose discharge times are in the hours. Using a 10 nF, or even a 1 nF cap (should do the job just fine - the ADC's cap is a few pF only) brings down this reaction time to 3.4 ms.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Due_unto

Thank you! That helped clear up a few misconceptions I had about the ADC characteristics.
Do not look into laser with remaining good eye.

Microboard

Duo_unto
 
Thanks for your divider drawing, i have built it minus the .01uF cap i don't have one at the moment.

I doubled the statement and its reading same has the 6v battery with the meter.

Just trying to work out the best voltages for the battery levels now.

Thank you all for your posts.

I will be back with some more problems soon..LOL






Microboard

After testing i've found with the diode theirs a fluctuation in the voltage on serial monitor but with out the diode its stable??

This caused my LEDs to flash from one to other at between the voltages..




wvmarle

Please post diagram of your actual circuit (the ones with and without the diode).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Microboard

When i have installed the battery monitor its fluctuating under load 2 x rc motors being powered,
also its tripping the nano board and resetting it.

Would a diode fix this to regulate the voltage ?



wvmarle

Please post diagram of your actual circuit.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up