Go Down

### Topic: 12v lead acid battery cutoff sketch (Read 4370 times)previous topic - next topic

#### highnitro

##### Aug 31, 2011, 02:00 am
hi there everyone,

I need to make a simple means of disconnecting my 12V lead acid battery from a DC water pump. the problem is on a series of cloudy days the pump draws the battery

down to far (8-9V) due to the lack of power normally coming from my solar panel (and charge controller). So i figured i use the arduino and the analogRead funtion to

monitor the battery voltage. I was seeking help in using the arduino to control a relay which would cutoff the pump allowing the battery to charge.

-does the analog read function only read up to 5V ? would more damage it ?

-i need the pump to cut out @ 10.5V

-i was thinking a voltage divider could be used to cut the battery voltage in half

-im thinking a delay would be needed after it cuts out the pump, due to the voltage rising fast after the load disappears

-where in the code would i put the delay command ?

any input would be much appreciated   i have the UNO version

#### retrolefty

#1
##### Aug 31, 2011, 02:17 am
-does the analog read function only read up to 5V ? would more damage it ?

Yes pin voltage in excess of Vcc voltage will cause damage, so 5vdc limit on 5 volt boards and 3.3 volt limit on boards running a 3.3vdc.

-i need the pump to cut out @ 10.5V

Your choice, but you might want to check battery manufacture data for safe discharge voltage to be sure.

-i was thinking a voltage divider could be used to cut the battery voltage in half

Yes, a typical solution. Wire a 10k ohm  and a 5k ohm resistors in series, 5k end to arduino ground and battery ground, 10k end to battery positive. Resistor junction wires to analog input pin. Scale the analogRead counts to a useful scale say in millivolts.

-im thinking a delay would be needed after it cuts out the pump, due to the voltage rising fast after the load disappears

Better method is called adding hysteresis in the switch states, so you need two decision values in your code so as to not chatter the relay on and off at a single voltage set-point. You should also wire the relay such that it is normally power on when battery voltage is OK and turned off with battery voltage is low, so that you are not consuming battery current for the relay coil in the low condition. Using a relay with normally closed and normally open contact options make this easy to do.

-where in the code would i put the delay command ?

I don't see your code? Actually using proper two values with proper hysteresis you shouldn't need a delay. Relay turns off power at your 10.5 value, but not turn it back on until 11.5, for example. You will have to play around with the values and proper separation values, but that's not hard to do.

Lefty

#### gardner

#2
##### Aug 31, 2011, 07:05 pmLast Edit: Aug 31, 2011, 08:19 pm by gardner Reason: 1
The interesting part of the state-of-charge curve on a 12V nominal lead acid battery is between about 10V and 14V or so.  What I have done is used a 10V zener diode to shift this voltage range into 0V..4V and fed this straight into the 5V A2D.  This gives good accuracy over the interesting range and avoids wasting input range of the A2D on the part of the voltage curve (0V..10V) over which the battery is essentially dead.

You should establish your cut-out point based on the discharge rate -- the voltage you will measure is a function of the current being drawn, the capacity of the battery and the state of charge.  10.5V is good a rule of thumb, but you can calculate a more suitable cut-out level if you know the current draw of your load, the internal resistance and the capacity of the battery.  Also, if you want the battery to last a while, you should target a 30% or 50% SOC for cut-off, not 0%.  Completely discharging a lead acid battery will shorten its life dramatically.

If the battery capacity is small, it will have a large internal resistance and the voltage rebound when the load is removed might be pretty big.  If it were me, I would be looking for the voltage to rebound to the 50% or greater charge level -- maybe 12.2V at open circuit -- before returning loads.

Of course if the battery is on a charge circuit, maybe solar panels, then assessing the SOC is more complicated -- a function of how much current is flowing in via the charger, what voltage it's charging at, what the internal resistance and capacity of the battery is.

For a simple circuit, I would in fact incorporate a timer and not rely on hysteresis to get things right.  If the SOC drops to, say 30% and you remove the load, and you know that the solar charger takes X hours to charge the battery, you can have your algorithm look for the voltage to rise to -- say 12.8V -- and stay above this level for X hours, before restoring loads.

EDIT: I was rummaging around looking for details on one of these points and found this:  http://www.scubaengineer.com/documents/lead_acid_battery_charging_graphs.pdf

#### highnitro

#3
##### Sep 02, 2011, 08:15 pmLast Edit: Sep 02, 2011, 08:18 pm by highnitro Reason: 1
Thank you guys for such detailed replies, your comments have made me rethink my approach but i am new to arduino and  writing the code is the next hurdle lol

if anyone could help me with this simple code structure i could tinker more and move forward. im using a breadboard to proof a concept but im stuck at verifying it.

seems to be an issue with the "if" line. im sure ots a simple problem that one of you guys would spot instantly
Code: [Select]
`// low voltage cut-off#define RELAY 7#define DIVIDER A0void setup(){  pinMode(RELAY, OUTPUT);  pinMode(DIVIDER, INPUT);} void loop(){ analogRead(DIVIDER);}if (DIVIDER <700){  digitalWrite(RELAY, HIGH);}else{  digitalWrite(RELAY, LOW);}`

#### wildbill

#4
##### Sep 03, 2011, 02:37 pm
You are reading the analog pin, but throwing the result away. Then you're comparing the pin number to 700. Both are constants, so they'll always give the same result. Lastly, a problem with braces put the if outside of any function. This is what you intended I think:

Code: [Select]
`void loop(){ int VoltageReading;VoltageReading=analogRead(DIVIDER);if (VoltageReading <700)  {   digitalWrite(RELAY, HIGH);  }else  {  digitalWrite(RELAY, LOW);  }}`

Go Up

Please enter a valid email to subscribe