mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
commander: add hysteresis for avionics power low/high check
We had a setup where the voltage was right at the threshold and the check toggled continuously. It still triggers immediately, and then keeps for 15 seconds
This commit is contained in:
parent
5fb810a5ea
commit
93b8bc1515
@ -36,6 +36,14 @@
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
PowerChecks::PowerChecks()
|
||||
{
|
||||
_voltage_low_hysteresis.set_hysteresis_time_from(false, 0_s);
|
||||
_voltage_low_hysteresis.set_hysteresis_time_from(true, 15_s);
|
||||
_voltage_high_hysteresis.set_hysteresis_time_from(false, 0_s);
|
||||
_voltage_high_hysteresis.set_hysteresis_time_from(true, 15_s);
|
||||
}
|
||||
|
||||
void PowerChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
if (circuit_breaker_enabled_by_val(_param_cbrk_supply_chk.get(), CBRK_SUPPLY_CHK_KEY)) {
|
||||
@ -77,7 +85,11 @@ void PowerChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
const float low_error_threshold = 4.7f;
|
||||
const float high_error_threshold = 5.4f;
|
||||
|
||||
if (avionics_power_rail_voltage < low_error_threshold) {
|
||||
const auto now = hrt_absolute_time();
|
||||
_voltage_low_hysteresis.set_state_and_update(avionics_power_rail_voltage < low_error_threshold, now);
|
||||
_voltage_high_hysteresis.set_state_and_update(avionics_power_rail_voltage > high_error_threshold, now);
|
||||
|
||||
if (_voltage_low_hysteresis.get_state()) {
|
||||
|
||||
/* EVENT
|
||||
* @description
|
||||
@ -96,7 +108,7 @@ void PowerChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
(double)avionics_power_rail_voltage);
|
||||
}
|
||||
|
||||
} else if (avionics_power_rail_voltage > high_error_threshold) {
|
||||
} else if (_voltage_high_hysteresis.get_state()) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* Check the voltage supply to the FMU, it must be below {2:.2} Volt.
|
||||
|
||||
@ -35,13 +35,14 @@
|
||||
|
||||
#include "../Common.hpp"
|
||||
|
||||
#include <lib/hysteresis/hysteresis.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/system_power.h>
|
||||
|
||||
class PowerChecks : public HealthAndArmingCheckBase
|
||||
{
|
||||
public:
|
||||
PowerChecks() = default;
|
||||
PowerChecks();
|
||||
~PowerChecks() = default;
|
||||
|
||||
void checkAndReport(const Context &context, Report &reporter) override;
|
||||
@ -49,6 +50,8 @@ public:
|
||||
private:
|
||||
uORB::Subscription _system_power_sub{ORB_ID(system_power)};
|
||||
bool _overcurrent_warning_sent{false};
|
||||
systemlib::Hysteresis _voltage_low_hysteresis{false};
|
||||
systemlib::Hysteresis _voltage_high_hysteresis{false};
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamInt<px4::params::CBRK_SUPPLY_CHK>) _param_cbrk_supply_chk,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user