I can then run the battery down, with the monitor connected and logging to SD card, and see how the voltage varies with the load. It will also give me a chance to try and estimate the number of amp-hours the battery can hold. My batteries are coming up to 3 years old this summer, so it will be interesting to see how they are still performing.
Last night I started coding some of the Arduino software to deal with estimating the state of charge of the batteries.
There are two types of battery monitor, the ones that just look at voltage, and the ones that count the charge going in/out of the battery. I'm hoping to do a hybrid approach of both. You can only really get a good estimate of the SoC by looking at the voltage if the battery has been 'at rest' for some time. This gives you an absolute reading of the SoC. Counting the charge in and out can be done at any time, but only gives you a relative SoC reading and is prone to drift. You also need to calculate things like charging factor (e.g. it can take 1.2-1.3A charging input to store 1A of charge). And deal with Peukerts law (drawing a large current is less efficient than a small current).
The problem with voltage readings is that a battery in a motorhome is seldom 'at rest' due to continuous loads such as the fridge compressor kicking in and lighting etc. However my battery bank is designed to let us run for 3-4 days off-grid and there *are* times when the batteries are at rest (e.g. at night when lights are off and fridge comes on less often as isn't opened as much, and cooler ambient temperature).
So my cunning plan is to try and periodically take 'at rest' readings when the battery *is* at rest. And the estimate between those readings by counting the charge going in and out. Hopefully when the next 'true' reading is taken it can be compared against the estimate so far by counting the current and the parameters used for counting the current can be updated to provide more accurate estimates.
We should be able to then extrapolate these readings to calculate the effective capacity of the battery bank. As this will be based on actual voltage readings, it should effectively compensate automatically for battery age and temperature.
I decided to work on a state system in which the batteries can be in one of four states: UNKNOWN, ATREST, CHARGING, LOAD. When it starts up the batteries are in UNKNOWN state, and then progress though the other states as things happen. ATREST is defined as when the load on the batteries is between 0.1A and -0.1A.
When the state changes, I store the time of the state change and the last state in some variables. I then check if we are in the ATREST state and how long since the last state change. If the last state was CHARGING then we must be ATREST for at least an hour before we take a voltage reading. If the last state was LOAD then we must have been ATREST for 5 minutes. These timings are just a guess, but from what I've observed of the batteries before they seem to 'settle' much quicker after a load then after charging. I think this is due to 'surface charge' on the batteries.
Once I have a 'true' voltage reading after being at rest, I then calculate the SoC as:
soc = 100 - ((12.80 - voltage) * 100)Again, we can tweak this once I get a better idea, but seems about right, with 100% SoC being 12.80v and 50% SoC being at 12.3v.
When I take a 'true' reading I will zero a variable the counts the charge that has gone through the system. Every second when I take a current and voltage reading this counter will be updated with the Ah that has been removed/added to the battery and will be used to estimate the SoC since the last 'true' reading. When the next true reading happens I can then compare it to my estimated SoC and adjust variables accordingly.