mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
battery: only reset soc filter with valid voltage measurement (#23513)
This commit is contained in:
@@ -108,10 +108,6 @@ void Battery::updateCurrent(const float current_a)
|
|||||||
|
|
||||||
void Battery::updateBatteryStatus(const hrt_abstime ×tamp)
|
void Battery::updateBatteryStatus(const hrt_abstime ×tamp)
|
||||||
{
|
{
|
||||||
if (!_battery_initialized && _internal_resistance_initialized && _params.n_cells > 0) {
|
|
||||||
resetInternalResistanceEstimation(_voltage_v, _current_a);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Require minimum voltage otherwise override connected status
|
// Require minimum voltage otherwise override connected status
|
||||||
if (_voltage_v < LITHIUM_BATTERY_RECOGNITION_VOLTAGE) {
|
if (_voltage_v < LITHIUM_BATTERY_RECOGNITION_VOLTAGE) {
|
||||||
_connected = false;
|
_connected = false;
|
||||||
@@ -121,9 +117,13 @@ void Battery::updateBatteryStatus(const hrt_abstime ×tamp)
|
|||||||
_last_unconnected_timestamp = timestamp;
|
_last_unconnected_timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait with initializing filters to avoid relying on a voltage sample from the rising edge
|
// Wait with initializing filters to avoid relying on a voltage sample from the rising edge
|
||||||
_battery_initialized = _connected && (timestamp > _last_unconnected_timestamp + 2_s);
|
_battery_initialized = _connected && (timestamp > _last_unconnected_timestamp + 2_s);
|
||||||
|
|
||||||
|
if (_connected && !_battery_initialized && _internal_resistance_initialized && _params.n_cells > 0) {
|
||||||
|
resetInternalResistanceEstimation(_voltage_v, _current_a);
|
||||||
|
}
|
||||||
|
|
||||||
sumDischarged(timestamp, _current_a);
|
sumDischarged(timestamp, _current_a);
|
||||||
_state_of_charge_volt_based =
|
_state_of_charge_volt_based =
|
||||||
calculateStateOfChargeVoltageBased(_voltage_v, _current_a);
|
calculateStateOfChargeVoltageBased(_voltage_v, _current_a);
|
||||||
|
|||||||
Reference in New Issue
Block a user