Browse Source

Make battery failsafe limits configurable

sbg
Lorenz Meier 9 years ago
parent
commit
3003ed8d40
  1. 8
      src/modules/systemlib/battery.cpp
  2. 2
      src/modules/systemlib/battery.h
  3. 30
      src/modules/systemlib/battery_params.c

8
src/modules/systemlib/battery.cpp

@ -48,6 +48,8 @@ Battery::Battery() : @@ -48,6 +48,8 @@ Battery::Battery() :
_param_n_cells(this, "N_CELLS"),
_param_capacity(this, "CAPACITY"),
_param_v_load_drop(this, "V_LOAD_DROP"),
_param_low_thr(this, "LOW_THR"),
_param_crit_thr(this, "CRIT_THR"),
_voltage_filtered_v(0.0f),
_throttle_filtered(0.0f),
_discharged_mah(0.0f),
@ -162,13 +164,11 @@ Battery::estimateRemaining(float voltage_v, float throttle_normalized) @@ -162,13 +164,11 @@ Battery::estimateRemaining(float voltage_v, float throttle_normalized)
void
Battery::determineWarning()
{
// TODO: Determine threshold or make params.
// Smallest values must come first
if (_remaining < 0.09f) {
if (_remaining < _param_crit_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
} else if (_remaining < 0.18f) {
} else if (_remaining < _param_low_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_LOW;
}
}

2
src/modules/systemlib/battery.h

@ -101,6 +101,8 @@ private: @@ -101,6 +101,8 @@ private:
control::BlockParamInt _param_n_cells;
control::BlockParamFloat _param_capacity;
control::BlockParamFloat _param_v_load_drop;
control::BlockParamFloat _param_low_thr;
control::BlockParamFloat _param_crit_thr;
float _voltage_filtered_v;
float _throttle_filtered;

30
src/modules/systemlib/battery_params.c

@ -66,6 +66,36 @@ PARAM_DEFINE_FLOAT(BAT_V_EMPTY, 3.4f); @@ -66,6 +66,36 @@ PARAM_DEFINE_FLOAT(BAT_V_EMPTY, 3.4f);
*/
PARAM_DEFINE_FLOAT(BAT_V_CHARGED, 4.2f);
/**
* Low threshold
*
* Sets the threshold (between 0 and 1, which is equivalent to between 0 and 100%)
* when the battery will be reported as low. This has to be higher than the critical
* threshold.
*
* @group Battery Calibration
* @decimal 2
* @min 0.15
* @max 0.5
* @increment 0.01
*/
PARAM_DEFINE_FLOAT(BAT_LOW_THR, 0.18f);
/**
* Critical threshold
*
* Sets the threshold (between 0 and 1, which is equivalent to between 0 and 100%)
* when the battery will be reported as critically low. This has to be lower than
* the low threshold. This threshold commonly will trigger RTL or landing.
*
* @group Battery Calibration
* @decimal 2
* @min 0.05
* @max 0.14
* @increment 0.01
*/
PARAM_DEFINE_FLOAT(BAT_CRIT_THR, 0.09f);
/**
* Voltage drop per cell on 100% load
*

Loading…
Cancel
Save