Hook up multi bank fuel trim (#2532)
* multi bank trim * cleaning * output channels * output channels
This commit is contained in:
parent
379b3dffb8
commit
3968204dfa
|
@ -133,7 +133,7 @@ typedef struct {
|
|||
scaled_percent iatCorrection; // 64
|
||||
scaled_percent cltCorrection; // 66
|
||||
scaled_percent baroCorrection; // 68
|
||||
scaled_percent shortTermFuelTrim; // 70
|
||||
uint16_t unused70; // 70
|
||||
|
||||
// Wall model AE
|
||||
scaled_ms wallFuelAmount; // 72
|
||||
|
@ -271,7 +271,10 @@ typedef struct {
|
|||
scaled_angle secondVvtPositionBank1; // 290
|
||||
scaled_angle vvtPositionBank2; // 292
|
||||
scaled_angle secondVvtPositionBank2; // 294
|
||||
uint8_t unusedAtTheEnd[42]; // we have some unused bytes to allow compatible TS changes
|
||||
|
||||
scaled_percent fuelTrim[2]; // 296 & 298
|
||||
|
||||
uint8_t unusedAtTheEnd[38]; // we have some unused bytes to allow compatible TS changes
|
||||
|
||||
// Temporary - will remove soon
|
||||
TsDebugChannels* getDebugChannels() {
|
||||
|
|
|
@ -51,7 +51,8 @@ static constexpr LogField fields[] = {
|
|||
{tsOutputChannels.veValue, GAUGE_NAME_FUEL_VE, "%", 1},
|
||||
{tsOutputChannels.tCharge, "tCharge", "C", 1},
|
||||
{tsOutputChannels.injectorLagMs, GAUGE_NAME_INJECTOR_LAG, "ms", 3},
|
||||
{tsOutputChannels.shortTermFuelTrim, GAUGE_NAME_FUEL_TRIM, "%", 3},
|
||||
{tsOutputChannels.fuelTrim[0], GAUGE_NAME_FUEL_TRIM, "%", 2},
|
||||
{tsOutputChannels.fuelTrim[1], GAUGE_NAME_FUEL_TRIM_2, "%", 2},
|
||||
{tsOutputChannels.wallFuelCorrection, GAUGE_NAME_FUEL_WALL_CORRECTION, "ms", 3},
|
||||
{tsOutputChannels.tpsAccelFuel, GAUGE_NAME_FUEL_TPS_EXTRA, "ms", 3},
|
||||
{tsOutputChannels.ignitionAdvance, GAUGE_NAME_TIMING_ADVANCE, "deg", 1},
|
||||
|
|
|
@ -560,7 +560,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
// 48
|
||||
tsOutputChannels->fuelBase = engine->engineState.baseFuel * 1000; // Convert grams to mg
|
||||
// 64
|
||||
tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection);
|
||||
tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection)[0];
|
||||
|
||||
|
||||
// 104
|
||||
|
@ -611,7 +611,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
// 120
|
||||
tsOutputChannels->firmwareVersion = getRusEfiVersion();
|
||||
// 268
|
||||
tsOutputChannels->shortTermFuelTrim = 100.0f * (ENGINE(engineState.running.pidCorrection) - 1.0f);
|
||||
tsOutputChannels->fuelTrim[0] = 100.0f * (ENGINE(stftCorrection)[0] - 1.0f);
|
||||
tsOutputChannels->fuelTrim[1] = 100.0f * (ENGINE(stftCorrection)[1] - 1.0f);
|
||||
|
||||
// 276
|
||||
tsOutputChannels->accelerationX = engine->sensors.accelerometer.x;
|
||||
// 278
|
||||
|
|
|
@ -234,12 +234,14 @@ public:
|
|||
floatms_t injectionDuration = 0;
|
||||
|
||||
// Per-injection fuel mass, including TPS accel enrich
|
||||
float injectionMass = 0;
|
||||
float injectionMass[STFT_BANK_COUNT] = {0};
|
||||
|
||||
float stftCorrection[STFT_BANK_COUNT] = {0};
|
||||
|
||||
/**
|
||||
* This one with wall wetting accounted for, used for logging.
|
||||
*/
|
||||
floatms_t actualLastInjection = 0;
|
||||
floatms_t actualLastInjection[STFT_BANK_COUNT] = {0};
|
||||
|
||||
// Standard cylinder air charge - 100% VE at standard temperature, grams per cylinder
|
||||
float standardAirCharge = 0;
|
||||
|
|
|
@ -128,10 +128,6 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// todo: move this into slow callback, no reason for CLT corr to be here
|
||||
running.coolantTemperatureCoefficient = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// TODO: consume correction from the second bank
|
||||
auto clResult = fuelClosedLoopCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
running.pidCorrection = clResult.banks[0];
|
||||
|
||||
// Fuel cut-off isn't just 0 or 1, it can be tapered
|
||||
fuelCutoffCorrection = getFuelCutOffCorrection(nowNt, rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
@ -158,7 +154,15 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
updateTChargeK(rpm, tps.value_or(0) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
float injectionMass = getInjectionMass(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
ENGINE(injectionMass) = injectionMass;
|
||||
auto clResult = fuelClosedLoopCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// compute per-bank fueling
|
||||
for (size_t i = 0; i < STFT_BANK_COUNT; i++) {
|
||||
float corr = clResult.banks[i];
|
||||
ENGINE(injectionMass)[i] = injectionMass * corr;
|
||||
ENGINE(stftCorrection)[i] = corr;
|
||||
}
|
||||
|
||||
// Store the pre-wall wetting injection duration for scheduling purposes only, not the actual injection duration
|
||||
ENGINE(injectionDuration) = ENGINE(injectorModel)->getInjectionDuration(injectionMass);
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0);
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0);
|
||||
|
||||
floatms_t runningFuel = baseFuel * baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection * ENGINE(engineState.running.pidCorrection);
|
||||
floatms_t runningFuel = baseFuel * baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0);
|
||||
DISPLAY_TEXT(eol);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ struct Fueling {
|
|||
static void populateFrame(Fueling& msg) {
|
||||
msg.cylAirmass = engine->engineState.sd.airMassInOneCylinder;
|
||||
msg.estAirflow = engine->engineState.airFlow;
|
||||
msg.fuel_pulse = engine->actualLastInjection;
|
||||
msg.fuel_pulse = engine->actualLastInjection[0];
|
||||
|
||||
// todo
|
||||
msg.stft = 0;
|
||||
|
|
|
@ -132,11 +132,10 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
|
|||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Clt).value_or(0) + ODB_TEMP_EXTRA);
|
||||
break;
|
||||
case PID_STFT_BANK1:
|
||||
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(engineState.running.pidCorrection));
|
||||
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(stftCorrection)[0]);
|
||||
break;
|
||||
case PID_STFT_BANK2:
|
||||
// TODO: use second fueling bank
|
||||
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(engineState.running.pidCorrection));
|
||||
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(stftCorrection)[1]);
|
||||
break;
|
||||
case PID_INTAKE_MAP:
|
||||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Map).value_or(0));
|
||||
|
|
|
@ -203,9 +203,13 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
|
|||
return;
|
||||
}
|
||||
|
||||
// Select fuel mass from the correct bank
|
||||
uint8_t bankIndex = CONFIG(cylinderBankSelect[this->ownIndex]);
|
||||
float injectionMassGrams = ENGINE(injectionMass)[bankIndex];
|
||||
|
||||
// Perform wall wetting adjustment on fuel mass, not duration, so that
|
||||
// it's correct during fuel pressure (injector flow) or battery voltage (deadtime) transients
|
||||
const float injectionMassGrams = wallFuel.adjust(ENGINE(injectionMass) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
injectionMassGrams = wallFuel.adjust(injectionMassGrams PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
const floatms_t injectionDuration = ENGINE(injectorModel)->getInjectionDuration(injectionMassGrams);
|
||||
|
||||
#if EFI_PRINTF_FUEL_DETAILS
|
||||
|
@ -229,7 +233,8 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
|
|||
|
||||
ENGINE(engineState.fuelConsumption).consumeFuel(injectionMassGrams * numberOfInjections, nowNt);
|
||||
|
||||
ENGINE(actualLastInjection) = injectionDuration;
|
||||
ENGINE(actualLastInjection)[bankIndex] = injectionDuration;
|
||||
|
||||
if (cisnan(injectionDuration)) {
|
||||
warning(CUSTOM_OBD_NAN_INJECTION, "NaN injection pulse");
|
||||
return;
|
||||
|
|
|
@ -80,15 +80,9 @@ float postCrankingFuelCorrection
|
|||
|
||||
|
||||
floatms_t injectorLag;injectorLag(VBatt)\nthis value depends on a slow-changing VBatt value, so\nwe update it once in a while
|
||||
|
||||
floatms_t pidCorrection;closed-loop fuel correction
|
||||
|
||||
|
||||
floatms_t baseFuel;
|
||||
floatms_t baseFuel;
|
||||
floatms_t fuel;Actual injection duration with CLT, IAT and TPS acceleration corrections per cycle, as squirt duration.\nWithout injector lag.\n@see baseFuel\n@see actualLastInjection
|
||||
|
||||
|
||||
|
||||
! end of running_fuel_s structure definition
|
||||
end_struct
|
||||
|
||||
|
|
|
@ -1742,6 +1742,7 @@ end_struct
|
|||
#define GAUGE_NAME_FUEL_LAST_INJECTION "fuel: Last injection"
|
||||
#define GAUGE_NAME_FUEL_BASE "fuel: base mass"
|
||||
#define GAUGE_NAME_FUEL_TRIM "fuel: fuel trim"
|
||||
#define GAUGE_NAME_FUEL_TRIM_2 "fuel: fuel trim 2"
|
||||
#define GAUGE_NAME_FUEL_WALL_AMOUNT "fuel: wall amount"
|
||||
#define GAUGE_NAME_FUEL_WALL_CORRECTION "fuel: wall corr ms"
|
||||
#define GAUGE_NAME_FUEL_LOAD "fuel: load"
|
||||
|
|
|
@ -259,7 +259,8 @@ enable2ndByteCanID = false
|
|||
iatCorrection = scalar, S16, 64, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
cltCorrection = scalar, S16, 66, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
baroCorrection = scalar, S16, 68, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
fuelPidCorrection=scalar, S16, 70, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
fuelPidCorrection=scalar, S16, 296, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
fuelPidCorrection2=scalar, S16, 298, "%",{1/@@PACK_MULT_PERCENT@@}, 0
|
||||
|
||||
; Wall model AE
|
||||
wallFuelAmount = scalar, U16, 72, "ms",{1/@@PACK_MULT_MS@@}, 0
|
||||
|
@ -1070,6 +1071,7 @@ gaugeCategory = Fueling
|
|||
fuelRunningGauge = fuelRunning, @@GAUGE_NAME_FUEL_RUNNING@@, "mg", 0, 100, 0, 0, 100, 100, 3, 1
|
||||
baseFuelGauge = baseFuel, @@GAUGE_NAME_FUEL_BASE@@, "mg", 0, 100, 0, 0, 100, 100, 2, 0
|
||||
fuelPidCorrectionGauge = fuelPidCorrection, @@GAUGE_NAME_FUEL_TRIM@@, "%", -10, 10, -8, -5, 5, 8, 3, 1
|
||||
fuelPidCorrectionGauge2= fuelPidCorrection2, @@GAUGE_NAME_FUEL_TRIM_2@@, "%", -10, 10, -8, -5, 5, 8, 3, 1
|
||||
fuelingLoadGauge = fuelingLoad, @@GAUGE_NAME_FUEL_LOAD@@, "%", 0, 300, 0, 0, 300, 300, 1, 1
|
||||
totalFuelConsumptionGauge = totalFuelConsumption, @@GAUGE_NAME_FUEL_CONSUMPTION@@, "g", 0, 10000, 0, 0, 10000, 10000, 0, 0
|
||||
fuelFlowRateGauge = fuelFlowRate, @@GAUGE_NAME_FUEL_FLOW@@, "g/s", 0, 50, 0, 0, 50, 50, 2, 0
|
||||
|
@ -1262,6 +1264,7 @@ gaugeCategory = DynoView
|
|||
entry = actualLastInjection, @@GAUGE_NAME_FUEL_LAST_INJECTION@@, float, "%.3f"
|
||||
entry = baseFuel, @@GAUGE_NAME_FUEL_BASE@@, float, "%.2f"
|
||||
entry = fuelPidCorrection,@@GAUGE_NAME_FUEL_TRIM@@, float, "%.2f"
|
||||
entry = fuelPidCorrection2,@@GAUGE_NAME_FUEL_TRIM_2@@, float, "%.2f"
|
||||
entry = veValue, @@GAUGE_NAME_FUEL_VE@@, float, "%.3f"
|
||||
entry = injectorDutyCycle,@@GAUGE_NAME_FUEL_INJ_DUTY@@,float,"%.3f"
|
||||
entry = coilDutyCycle, @@GAUGE_NAME_DWELL_DUTY@@, float,"%.3f"
|
||||
|
|
Loading…
Reference in New Issue