Skip to content

Commit 5c3d417

Browse files
committed
simpler ETB jam detection #489
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.
1 parent d23fe55 commit 5c3d417

File tree

11 files changed

+13
-155
lines changed

11 files changed

+13
-155
lines changed

firmware/controllers/actuators/electronic_throttle.cpp

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,13 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
199199
m_pid.initPidClass(pidParameters);
200200
m_pedalMap = pedalMap;
201201

202-
// Ignore 3% position error before complaining
203-
m_errorAccumulator.init(3.0f, etbPeriodSeconds);
204-
205202
reset();
206203

207204
return true;
208205
}
209206

210207
void EtbController::reset() {
211208
m_shouldResetPid = true;
212-
etbDutyRateOfChange = etbDutyAverage = 0;
213209
m_dutyRocAverage.reset();
214210
m_dutyAverage.reset();
215211
etbTpsErrorCounter = 0;
@@ -482,15 +478,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
482478
if (m_isAutotune) {
483479
return getClosedLoopAutotune(target, observation);
484480
} else {
485-
// Check that we're not over the error limit
486-
etbIntegralError = m_errorAccumulator.accumulate(target - observation);
487-
488-
// Allow up to 10 percent-seconds of error
489-
if (etbIntegralError > 10.0f) {
490-
// TODO: figure out how to handle uncalibrated ETB
491-
//getLimpManager()->reportEtbProblem();
492-
}
493-
481+
checkJam(target, observation);
494482
// Normal case - use PID to compute closed loop part
495483
return m_pid.getOutput(target, observation, etbPeriodSeconds);
496484
}
@@ -615,33 +603,24 @@ void EtbController::update() {
615603
return;
616604
}
617605

618-
auto output = ClosedLoopController::update();
619-
620-
if (!output) {
621-
return;
622-
}
623-
624-
checkOutput(output.Value);
606+
ClosedLoopController::update();
625607
}
626608

627-
void EtbController::checkOutput(percent_t output) {
628-
etbDutyAverage = m_dutyAverage.average(absF(output));
629-
630-
etbDutyRateOfChange = m_dutyRocAverage.average(absF(output - prevOutput));
631-
prevOutput = output;
609+
void EtbController::checkJam(percent_t setpoint, percent_t observation) {
610+
float absError = std::abs(setpoint - observation);
632611

633-
float integrator = absF(m_pid.getIntegration());
634-
auto integratorLimit = engineConfiguration->etbJamIntegratorLimit;
612+
auto jamDetectThreshold = engineConfiguration->jamDetectThreshold;
635613

636-
if (integratorLimit != 0) {
614+
if (jamDetectThreshold != 0) {
637615
auto nowNt = getTimeNowNt();
638616

639-
if (integrator > integratorLimit) {
617+
if (absError > jamDetectThreshold) {
640618
if (m_jamDetectTimer.hasElapsedSec(engineConfiguration->etbJamTimeout)) {
641619
// ETB is jammed!
642620
jamDetected = true;
643621

644622
// TODO: do something about it!
623+
// getLimpManager()->reportEtbProblem();
645624
}
646625
} else {
647626
m_jamDetectTimer.reset(getTimeNowNt());

firmware/controllers/actuators/electronic_throttle.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ struct_no_prefix electronic_throttle_s
1818
bit etbRevLimitActive
1919
bit jamDetected
2020

21-
float etbDutyRateOfChange;"ETB duty rate of change";"per", 1, 0, -0,20, 2
22-
float etbDutyAverage;"ETB average duty";"per", 1, 0, -20,50, 2
2321
uint16_t etbTpsErrorCounter;"ETB TPS error counter";"count", 1, 0, 0,3, 0
2422
uint16_t etbPpsErrorCounter;"ETB pedal error counter";"count", 1, 0, 0,3, 0
2523

firmware/controllers/actuators/electronic_throttle_impl.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "sensor.h"
1414
#include "efi_pid.h"
15-
#include "error_accumulator.h"
1615
#include "electronic_throttle_generated.h"
1716
#include "exp_average.h"
1817

@@ -53,9 +52,9 @@ class EtbController : public IEtbController, public electronic_throttle_s {
5352
expected<percent_t> getClosedLoop(percent_t setpoint, percent_t observation) override;
5453
expected<percent_t> getClosedLoopAutotune(percent_t setpoint, percent_t actualThrottlePosition);
5554

56-
void setOutput(expected<percent_t> outputValue) override;
55+
void checkJam(percent_t setpoint, percent_t observation);
5756

58-
void checkOutput(percent_t output);
57+
void setOutput(expected<percent_t> outputValue) override;
5958

6059
// Used to inspect the internal PID controller's state
6160
const pid_state_s& getPidState() const override { return m_pid; };
@@ -90,8 +89,6 @@ class EtbController : public IEtbController, public electronic_throttle_s {
9089
DcMotor *m_motor = nullptr;
9190
Pid m_pid;
9291
bool m_shouldResetPid = false;
93-
// todo: rename to m_targetErrorAccumulator
94-
ErrorAccumulator m_errorAccumulator;
9592

9693
/**
9794
* @return true if OK, false if should be disabled

firmware/controllers/closed_loop_controller.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
template <typename TInput, typename TOutput>
1010
class ClosedLoopController {
1111
public:
12-
expected<TOutput> update() {
12+
void update() {
1313
expected<TOutput> outputValue = getOutput();
1414
setOutput(outputValue);
15-
16-
return outputValue;
1715
}
1816

1917
private:

firmware/integration/rusefi_config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ float tChargeAirDecrLimit;Maximum allowed rate of decrease allowed for the estim
13231323

13241324
uint16_t autoscale fordInjectorSmallPulseBreakPoint;;"mg", 0.001, 0, 0, 65, 3
13251325

1326-
uint8_t etbJamIntegratorLimit;;"%", 1, 0, 0, 50, 0
1326+
uint8_t jamDetectThreshold;;"%", 1, 0, 0, 50, 0
13271327

13281328
! Someday there will be a 6th option for BMW S55 that uses a separate shaft just for HPFP
13291329
#define hpfp_cam_e_enum "NONE", "Intake 1", "Exhaust 1", "Intake 2", "Exhaust 2"

firmware/tunerstudio/tunerstudio.template.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4225,7 +4225,7 @@ dialog = tcuControls, "Transmission Settings"
42254225
field = "PWM Frequency", etbFreq
42264226
field = "Minimum ETB position", etbMinimumPosition
42274227
field = "Maximum ETB position", etbMaximumPosition
4228-
field = "Jam detection integrator max", etbJamIntegratorLimit
4228+
field = "Jam detection error max", jamDetectThreshold
42294229
field = "Jam detection timeout period", etbJamTimeout
42304230
field = "Duty Averaging Length", etbExpAverageLength
42314231
field = "Rate of change Averaging Length", etbRocExpAverageLength

firmware/util/math/error_accumulator.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

firmware/util/math/error_accumulator.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

firmware/util/util.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ UTILSRC_CPP = \
88
$(UTIL_DIR)/containers/listener_array.cpp \
99
$(UTIL_DIR)/containers/local_version_holder.cpp \
1010
$(UTIL_DIR)/math/biquad.cpp \
11-
$(UTIL_DIR)/math/error_accumulator.cpp \
1211
$(UTIL_DIR)/math/efi_pid.cpp \
1312
$(UTIL_DIR)/math/interpolation.cpp \
1413
$(PROJECT_DIR)/util/datalogging.cpp \

unit_tests/tests/util/test_error_accumulator.cpp

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)