ETB duty cycle jitter #4833

This commit is contained in:
Andrey 2022-11-29 21:03:21 -05:00
parent 4a7a48779d
commit a6adca0afb
1 changed files with 16 additions and 8 deletions

View File

@ -524,14 +524,6 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
etbDutyRateOfChange = m_dutyRocAverage.average(output - prevOutput);
prevOutput = output;
// seems good enough to simply check for both TPS sensors
bool isInputError = isTps1Error() || isTps2Error() || isPedalError();
// current basic implementation is to check for input error counter only while engine is not running
// we can make this logic smarter one day later
if (Sensor::getOrZero(SensorType::Rpm) == 0 && wasInputError != isInputError) {
wasInputError = isInputError;
etbInputErrorCounter++;
}
return output;
}
}
@ -597,6 +589,22 @@ void EtbController::update() {
&& engine->etbAutoTune
&& m_function == ETB_Throttle1;
if (!m_isAutotune) {
// note that ClosedLoopController has it's own setpoint error validation so ours with the counter has to be here
// seems good enough to simply check for both TPS sensors
int errorState = (isTps1Error() ? 1 : 0) + (isTps2Error() ? 2 : 0)
+ (isPedalError() ? 4 : 0);
// current basic implementation is to check for input error counter only while engine is not running
// we can make this logic smarter one day later
if (Sensor::getOrZero(SensorType::Rpm) == 0
&& prevErrorState != errorState) {
prevErrorState = errorState;
etbInputErrorCounter++;
}
}
ClosedLoopController::update();
}