From 9dda1a21bcf2f71db8a3370866e4c627da12c41f Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 18 May 2020 11:32:00 -0700 Subject: [PATCH] Redundant tps (#1427) * add redundant sensor * add tests * add configure, info printing * tests * tests * partial hookup * fix * fix * bad makefile merge * use second TPS config * update test * update test * sensor names * set second pin by default * fix auto cal * auto cal both sensors * add reconfigure of secondary sensors * gobblin' up your ram * slow down write a little bit * put split in debug gauge * s Co-authored-by: Matthew Kennedy Co-authored-by: Matthew Kennedy --- .../binary/tunerstudio_configuration.h | 2 + firmware/console/status_loop.cpp | 3 +- .../actuators/electronic_throttle.cpp | 37 +++++++++++++++--- .../controllers/algo/engine_configuration.cpp | 1 + firmware/controllers/engine_controller.cpp | 2 +- firmware/init/sensor/init_tps.cpp | 38 +++++++++++++++---- firmware/tunerstudio/rusefi.input | 34 ++++++++++------- unit_tests/tests/sensor/test_sensor_init.cpp | 6 ++- 8 files changed, 93 insertions(+), 30 deletions(-) diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index 2b76b0f78f..0e2b87b685 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -26,6 +26,8 @@ enum class TsCalMode : uint8_t { EtbKp = 3, EtbKi = 4, EtbKd = 5, + Tps1SecondaryMax = 6, + Tps1SecondaryMin = 7, }; /** diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 5abd1fc5b4..6ba5d321eb 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -1006,7 +1006,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->debugFloatField7 = (engineConfiguration->afr.hwChannel != EFI_ADC_NONE) ? getVoltageDivided("ego", engineConfiguration->afr.hwChannel PASS_ENGINE_PARAMETER_SUFFIX) : 0.0f; break; case DBG_ANALOG_INPUTS2: - tsOutputChannels->debugFloatField4 = getVoltage("debug", engineConfiguration->throttlePedalPositionAdcChannel PASS_ENGINE_PARAMETER_SUFFIX); + tsOutputChannels->debugFloatField1 = Sensor::get(SensorType::Tps1Primary).value_or(0) - Sensor::get(SensorType::Tps1Secondary).value_or(0); + tsOutputChannels->debugFloatField2 = Sensor::get(SensorType::Tps2Primary).value_or(0) - Sensor::get(SensorType::Tps2Secondary).value_or(0); break; case DBG_INSTANT_RPM: { diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 0ee64eb419..e9edc7a154 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -105,6 +105,20 @@ static SensorType indexToTpsSensor(size_t index) { } } +static SensorType indexToTpsSensorPrimary(size_t index) { + switch(index) { + case 0: return SensorType::Tps1Primary; + default: return SensorType::Tps2Primary; + } +} + +static SensorType indexToTpsSensorSecondary(size_t index) { + switch(index) { + case 0: return SensorType::Tps1Secondary; + default: return SensorType::Tps2Secondary; + } +} + static percent_t directPwmValue = NAN; static percent_t currentEtbDuty; @@ -449,8 +463,8 @@ struct EtbImpl final : public EtbController, public PeriodicController<512> { motor->set(0.5f); motor->enable(); chThdSleepMilliseconds(1000); - tsOutputChannels.calibrationMode = TsCalMode::Tps1Max; - tsOutputChannels.calibrationValue = Sensor::getRaw(indexToTpsSensor(myIndex)) * TPS_TS_CONVERSION; + float primaryMax = Sensor::getRaw(indexToTpsSensorPrimary(myIndex)) * TPS_TS_CONVERSION; + float secondaryMax = Sensor::getRaw(indexToTpsSensorSecondary(myIndex)) * TPS_TS_CONVERSION; // Let it return motor->set(0); @@ -459,14 +473,27 @@ struct EtbImpl final : public EtbController, public PeriodicController<512> { // Now grab closed motor->set(-0.5f); chThdSleepMilliseconds(1000); - tsOutputChannels.calibrationMode = TsCalMode::Tps1Min; - tsOutputChannels.calibrationValue = Sensor::getRaw(indexToTpsSensor(myIndex)) * TPS_TS_CONVERSION; + float primaryMin = Sensor::getRaw(indexToTpsSensorPrimary(myIndex)) * TPS_TS_CONVERSION; + float secondaryMin = Sensor::getRaw(indexToTpsSensorSecondary(myIndex)) * TPS_TS_CONVERSION; // Finally disable and reset state motor->disable(); - // Wait to let TS grab the state before we leave cal mode + // Write out the learned values to TS, waiting briefly after setting each to let TS grab it + tsOutputChannels.calibrationMode = TsCalMode::Tps1Max; + tsOutputChannels.calibrationValue = primaryMax; chThdSleepMilliseconds(500); + tsOutputChannels.calibrationMode = TsCalMode::Tps1Min; + tsOutputChannels.calibrationValue = primaryMin; + chThdSleepMilliseconds(500); + + tsOutputChannels.calibrationMode = TsCalMode::Tps1SecondaryMax; + tsOutputChannels.calibrationValue = secondaryMax; + chThdSleepMilliseconds(500); + tsOutputChannels.calibrationMode = TsCalMode::Tps1SecondaryMin; + tsOutputChannels.calibrationValue = secondaryMin; + chThdSleepMilliseconds(500); + tsOutputChannels.calibrationMode = TsCalMode::None; m_isAutocal = false; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index eeffe45f3d..f1fe1d6f5f 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -312,6 +312,7 @@ void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE; engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; + engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_NONE; engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE; engineConfiguration->vRefAdcChannel = EFI_ADC_NONE; engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index f8bd508b2e..8ae50cadae 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -696,7 +696,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) * UNUSED_SIZE contants. */ #ifndef RAM_UNUSED_SIZE -#define RAM_UNUSED_SIZE 10000 +#define RAM_UNUSED_SIZE 9800 #endif #ifndef CCM_UNUSED_SIZE #define CCM_UNUSED_SIZE 2900 diff --git a/firmware/init/sensor/init_tps.cpp b/firmware/init/sensor/init_tps.cpp index e737e4a0ff..4e742d1b6f 100644 --- a/firmware/init/sensor/init_tps.cpp +++ b/firmware/init/sensor/init_tps.cpp @@ -3,6 +3,7 @@ #include "error_handling.h" #include "global.h" #include "functional_sensor.h" +#include "redundant_sensor.h" #include "proxy_sensor.h" #include "linear_func.h" #include "tps.h" @@ -10,14 +11,17 @@ EXTERN_ENGINE; LinearFunc tpsFunc1p(TPS_TS_CONVERSION); -//LinearFunc tpsFunc1s(TPS_TS_CONVERSION); +LinearFunc tpsFunc1s(TPS_TS_CONVERSION); LinearFunc tpsFunc2p(TPS_TS_CONVERSION); -//LinearFunc tpsFunc2s(TPS_TS_CONVERSION); +LinearFunc tpsFunc2s(TPS_TS_CONVERSION); -FunctionalSensor tpsSens1p(SensorType::Tps1, MS2NT(10)); -//FunctionalSensor tpsSens1s(SensorType::Tps1Secondary, MS2NT(10)); -FunctionalSensor tpsSens2p(SensorType::Tps2, MS2NT(10)); -//FunctionalSensor tpsSens2s(SensorType::Tps2Secondary, MS2NT(10)); +FunctionalSensor tpsSens1p(SensorType::Tps1Primary, MS2NT(10)); +FunctionalSensor tpsSens1s(SensorType::Tps1Secondary, MS2NT(10)); +FunctionalSensor tpsSens2p(SensorType::Tps2Primary, MS2NT(10)); +FunctionalSensor tpsSens2s(SensorType::Tps2Secondary, MS2NT(10)); + +RedundantSensor tps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary); +RedundantSensor tps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary); LinearFunc pedalFunc; FunctionalSensor pedalSensor(SensorType::AcceleratorPedal, MS2NT(10)); @@ -33,10 +37,10 @@ static void configureTps(LinearFunc& func, float closed, float open, float min, ); } -static void initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) { +static bool initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) { // Only register if we have a sensor if (channel == EFI_ADC_NONE) { - return; + return false; } configureTps(func, closed, open, min, max); @@ -47,6 +51,19 @@ static void initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_ if (!sensor.Register()) { firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", sensor.getSensorName()); + return false; + } + + return true; +} + +static void initTpsFuncAndRedund(RedundantSensor& redund, LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) { + bool hasSecond = initTpsFunc(func, sensor, channel, closed, open, min, max); + + redund.configure(5.0f, !hasSecond); + + if (!redund.Register()) { + firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", redund.getSensorName()); } } @@ -55,7 +72,9 @@ void initTps(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float max = CONFIG(tpsErrorDetectionTooHigh); initTpsFunc(tpsFunc1p, tpsSens1p, CONFIG(tps1_1AdcChannel), CONFIG(tpsMin), CONFIG(tpsMax), min, max); + initTpsFuncAndRedund(tps1, tpsFunc1s, tpsSens1s, CONFIG(tps1_2AdcChannel), CONFIG(tps1SecondaryMin), CONFIG(tps1SecondaryMax), min, max); initTpsFunc(tpsFunc2p, tpsSens2p, CONFIG(tps2_1AdcChannel), CONFIG(tps2Min), CONFIG(tps2Max), min, max); + initTpsFuncAndRedund(tps2, tpsFunc2s, tpsSens2s, CONFIG(tps2_2AdcChannel), CONFIG(tps2SecondaryMin), CONFIG(tps2SecondaryMax), min, max); initTpsFunc(pedalFunc, pedalSensor, CONFIG(throttlePedalPositionAdcChannel), CONFIG(throttlePedalUpVoltage), CONFIG(throttlePedalWOTVoltage), min, max); // Route the pedal or TPS to driverIntent as appropriate @@ -75,6 +94,9 @@ void reconfigureTps(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float max = CONFIG(tpsErrorDetectionTooHigh); configureTps(tpsFunc1p, CONFIG(tpsMin), CONFIG(tpsMax), min, max); + configureTps(tpsFunc1s, CONFIG(tps1SecondaryMin), CONFIG(tps1SecondaryMax), min, max); configureTps(tpsFunc2p, CONFIG(tps2Min), CONFIG(tps2Max), min, max); + configureTps(tpsFunc2s, CONFIG(tps2SecondaryMin), CONFIG(tps2SecondaryMax), min, max); + configureTps(pedalFunc, CONFIG(throttlePedalUpVoltage), CONFIG(throttlePedalWOTVoltage), min, max); } diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 430ab4a7d4..ed982c85b2 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -389,21 +389,21 @@ enable2ndByteCanID = false ; wall of debug mode :) ; https://rusefi.com/wiki/index.php?title=Manual:Debug_fields -; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 -; Alternator TPS Acceleration Warmup-Pid Idle Engine Load Acc Trigger Counters VVT Cranking Ignition Timing ETB PID CJ125 CAN TLE8888 Boost Start Launcher ETB Autotune - debugFieldF1List = bits, U08, [0:7], "Controller Output", "From TPS", "", "Controller Output", "Idle output", "Channel 1 Rise Counter", "", "", "VVT Event Position","", "Ign IAT Corr", "", "", "", "", "", "", "ETB Controller Output", "", "", "df1", "df1", "22df1", "", "23:df1", "CJ125: output", "", "", "", "", "", "", "", "", "", "", "Boost Open Loop Duty", "S unused" "", "Osc Amplitude" - debugFieldF2List = bits, U08, [0:7], "I-Term", "To TPS", "", "I-Term", "Idle df2", "Channel 2 Rise Counter", "", "", "VVT Ratio", "", "Ign CLT Corr", "", "", "", "", "", "", "ETB I-Term", "", "", "df2", "df2", "22df2", "", "23:df2", "CJ125: i-term", "", "", "", "", "", "", "", "", "", "", "Boost Closed Loop Duty","S unused" "", "Duty Amplitude" - debugFieldF3List = bits, U08, [0:7], "Previous Error", "Current TPS<>TPS", "", "", "Idle df3", "ICU sum", "", "", "", "", "Ign FSIO Adj", "", "", "", "", "", "", "ETB err", "", "", "df3", "df3", "22df3", "", "23:df3", "CJ125: err", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Tu" - debugFieldF4List = bits, U08, [0:7], "I Gain", "Extra Fuel", "", "", "Idle df4", "VVT rise", "", "", "", "", "Ign PID Adj", "", "", "", "", "", "", "ETB I setting", "", "", "df4", "df4", "22df4", "", "23:df4", "CJ125: UA", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ku" - debugFieldF5List = bits, U08, [0:7], "D Gain", "df5", "df5", "df5", "Idle df5", "VVT fall", "df5", "", "", "", "", "", "", "", "", "", "", "ETB D setting", "df5", "df5", "df5", "df5", "22df5", "", "23:df5", "CJ125: UR", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kp" - debugFieldF6List = bits, U08, [0:7], "D Term", "", "", "", "Idle df6", "Current Gap", "", "", "", "", "", "", "", "", "", "", "", "ETB df6", "", "", "df6", "df6", "22df6", "", "23:df6", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ki" - debugFieldF7List = bits, U08, [0:7], "Max-Value", "", "", "", "Idle df7", "", "", "", "", "", "", "", "", "", "", "", "", "ETB df7", "", "", "df7", "df7", "22df7", "", "23:df7", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kd" +; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 +; Alternator TPS Acceleration Warmup-Pid Idle Engine Load Acc Trigger Counters VVT Cranking Ignition Timing ETB PID CJ125 CAN TLE8888 Analog inputs 2 Boost Start Launcher ETB Autotune + debugFieldF1List = bits, U08, [0:7], "Controller Output", "From TPS", "", "Controller Output", "Idle output", "Channel 1 Rise Counter", "", "", "VVT Event Position","", "Ign IAT Corr", "", "", "", "", "", "", "ETB Controller Output", "", "", "df1", "df1", "22df1", "", "23:df1", "CJ125: output", "", "", "", "", "", "", "TPS1 Pri/Sec Diff", "", "", "", "Boost Open Loop Duty", "S unused" "", "Osc Amplitude" + debugFieldF2List = bits, U08, [0:7], "I-Term", "To TPS", "", "I-Term", "Idle df2", "Channel 2 Rise Counter", "", "", "VVT Ratio", "", "Ign CLT Corr", "", "", "", "", "", "", "ETB I-Term", "", "", "df2", "df2", "22df2", "", "23:df2", "CJ125: i-term", "", "", "", "", "", "", "TPS2 Pri/Sec Diff", "", "", "", "Boost Closed Loop Duty","S unused" "", "Duty Amplitude" + debugFieldF3List = bits, U08, [0:7], "Previous Error", "Current TPS<>TPS", "", "", "Idle df3", "ICU sum", "", "", "", "", "Ign FSIO Adj", "", "", "", "", "", "", "ETB err", "", "", "df3", "df3", "22df3", "", "23:df3", "CJ125: err", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Tu" + debugFieldF4List = bits, U08, [0:7], "I Gain", "Extra Fuel", "", "", "Idle df4", "VVT rise", "", "", "", "", "Ign PID Adj", "", "", "", "", "", "", "ETB I setting", "", "", "df4", "df4", "22df4", "", "23:df4", "CJ125: UA", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ku" + debugFieldF5List = bits, U08, [0:7], "D Gain", "df5", "df5", "df5", "Idle df5", "VVT fall", "df5", "", "", "", "", "", "", "", "", "", "", "ETB D setting", "df5", "df5", "df5", "df5", "22df5", "", "23:df5", "CJ125: UR", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kp" + debugFieldF6List = bits, U08, [0:7], "D Term", "", "", "", "Idle df6", "Current Gap", "", "", "", "", "", "", "", "", "", "", "", "ETB df6", "", "", "df6", "df6", "22df6", "", "23:df6", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ki" + debugFieldF7List = bits, U08, [0:7], "Max-Value", "", "", "", "Idle df7", "", "", "", "", "", "", "", "", "", "", "", "", "ETB df7", "", "", "df7", "df7", "22df7", "", "23:df7", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kd" - debugFieldI1List = bits, U08, [0:7], "P-Gain", "", "", "", "Idle di1", "Channel 1 Fall Counter", "", "", "VVT Sync Counter", "", "Multispark Count", "", "", "", "", "", "", "ETB P-Gain", "", "", "di1", "di1", "22di1", "", "23:di1", "CJ125: state", "read count","", "", "", "", "SPI Counter", "", "", "", "", "", "Start Count" "", "" - debugFieldI2List = bits, U08, [0:7], "Offset", "", "", "", "Idle di2", "Channel 2 Fall Counter", "", "", "", "", "", "", "", "", "", "", "", "ETB di2", "", "", "di2", "di2", "22di2", "", "23:di2", "", "", "", "", "", "", "Latest Transmit","", "", "", "", "", "S unused" "", "" - debugFieldI3List = bits, U08, [0:7], "", "", "", "", "Idle di3", "Cycle Index", "", "", "", "", "", "", "", "", "", "", "", "ETB di3", "", "", "di3", "di3", "22di3", "", "23:di3", "", "", "", "", "", "", "Latest Received","", "", "", "", "", "S unused" "", "" - debugFieldI4List = bits, U08, [0:7], "", "", "", "", "Idle di4", "Cycle Cnt 1", "", "", "", "", "", "", "", "", "", "", "", "ETB di4", "", "", "di4", "di4", "22di4", "", "23:di4", "", "", "", "", "", "", "Init Count", "", "", "", "", "", "S unused" "", "" - debugFieldI5List = bits, U08, [0:7], "", "", "", "", "Idle di5", "Cycle Cnt 2", "", "", "", "", "", "", "", "", "", "di5", "di5", "ETB di5", "di5", "di5", "di5", "di5", "22di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "S di5" "", "" + debugFieldI1List = bits, U08, [0:7], "P-Gain", "", "", "", "Idle di1", "Channel 1 Fall Counter", "", "", "VVT Sync Counter", "", "Multispark Count", "", "", "", "", "", "", "ETB P-Gain", "", "", "di1", "di1", "22di1", "", "23:di1", "CJ125: state", "read count","", "", "", "", "SPI Counter", "", "", "", "", "", "Start Count" "", "" + debugFieldI2List = bits, U08, [0:7], "Offset", "", "", "", "Idle di2", "Channel 2 Fall Counter", "", "", "", "", "", "", "", "", "", "", "", "ETB di2", "", "", "di2", "di2", "22di2", "", "23:di2", "", "", "", "", "", "", "Latest Transmit","", "", "", "", "", "S unused" "", "" + debugFieldI3List = bits, U08, [0:7], "", "", "", "", "Idle di3", "Cycle Index", "", "", "", "", "", "", "", "", "", "", "", "ETB di3", "", "", "di3", "di3", "22di3", "", "23:di3", "", "", "", "", "", "", "Latest Received","", "", "", "", "", "S unused" "", "" + debugFieldI4List = bits, U08, [0:7], "", "", "", "", "Idle di4", "Cycle Cnt 1", "", "", "", "", "", "", "", "", "", "", "", "ETB di4", "", "", "di4", "di4", "22di4", "", "23:di4", "", "", "", "", "", "", "Init Count", "", "", "", "", "", "S unused" "", "" + debugFieldI5List = bits, U08, [0:7], "", "", "", "", "Idle di5", "Cycle Cnt 2", "", "", "", "", "", "", "", "", "", "di5", "di5", "ETB di5", "di5", "di5", "di5", "di5", "22di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "", "di5", "di5", "di5", "di5", "S di5" "", "" [ConstantsExtensions] ; defaultValue is used to provide TunerStudio with a value to use in the case of @@ -412,9 +412,15 @@ enable2ndByteCanID = false ; defaultValue = constantName, value; defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 + ; TPS 1 Primary maintainConstantValue = tpsMax, { (calibrationMode == 1 ) ? calibrationValue : tpsMax } maintainConstantValue = tpsMin, { (calibrationMode == 2 ) ? calibrationValue : tpsMin } + ; TPS 1 Secondary + maintainConstantValue = tps1SecondaryMax, { (calibrationMode == 6 ) ? calibrationValue : tps1SecondaryMax } + maintainConstantValue = tps1SecondaryMin, { (calibrationMode == 7 ) ? calibrationValue : tps1SecondaryMin } + + ; ETB Auto Gain Calibration maintainConstantValue = etb_pFactor, { (calibrationMode == 3 ) ? calibrationValue : etb_pFactor } maintainConstantValue = etb_iFactor, { (calibrationMode == 4 ) ? calibrationValue : etb_iFactor } maintainConstantValue = etb_dFactor, { (calibrationMode == 5 ) ? calibrationValue : etb_dFactor } diff --git a/unit_tests/tests/sensor/test_sensor_init.cpp b/unit_tests/tests/sensor/test_sensor_init.cpp index 37f28a7624..b028b73a65 100644 --- a/unit_tests/tests/sensor/test_sensor_init.cpp +++ b/unit_tests/tests/sensor/test_sensor_init.cpp @@ -34,7 +34,7 @@ TEST(SensorInit, Tps) { initTps(PASS_ENGINE_PARAMETER_SIGNATURE); // Ensure the sensors were registered - auto s = const_cast(Sensor::getSensorOfType(SensorType::Tps1)); + auto s = const_cast(Sensor::getSensorOfType(SensorType::Tps1Primary)); ASSERT_NE(nullptr, s); // Test in range @@ -45,6 +45,10 @@ TEST(SensorInit, Tps) { // Test out of range EXPECT_POINT_INVALID(s, 0.0f); EXPECT_POINT_INVALID(s, 5.0f); + + // Test that the passthru (redundant sensor) is working + EXPECT_POINT_VALID(s, 2.5f, 50.0f); + EXPECT_NEAR(50.0f, Sensor::get(SensorType::Tps1).value_or(-1), EPS2D); } TEST(SensorInit, Pedal) {