Skip to content

Commit

Permalink
ETB overheats due to constant isTpsError true/false/true/false jitter…
Browse files Browse the repository at this point in the history
…: this seems obvious enough to disable ETB at least on non running engine #4832
  • Loading branch information
rusefillc committed Nov 30, 2022
1 parent 4a35b55 commit 1e7baa1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
37 changes: 26 additions & 11 deletions firmware/controllers/actuators/electronic_throttle.cpp
Expand Up @@ -160,9 +160,10 @@ static percent_t directPwmValue = NAN;
// this macro clamps both positive and negative percentages from about -100% to 100%
#define ETB_PERCENT_TO_DUTY(x) (clampF(-ETB_DUTY_LIMIT, 0.01f * (x), ETB_DUTY_LIMIT))

bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) {
bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool hasPedal) {
if (function == ETB_None) {
// if not configured, don't init.
etbErrorCode = (int8_t)TpsState::NotConfigured;
return false;
}

Expand All @@ -172,12 +173,14 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
// If we are a throttle, require redundant TPS sensor
if (function == ETB_Throttle1 || function == ETB_Throttle2) {
// We don't need to init throttles, so nothing to do here.
if (!initializeThrottles) {
if (!hasPedal) {
etbErrorCode = (int8_t)TpsState::PpsError;
return false;
}

// If no sensor is configured for this throttle, skip initialization.
if (!Sensor::hasSensor(functionToTpsSensorPrimary(function))) {
etbErrorCode = (int8_t)TpsState::TpsError;
return false;
}

Expand All @@ -188,6 +191,7 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
Sensor::getSensorName(m_positionSensor)
);

etbErrorCode = (int8_t)TpsState::Redundancy;
return false;
}

Expand All @@ -196,7 +200,7 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
OBD_TPS_Configuration,
"Use of electronic throttle requires accelerator pedal to be redundant."
);

etbErrorCode = (int8_t)TpsState::Redundancy;
return false;
}
}
Expand Down Expand Up @@ -536,7 +540,9 @@ void EtbController::setOutput(expected<percent_t> outputValue) {
}
#endif

if (!m_motor) return;
if (!m_motor) {
return;
}

// If ETB is allowed, output is valid, and we aren't paused, output to motor.
if (getLimpManager()->allowElectronicThrottle()
Expand Down Expand Up @@ -567,12 +573,21 @@ void EtbController::update() {

if (!cisnan(directPwmValue)) {
m_motor->set(directPwmValue);
etbErrorCode = (int8_t)TpsState::Manual;
return;
}

if ((engineConfiguration->disableEtbWhenEngineStopped && !engine->triggerCentral.engineMovedRecently())
|| (etbInputErrorCounter > 50)
|| engine->engineState.lua.luaDisableEtb) {
TpsState localReason = TpsState::None;
if (engineConfiguration->disableEtbWhenEngineStopped && !engine->triggerCentral.engineMovedRecently()) {
localReason = TpsState::Setting;
} else if (etbInputErrorCounter > 50) {
localReason = TpsState::InputJitter;

This comment has been minimized.

Copy link
@mck1117

mck1117 Nov 30, 2022

Member

pedantry: jitter is not the correct word for what this detects

This comment has been minimized.

Copy link
@rusefillc

rusefillc Nov 30, 2022

Author Contributor

Gimme your best word and I shall use!

This comment has been minimized.

Copy link
@mck1117

mck1117 Nov 30, 2022

Member

in #4854

} else if (engine->engineState.lua.luaDisableEtb) {
localReason = TpsState::Lua;
}

if (localReason != TpsState::None) {
etbErrorCode = (int8_t)localReason;
// If engine is stopped and so configured, skip the ETB update entirely
// This is quieter and pulls less power than leaving it on all the time
m_motor->disable();
Expand Down Expand Up @@ -956,10 +971,10 @@ static pid_s* getEtbPidForFunction(etb_function_e function) {
}

void doInitElectronicThrottle() {
bool shouldInitThrottles = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
bool hasPedal = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);

#if EFI_UNIT_TEST
printf("doInitElectronicThrottle %s\n", boolToString(shouldInitThrottles));
printf("doInitElectronicThrottle %s\n", boolToString(hasPedal));
#endif // EFI_UNIT_TEST

engineConfiguration->etb1configured = engineConfiguration->etb2configured = false;
Expand All @@ -981,7 +996,7 @@ void doInitElectronicThrottle() {

auto pid = getEtbPidForFunction(func);

bool etbConfigured = controller->init(func, motor, pid, &pedal2tpsMap, shouldInitThrottles);
bool etbConfigured = controller->init(func, motor, pid, &pedal2tpsMap, hasPedal);
if (i == 0) {
engineConfiguration->etb1configured = etbConfigured;
} else if (i == 1) {
Expand All @@ -991,7 +1006,7 @@ void doInitElectronicThrottle() {

if (!engineConfiguration->etb1configured && !engineConfiguration->etb2configured) {
// It's not valid to have a PPS without any ETBs - check that at least one ETB was enabled along with the pedal
if (shouldInitThrottles) {
if (hasPedal) {
firmwareError(OBD_PCM_Processor_Fault, "A pedal position sensor was configured, but no electronic throttles are configured.");
}

Expand Down
5 changes: 4 additions & 1 deletion firmware/controllers/limp_manager.h
Expand Up @@ -33,7 +33,10 @@ enum class TpsState : uint8_t {
PpsError, // 3
InputJitter,
PidJitter,
Lua
Lua, // 6
Manual,
NotConfigured,
Redundancy, // 9
// keep this list in sync with etbCutCodeList in rusefi.input!
};

Expand Down
2 changes: 1 addition & 1 deletion firmware/tunerstudio/rusefi.input
Expand Up @@ -239,7 +239,7 @@ enable2ndByteCanID = false
fuelIgnCutCodeList = bits, U08, [0:7], "None", "fatal error", "setting disabled", "RPM limit", "fault RPM limit", "boost cut", "oil pressure", "stop requested", "ETB problem", "launch control", "max injector duty", "flood clear", "engine sync", "kickstart", "ign off"

; TpsState
etbCutCodeList = bits, U08, [0:7], "None", "engine off setting", "TPS error", "PPS error", "Input noise", "PID noise", "Lua"
etbCutCodeList = bits, U08, [0:7], "None", "engine off setting", "TPS error", "PPS error", "Input noise", "PID noise", "Lua", "Manual", "N/A", "Redundancy"

[ConstantsExtensions]
; defaultValue is used to provide TunerStudio with a value to use in the case of
Expand Down

0 comments on commit 1e7baa1

Please sign in to comment.