Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help!Low battery monitor,using microcontroller

Not open for further replies.


Newbie level 5
Jul 22, 2009
Reaction score
Trophy points
Activity points
microcontroller battery monitor

Hey,im working on a low battery project to be used on a UPS to detecte low battery and overload,when low battery at (10.2V) an alarm is tuned using reading the voltage through 10bit ADC through a voltage divider,im filtering the output voltage through a lowpass fillter.Im able to read the battery voltage just fine,but im having a problem when a put a load on the UPS i have a voltage drop making the alarm sounding before expected(the battery didnt yet reach 10.2 volts,and this is expected since im pulling a high current form the battery.i need to read the real voltage on the battery not the droped voltage does anyone have an idea of how i able to do that?

pic battery monitor

Hai twisted

It happens. To avoid this problem check voltage for a predefined time say for example .5 seconds. If the voltage stays below 10.2V for .5 seconds then switch the alarm

MicroCon viewtopic

You can set a low pass (RCfilter) at the input of the ADC.
The short dips will not pass.

battery monitoring through microcontroller

or use a current sensor so if the current is too big, or transient, you can ignore the voltage rating (for a while).

low battery monitor

i have tried to 0.1sec delay before but the problem is not here because the voltage drop is constant,i think due to the battery internal resistance or the wires resistvity,im using 6mm² wiers and its not a good soulution to increase the wire crosssection to 10mm²...the drop increases with the increase of the load,so dont know .
and im already using a lowpassfilter in the input of the ADC
thanks guys

microcontroller read battery

How much current are you drawing?
This also depends on your battery capacity as well and what type of battery it is
there are lots of factors you have to look at and take into consideration.
EG. 12V 100AH at the 20hr rate will only supply 5amps for when 20 hours before 100% discharge but only 80% recommend (again depends on battery) Car batteries are not meant for heavy discharging, these work by cold cranking amps, The battery I would say you need is a deep cycle type.

So if your load was drawing a continuous load of 15 amps the 100/15=6.66hrs before flat, This is not strictly true the battery will only last 5.30hrs and if it was 30amps then it would only last 2.3 hours.

So carrying on from above you need to check if your battery is capable of supplying the required current for the hours you require,
other factors where are you measuring your voltage from at the battery terminals or at the load end, even if your current draw was 60amps it still would take 1hr before flat.

why not try a 1-5 seconds delay before sounding alarm, you could try and take several samples over 1 or 2 minutes then work out the average from that before sounding alarm

Your cable could be causing some of the problem if current draw is too much have your tried this way measure you voltage at the battery then at your UPS end see what the difference then subtract that from the reading or just calibrate what your reading at the battery end with your meter, Let’s say if your meter reads 12.01V on the battery terminals then at the load end it reads 11.67V then you can take that of in the software or just get your LCD or raw value to what your meter reads,

hope that helps

check battery microcontroller

microcon provided the best idea. Basically this is a programmable lowpass. You read the ADC and several times in a given time frame and look at the gradient. You should know how low the dip last and when the voltage comes back up. So, sit it out if it is just a short dip.
I do not know about your particular application but a low bat warning with a lead battery will be just as good if it comes 5 or 10 seconds later. In regular working mode the voltage will drop very slowly.
However, if you need to provide an alert for a short voltage dip as well, you are in trouble :|
A "real low bat situation" should show a different voltage curve that you can scan with the ADC and evaluate with you MCU.

hth, Bob
**broken link removed**

my battery reads 10.2 volts is the battery done

hey wizpic
the current im drawing from the battery is not constant it is load dependent ,and the load it self is not constant since i need it to work anything,and yes im using a (car battery acid lead...) also the battery may vary from 100Ahr,150Ahr or 200Ahr,so u see i have many variables.
when measuring the voltage on the battery terminals,and on the UPS end there is a differnce that whats causeing the problem foe example: on a 300Watt load the difference is about 0.25Volts ,and on 500Watt load the difference is u see the voltage drop is not constant.and about the 1 or 5sec delays it wont work because the voltage drop doesnt rise up it remains the same!!!! so its not just a DIP
when i started this project i thought it would be the peace of cake :|

lead battery monitor

Twisted Car batteries are not the best choice you really need to use a marine type or leasure battery these are best for contstant load, Car batteries only hold charge for a short time has they are best for crnking and supplying currents for a short time, If you draw 500W(41amps) a 200AH battery will last about 5 hrs before 10.2 volts is reached, I would upgrade the cable to 10-16mm, This should reduce volts drop big time, the cable lenth play a big part in it to.

That's the trouble you think it will be easy but it never seems to go that way some projects take longer than you think.:D

battery monitoring using microcontroller

well as i said its not possible to increase the wire to 10 or 16mm ,its not economical to do that...though it might work...need to find a better way.
something else i have seen a working circut made on LM324 IC and it doent seem to have the same problem it is able to detect the voltage correctly but i cant seem to know how it is able to do that!!! if u want i can scan the design of this circut.

microcontroller battery voltage

I shall have to have a think about this one if you can scan it I will have a look adnd may get a better idea from there. How close do you have to be to 10.2 ?

battery monitoring adc

ok here is the schem. ,on this circut when i can set the voltage i want using the variable resistence...the werid thing that its not effected by the voltage drop it always sounds the alarm on 10.2(after i chose this voltage by the variable),i dont get it !!!!
i need to be as close as i can get to 10.2volts

op amp battery monitor

I will have a look and study the drawing,
one question if this works well then why re-invent the wheel unles you want the pic to do other stuff then I can understand.

is the load varibale by the same unit of does this depend on on what saize unit you fit ?
The only reason in asking if they are different units hen you coudl use a dip switch to tell the pic what routine to use either 200W or 500W say.

low battery sense pic18

this is a part of a big poject,im using the pic in other things too.
the load is not variable by the same unit it could be anything...i know what ur saying i thougth about it to.
i have an idea i dont know if it would work,im thinking that if i calculate the resistivty of the wire i can solve this problem...but i dont know maybe thats not what causeing it,and why is it working on the 324 IC!!

low bat

The LM324 is analog and pic digital, What language you writing the code in ?
How long does it take to reach 10.2V
I have just re-read the topic am I right in saying the alarm goes off before 10.2 is reached

Have you got a scheamtic for your set up on the A/D part or what does your R/D consist of ? do you have LCD on there , The only reason I ask I can write a bit of code for you to test

PM if you don't want to upload here

voltage monitor with microcontroller

I failed to see how the analog / discrete solution will achieve what you couldn't do with a mcu.

if I were you, I would go back and think through the conditions under which you want to generate a "low battery" signal and then implement that in a mcu of your choice.

because whatever you can do with a discrete / analog solution, you will be able to implement that with a digital solution.

battery monitor divider

millwood said:
I failed to see how the analog / discrete solution will achieve what you couldn't do with a mcu.

if I were you, I would go back and think through the conditions under which you want to generate a "low battery" signal and then implement that in a mcu of your choice.

because whatever you can do with a discrete / analog solution, you will be able to implement that with a digital solution.

You are right....

You can implement anything / everything in digital.

In this case, i think the opamp is very slow and took much time to sense a low battery condition, which he has not tried with the micro

using adc to detect low bat

im using MickroC,i can send u the code but it would be pointless because in my testes i redused the code to just reading the ADC and truning ON or OFF a led and a couple of delays,and the scheamtics its just a voltage divider and a low pass filter basicly a very simple circut...
How long does it take to reach depends if the battery is full and on how mush currrent im drawing from it...
millwood dude i also failed to see how the analog achieved what i couldn't do with a pic,i dont know realy i dont ,if i did i wouldnt have asked :cry:
by the way how slow is the OPamp...its slow compared to the mcu,but not that slow!!!!
well guys i guess there is something missing and the weird thing is that the other day i found a circut made very simler to mine the connections are very similer to mine ,but i dont know who made it and i dont have the code...i made some testes on it and it works just fine!!!!ok this is a bit crazy i know...
well i guess i will analyize th 324 maybe i will find something.
battery monitoring using op amp

Do you print on a LCD ?
If so with no load how does the voltage on the lcd display compared your multi-meter so close or how far away is it, I don't use C, I was just going to try it my end and send you the hex file to try, I just can't seem to understand the op-amp works but not the PIC, I have done a simualr thing and that is spot on every time the lower voltage limt is reached.
Let me know what your set up is IE. what port the LCD on and your input is, I've ran a quick test and I can get mine to switch a LED on once 10.2V is reached
battery monitor pic microcontroller

i think you you should calculate the load and acoording to the load you can define the cut off voltage .
Not open for further replies.

Part and Inventory Search

Welcome to