7#ifndef COMPONENT_CHARGE_POLICY_H
8#define COMPONENT_CHARGE_POLICY_H
95 _isOverVoltage =
true;
96 _overVoltageTime_ms = time_ms;
97 _isEndOfChargeDeglitching =
false;
110 _isOverVoltage =
false;
123 if (not _isEndOfChargeDeglitching)
125 _isEndOfChargeDeglitching =
true;
126 _endOfChargeTime_ms = time_ms;
130 _isEndOfChargeDeglitching =
false;
137 _isEndOfChargeDeglitching =
false;
146 _isEndOfChargeDeglitching =
false;
155 bool _isFull =
false;
156 bool _isOverVoltage =
false;
157 uint32_t _overVoltageTime_ms = 0;
158 bool _isEndOfChargeDeglitching =
false;
159 uint32_t _endOfChargeTime_ms = 0;
Track the charge stop state (battery full, over voltage)
Definition: charge_policy.h:84
bool is_full() const
True if the battery charge is done.
Definition: charge_policy.h:150
bool update(const uint32_t time_ms, const Inputs &in)
Update the state with new measurements.
Definition: charge_policy.h:90
void clear_full()
Forget the battery full state (power source change). The over voltage state is kept,...
Definition: charge_policy.h:143
bool is_over_voltage_stopped() const
True if the charge is stopped by an over voltage.
Definition: charge_policy.h:152
static constexpr uint32_t endOfChargeDeglitch_ms
The end of charge condition must stay true for this time before the charge is considered done.
Definition: charge_policy.h:30
static constexpr uint16_t fullLevel
Battery level (percent * 100) from which the battery is considered full.
Definition: charge_policy.h:26
static constexpr uint16_t packOverVoltage_mV
A pack over this voltage stops the charge immediately.
Definition: charge_policy.h:37
bool is_end_of_charge(const Inputs &in)
True if the battery reached the end of charge: pack at the target voltage, or charge current tapered ...
Definition: charge_policy.h:68
static constexpr uint32_t overVoltagePause_ms
After an over voltage, the charge stays stopped at least this long (lets the balancer work)
Definition: charge_policy.h:42
static constexpr uint16_t cellResumeVoltage_mV
After an over voltage, the charge can restart when all cells are below this voltage.
Definition: charge_policy.h:40
static constexpr uint16_t cellOverVoltageMargin_mV
Accepted cell voltage above the safe maximum (cell imbalance, measure noise)
Definition: charge_policy.h:33
static constexpr uint16_t cellOverVoltage_mV
A cell over this voltage stops the charge immediately.
Definition: charge_policy.h:35
static constexpr uint16_t rechargeLevel
Once full, the charge restarts below this battery level (percent * 100)
Definition: charge_policy.h:28
bool is_over_voltage(const Inputs &in)
True if a cell or the pack is over the charge voltage limit.
Definition: charge_policy.h:62
static constexpr uint8_t batterySeriesCount
number of batteries in series for this model
Definition: constants.h:61
static constexpr uint32_t batteryEndOfChargeCurrent_mA
End of charge current (C/20), in milliAmps: in constant voltage phase, the charge is done below this ...
Definition: constants.h:138
static constexpr uint16_t batteryMaxVoltageSafe_mV
max voltage of a li-ion cell to maximise lifetime
Definition: constants.h:119
static constexpr uint16_t maxSafeLiionVoltage_mV
maximum allowed li-ion voltage safe zone
Definition: constants.h:89
Program scope.
Definition: control_fixed_modes.hpp:14
Define the system hardware constants.