From 058421cc7d621687661c91080af300e19fed82f4 Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 7 Mar 2017 01:28:26 -0500 Subject: [PATCH] #368 progress --- firmware/console/binary/tunerstudio_configuration.h | 9 +++++---- firmware/console/status_loop.cpp | 3 +++ firmware/controllers/algo/fuel_math.cpp | 4 ++++ firmware/tunerstudio/rusefi.ini | 5 ++++- firmware/tunerstudio/rusefi.input | 3 +++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index 0b5eb99956..51b0e25289 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -100,9 +100,9 @@ typedef struct { */ float engineLoadAccelExtra; // offset 124 float tpsAccelFuel; // offset 128 - float baroCorrection; - float pedalPosition; - float injectorDutyCycle; + float baroCorrection; // 132 + float pedalPosition; // 138 + float injectorDutyCycle; // 140 int knockCount; // 144 float fuelTankGauge; // 148 float knockLevel; // 152 @@ -150,7 +150,8 @@ typedef struct { float debugFloatField7; // 260 int firmwareVersion; // 264 float fuelPidCorrection; // 268 - int unused3[21]; + float coilDutyCycle; // 272 + int unused3[20]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 22501ad120..ceea8a6203 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -49,6 +49,7 @@ #include "fuel_math.h" #include "main_trigger_callback.h" #include "engine_math.h" +#include "spark_logic.h" #include "idle_thread.h" #include "engine_configuration.h" #include "rfiutil.h" @@ -718,6 +719,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->fuelBase = engine->engineState.baseFuel; tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection); + tsOutputChannels->coilDutyCycle = getCoilDutyCycle(rpm PASS_ENGINE_PARAMETER); + efitimesec_t now = getTimeNowSeconds(); tsOutputChannels->timeSeconds = now; tsOutputChannels->firmwareVersion = getRusEfiVersion(); diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 851cbaf0b2..4ff784f61c 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -95,6 +95,7 @@ angle_t getinjectionOffset(float rpm DECLARE_ENGINE_PARAMETER_S) { /** * Number of injections into each cylinder per engine cycle + * @see getNumberOfSparks */ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { switch (mode) { @@ -110,6 +111,9 @@ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { } } +/** + * @see getCoilDutyCycle + */ percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_S) { floatms_t totalPerCycle = getInjectionDuration(rpm PASS_ENGINE_PARAMETER) * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engineConfiguration->operationMode == TWO_STROKE ? 1 : 2); diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 1d7404fc12..fc85bbe714 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 Mon Mar 06 17:05:02 EST 2017 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 06 19:02:13 EST 2017 pageSize = 16376 page = 1 @@ -921,6 +921,7 @@ fileVersion = { 20161225 } debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; firmwareVersion = scalar,U32, 264, "version_f", 1, 0 fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 + coilDutyCycle = scalar, F32, 272, "perc", 1, 0 egoCorrection = { 100 } time = { timeNow } @@ -1196,6 +1197,7 @@ fileVersion = { 20161225 } pulseWidthGauge = pulseWidth, "fuel final squirt, per injection", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 baseFuelGauge = baseFuel, "fuel: base duration, before corr", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 fuelPidCorrectionGauge = fuelPidCorrection, "fuel: closed loop correction", "mSec", -11, 11, 1.0, 1.2, 20, 25, 3, 1 + coilDutyCycleGauge = coilDutyCycle, "dwell: duty cycle", "perc", -11, 11, 1.0, 1.2, 100, 100, 3, 1 crankingFuelGauge = crankingFuel, "fuel: crank Width", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 iatCorrectionGauge = iatCorrection, "fuel: IAT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2 @@ -1305,6 +1307,7 @@ fileVersion = { 20161225 } entry = fuelPidCorrection,"fuel: pid", float, "%.2f" entry = veValue, "fuel: VE", float, "%.3f" entry = injectorDutyCycle,"fuel: duty cyc",float,"%.3f" + entry = coilDutyCycle, "dwell: duty", float,"%.3f" entry = engineLoadAccelExtra, "fuel: load extra",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f" diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 030c626e39..bf39429b42 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -853,6 +853,7 @@ fileVersion = { 20161225 } debugFloatField7 = scalar, F32, 260, "val", 1, 0.0; firmwareVersion = scalar,U32, 264, "version_f", 1, 0 fuelPidCorrection = scalar, F32, 268, "ms", 1, 0 + coilDutyCycle = scalar, F32, 272, "perc", 1, 0 egoCorrection = { 100 } time = { timeNow } @@ -1128,6 +1129,7 @@ fileVersion = { 20161225 } pulseWidthGauge = pulseWidth, "fuel final squirt, per injection", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 baseFuelGauge = baseFuel, "fuel: base duration, before corr", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 fuelPidCorrectionGauge = fuelPidCorrection, "fuel: closed loop correction", "mSec", -11, 11, 1.0, 1.2, 20, 25, 3, 1 + coilDutyCycleGauge = coilDutyCycle, "dwell: duty cycle", "perc", -11, 11, 1.0, 1.2, 100, 100, 3, 1 crankingFuelGauge = crankingFuel, "fuel: crank Width", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 iatCorrectionGauge = iatCorrection, "fuel: IAT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2 @@ -1237,6 +1239,7 @@ fileVersion = { 20161225 } entry = fuelPidCorrection,"fuel: pid", float, "%.2f" entry = veValue, "fuel: VE", float, "%.3f" entry = injectorDutyCycle,"fuel: duty cyc",float,"%.3f" + entry = coilDutyCycle, "dwell: duty", float,"%.3f" entry = engineLoadAccelExtra, "fuel: load extra",float, "%.3f" entry = engineLoadDelta, "fuel: load change",float, "%.3f"