diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 320344c830..62b07d67f5 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -129,13 +129,14 @@ EngineState::EngineState() { injectorLag = 0; warningCounter = 0; lastErrorCode = 0; + crankingTime = 0; targetAFR = 0; tpsAccelEnrich = 0; tChargeK = 0; runningFuel = baseFuel = currentVE = 0; timeOfPreviousWarning = -10; baseTableFuel = iat = iatFuelCorrection = 0; - clt = cltFuelCorrection = 0; + clt = cltFuelCorrection = postCrankingFuelCorrection = 0; warmupTargetAfr = airMass = 0; baroCorrection = timingAdvance = fuelTankGauge = 0; sparkDwell = mapAveragingDuration = 0; @@ -153,6 +154,13 @@ void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_F) { void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) { int rpm = ENGINE(rpmCalculator.rpmValue); + efitick_t nowNt = getTimeNowNt(); + if (isCrankingR(rpm)) { + crankingTime = nowNt; + } else { + timeSinceCranking = nowNt - crankingTime; + } + sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER); dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 9dbe62767a..a4a3d26659 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -109,6 +109,9 @@ public: float iat; float clt; + efitick_t crankingTime; + efitick_t timeSinceCranking; + int warningCounter; int lastErrorCode; efitimesec_t timeOfPreviousWarning; @@ -143,6 +146,7 @@ public: // fuel-related; float iatFuelCorrection; float cltFuelCorrection; + float postCrankingFuelCorrection; /** * Global injector lag + injectorLag(VBatt) * diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 53b34a61ec..95f0f4f66f 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -362,6 +362,9 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->acCutoffLowRpm = 700; engineConfiguration->acCutoffHighRpm = 5000; + engineConfiguration->postCrankingTargetClt = 25; + engineConfiguration->postCrankingDurationSec = 2; + initTemperatureCurve(IAT_CURVE_SIZE, config->iatFuelCorrBins, config->iatFuelCorr, 1); engineConfiguration->tachPulseDuractionMs = 4; diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 30f3b5618c..fbe390e23a 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -649,7 +649,7 @@ typedef enum { FSIO_ADC = 6, AUX_PID_1 = 7, DBG_VVT = 8, - DM_9 = 9, + DBG_POST_CRANKING_ENRICH = 9, DM_10 = 10, DM_11 = 11, DM_12 = 12, diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 7301ef0c5c..2d567822bc 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -109,7 +109,7 @@ float baseFuel;+Fuel squirt duration while cranking\nA number of curves adjust t int16_t rpm;+Cranking mode threshold. Special cranking logic controls fuel and spark while RPM is below this threshold\nset_cranking_rpm X;"RPM", 1, 0, 0, 3000, 0 end_struct -#define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" +#define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "post-crank enrich", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" custom debug_mode_e 4 bits, U32, @OFFSET@, [0:3], @@debug_mode_e_enum@@ #define vvt_mode_e_enum "First half", "Second half", "2GZ", "Miata NB2", "mode4", "mode5", "mode6", "mode7" diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 2a307c8bbd..07866a0e89 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 Tue Dec 06 21:51:50 EST 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 06 22:04:27 EST 2016 pageSize = 16376 page = 1 @@ -554,7 +554,7 @@ page = 1 tpsDecelEnleanmentThreshold = scalar, F32, 2232, "roc", 1, 0, 0, 200, 3 tpsDecelEnleanmentMultiplier = scalar, F32, 2236, "coeff", 1, 0, 0, 200, 3 slowAdcAlpha = scalar, F32, 2240, "coeff", 1, 0, 0, 200, 3 - debugMode = bits, U32, 2244, [0:3], "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" + debugMode = bits, U32, 2244, [0:3], "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "post-crank enrich", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" warmupAfrPid_pFactor = scalar, F32, 2248, "value", 1, 0, 0, 1000, 5 warmupAfrPid_iFactor = scalar, F32, 2252, "value", 1, 0, 0, 1000, 5 warmupAfrPid_dFactor = scalar, F32, 2256, "value", 1, 0, 0, 1000, 5 @@ -1950,6 +1950,9 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" field = "" field = "" field = "enable Cylinder Cleanup", isCylinderCleanupEnabled + field = "Post-Cranking target (C)", postCrankingTargetClt + field = "Post-Cranking factor", postCrankingFactor + field = "Post-Cranking duraction", postCrankingDurationSec dialog = EngineLoadAccelPanel, "Engine Load" diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 07dee1766e..6788664960 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1910,6 +1910,9 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" field = "" field = "" field = "enable Cylinder Cleanup", isCylinderCleanupEnabled + field = "Post-Cranking target (C)", postCrankingTargetClt + field = "Post-Cranking factor", postCrankingFactor + field = "Post-Cranking duraction", postCrankingDurationSec dialog = EngineLoadAccelPanel, "Engine Load" diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 0f4cc760b5..bea6ade635 100644 --- a/java_console/models/src/com/rusefi/config/Fields.java +++ b/java_console/models/src/com/rusefi/config/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config; -// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 06 21:51:50 EST 2016 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 06 22:04:27 EST 2016 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int FSIO_ADC_COUNT = 4; @@ -1474,7 +1474,7 @@ public class Fields { public static final Field TPSDECELENLEANMENTTHRESHOLD = Field.create("TPSDECELENLEANMENTTHRESHOLD", 2232, FieldType.FLOAT); public static final Field TPSDECELENLEANMENTMULTIPLIER = Field.create("TPSDECELENLEANMENTMULTIPLIER", 2236, FieldType.FLOAT); public static final Field SLOWADCALPHA = Field.create("SLOWADCALPHA", 2240, FieldType.FLOAT); - public static final String[] debug_mode_e = {"Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15"}; + public static final String[] debug_mode_e = {"Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "post-crank enrich", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15"}; public static final Field DEBUGMODE = Field.create("DEBUGMODE", 2244, FieldType.INT, debug_mode_e); public static final Field WARMUPAFRPID_PFACTOR = Field.create("WARMUPAFRPID_PFACTOR", 2248, FieldType.FLOAT); public static final Field WARMUPAFRPID_IFACTOR = Field.create("WARMUPAFRPID_IFACTOR", 2252, FieldType.FLOAT);