![](/media/cache/profiles/TAG-avatar.png.50x50_q85.png)
Code to assist in measuring a battery's Chemical ID.
New releases of this code have moved to GitHub: https://github.com/USCRPL/BQ34Z100G1-Utils
Diff: ChemIDMeasurer.h
- Revision:
- 0:246ef70a9e6e
diff -r 000000000000 -r 246ef70a9e6e ChemIDMeasurer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ChemIDMeasurer.h Sun Feb 07 20:57:24 2021 -0800 @@ -0,0 +1,51 @@ +// +// Class to collect data needed for measuring the Chem ID of a battery +// + +#ifndef PLZDONTEXPLODE_CHEMIDMEASURER_H +#define PLZDONTEXPLODE_CHEMIDMEASURER_H + +#include <BQ34Z100.h> + +class ChemIDMeasurer +{ + BQ34Z100 soc; + + Timer totalTimer; + Timer stateTimer; + + enum class State + { + INIT, // Initial state. + CHARGE, // First, charge to full power until charge current <= C/100. + RELAX_CHARGED, // Relax for two hours to reach open circuit voltage + DISCHARGE, // Discharge at C/10 until the term voltage is reached + RELAX_DISCHARGED, // Relax for five hours to reach open circuit voltage + DONE // Measurement finished + }; + State state = State::INIT; + + // Turn the charger on + void activateCharger(); + + // Turn the charger off. + void deactivateCharger(); + + void activateLoad(); + + void deactivateLoad(); + + // Change current state. + void setState(State newState); + +public: + ChemIDMeasurer(); + + /** + * Loop to run the ID measurement + */ + void runMeasurement(); +}; + + +#endif //PLZDONTEXPLODE_CHEMIDMEASURER_H