From 82a3074cbd18ffdecdd97a4ffa56ee6dacc7d103 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 29 Nov 2022 11:42:09 -0500 Subject: [PATCH] ETB overheats due to constant isTpsError true/false/true/false jitter #4832 --- .../actuators/electronic_throttle.cpp | 2 +- .../actuators/electronic_throttle_impl.h | 3 +- .../tests/actuators/test_etb_integrated.cpp | 31 +++++++++++++++++++ unit_tests/tests/tests.mk | 1 + 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 unit_tests/tests/actuators/test_etb_integrated.cpp diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 8d6b542015..648617333a 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -259,7 +259,7 @@ expected EtbController::getSetpoint() { expected EtbController::getSetpointIdleValve() const { // VW ETB idle mode uses an ETB only for idle (a mini-ETB sets the lower stop, and a normal cable // can pull the throttle up off the stop.), so we directly control the throttle with the idle position. -#if EFI_TUNER_STUDIO && (EFI_PROD_CODE || EFI_SIMULATOR) +#if EFI_TUNER_STUDIO engine->outputChannels.etbTarget = m_idlePosition; #endif // EFI_TUNER_STUDIO return clampF(0, m_idlePosition, 100); diff --git a/firmware/controllers/actuators/electronic_throttle_impl.h b/firmware/controllers/actuators/electronic_throttle_impl.h index 4009ebf87b..1f154e4e44 100644 --- a/firmware/controllers/actuators/electronic_throttle_impl.h +++ b/firmware/controllers/actuators/electronic_throttle_impl.h @@ -71,6 +71,8 @@ public: void setLuaAdjustment(percent_t adjustment) override; float getLuaAdjustment() const; + float prevOutput = 0; + protected: // This is set if an automatic TPS calibration should be run bool m_isAutocal = false; @@ -90,7 +92,6 @@ private: ExpAverage m_dutyRocAverage; ExpAverage m_dutyAverage; - float prevOutput = 0; // Pedal -> target map const ValueProvider3D* m_pedalMap = nullptr; diff --git a/unit_tests/tests/actuators/test_etb_integrated.cpp b/unit_tests/tests/actuators/test_etb_integrated.cpp new file mode 100644 index 0000000000..d0e918c71f --- /dev/null +++ b/unit_tests/tests/actuators/test_etb_integrated.cpp @@ -0,0 +1,31 @@ +#include "pch.h" +#include "init.h" +#include "electronic_throttle_impl.h" + +TEST(etb, integrated) { + EngineTestHelper eth(TEST_ENGINE); + + engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; + engineConfiguration->tps1_2AdcChannel = EFI_ADC_3; + + engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_3; + engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_3; + + Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 40); + Sensor::setMockValue(SensorType::AcceleratorPedalSecondary, 40); + + 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); + +} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index cae260c1a3..1ab4403409 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -107,6 +107,7 @@ TESTS_SRC_CPP = \ tests/actuators/test_boost.cpp \ tests/actuators/test_dc_motor.cpp \ tests/actuators/test_etb.cpp \ + tests/actuators/test_etb_integrated.cpp \ tests/actuators/test_fan_control.cpp \ tests/actuators/test_fuel_pump.cpp \ tests/actuators/test_gppwm.cpp \