From 3a8d92f87981f16ab3691f8909179484bb8a081c Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 15 Sep 2021 05:07:33 -0700 Subject: [PATCH] Dwell voltage correction (#3234) * cfg + impl * ui * value_or * changelog * fix --- firmware/CHANGELOG.md | 1 + firmware/controllers/math/engine_math.cpp | 14 +++++++++++++- firmware/integration/rusefi_config.txt | 9 +++++++-- firmware/tunerstudio/rusefi.input | 13 +++++++++++-- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index e52ce8ec24..1f0505f866 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -29,6 +29,7 @@ All notable user-facing or behavior-altering changes will be documented in this ### Added - Ford PIP trigger decoder https://github.com/rusefi/rusefi/wiki/Images/triggers/trigger_65.png + - Dwell battery voltage correction table ## September 2021 Release - "Iguana Awareness Day" diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 5c29f2884a..c1c8425e96 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -81,7 +81,19 @@ floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { } else { efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN); - dwellMs = interpolate2d(rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues); + auto base = interpolate2d(rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues); + auto voltageMult = 0.02f * + interpolate2d( + 10 * Sensor::get(SensorType::BatteryVoltage).value_or(0), + engineConfiguration->dwellVoltageCorrVoltBins, + engineConfiguration->dwellVoltageCorrValues); + + // for compat (table full of zeroes) + if (voltageMult < 0.1f) { + voltageMult = 1; + } + + dwellMs = base * voltageMult; } if (cisnan(dwellMs) || dwellMs <= 0) { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 6aa689dae7..1982b116f1 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -912,9 +912,14 @@ output_pin_e acFanPin;+Optional Radiator Fan used with A/C pin_output_mode_e[FSIO_COMMAND_COUNT iterate] gpioPinModes; - uint8_t[10] unusedpinModesWhereHere;;"", 1, 0, 0, 255, 0 + uint8_t[DWELL_CURVE_SIZE] dwellVoltageCorrVoltBins;;"volts", 0.1, 0, 0, 20, 1 + + uint8_t[2] unusedpinModesWhereHere;;"", 1, 0, 0, 255, 0 output_pin_e[FSIO_COMMAND_COUNT iterate] fsioOutputPins;todo: more comments - uint8_t[10] unusedOutputWhereHere;;"", 1, 0, 0, 255, 0 + + uint8_t[DWELL_CURVE_SIZE] dwellVoltageCorrValues;;"multiplier", 0.02, 0, 0, 5, 2 + + uint8_t[2] unusedOutputWhereHere;;"", 1, 0, 0, 255, 0 brain_pin_e[EGT_CHANNEL_COUNT iterate] max31855_cs; diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index b7ea7aa5c5..65ee0de1ef 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -597,13 +597,21 @@ enable2ndByteCanID = false xBins = mapAccelTaperBins yBins = mapAccelTaperMult - curve = dwellCorrection, "Dwell time RPM based" + curve = dwellCorrection, "Dwell time base" columnLabel = "RPM", "Dwell" xAxis = 0, 8000, 9 yAxis = 0, 8, 9 xBins = sparkDwellRpmBins, RPMValue yBins = sparkDwellValues gauge = RPMGauge + + curve = dwellVoltageCorrection, "Dwell voltage correction" + columnLabel = "Battery Volts", "Multiplier" + xAxis = 6, 16, 5 + yAxis = 0, 3, 7 + xBins = dwellVoltageCorrVoltBins, VBatt + yBins = dwellVoltageCorrValues + gauge = VBattGauge curve = map_samplingAngleCurve, "MAP Sampling Start Angle" columnLabel = "RPM", "Angle" @@ -2064,7 +2072,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" panel = multisparkDwellParams dialog = dwellSettings, "", yAxis - panel = dwellCorrection, Center + panel = dwellCorrection + panel = dwellVoltageCorrection ; Sensors->AUX1 Thermistor Sensor Setting dialog = auxTempSensor1Sensor, "aux1 Thermistor Settings"