Skip to content

Commit 0b4e9a0

Browse files
committed
add brake sensor high/low threshold values to prevent flickering
1 parent 754de0c commit 0b4e9a0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

ETC/src/etc_controller.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ void ETCController::updateState() {
109109
static_cast<int16_t>(pedalTravel * ETCController::MAX_TORQUE) :
110110
0;
111111

112-
this->brakeLightOutput.write(this->state.brakes_read >= ETCController::BRAKE_TOLERANCE);
112+
113+
if (this->state.brakes_read >= ETCController::BRAKE_TOLERANCE_HIGH) {
114+
this->brakeLightOutput.write(1);
115+
} else if (this->state.brakes_read <= ETCController::BRAKE_TOLERANCE_LOW) {
116+
this->brakeLightOutput.write(0);
117+
}
113118
}
114119

115120

@@ -128,7 +133,7 @@ void ETCController::checkStartConditions() {
128133
// If the brake is pressed past the tolerance threshold and the tractive system is ready
129134
// then the motor can be enabled. The last condition for motor start is the cockpit switch
130135
// being set to the ON position, which is what calls this method.
131-
if(this->state.ts_ready && this->state.brakes_read >= ETCController::BRAKE_TOLERANCE && this->state.pedal_travel < 0.05) {
136+
if(this->state.ts_ready && this->state.brakes_read >= ETCController::BRAKE_TOLERANCE_HIGH && this->state.pedal_travel < 0.05) {
132137
this->state.motor_enabled = true;
133138
this->runRTDS();
134139
}
@@ -171,7 +176,7 @@ void ETCController::set_brake_implausibility() {
171176
this->state.brakes_implausibility = false;
172177
}
173178
} else {
174-
if (this->state.brakes_read >= BRAKE_TOLERANCE && this->state.pedal_travel > 0.25f) {
179+
if (this->state.brakes_read >= BRAKE_TOLERANCE_HIGH && this->state.pedal_travel > 0.25f) {
175180
this->state.brakes_implausibility = true;
176181
}
177182
}

ETC/src/etc_controller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class ETCController {
9292
static constexpr float MAX_VOLTAGE = 3.3f;
9393

9494
/** The percentage tolerance for the brake pedal to be considered pressed. */
95-
static constexpr float BRAKE_TOLERANCE = 0.50f;
95+
static constexpr float BRAKE_TOLERANCE_HIGH = 0.38f;
96+
static constexpr float BRAKE_TOLERANCE_LOW = 0.25f;
9697

9798
/** The voltage divider slope for the hall-effect 1 sensor. */
9899
static constexpr float HE1_SCALE = (330.0f / 480.0f);

0 commit comments

Comments
 (0)