forked from Archive/PX4-Autopilot
battery: report over voltage
This commit is contained in:
parent
54d26e084a
commit
ae888b73d0
|
@ -166,6 +166,7 @@ battery_status_s Battery::getBatteryStatus()
|
|||
battery_status.id = static_cast<uint8_t>(_index);
|
||||
battery_status.warning = _warning;
|
||||
battery_status.timestamp = hrt_absolute_time();
|
||||
battery_status.faults = determineFaults();
|
||||
return battery_status;
|
||||
}
|
||||
|
||||
|
@ -267,6 +268,19 @@ uint8_t Battery::determineWarning(float state_of_charge)
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Battery::determineFaults()
|
||||
{
|
||||
uint16_t faults{0};
|
||||
|
||||
if ((_params.n_cells > 0)
|
||||
&& (_voltage_v > (_params.n_cells * _params.v_charged * 1.05f))) {
|
||||
// Reported as a "spike" since "over-voltage" does not exist in MAV_BATTERY_FAULT
|
||||
faults |= (1 << battery_status_s::BATTERY_FAULT_SPIKES);
|
||||
}
|
||||
|
||||
return faults;
|
||||
}
|
||||
|
||||
void Battery::computeScale()
|
||||
{
|
||||
const float voltage_range = (_params.v_charged - _params.v_empty);
|
||||
|
|
|
@ -150,6 +150,7 @@ private:
|
|||
float calculateStateOfChargeVoltageBased(const float voltage_v, const float current_a);
|
||||
void estimateStateOfCharge();
|
||||
uint8_t determineWarning(float state_of_charge);
|
||||
uint16_t determineFaults();
|
||||
void computeScale();
|
||||
float computeRemainingTime(float current_a);
|
||||
|
||||
|
|
Loading…
Reference in New Issue