Battery level measuring circuit - Page 1
Forum section: electronics / projects

author: kallileo
author_rank: Contributor
timestamp: March 18, 2016, 06:33:17 pm
content: I have two 12v batteries in series and need to measure the charge level using a analog input (0-5V) of my PLC.It seems that I have to design a simple circuit to convert 24v to 5v but I also want to have the output isolated from the input.The most simple solution would be to use a voltage divider but the output isn't isolated.I'm an automation engineer and I'm not really experienced in electronics design so I need some tips on where to start.

author: Seekonk
author_rank: Super Contributor
timestamp: March 18, 2016, 06:44:22 pm
content: An opto isolator is some what linear. Use an 18V zener and resistor on the LED side and that should give an expanded range. It would have to be calibrated for each opto. MAP function would recreate voltage. Not perfect, but battery voltage is a very poor indicator of charge anyway.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 18, 2016, 07:28:22 pm
content: It is very difficult to get a good indication of state-of-charge of a lead acid battery. Voltage tells you if the battery is connected to a charger. If you have moments of negligible load currents, you can then estimate the state-of-charge somewhat, but you need to know when to measure, because it's normal that the voltage drops under load.OTOH, most lead acids die rather quickly if they are at anything else than 100%, which is why they are charged whenever possible. So, indication of non-full / charger not working is often enough; this is what cars normally have (an indicator light for voltage less than about 13.5-14V, which happens instantly if the generator stops working).There are special linear optocouplers. Get one. It's one of the easiest ways. They often need a simple opamp feedback for linearity (AFAIK some have it integrated), but the datasheets show the typical application circuit.

author: Seekonk
author_rank: Super Contributor
timestamp: March 18, 2016, 08:06:50 pm
content: There will be lots of suggestions to over complicate your life. This is all you need for a general 20-28V battery monitor. Adjust pot to get 3-4 volts on PLC sense resistor. Optos vary wildly but this should get you in the ballpark.

author: kallileo
author_rank: Contributor
timestamp: March 18, 2016, 09:55:11 pm
content: The two 45Ah car batteries are used to supply a propulsion motor of a electric vehicle.I already use a voltage divider with 2.2k and 470R resistors to measure the voltage but when the vehicle connected to the charging station it's grounded and I prefer keep the inputs of the plc and the hmi isolated from earth and high voltages.So now the PLC measures the voltage on the 470? resistor which varies between 4,3 - 5v and get the charging level.I don't need accurate measurement but just a rough estimation.When the batteries are charging the voltage is around 28v and I consider the batteries fully charged until the voltage drops below 25v. Between 25 and 24 the voltage normal and from 24 and below I consider it to be low.Seekonk i will experiment with your circuit...but i want to avoid adjusting pots even if it makes the measurment less accurate.

author: Seekonk
author_rank: Super Contributor
timestamp: March 18, 2016, 10:08:58 pm
content: but i want to avoid adjusting pots even if it makes the measurment less accurate.I can understand that, but due to component tolerances this method does not stand a chance without adjustment. There certainly are expensive ways to do it. If forced to do it right now I would use a $2.50 328 nano board, measure voltage with A/D, send out PWM to opto driven to saturation and average that to PLC A/D.Considering you would be making a board it would be easy to make a test jig for the opto solution. With just two resistor positions, 5 resistor valuess could get you more than 13 resistances. Test and stuff.

author: hamdi.tn
author_rank: Frequent Contributor
timestamp: March 18, 2016, 10:16:59 pm
content: if you definitely need isolated analog output, easiest way is some isolated opamp from TI. simple as that. but it's not the cheapest thing you can buyas i remember something around 10€.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 19, 2016, 06:56:15 am
content: Quote from: kallileo on March 18, 2016, 09:55:11 pmYou realize that so-called "car batteries" cannot be used in EV propulsion?Just sayin' to save your money. They will last about a few dozen cycles. It's the most expensive set of batteries you'll ever find; those few test drives will be expensive as hell.Li-ion is really cheapest today, but if you must use lead acid, use deep discharge variety, specifically made for this purpose, not a car starter battery.For EV, you really want to have rather accurate battery monitoring. Current integration is the only viable solution (especially with lead acid); you need a current sensor and a microcontroller or a specific IC that integrates current over time. This is called Coulomb counting. If this sounds too complex, there are products on the market that do exactly this so you don't need to DIY.

author: kallileo
author_rank: Contributor
timestamp: March 19, 2016, 07:40:41 am
content: Quote from: Siwastaja on March 19, 2016, 06:56:15 amI was mostly referring to the size.I'm totally aware of that. The batteries on my machine (electrically driven trolley) are specially made for EV and they are two times more expensive than the normal ones. Have been using them for 2 years now without any problem.There is absolutely no need for accurate monitoring as the voltage divider solution is sufficient and I just want to add isolation. The isolation is probably not even needed but I look at it as exercise to better understand electronics design so any circuits would be interesting to study.It seems that I will have to start with linear mode of the optocouplers, zener diodes and isolated opamps.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 19, 2016, 07:59:33 am
content: Quote from: kallileo on March 19, 2016, 07:40:41 amOK, good! I just wanted to make sure because I have seen people losing a lot of money and then getting frustrated.Accurate SoC monitoring is something what most people really want in an EV, but if it's a trolley that's not driven on public roads and not far away from charging points, then this isn't so much of an issue.That zener solution would be good enough. At least you'll get an indication briefly before the batteries are completely flat, so maybe you can return to a charging point.

