This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anyone got a Battery SOC Algorithm ?
#1
I currently monitor voltage and current in/out for my 3 battery banks and wondered if I could devise a Coulomb-counting battery monitor.
I was thinking of something in Node-red but thought Id ask if anyone has done it already
Its the algorithm I really need but if anyone has a NR flow or node that would be perfect
Thanks
Reply
#2
You got me interested, so I did a bit of Googling.

This is interesting, but it might be a little complex to code! https://www.researchgate.net/publication...easurement

Well, I'll be darned. https://github.com/jogrady23/kalman-filter-battery-soc
Reply
#3
(2021-02-04, 09:32 PM)abarrow Wrote: You got me interested, so I did a bit of Googling.

This is interesting, but it might be a little complex to code! https://www.researchgate.net/publication...easurement

Thanks - I'll take a proper look at that tomorrow
I also searched and came up with a number of University projects/papers with various algorithms to play with 
I was secretly hoping that someone would have coded it all up into a neat little Node-Red flow  Wink
Reply
#4
Complex stuff!! Think it would be better to save all the data in influxdb then do the calcs with SQL.
Reply
#5
(2021-02-04, 10:36 PM)PaddyB Wrote: Complex stuff!! Think it would be better to save all the data in  influxdb then do the calcs with SQL.

Agreed
Its already going to an Influx db 
I think I'll experiment initially with counting the Coulombs and cross check against low load/no charge overnight voltages see where that gets me
Reply
#6
Interesting paper.  Off the cuff, the authors are thinking about new batteries and ignore battery capacity deteriorates with time and usage.  Deterioration is different and known for different battery types like Lithium, Gel or Lead Acid.  Deep cycle batteries are built better and deteriorate more slowly.

In my day job as an electrical engineer, I'd research this for a proper answer.  These thoughts are factors that come to mind for the battery measurement task.  I intend to do an actual algorythm for this in the next few months.  I'm sure the smart battery chargers and solar controllers have remaining capacity in a battery figured out.

Coulomb counting couldn't be easier.  An Amp is a Coulomb per sec or 6.241e18 electrons per sec.  100 AH batteries in theory are at 50% after 50 Amp draw for an hour.  Hot batteries don't give as much, cold batteries (5Amps for 10 hours) give more.  Capacity left in a battery could be calculated on the fly, or stored in a database and calced easily. Actual curves based on high or low draws could be considered.

Problem is, you don't know the AH capacity of your battery.  You can measure how much gas you used, but your gas tank is probably smaller than you think.  Amp hour capacity of batteries deteriorates with use, more so with most batteries if you run them down to zero a lot. There are accurate pulsed measurements of actual amp hour capacity, but that's overkill.  For most uses, a battery that hits 66% of original AH capacity should be replaced as deterioration increases past there.  Measuring voltage at a particular rate of discharge or better at no discharge somewhat indicates actual battery capacity deterioration.  This measurement doesn't work if the battery has been recently under a charge from shore power or the alternator.  I recall this is called a "surface" charge.

I'm looking at doing current measurement with a INA260 0.01 ohm shunt or a toroid with an ACS 712 or similar.  The electrical isolation of the toroid seems better but then I'd need a ADC to measure voltage at the battery.

Another real world thought is to flag a low battery voltage after extended charge.  Batteries fail by shorting out a cell when the plates touch.
Reply
#7
Related: as the algo is going to have a drift you need to reset the SoC somehow periodically. https://m.youtube.com/watch?v=mEN15Z_S4kE
Reply
#8
(2021-02-04, 11:58 PM)SailAlpha Wrote:  I'm sure the smart battery chargers and solar controllers have remaining capacity in a battery figured out.

I'm more sure they don't!  Big Grin

For starters they don't know where the power is going, I suspect nearly all solar regulators go to float too soon as they think power going into a fridge is going into a battery. Victron might be one of the very few exceptions as their smartshunt will tell a smart regulator soc & amps in/out so the regulator knows what's happening at the batteries. I recently got a smartguage which from testing came out as a very accurate gauge of battery state of charge, very interesting running that alongside a victron smartshunt with all the data going into influxdb. with some tweaking of battery capacity on the smart shunt you can get the 2 to display fairly close output but temperature and current draw makes a big difference. Warm batteries have quite a lot more capacity than cold batteries. IMHO, with lead acid it's much more important getting them back to really fully charged (not what the regulator or bms says) often than it is know the exact soc at any given moment. 
Interesting project but so many variables with peukerts and charge efficiency all varying with temperature it is a very complex calculation to guess soc...
Reply
#9
(2021-02-05, 11:24 AM)PaddyB Wrote:
(2021-02-04, 11:58 PM)SailAlpha Wrote:  I'm sure the smart battery chargers and solar controllers have remaining capacity in a battery figured out.

I'm more sure they don't!  Big Grin

For starters they don't know where the power is going, I suspect nearly all solar regulators go to float too soon as they think power going into a fridge is going into a battery. Victron might be one of the very few exceptions as their smartshunt will tell a smart regulator soc & amps in/out so the regulator knows what's happening at the batteries. I recently got a smartguage which from testing came out as a very accurate gauge of battery state of charge, very interesting running that alongside a victron smartshunt with all the data going into influxdb. with some tweaking of battery capacity on the smart shunt you can get the 2 to display fairly close output but temperature and current draw makes a big difference. Warm batteries have quite a lot more capacity than cold batteries. IMHO, with lead acid it's much more important getting them back to really fully charged (not what the regulator or bms says) often than it is know the exact soc at any given moment. 
Interesting project but so many variables with peukerts and charge efficiency all varying with temperature it is a very complex calculation to guess soc...

Yes I'm happy that I can now accurately monitor (and record) Battery voltage and amps In/Out. 
I already have a NASA BM1 on the boat which has a SOC function. The SOC function does appear to count Amps In/Out but its clearly not as sophisticated as the Victron.
In practise I ignore the SOC function and just use the BM1 as a Volt/Ammeter.
The idea of trying to emulate a Victron BM is a just lockdown brain teaser but I prefer it to Sudoku.
Reply
#10
The Victron SmartShunt was mentioned and just did a post for a DIY connection to the VE.Direct interface.
Found here https://pysselilivet.blogspot.com/2021/0...berry.html
Signal K have a plugin, @signalk/vedirect-serial-usb, which handles the output and format it as SK data.
________________________________________

Blog; https://pysselilivet.blogspot.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)