From 17275e4f4ba58f5d3319d0a5cffb7fe5bec5a387 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 28 Feb 2024 19:34:02 -0500 Subject: [PATCH] maximumIgnitionTiming does not account timing_offset_cylinder #5894 only: renaming field so that we do not have two entities with same name and different meaning --- firmware/controllers/algo/engine2.cpp | 2 +- firmware/controllers/algo/ignition_state.txt | 2 +- firmware/controllers/engine_cycle/spark_logic.cpp | 12 ++++++------ unit_tests/tests/trigger/test_trigger_decoder.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index a770ee4f97..9e23be2c9c 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -107,7 +107,7 @@ void EngineState::periodicFastCallback() { int rpm = Sensor::getOrZero(SensorType::Rpm); engine->ignitionState.sparkDwell = engine->ignitionState.getSparkDwell(rpm); - engine->ignitionState.dwellAngle = cisnan(rpm) ? NAN : engine->ignitionState.sparkDwell / getOneDegreeTimeMs(rpm); + engine->ignitionState.dwellDurationAngle = cisnan(rpm) ? NAN : engine->ignitionState.sparkDwell / getOneDegreeTimeMs(rpm); // todo: move this into slow callback, no reason for IAT corr to be here engine->fuelComputer.running.intakeTemperatureCoefficient = getIatFuelCorrection(); diff --git a/firmware/controllers/algo/ignition_state.txt b/firmware/controllers/algo/ignition_state.txt index d9f4e275d6..cf1b2d5213 100644 --- a/firmware/controllers/algo/ignition_state.txt +++ b/firmware/controllers/algo/ignition_state.txt @@ -4,7 +4,7 @@ struct_no_prefix ignition_state_s float baseDwell;"Ignition: base dwell";"ms", 1,0, 0,30, 1,@@GAUGE_CATEGORY_TIMING@@ floatms_t sparkDwell;@@GAUGE_COIL_DWELL_TIME@@;"ms", 1,0, 0,30, 1,@@GAUGE_CATEGORY_TIMING@@ - angle_t dwellAngle;Ignition: dwell duration\nas crankshaft angle\nNAN if engine is stopped\nSee also sparkDwell;"deg", 1,0, 0,120, 1,@@GAUGE_CATEGORY_TIMING@@ + angle_t dwellDurationAngle;Ignition: dwell duration\nas crankshaft angle\nNAN if engine is stopped\nSee also sparkDwell;"deg", 1,0, 0,120, 1,@@GAUGE_CATEGORY_TIMING@@ int16_t autoscale cltTimingCorrection;Ign: CLT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2,@@GAUGE_CATEGORY_TIMING@@ int16_t autoscale timingIatCorrection;Ign: IAT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2,@@GAUGE_CATEGORY_TIMING@@ diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 9c4b83c6c2..705254f3f3 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -222,9 +222,9 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) { } #endif /* EFI_UNIT_TEST */ - // now that we've just fired a coil let's prepare the new schedule for the next engine revolution + // now that we've jdwellAngleDurationust fired a coil let's prepare the new schedule for the next engine revolution - angle_t dwellAngleDuration = engine->ignitionState.dwellAngle; + angle_t dwellAngleDuration = engine->ignitionState.dwellDurationAngle; floatms_t sparkDwell = engine->ignitionState.sparkDwell; if (cisnan(dwellAngleDuration) || cisnan(sparkDwell)) { // we are here if engine has just stopped @@ -410,7 +410,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event, void initializeIgnitionActions() { IgnitionEventList *list = &engine->ignitionEvents; - angle_t dwellAngle = engine->ignitionState.dwellAngle; + angle_t dwellAngle = engine->ignitionState.dwellDurationAngle; floatms_t sparkDwell = engine->ignitionState.sparkDwell; if (cisnan(engine->engineState.timingAdvance[0]) || cisnan(dwellAngle)) { // error should already be reported @@ -444,11 +444,11 @@ static void prepareIgnitionSchedule() { maxAllowedDwellAngle = getEngineCycle(operationMode) / engineConfiguration->cylindersCount / 1.1; } - if (engine->ignitionState.dwellAngle == 0) { + if (engine->ignitionState.dwellDurationAngle == 0) { warning(ObdCode::CUSTOM_ZERO_DWELL, "dwell is zero?"); } - if (engine->ignitionState.dwellAngle > maxAllowedDwellAngle) { - warning(ObdCode::CUSTOM_DWELL_TOO_LONG, "dwell angle too long: %.2f", engine->ignitionState.dwellAngle); + if (engine->ignitionState.dwellDurationAngle > maxAllowedDwellAngle) { + warning(ObdCode::CUSTOM_DWELL_TOO_LONG, "dwell angle too long: %.2f", engine->ignitionState.dwellDurationAngle); } // todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that diff --git a/unit_tests/tests/trigger/test_trigger_decoder.cpp b/unit_tests/tests/trigger/test_trigger_decoder.cpp index 4f57d6bd66..df23e6d78b 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder.cpp @@ -237,7 +237,7 @@ TEST(misc, testRpmCalculator) { eth.firePrimaryTriggerRise(); ASSERT_EQ(1500, Sensor::getOrZero(SensorType::Rpm)); - assertEqualsM("dwell", 4.5, engine->ignitionState.dwellAngle); + assertEqualsM("dwell", 4.5, engine->ignitionState.dwellDurationAngle); assertEqualsM("fuel #2", 4.5450, engine->engineState.injectionDuration); assertEqualsM("one degree", 111.1111, engine->rpmCalculator.oneDegreeUs); ASSERT_EQ( 1, ilist->isReady) << "size #2"; @@ -287,7 +287,7 @@ TEST(misc, testRpmCalculator) { eth.fireRise(5); ASSERT_EQ( 4, engine->executor.size()) << "queue size 4.3"; - assertEqualsM("dwell", 4.5, eth.engine.ignitionState.dwellAngle); + assertEqualsM("dwell", 4.5, eth.engine.ignitionState.dwellDurationAngle); assertEqualsM("fuel #3", 4.5450, eth.engine.engineState.injectionDuration); ASSERT_EQ(1500, Sensor::getOrZero(SensorType::Rpm));