author: kallileo
author_rank: Contributor
timestamp: March 20, 2016, 09:00:24 am
content: I'm trying to simulate the circuit and but it seems that I'm making a mistake somewhere.The input seems to work as I get 6mA or more (depending of the combination of resistors and voltage level) flowing but the output doesn't work as I get only 11mV at R3 and few ?A flowing through it.What could be the problem?

author: kallileo
author_rank: Contributor
timestamp: March 20, 2016, 09:33:58 am
content: Thanks.I found it myself as soon as I finished the breakfast.I want avoid using specialized ICs and complex circuits.Does it makes sense putting a small fuse (50mA) on the input to protect the optocoupler?The simulated values of Vout to Vin are shown in the attached chart.If the real values anywhere near the simulated chart is more that enough for my application.

author: Seekonk
author_rank: Super Contributor
timestamp: March 20, 2016, 02:57:03 pm
content: A 50 ma fuse will cost more than the entire circuit. What I often do with battery circuits like thay is burry the 1000 ohm resistor in the terminal lug that attaches to the battery and put several layers of shrink on it. Then if the lead gets crushed no damage can be done.

author: Buriedcode
author_rank: Super Contributor
timestamp: March 20, 2016, 06:42:43 pm
content: I haven't seem this mentioned, but if you're after isolation, and a fairly accurate result... whats wrong with PWM?A simple opamp (ramp) and comparator circuit on the battery side, and either a LPF or directly reading the duty on the other. A micro on the battery side would need heavy regulation to cope with transients, but an opamp circuit should fair better. Traditionally V-F converters were used,

author: Zero999
author_rank: Super Contributor
timestamp: March 20, 2016, 07:58:52 pm
content: http://www.silabs.com/Support%20Documents/TechnicalDocs/AN614.pdfhttp://www.edn.com/design/analog/4402736/Inexpensive-analog-isolation-using-a-digital-isolatorhttp://cds.linear.com/docs/en/lt-journal/LTJournal-V21N3-10-di-LTC6992-Tim_Regan.pdf

author: AndrewDojo
author_rank: Contributor
timestamp: March 20, 2016, 08:10:02 pm
content: You might consider using a 555 or similar on the battery side as a voltage controlled oscillator.Send the oscillator output through the opto.Then on the PLC side, you can either convert the frequency back to a voltage using an RC filter, or just measure the frequency directly in the PLC.

author: Zero999
author_rank: Super Contributor
timestamp: March 20, 2016, 08:14:45 pm
content: Quote from: Buriedcode on March 20, 2016, 06:42:43 pmIf you were to use a micro, then it would make sense to transmit the data digitally to the PLC, via RS232 or Profibus, which can easily isolated.

author: AndrewDojo
author_rank: Contributor
timestamp: March 20, 2016, 08:23:39 pm
content: Quote from: AndrewDojo on March 20, 2016, 08:10:02 pmCorrecting myself, the 555 would need to be in a pulse width modulation circuit to do RC integration.

author: Seekonk
author_rank: Super Contributor
timestamp: March 20, 2016, 10:40:05 pm
content: Quote from: Seekonk on March 18, 2016, 10:08:58 pmQuick and dirty half dozen lines of code. I can just imagine the time to do an op amp design. I think the original opto design is fairly simple. Just have a couple resistors on the board and clip the leads till it cals in.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 21, 2016, 07:44:13 am
content: For some, coding a few dozens of lines and programming an MCU is a near-impossible task.For some, googling an op amp schematic and possibly drawing a few symbols in LTspice and having a quick simulation is a near-impossible task.In reality, both are extremely quick and easy solutions. Just choose one that is more familiar to you.Or, do the simple zener opto thingie shown first. It's nonlinear and drifty, but so is the battery voltage as the SoC indicator - even more so. You'll get the indication of "you're going to need to stop the vehicle very soon" and not much more anyway.

author: max_torque
author_rank: Super Contributor
timestamp: March 21, 2016, 07:50:20 pm
content: LT have some nice "singe chip" voltage to frequency devices in the Timerblox series (LTC6992 etc) These make converting a voltage to a digital signal and passing it across an isolation barrier very easy!

author: Smokey
author_rank: Super Contributor
timestamp: March 21, 2016, 11:17:53 pm
content: Avago Analog Isolators... Done.http://www.avagotech.com/products/optocouplers/hermetic/isolation-amplifiers/