Good afternoon all,
I am designing and prototyping a vehicle monitoring and control system, based around and ESP8266 with additional ADC inputs via an MCP3008, additional I/O via an MCP23008, voltage sensors via standard resistor divider circuits, amps via shunt resistors then via AD623ANZ Instrumentation Amplifiers, outputs relay controlled, visual display via a Nextion display, and so far all is working as expected.
The unit is monitoring the water tanks (clean and grey), controlling the roof fan, wall fans, inside lights, kitchen lights, radio (entertainment), and inverter (when required). It is also monitoring the remaining gas in the tank, outside and inside temperatures, battery temperature, GPS location, distance from home, and more ....
As stated above all is working, so far, as expected, and the prototyping is going well; Circuit board ordered and partly assembled. (Assembling one part at a time and checking before moving on to the next).
My question is this:
My battery monitoring system is
- aware of the Ah rating of the battery (currently just a constant of 110).
- aware if the battery 'full' voltage (currently a constant of 12.8 ).
- is monitoring the voltage of the battery.
- is monitoring the current draw of the battery.
- is monitoring the temperature of the battery.
I am trying to work out how I might work out the approximate time remaining on the battery, but this is not quite as simple as first thoughts might lead you to believe...... or maybe it is and it's me that's over complicating it!
Firstly, for the calculations I am assuming that the battery is not being charged at the same time as being used (i.e. via solar charger, or battery charger), so is a 'stand alone' unit.
Its easy to state that:
- Capacity (Ah) = Amps (A) * Time (h)
Therefore is the Capacity is 110Ah and the draw is 10 Amps the time would be 110 / 10 = 11hrs. This assumes that the full capacity of the batter can be used, which (of course) it can't.
Standard Deep Discharge Leisure type Lead Acid battery should probably not run past 80% capacity, so i'll assume that the Capacity is actually only 80% of the marked Capacity i.e 110 * 0.8 = 88Ah.
Therefore for the above calculation drawing 10Amps would result in a running time of 88 / 10 = 8.8hrs (not 11hrs as before).
For now I am also trying to ignore Peukart effect, so am not worried if I'm drawing 1A or 50A, but maybe that is a mistake?
So far I have:
readADC=analogRead(analogInput); // read ADC value amps=(readADC*50.0)/1023.0; // calculate 'current' amps
this calculates the Amps being drawn. The Shunt resistor is 0-50mV for 0-50Amps, and the AD623ANZ gain set to scale this to 0-5v for the MCP3008 ADC, so this makes the calculation very easy.
I can calculate a 'running average' of the Amps by something like:
readADC=analogRead(analogInput); // read ADC value avgADC = ((avgADC*numberOfSamples) + readADC) / (numberOfSamples+1); numberOfSamples++; // increment number of samples counter amps=(readADC*50.0)/1023.0; // calculate 'current' amps avgAmps=(avgADC*50.0)/1023.0; // calculate 'average' amps
and can easily modify this to be calculating the average over a period of time (say 1 minute).
What I'm struggling with is where I go from here? Do I 'sum the Ah used' and take these away from the Capacity? How do I know where the discharge point of the battery is? How do I know how much of the 'Capacity' is available to start with? A big part of me thinks I should be using the monitored voltage in the calculations as well, after-all anything lower that 10v and it's basically a dead battery!
This can be done as whilst investigating I came across this commercial unit that displays the 'remaining time' (See attachment).
I'm not after someone to write me the code, just to suggest methods that I might use as I think that I am now overthinking it and cannot see the wood for the trees!