ETB duty cycle jitter #4833

This commit is contained in:
Andrey 2022-11-29 14:59:08 -05:00
parent 368517780d
commit 3070e1b3c8
4 changed files with 12 additions and 5 deletions

View File

@ -215,6 +215,9 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
void EtbController::reset() {
m_shouldResetPid = true;
etbDutyRateOfChange = etbDutyAverage = 0;
m_dutyRocAverage.reset();
m_dutyAverage.reset();
}
void EtbController::onConfigurationChange(pid_s* previousConfiguration) {
@ -740,12 +743,11 @@ static void showEtbInfo() {
#endif /* EFI_PROD_CODE */
}
static void etbPidReset() {
void etbPidReset() {
for (int i = 0 ; i < ETB_COUNT; i++) {
if (auto controller = engine->etbControllers[i]) {
controller->reset();
}
}
}

View File

@ -119,6 +119,8 @@ private:
Timer m_luaAdjustmentTimer;
};
void etbPidReset();
class EtbController1 : public EtbController { };
class EtbController2 : public EtbController {

View File

@ -15,6 +15,11 @@ public:
smoothingFactor = 2 / (length + 1.0);
}
void reset() {
current = 0;
smoothingFactor = 0.5;
}
private:
float current = 0;
float smoothingFactor = 0.5;

View File

@ -5,6 +5,7 @@
TEST(etb, integrated) {
EngineTestHelper eth(TEST_ENGINE);
etbPidReset(); // ETB controlles are global shared instances :(
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3;
engineConfiguration->tps1_2AdcChannel = EFI_ADC_3;
@ -17,15 +18,12 @@ TEST(etb, integrated) {
Sensor::setMockValue(SensorType::Tps1, 25.0f, true);
initTps();
doInitElectronicThrottle();
EtbController *etb = (EtbController*)engine->etbControllers[0];
etb->update();
ASSERT_EQ(engine->outputChannels.etbTarget, 40);
ASSERT_EQ(etb->prevOutput, 100);
ASSERT_EQ(etb->etbDutyAverage, 50);