simpler ETB jam detection #6925
rather than try to integrate error over time, simply fault if there's been too much error for too long. Up to +-X error is allowed for any period of time, more is allowed for Y seconds.
This commit is contained in:
parent
454e1d9d94
commit
3ee894594d
|
@ -196,9 +196,6 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
|
|||
m_pid.initPidClass(pidParameters);
|
||||
m_pedalProvider = pedalProvider;
|
||||
|
||||
// Ignore 3% position error before complaining
|
||||
m_errorAccumulator.init(3.0f, etbPeriodSeconds);
|
||||
|
||||
reset();
|
||||
|
||||
return true;
|
||||
|
@ -498,15 +495,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
|
|||
if (m_isAutotune) {
|
||||
return getClosedLoopAutotune(target, observation);
|
||||
} else {
|
||||
// Check that we're not over the error limit
|
||||
etbIntegralError = m_errorAccumulator.accumulate(target - observation);
|
||||
|
||||
// Allow up to 10 percent-seconds of error
|
||||
if (etbIntegralError > 10.0f) {
|
||||
// TODO: figure out how to handle uncalibrated ETB
|
||||
//getLimpManager()->reportEtbProblem();
|
||||
}
|
||||
|
||||
checkJam(target, observation);
|
||||
// Normal case - use PID to compute closed loop part
|
||||
return m_pid.getOutput(target, observation, etbPeriodSeconds);
|
||||
}
|
||||
|
@ -636,23 +625,21 @@ void EtbController::update() {
|
|||
ClosedLoopController::update();
|
||||
}
|
||||
|
||||
void EtbController::checkOutput(percent_t output) {
|
||||
void EtbController::checkJam(percent_t setpoint, percent_t observation) {
|
||||
float absError = std::abs(setpoint - observation);
|
||||
|
||||
prevOutput = output;
|
||||
auto jamDetectThreshold = engineConfiguration->jamDetectThreshold;
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
auto integratorLimit = engineConfiguration->jamDetectThreshold;
|
||||
|
||||
if (integratorLimit != 0) {
|
||||
float integrator = absF(m_pid.getIntegration());
|
||||
if (jamDetectThreshold != 0) {
|
||||
auto nowNt = getTimeNowNt();
|
||||
|
||||
if (integrator > integratorLimit) {
|
||||
if (absError > jamDetectThreshold) {
|
||||
if (m_jamDetectTimer.hasElapsedSec(engineConfiguration->etbJamTimeout)) {
|
||||
// ETB is jammed!
|
||||
jamDetected = true;
|
||||
|
||||
// TODO: do something about it!
|
||||
// getLimpManager()->reportEtbProblem();
|
||||
}
|
||||
} else {
|
||||
m_jamDetectTimer.reset(nowNt);
|
||||
|
@ -661,8 +648,6 @@ void EtbController::checkOutput(percent_t output) {
|
|||
|
||||
jamTimer = m_jamDetectTimer.getElapsedSeconds(nowNt);
|
||||
}
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
}
|
||||
|
||||
void EtbController::autoCalibrateTps() {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "sensor.h"
|
||||
#include "efi_pid.h"
|
||||
#include "error_accumulator.h"
|
||||
#include "electronic_throttle_generated.h"
|
||||
|
||||
/**
|
||||
|
@ -53,9 +52,9 @@ public:
|
|||
expected<percent_t> getClosedLoop(percent_t setpoint, percent_t observation) override;
|
||||
expected<percent_t> getClosedLoopAutotune(percent_t setpoint, percent_t actualThrottlePosition);
|
||||
|
||||
void setOutput(expected<percent_t> outputValue) override;
|
||||
void checkJam(percent_t setpoint, percent_t observation);
|
||||
|
||||
void checkOutput(percent_t output);
|
||||
void setOutput(expected<percent_t> outputValue) override;
|
||||
|
||||
// Used to inspect the internal PID controller's state
|
||||
const pid_state_s& getPidState() const override { return m_pid; };
|
||||
|
@ -94,8 +93,6 @@ private:
|
|||
DcMotor *m_motor = nullptr;
|
||||
Pid m_pid;
|
||||
bool m_shouldResetPid = false;
|
||||
// todo: rename to m_targetErrorAccumulator
|
||||
ErrorAccumulator m_errorAccumulator;
|
||||
|
||||
/**
|
||||
* @return true if OK, false if should be disabled
|
||||
|
|
Loading…
Reference in New Issue