From 2b6e12bc32943153db862b9c1d88a85116008a66 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 1 Jan 2016 19:02:59 -0500 Subject: [PATCH] auto-sync --- firmware/config/engines/dodge_neon.cpp | 14 +++++ firmware/controllers/algo/engine.cpp | 56 ++++++++++--------- firmware/controllers/core/table_helper.cpp | 2 +- .../controllers/sensors/hip9011_lookup.cpp | 9 ++- firmware/integration/rusefi_config.txt | 2 +- firmware/tunerstudio/rusefi.ini | 4 +- unit_tests/test_engine_math.cpp | 4 +- 7 files changed, 57 insertions(+), 34 deletions(-) diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 6f0d00f4eb..a1ebb9b3f0 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -392,6 +392,20 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { #if EFI_HIP_9011 || defined(__DOXYGEN__) setHip9011FrankensoPinout(); #endif + boardConfiguration->hip9011Gain = 0.3; + + float t = 0.5; + + engineConfiguration->knockNoise[0] = 2.1 + t; // 800 + engineConfiguration->knockNoise[1] = 2.1 + t; // 1700 + engineConfiguration->knockNoise[2] = 2.2 + t; // 2600 + engineConfiguration->knockNoise[3] = 2.2 + t; // 3400 + engineConfiguration->knockNoise[4] = 2.3 + t; // 4300 + engineConfiguration->knockNoise[5] = 2.7 + t; // 5200 + engineConfiguration->knockNoise[6] = 3.1 + t; // 6100 + engineConfiguration->knockNoise[7] = 3.3 + t; // 7000 + + engineConfiguration->cylinderBore = 87.5; boardConfiguration->clutchDownPin = GPIOC_12; diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 31c84bcc9f..3ecc20ae56 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -18,6 +18,7 @@ #include "engine_math.h" #include "advance_map.h" #include "speed_density.h" +#include "advance_map.h" #if EFI_PROD_CODE #include "injector_central.h" @@ -28,6 +29,9 @@ static LoggingWithStorage logger("engine"); extern engine_pins_s enginePins; +extern fuel_Map3D_t veMap; +extern fuel_Map3D_t afrMap; + EXTERN_ENGINE ; @@ -108,6 +112,31 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) { iatFuelCorrection = getIatCorrection(iat PASS_ENGINE_PARAMETER); cltFuelCorrection = getCltCorrection(clt PASS_ENGINE_PARAMETER); + engineNoiseHipLevel = interpolate2d(rpm, engineConfiguration->knockNoiseRpmBins, + engineConfiguration->knockNoise, ENGINE_NOISE_CURVE_SIZE); + + baroCorrection = getBaroCorrection(PASS_ENGINE_PARAMETER_F); + + injectionOffset = getinjectionOffset(rpm PASS_ENGINE_PARAMETER); + float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); + timingAdvance = getAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER); + + if (engineConfiguration->algorithm == LM_SPEED_DENSITY) { + float coolantC = ENGINE(engineState.clt); + float intakeC = ENGINE(engineState.iat); + float tps = getTPS(PASS_ENGINE_PARAMETER_F); + tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); + float map = getMap(); + + /** + * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ + */ + currentVE = baroCorrection * veMap.getValue(map, rpm) * 0.01; + targerAFR = afrMap.getValue(map, rpm); + } else { + baseTableFuel = getBaseTableFuel(engineConfiguration, rpm, engineLoad); + } + } @@ -225,8 +254,6 @@ void Engine::watchdog() { #endif } -extern fuel_Map3D_t veMap; -extern fuel_Map3D_t afrMap; /** * The idea of this method is to execute all heavy calculations in a lower-priority thread, @@ -234,7 +261,6 @@ extern fuel_Map3D_t afrMap; */ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) { int rpm = rpmCalculator.rpmValue; - float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); if (isValidRpm(rpm)) { MAP_sensor_config_s * c = &engineConfiguration->map; @@ -257,30 +283,6 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) { } engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_F); - - //engineState.engineNoiseHipLevel = interpolate2d(rpm) - - - engine->engineState.baroCorrection = getBaroCorrection(PASS_ENGINE_PARAMETER_F); - - engine->engineState.injectionOffset = getinjectionOffset(rpm PASS_ENGINE_PARAMETER); - engine->engineState.timingAdvance = getAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER); - - if (engineConfiguration->algorithm == LM_SPEED_DENSITY) { - float coolantC = ENGINE(engineState.clt); - float intakeC = ENGINE(engineState.iat); - float tps = getTPS(PASS_ENGINE_PARAMETER_F); - engine->engineState.tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); - float map = getMap(); - - /** - * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ - */ - engine->engineState.currentVE = engine->engineState.baroCorrection * veMap.getValue(map, rpm) * 0.01; - engine->engineState.targerAFR = afrMap.getValue(map, rpm); - } else { - engine->engineState.baseTableFuel = getBaseTableFuel(engineConfiguration, rpm, engineLoad); - } } StartupFuelPumping::StartupFuelPumping() { diff --git a/firmware/controllers/core/table_helper.cpp b/firmware/controllers/core/table_helper.cpp index 43005a408d..227970a68f 100644 --- a/firmware/controllers/core/table_helper.cpp +++ b/firmware/controllers/core/table_helper.cpp @@ -25,5 +25,5 @@ void setTableBin(float array[], int size, float from, float to) { } void setRpmTableBin(float array[], int size) { - setTableBin2(array, size, 800, 7000, 1); + setTableBin2(array, size, 800, 7000, 100); } diff --git a/firmware/controllers/sensors/hip9011_lookup.cpp b/firmware/controllers/sensors/hip9011_lookup.cpp index 58ecbc3f30..ef4709bb33 100644 --- a/firmware/controllers/sensors/hip9011_lookup.cpp +++ b/firmware/controllers/sensors/hip9011_lookup.cpp @@ -86,6 +86,13 @@ EXTERN_ENGINE; void initEngineNoiseTable(DECLARE_ENGINE_PARAMETER_F) { setRpmTableBin(engineConfiguration->knockNoiseRpmBins, ENGINE_NOISE_CURVE_SIZE); - // engineConfiguration->knockNoiseBins[0] + engineConfiguration->knockNoise[0] = 2; // 800 + engineConfiguration->knockNoise[1] = 2; // 1700 + engineConfiguration->knockNoise[2] = 2; // 2600 + engineConfiguration->knockNoise[3] = 2; // 3400 + engineConfiguration->knockNoise[4] = 2; // 4300 + engineConfiguration->knockNoise[5] = 2; // 5200 + engineConfiguration->knockNoise[6] = 2; // 6100 + engineConfiguration->knockNoise[7] = 2; // 7000 } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index f422340ff8..1d6c9ec62e 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -598,7 +598,7 @@ baro_corr_table_t baroCorrTable; brain_pin_e binarySerialRxPin; brain_pin_e consoleSerialTxPin; brain_pin_e consoleSerialRxPin; - float[ENGINE_NOISE_CURVE_SIZE] knockNoise;Knock sensor output knock detection threshold depending on current RPM;;"v", 1, 0, 0.0, 10, 2 + float[ENGINE_NOISE_CURVE_SIZE] knockNoise;Knock sensor output knock detection threshold depending on current RPM;"v", 1, 0, 0.0, 10, 2 float[ENGINE_NOISE_CURVE_SIZE] knockNoiseRpmBins;;"RPM", 1, 0, 0.0, 18000, 2 pid_s etb; diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 0c5b741781..9c8b1ec253 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -41,7 +41,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 Fri Jan 01 17:06:33 EST 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 01 18:49:44 EST 2016 pageSize = 16088 page = 1 @@ -489,7 +489,7 @@ page = 1 binarySerialRxPin = bits, U32, 1940, [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" consoleSerialTxPin = bits, U32, 1944, [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" consoleSerialRxPin = bits, U32, 1948, [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" - knockNoise = array, F32, 1952, [8], ;"v", 1, 0, 0.0, 10, 2 + knockNoise = array, F32, 1952, [8], "v", 1, 0, 0.0, 10, 2 knockNoiseRpmBins = array, F32, 1984, [8], "RPM", 1, 0, 0.0, 18000, 2 etb_pFactor = scalar, F32, 2016, "value", 1, 0, 0, 1000, 2 etb_iFactor = scalar, F32, 2020, "value", 1, 0, 0, 1000, 2 diff --git a/unit_tests/test_engine_math.cpp b/unit_tests/test_engine_math.cpp index a75f0510f1..255252de65 100644 --- a/unit_tests/test_engine_math.cpp +++ b/unit_tests/test_engine_math.cpp @@ -55,8 +55,8 @@ void testIgnitionMapGenerator(void) { assertEquals(22.0, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 101.6)); assertEquals(32.2, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 145)); - assertEquals(47.5, getInitialAdvance(2400, 40, 36)); - assertEquals(54.0, getInitialAdvance(4400, 40, 36)); + assertEqualsM2("2400", 47.4, getInitialAdvance(2400, 40, 36), 0.1); + assertEqualsM2("4400", 53.9, getInitialAdvance(4400, 40, 36), 0.1); } void testMafLookup(void) {