Initial Brainstorming for Lifetime Ah Counters
I want to add two "lifetime mAh" accumulators: one for assist and another for regen. To minimize EEPROM write cycles, each accumulator is a uint16 in RAM.
To prevent losing this data, we need to write each value in RAM to EEPROM whenever any of the following occur:
-keyOff event occurs, or;
-grid charger unplug event occurs, or;
-an accumulator is close to full (e.g. greater than 65000), or;
-24 hours have elapsed since the last EEPROM update.
Each time we write RAM value to EEPROM, we immediately set the RAM value back to 0.
Each EEPROM accumulator (assist and regen) is uint32, with each count being 1 mAh. Therefore, each EEPROM accumulator can count up to 4.3 MAh, which is way more than we'll ever need.
Use EEPROM.update - instead of EEPROM.write - to reduce write wear on the EEPROM.
Finally, we need a way for the customer to reset both lifetime values in EEPROM... "$TESTE" is an existing method to do this... probably makes sense to just add the clearing code to that existing function... and probably make it a little harder for the customer to accidentally reset all these values (if they accidentally type "$TESTE"). The easiest safeguard to implement is probably just requiring the user to enter "$TESTE" twice in a five second period (i.e. the first thing $TESTE does is look to see when the latest TESTE was received, and if it was more than five seconds it would say "Type '$TESTE' again within five seconds to reset all EEPROM data"... that's non-blocking and non-modal.
...
To display this lifetime mAh data to the customer, I propose we add it to the "$TESTW" command, which displays battery temp and SoC history. Something like:
Lifetime Assist: 123.456 Ah
Lifetime Regen: 234.567 Ah
Note that $TESTW would need to read each value (assist and regen) from EEPROM, and then also add the corresponding value in RAM. Otherwise, we'd miss the residual mAh stored in RAM.
0 条评论