diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index d8bc5888ca..1bec714041 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -241,7 +241,7 @@ void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode, tsSendResponse(tsChannel, mode, NULL, 0); } -static void onlineTuneBytes(int currentPageId, int offset, int count) { +static void onlineTuneBytes(int currentPageId, uint32_t offset, int count) { if (offset > sizeof(engine_configuration_s)) { int maxSize = sizeof(persistent_config_s) - offset; if (count > maxSize) { diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 6a00725683..d3dec0662f 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -768,7 +768,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->clutchUpState = engine->clutchUpState; tsOutputChannels->clutchDownState = engine->clutchDownState; - tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake); + tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake PASS_ENGINE_PARAMETER); float timing = engine->engineState.timingAdvance; tsOutputChannels->ignitionAdvance = timing > 360 ? timing - 720 : timing; tsOutputChannels->sparkDwell = ENGINE(engineState.sparkDwell); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 3dc648254b..58c89aa400 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -190,7 +190,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) { float coolantC = ENGINE(engineState.clt); float intakeC = ENGINE(engineState.iat); float tps = getTPS(PASS_ENGINE_PARAMETER_F); - tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); + tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC PASS_ENGINE_PARAMETER)); float map = getMap(); /** diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index dda4b653ca..a1323af7b8 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 Oct 02 13:12:05 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Oct 11 20:15:08 EDT 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -1798,7 +1798,7 @@ typedef struct { */ float crankingCycleBins[CRANKING_CURVE_SIZE]; /** - * CLT-based adjustment for simple manual idle controller + * CLT-based idle position multiplier for simple manual idle controller * offset 7032 */ float cltIdleCorrBins[CLT_CURVE_SIZE]; @@ -1959,4 +1959,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Oct 02 13:12:05 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Oct 11 20:15:08 EDT 2016 diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index fb65a16baa..81eb848ab7 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -14,14 +14,11 @@ #include "engine_math.h" #include "engine_state.h" -#define K_AT_MIN_RPM_MIN_TPS 0.25 -#define K_AT_MIN_RPM_MAX_TPS 0.25 -#define K_AT_MAX_RPM_MIN_TPS 0.25 -#define K_AT_MAX_RPM_MAX_TPS 0.9 - #define rpmMin 500 #define rpmMax 8000 +EXTERN_ENGINE; + fuel_Map3D_t veMap("VE"); fuel_Map3D_t ve2Map("VE2"); afr_Map3D_t afrMap("AFR", 1.0 / AFR_STORAGE_MULT); @@ -30,11 +27,11 @@ baroCorr_Map3D_t baroCorrMap("baro"); #define tpMin 0 #define tpMax 100 // http://rusefi.com/math/t_charge.html -float getTCharge(int rpm, float tps, float coolantTemp, float airTemp) { - float minRpmKcurrentTPS = interpolate(tpMin, K_AT_MIN_RPM_MIN_TPS, tpMax, - K_AT_MIN_RPM_MAX_TPS, tps); - float maxRpmKcurrentTPS = interpolate(tpMin, K_AT_MAX_RPM_MIN_TPS, tpMax, - K_AT_MAX_RPM_MAX_TPS, tps); +float getTCharge(int rpm, float tps, float coolantTemp, float airTemp DECLARE_ENGINE_PARAMETER_S) { + float minRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMinRpmMinTps, tpMax, + engineConfiguration->tChargeMinRpmMaxTps, tps); + float maxRpmKcurrentTPS = interpolate(tpMin, engineConfiguration->tChargeMaxRpmMinTps, tpMax, + engineConfiguration->tChargeMaxRpmMaxTps, tps); float Tcharge_coff = interpolate(rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm); diff --git a/firmware/controllers/math/speed_density.h b/firmware/controllers/math/speed_density.h index 82dc033c9e..2a6707ff14 100644 --- a/firmware/controllers/math/speed_density.h +++ b/firmware/controllers/math/speed_density.h @@ -9,7 +9,7 @@ #include "engine.h" -float getTCharge(int rpm, float tps, float coolantTemp, float airTemp); +float getTCharge(int rpm, float tps, float coolantTemp, float airTemp DECLARE_ENGINE_PARAMETER_S); void setDetaultVETable(persistent_config_s *config); float getAirMass(engine_configuration_s *engineConfiguration, float VE, float MAP, float tempK); float sdMath(engine_configuration_s *engineConfiguration, float airMass, float AFR); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 186ca51b61..77761618f0 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -732,10 +732,10 @@ float[MAP_ACCEL_TAPER] mapAccelTaperMult;;"mult", 1, 0, 0.0, 300, brain_input_pin_e camInput; pid_dt[AUX_PID_COUNT iterate] auxPidDT; float crankingIdleAdjustment;Extra idle while cranking;"percent", 1, 0, -100.0, 100, - float tChargeMinRpmMinTps; - float tChargeMinRpmMaxTps; - float tChargeMaxRpmMinTps; - float tChargeMaxRpmMaxTps; + float tChargeMinRpmMinTps;;"mult", 1, 0, 0, 3, 4 + float tChargeMinRpmMaxTps;;"mult", 1, 0, 0, 3, 4 + float tChargeMaxRpmMinTps;;"mult", 1, 0, 0, 3, 4 + float tChargeMaxRpmMaxTps;;"mult", 1, 0, 0, 3, 4 brain_pin_e[AUX_PID_COUNT iterate] auxPidPins; fsio_pwm_freq_t[AUX_PID_COUNT iterate] auxPidFrequency; int alternatorPwmFrequency;;"Hz", 1, 0, 0, 3000.0, 0 diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index beb0a6cd9a..532844abcf 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -294,5 +294,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20161010; + return 20161011; } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 5939ec123b..2b44a917cb 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -42,7 +42,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Oct 08 21:51:08 EDT 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Oct 11 20:15:08 EDT 2016 pageSize = 16376 page = 1 @@ -577,10 +577,10 @@ page = 1 auxPidDT3 = scalar, U32, 2420, "ms", 1, 0, 0, 3000, 0 auxPidDT4 = scalar, U32, 2424, "ms", 1, 0, 0, 3000, 0 crankingIdleAdjustment = scalar, F32, 2428, "percent", 1, 0, -100.0, 100, -;skipping tChargeMinRpmMinTps offset 2432 -;skipping tChargeMinRpmMaxTps offset 2436 -;skipping tChargeMaxRpmMinTps offset 2440 -;skipping tChargeMaxRpmMaxTps offset 2444 + tChargeMinRpmMinTps = scalar, F32, 2432, "mult", 1, 0, 0, 3, 4 + tChargeMinRpmMaxTps = scalar, F32, 2436, "mult", 1, 0, 0, 3, 4 + tChargeMaxRpmMinTps = scalar, F32, 2440, "mult", 1, 0, 0, 3, 4 + tChargeMaxRpmMaxTps = scalar, F32, 2444, "mult", 1, 0, 0, 3, 4 auxPidPins1 = bits, U32, 2448, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" auxPidPins2 = bits, U32, 2452, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" auxPidPins3 = bits, U32, 2456, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -1368,6 +1368,7 @@ fileVersion = { 20160702 } subMenu = baroCorrTbl, "Baro Correction", 0, {fuelAlgorithm == 3} subMenu = std_separator subMenu = std_realtime, "&Realtime Display", 0 + subMenu = tChargeSettings, "tCharge Settings" menu = "3D Map Tuning" ; subMenu = std_realtime, "Realtime Display" @@ -1449,6 +1450,11 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" [UserDefined] + dialog = tChargeSettings, "tChart Settings" + field = "MinRpm MinTps", tChargeMinRpmMinTps + field = "MinRpm MaxTps", tChargeMinRpmMaxTps + field = "MaxRpm MinTps", tChargeMaxRpmMinTps + field = "MaxRpm MaxTps", tChargeMaxRpmMaxTps dialog = baseInjection, "Injection" field = "Enabled", isInjectionEnabled diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 46107155a7..1938e33925 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1345,6 +1345,7 @@ fileVersion = { 20160702 } subMenu = baroCorrTbl, "Baro Correction", 0, {fuelAlgorithm == 3} subMenu = std_separator subMenu = std_realtime, "&Realtime Display", 0 + subMenu = tChargeSettings, "tCharge Settings" menu = "3D Map Tuning" ; subMenu = std_realtime, "Realtime Display" @@ -1426,6 +1427,11 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" [UserDefined] + dialog = tChargeSettings, "tChart Settings" + field = "MinRpm MinTps", tChargeMinRpmMinTps + field = "MinRpm MaxTps", tChargeMinRpmMaxTps + field = "MaxRpm MinTps", tChargeMaxRpmMinTps + field = "MaxRpm MaxTps", tChargeMaxRpmMaxTps dialog = baseInjection, "Injection" field = "Enabled", isInjectionEnabled diff --git a/unit_tests/test_engine_math.cpp b/unit_tests/test_engine_math.cpp index e9fcad2fde..bc24a4ef7f 100644 --- a/unit_tests/test_engine_math.cpp +++ b/unit_tests/test_engine_math.cpp @@ -30,8 +30,7 @@ void testEngineMath(void) { printf("*************************************************** testEngineMath\r\n"); EngineTestHelper eth(FORD_ESCORT_GT); - Engine * engine = ð.engine; - engine_configuration_s *engineConfiguration = engine->engineConfiguration; + EXPAND_EngineTestHelper; engineConfiguration->operationMode = FOUR_STROKE_CAM_SENSOR; @@ -39,14 +38,14 @@ void testEngineMath(void) { assertEqualsM("6000 RPM", 5, getOneDegreeTimeMs(6000) * 180); - assertEquals(312.5, getTCharge(1000, 0, 300, 350)); - assertEquals(313.5833, getTCharge(1000, 50, 300, 350)); - assertEquals(314.6667, getTCharge(1000, 100, 300, 350)); + assertEquals(312.5, getTCharge(1000, 0, 300, 350 PASS_ENGINE_PARAMETER)); + assertEquals(313.5833, getTCharge(1000, 50, 300, 350 PASS_ENGINE_PARAMETER)); + assertEquals(314.6667, getTCharge(1000, 100, 300, 350 PASS_ENGINE_PARAMETER)); - assertEquals(312.5, getTCharge(4000, 0, 300, 350)); - assertEquals(320.0833, getTCharge(4000, 50, 300, 350)); - assertEquals(327.6667, getTCharge(4000, 100, 300, 350)); + assertEquals(312.5, getTCharge(4000, 0, 300, 350 PASS_ENGINE_PARAMETER)); + assertEquals(320.0833, getTCharge(4000, 50, 300, 350 PASS_ENGINE_PARAMETER)); + assertEquals(327.6667, getTCharge(4000, 100, 300, 350 PASS_ENGINE_PARAMETER)); } void testIgnitionMapGenerator(void) {