While you are thinking so deeply about state of charge indication, I would like to put a bug in your ear for a “smart” state of charge indicator.
WIBNI: Smart State Of Charge Meter
Imagine an I2C device with two barrel connectors …
Hardware:
- I2C communication
- 5.5x2.1mm Barrel plug input
- 5.5x2.1mm Barrel plug output
- Instantaneous Voltage Sensor
- Average Voltage Sensor (n readings over approx. 1 second, does not need accurate timer)
- Instantaneous Current Sensor
- Average Current Sensor (n readings over approx. 1 second)
- Either multiple single color LEDs (blue, green, yellow, red)
or a single multi-color programmable LED
Software API:
-
averageV: reports the average voltage. Filters out load variance induced voltage fluctuations,
(or peak-deltaV charging variations) -
averageC: reports the average current flow. Filters rapidly changing load (or charging pulses/dips)
-
fastV: reports instantaneous voltage
-
fastC: reports instantaneous current
-
ledV(n,v) or ledV(color,v): light LEDn or set LED color when average voltage is above “v”
defaults:
4_Blue=“Recently full”,
3_Green=“Still Lots o’juice”,
2_Yellow=“OK, but”,
1_Red=“Danger Zone” -
dV: reports the rate of change of the averageV (slope) over a longer period (non-hardware feature)
(sufficient to detect charging vs discharging) -
startDcycle: returns datetime of peak average voltage when dV negative (non-hardware feature)
-
currentDcycle: returns current duration of discharge cycle (non-hardware feature)
-
start/stop a systemctl smartmeter.service. (non-hardware feature)
-
A future software update could enable the service to incorporate “learning” the voltage reading versus time remaining versus current load from a run-history saved to disk by the smartmeter.service
(And while I’m dreaming … if it incorporated a battery backed up RTC with a settable “wake-up” alarm connected to a relay that switched the output we could back the robot onto a charger dock, set a “wake-up” time when the battery should be full, perform an orderly shutdown, followed by a removal of power to the robot with the knowledge it will awake fully rested, and ready for another go at “life”.)
Background: I tried using an ACS710 current sensor, and a resistor-divider voltage sensor on my prior Raspberry Pi / MCP3208 10bit A2D equiped RugWarrior robot. The A2D readings from both the current sensor and the voltage sensor had surprisingly large variances placing a significant burden on the processor to create the averages.