diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index c10541cc17..db936cfb06 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -177,8 +177,8 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_ENGINE_PARAMETER_F) { * TPS */ engineConfiguration->tpsAdcChannel = EFI_ADC_3; - engineConfiguration->tpsMin = 108; // convert 12to10 bit (ADC/4) - engineConfiguration->tpsMax = 812; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMax = 108; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMin = 812; // convert 12to10 bit (ADC/4) /** * IAT */ diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 89c03c5f49..91c2ab2a2a 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -382,8 +382,8 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { * TPS */ engineConfiguration->tpsAdcChannel = EFI_ADC_2; - engineConfiguration->tpsMin = 125; // convert 12to10 bit (ADC/4) - engineConfiguration->tpsMax = 625; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMax = 125; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMin = 625; // convert 12to10 bit (ADC/4) /** * IAT D15/W7 diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index e47c08dde6..d90ef6af6b 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -216,8 +216,8 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { // we have a 1999 Auto Miata TB mounted on this car engineConfiguration->hasTpsSensor = true; - engineConfiguration->tpsMin = 115; // convert 12to10 bit (ADC/4) - engineConfiguration->tpsMax = 630; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMin = 630; // convert 12to10 bit (ADC/4) + engineConfiguration->tpsMax = 115; // convert 12to10 bit (ADC/4) engineConfiguration->tpsAdcChannel = EFI_ADC_3; // engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index a0d495962e..9cdcd90363 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -352,8 +352,8 @@ void setMiata1994_s(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->fanOffTemperature = 90; engineConfiguration->fanOnTemperature = 95; - engineConfiguration->tpsMin = 86; - engineConfiguration->tpsMax = 596; + engineConfiguration->tpsMax = 86; + engineConfiguration->tpsMin = 596; boardConfiguration->malfunctionIndicatorPin = GPIOE_5; boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 4b296f3119..ed09852118 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 12 22:41:42 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 12 23:06:44 EDT 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -865,13 +865,13 @@ typedef struct { offset 80 bit 28 */ bool issue_294_29 : 1; /** - * todo: extract these two fields into a structure + * Closed throttle. todo: extract these two fields into a structure * todo: we need two sets of TPS parameters - modern ETBs have two sensors * offset 84 */ int16_t tpsMin; /** - * tpsMax value as 10 bit ADC value. Not Voltage! + * Full throtle. tpsMax value as 10 bit ADC value. Not Voltage! * offset 86 */ int16_t tpsMax; @@ -1798,4 +1798,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 12 22:41:42 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 12 23:06:44 EDT 2016 diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index 78effe7385..cc89ed1aad 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -62,7 +62,7 @@ percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S) { warning(OBD_PCM_Processor_Fault, "Invalid TPS configuration: same value %d", engineConfiguration->tpsMin); return NAN; } - float result = interpolate(TPS_TS_CONVERSION * engineConfiguration->tpsMin, 0, TPS_TS_CONVERSION * engineConfiguration->tpsMax, 100, adc); + float result = interpolate(TPS_TS_CONVERSION * engineConfiguration->tpsMax, 0, TPS_TS_CONVERSION * engineConfiguration->tpsMin, 100, adc); // this would put the value into the 0-100 range return maxF(0, minF(100, result)); } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 4e2bbb4876..d0ab873c34 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -413,7 +413,7 @@ static void printTPSInfo(void) { ioportid_t port = getAdcChannelPort(engineConfiguration->tpsAdcChannel); int pin = getAdcChannelPin(engineConfiguration->tpsAdcChannel); - scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax, + scheduleMsg(&logger, "tps min (closed) %d/max (full) %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax, getTPSVoltage(PASS_ENGINE_PARAMETER_F), portname(port), pin); #endif scheduleMsg(&logger, "current 10bit=%d value=%f rate=%f", getTPS12bitAdc() / TPS_TS_CONVERSION, getTPS(PASS_ENGINE_PARAMETER_F), diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index d1197ae370..5fc0dcb0cb 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -196,8 +196,8 @@ bit issue_294_28; bit issue_294_29; -int16_t tpsMin;todo: extract these two fields into a structure\ntodo: we need two sets of TPS parameters - modern ETBs have two sensors;"ADC", 1, 0, 0, 1023, 0 -int16_t tpsMax;tpsMax value as 10 bit ADC value. Not Voltage!;"ADC", 1, 0, 0, 1023, 0 +int16_t tpsMin;Closed throttle. todo: extract these two fields into a structure\ntodo: we need two sets of TPS parameters - modern ETBs have two sensors;"ADC", 1, 0, 0, 1023, 0 +int16_t tpsMax;Full throtle. tpsMax value as 10 bit ADC value. Not Voltage!;"ADC", 1, 0, 0, 1023, 0 int16_t tpsErrorDetectionTooLow;TPS error detection, what TPS % value is unrealistically low;"%", 1, 0, -40, 200, 0 int16_t tpsErrorDetectionTooHigh;;"%", 1, 0, -40, 200, 0 diff --git a/unit_tests/test_idle_controller.cpp b/unit_tests/test_idle_controller.cpp index e733023f31..b8e504fb26 100644 --- a/unit_tests/test_idle_controller.cpp +++ b/unit_tests/test_idle_controller.cpp @@ -28,13 +28,13 @@ void testIdleController(void) { efitimems_t time = 0; - assertEquals(60, is.getIdle(900, time PASS_ENGINE_PARAMETER)); + assertEqualsM("#1", 60.0, is.getIdle(900, time PASS_ENGINE_PARAMETER)); time += 2000; - assertEquals(60.5, is.getIdle(900, time PASS_ENGINE_PARAMETER)); + assertEqualsM("2", 60.0, is.getIdle(900, time PASS_ENGINE_PARAMETER)); time += 2000; - assertEquals(60.6, is.getIdle(1050, time PASS_ENGINE_PARAMETER)); + assertEquals(60.0, is.getIdle(1050, time PASS_ENGINE_PARAMETER)); } void testPidController(void) { diff --git a/unit_tests/test_sensors.cpp b/unit_tests/test_sensors.cpp index 5715d83962..89eb17af0c 100644 --- a/unit_tests/test_sensors.cpp +++ b/unit_tests/test_sensors.cpp @@ -32,14 +32,14 @@ void testTps(void) { EngineTestHelper eth(DODGE_RAM); EXPAND_EngineTestHelper; - engineConfiguration->tpsMin = 43; - engineConfiguration->tpsMax = 193; + engineConfiguration->tpsMax = 43; + engineConfiguration->tpsMin = 193; assertEquals(49.3333, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER)); - engineConfiguration->tpsMin = 193; - engineConfiguration->tpsMax = 43; + engineConfiguration->tpsMax = 193; + engineConfiguration->tpsMin = 43; assertEqualsM("test#2", 50.6667, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER)); } diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 8bde361ec3..2333d6d9c0 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -250,8 +250,8 @@ static void testStartupFuelPumping(void) { engine->rpmCalculator.mockRpm = 0; - engine->engineConfiguration->tpsMin = 0; - engine->engineConfiguration->tpsMax = 10; + engine->engineConfiguration->tpsMin = 10; + engine->engineConfiguration->tpsMax = 0; mockTps = TPS_TS_CONVERSION * 6; sf.update(PASS_ENGINE_PARAMETER_F);