diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index c07640ce69..04f25d1398 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -95,7 +95,7 @@ typedef struct { /** * Engine load delta */ - float engineLoadAccelDelta; // offset 124 + float engineLoadAccelExtra; // offset 124 float tpsAccelFuel; // offset 128 float baroCorrection; float pedalPosition; @@ -121,7 +121,8 @@ typedef struct { int debugIntField2; // 216 int debugIntField3; // 220 int timeSeconds; // 224 - int unused3[12]; + float engineLoadDelta; // 228 + int unused3[11]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 0a573f4312..b9b6a38306 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -618,7 +618,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getMaxDelta(); tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich; // engine load acceleration - tsOutputChannels->engineLoadAccelDelta = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); + tsOutputChannels->engineLoadAccelExtra = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); + tsOutputChannels->engineLoadDelta = engine->engineLoadAccelEnrichment.getMaxDelta(); + tsOutputChannels->iatCorrection = ENGINE(engineState.iatFuelCorrection); tsOutputChannels->cltCorrection = ENGINE(engineState.cltFuelCorrection); diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index cea097ec7a..e950f4b3e9 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -26,7 +26,7 @@ #include "engine_state.h" #include "engine_math.h" #include "signal_executor.h" -#if !EFI_UNIT_TEST +#if !EFI_UNIT_TEST || defined(__DOXYGEN__) #include "tunerstudio_configuration.h" extern TunerStudioOutputChannels tsOutputChannels; #endif @@ -111,38 +111,59 @@ floatms_t AccelEnrichmemnt::getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F) { float deltaMult = tpsTpsMap.getValue(tpsFrom, tpsTo); - - float result; + floatms_t extraFuel; if (d > engineConfiguration->tpsAccelEnrichmentThreshold) { - result = deltaMult; + extraFuel = deltaMult; } else if (d < -engineConfiguration->tpsDecelEnleanmentThreshold) { - result= d * engineConfiguration->tpsDecelEnleanmentMultiplier; + extraFuel = d * engineConfiguration->tpsDecelEnleanmentMultiplier; } else { - result = 0; + extraFuel = 0; } -#if !EFI_UNIT_TEST +#if !EFI_UNIT_TEST || defined(__DOXYGEN__) if (engineConfiguration->debugMode == DBG_TPS_ACCEL) { tsOutputChannels.debugFloatField1 = tpsFrom; tsOutputChannels.debugFloatField2 = tpsTo; tsOutputChannels.debugFloatField3 = deltaMult; - tsOutputChannels.debugFloatField4 = result; + tsOutputChannels.debugFloatField4 = extraFuel; } #endif - return result; + return extraFuel; } float AccelEnrichmemnt::getEngineLoadEnrichment(DECLARE_ENGINE_PARAMETER_F) { - float d = getMaxDelta(PASS_ENGINE_PARAMETER_F); + int index = getMaxDeltaIndex(PASS_ENGINE_PARAMETER_F); + + FuelSchedule *fs = engine->engineConfiguration2->injectionEvents; + float d = (cb.get(index) - (cb.get(index - 1))) * fs->eventsCount; + + float result = 0; + int distance = 0; + float taper = 0; if (d > engineConfiguration->engineLoadAccelEnrichmentThreshold) { - return d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; + + int distance = cb.currentIndex - index; + if (distance <= 0) // checking if indexes are out of order due to circular buffer nature + distance += minI(cb.getCount(), cb.getSize()); + + taper = interpolate2d(distance, engineConfiguration->mapAccelTaperBins, engineConfiguration->mapAccelTaperMult, MAP_ACCEL_TAPER); + + result = taper * d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; + } else if (d < -engineConfiguration->engineLoadDecelEnleanmentThreshold) { + result = d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; } - if (d < -engineConfiguration->engineLoadDecelEnleanmentThreshold) { - return d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; + +#if ! EFI_UNIT_TEST || defined(__DOXYGEN__) + if (engineConfiguration->debugMode == DBG_EL_ACCEL) { + tsOutputChannels.debugIntField1 = distance; + tsOutputChannels.debugFloatField1 = result; + tsOutputChannels.debugFloatField2 = taper; + } - return 0; +#endif + return result; } void AccelEnrichmemnt::reset() { diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 04ee615465..1b3c98714c 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -367,6 +367,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { setDefaultIatTimingCorrection(PASS_ENGINE_PARAMETER_F); setTableBin2(engineConfiguration->mapAccelTaperBins, FSIO_TABLE_8, 0, 32, 4); + setTableBin2(engineConfiguration->mapAccelTaperMult, FSIO_TABLE_8, 1, 1, 1); setTableBin2(config->tpsTpsAccelFromRpmBins, FSIO_TABLE_8, 0, 100, 10); setTableBin2(config->tpsTpsAccelToRpmBins, FSIO_TABLE_8, 0, 100, 10); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 303bcc989a..cb58f3c460 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -20,7 +20,7 @@ struct_no_prefix engine_configuration_s ! ! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version ! -#define TS_FILE_VERSION 20160122 +#define TS_FILE_VERSION 20160312 #define WARMUP_TARGET_AFR_SIZE 4 @@ -93,8 +93,8 @@ 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;"RPM", 1, 0, 0, 3000, 0 end_struct -#define debug_mode_e_enum "ALTERNATOR", "TPS_ACCEL", "WARMUP_PID", "mode3" -custom debug_mode_e 4 bits, U32, @OFFSET@, [0:1], @@debug_mode_e_enum@@ +#define debug_mode_e_enum "ALTERNATOR", "TPS_ACCEL", "WARMUP_PID", "mode3", "IDLE", "EL_ACCEL", "mode6", "mode7" +custom debug_mode_e 4 bits, U32, @OFFSET@, [0:2], @@debug_mode_e_enum@@ #define brain_input_pin_e_enum "INVALID", "INVALID", "PA2", "PA3", "INVALID", "PA5", "INVALID", "INVALID", "PA8", "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", "PC6", "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", "PE5", "INVALID", "PE7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "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" diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 0533aac561..c5cd78c3c6 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -275,5 +275,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 20160310; + return 20160312; } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 4ed499cf4b..95f3206222 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 Sat Mar 12 09:18:24 EST 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Mar 12 17:59:43 EST 2016 pageSize = 17080 page = 1 @@ -523,7 +523,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:1], "ALTERNATOR", "TPS_ACCEL", "WARMUP_PID", "mode3" + debugMode = bits, U32, 2244, [0:2], "ALTERNATOR", "TPS_ACCEL", "WARMUP_PID", "mode3", "IDLE", "EL_ACCEL", "mode6", "mode7" 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 @@ -738,7 +738,7 @@ fileVersion = { 20160122 } veValue = scalar, F32, 112, "ratio", 1, 0 deltaTps = scalar, F32, 116, "ratio", 1, 0 triggerErrorsCounter = scalar, U32,120, "counter", 1, 0 - engineLoadAccelDelta = scalar,F32, 124, "%", 1, 0 + engineLoadAccelExtra = scalar,F32, 124, "value", 1, 0 tpsAccelFuel = scalar, F32, 128, "ms", 1, 0 baroCorrection = scalar, F32, 132, "%", 1, 0 pedalPosition = scalar, F32, 136, "%", 1, 0 @@ -759,12 +759,17 @@ fileVersion = { 20160122 } debugFloatField5 = scalar, F32, 212, "val", 1, 0.0; debugIntField2 = scalar, U32, 216, "val", 1, 0.0; debugIntField3 = scalar, U32, 220, "val", 1, 0.0; + engineLoadDelta = scalar,F32, 228, "value", 1, 0 egoCorrection = { 100 } time = { timeNow } ; engineLoad = { algorithm == 0 ? MAF : TPS } [CurveEditor] +; xAxis = leftValue, rightValue, step +; yAxis = bottomValue, topValue, step + + curve = knockThresholdCurve, "Engine knock threshold RPM based" columnLabel = "RPM", "Threshold" xAxis = 0, 8000, 10 @@ -773,6 +778,13 @@ fileVersion = { 20160122 } yBins = knockNoise gauge = rpm + curve = mapAccelTaper, "Engine Load Acceleration Enrichment Taper" + columnLabel = "Distance", "Multiplier" + xAxis = 0, 128, 10 + yAxis = -5, 5, 10 + xBins = mapAccelTaperBins + yBins = mapAccelTaperMult + curve = dwellCorrection, "Dwell time RPM based" columnLabel = "RPM", "Dwell" xAxis = 0, 8000, 10 @@ -996,7 +1008,6 @@ fileVersion = { 20160122 } rpmAccelerationGa = rpmAcceleration, "rpm delta", "dRpm", 0, 3, 0, 1, 3, 4, 1, 1 massAirFlowValueGa = massAirFlowValue,"Air Flow", "kg/hr", 0, 50, -999, -999, 999, 999, 1, 1 veValueGauge = veValue, "fuel: VE", "", 0, 120, 10, 10, 100, 100, 1, 1 - deltaTpsGauge = deltaTps, "fuel: TPS delta", "", 0, 120, 10, 10, 100, 100, 1, 1 baroCorrectionGauge = baroCorrection,"BaroCorr", "%", 0, 120, 10, 10, 100, 100, 1, 1 pedalPositionGauge = pedalPosition,"Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1 knockCountGauge = knockCount,"Knock count", "count", 0, 120, 10, 10, 100, 100, 1, 1 @@ -1011,7 +1022,9 @@ fileVersion = { 20160122 } cltCorrectionGauge = cltCorrection, "fuel: CLT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2 injectorDutyCycleGauge=injectorDutyCycle, "fuel: injectorDutyCycle","%", 0, 120, 10, 10, 100, 100, 1, 1 - engineLoadAccelDeltaGauge = engineLoadAccelDelta,"fuel: load enrich","%", 0, 120, 10, 10, 100, 100, 1, 1 + engineLoadDeltaGauge = engineLoadDelta,"fuel: load change","value", 0, 120, 10, 10, 100, 100, 1, 1 + engineLoadAccelExtraGauge = engineLoadAccelExtra,"fuel: load extra","value", 0, 120, 10, 10, 100, 100, 1, 1 + deltaTpsGauge = deltaTps, "fuel: TPS change", "", 0, 120, 10, 10, 100, 100, 1, 1 tpsAccelFuelGauge = tpsAccelFuel,"fuel: TPS enrich", "ms", 0, 120, 10, 10, 100, 100, 1, 1 wallFuelAmountGauge = wallFuelAmount, "fuel: wall amount", "ms", 0, 100, 0, 0, 100, 100, 0, 0 wallFuelCorrectionGauge = wallFuelCorrection, "fuel: wall correction extra", "ms", 0, 100, 0, 0, 100, 100, 0, 0 @@ -1097,15 +1110,20 @@ fileVersion = { 20160122 } entry = pulseWidth, "fuel: pulse", float, "%.3f" entry = baseFuel, "fuel: base", float, "%.2f" entry = veValue, "fuel: VE", float, "%.3f" - entry = engineLoadAccelDelta, "fuel: EL delta",float, "%.3f" - entry = deltaTps, "fuel: tps delta",float, "%.3f" - entry = tpsAccelFuel, "fuel: tpsAccel", float, "%.3f" - entry = iatCorrection, "fuel: IAT corr", float, "%.3f" + + entry = engineLoadAccelExtra, "fuel: load extra",float, "%.3f" + entry = engineLoadDelta, "fuel: load change",float, "%.3f" + + entry = deltaTps, "fuel: TPS change",float, "%.3f" + entry = tpsAccelFuel, "fuel: TOS enrich", float, "%.3f" + entry = wallFuelCorrection,"fuel: wall corr ms", float, "%.3f" entry = wallFuelAmount, "fuel: wall amount", float, "%.3f" entry = baroCorrection, "baroCorrection",float,"%.3f" + entry = iatCorrection, "fuel: IAT corr", float, "%.3f" entry = cltCorrection, "cltCorrection", float,"%.3f" + entry = sparkDwellValue, "dwell", float,"%.3f" @@ -1175,6 +1193,7 @@ fileVersion = { 20160122 } subMenu = iatFuelCorrCurve, "Intake air temperature fuel Multiplier" subMenu = injPhaseTableTbl, "Injection Phase" subMenu = tpsTpsAccelTbl, "TPS/TPS acceleration Multiplier" + subMenu = mapAccelTaper, "Engine Load Acceleration Enrichment Taper" subMenu = std_separator subMenu = ignitionTableTbl, "Ignition Table" subMenu = ignitionIatCorrTableTbl, "Ignition Intake Air Temp correction"