diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index 442b0bf7d1..4629787b79 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -49,6 +49,9 @@ Release template (copy/paste this for new release): - fix detect cylinder for knock then wasted_spark #7062 - Change BMW E46 CAN interval to 10 ms #6974 +### Breaking Changes +- Now secondary injectors use `Secondary injector flow compensation mode` and `Secondary injector reference pressure` instead of `Injector flow compensation mode` and `Injector reference pressure` Tuner Studio settings #6972 + ## August 2024 "Day 898" ### Added diff --git a/firmware/controllers/algo/fuel/injector_model.cpp b/firmware/controllers/algo/fuel/injector_model.cpp index 7fe160771b..6a15961c28 100644 --- a/firmware/controllers/algo/fuel/injector_model.cpp +++ b/firmware/controllers/algo/fuel/injector_model.cpp @@ -44,6 +44,14 @@ InjectorNonlinearMode InjectorModelPrimary::getNonlinearMode() const { return engineConfiguration->injectorNonlinearMode; } +injector_compensation_mode_e InjectorModelPrimary::getInjectorCompensationMode() const { + return engineConfiguration->injectorCompensationMode; +} + +float InjectorModelPrimary::getFuelReferencePressure() const { + return engineConfiguration->fuelReferencePressure; +} + float InjectorModelSecondary::getSmallPulseFlowRate() const { // not supported on second bank return 0; @@ -54,6 +62,14 @@ float InjectorModelSecondary::getSmallPulseBreakPoint() const { return 0; } +injector_compensation_mode_e InjectorModelSecondary::getInjectorCompensationMode() const { + return engineConfiguration->secondaryInjectorCompensationMode; +} + +float InjectorModelSecondary::getFuelReferencePressure() const { + return engineConfiguration->secondaryInjectorFuelReferencePressure; +} + InjectorNonlinearMode InjectorModelSecondary::getNonlinearMode() const { // nonlinear not supported on second bank return InjectorNonlinearMode::INJ_None; @@ -68,11 +84,10 @@ expected InjectorModelWithConfig::getFuelDifferentialPressure() const { baroKpa = 101.325f; } - switch (engineConfiguration->injectorCompensationMode) { + switch (getInjectorCompensationMode()) { case ICM_FixedRailPressure: // Add barometric pressure, as "fixed" really means "fixed pressure above atmosphere" - return - engineConfiguration->fuelReferencePressure + return getFuelReferencePressure() + baroKpa - map.value_or(101.325); case ICM_SensedRailPressure: { @@ -112,11 +127,11 @@ expected InjectorModelWithConfig::getFuelDifferentialPressure() const { float InjectorModelWithConfig::getInjectorFlowRatio() { // Compensation disabled, use reference flow. - if (engineConfiguration->injectorCompensationMode == ICM_None) { + if (getInjectorCompensationMode() == ICM_None) { return 1.0f; } - float referencePressure = engineConfiguration->fuelReferencePressure; + const float referencePressure = getFuelReferencePressure(); if (referencePressure < 50) { // impossibly low fuel ref pressure diff --git a/firmware/controllers/algo/fuel/injector_model.h b/firmware/controllers/algo/fuel/injector_model.h index 4757c5d8e1..67db9df0cb 100644 --- a/firmware/controllers/algo/fuel/injector_model.h +++ b/firmware/controllers/algo/fuel/injector_model.h @@ -54,12 +54,14 @@ public: expected getFuelDifferentialPressure() const override; using interface_t = IInjectorModel; // Mock interface - private: + [[nodiscard]] virtual injector_compensation_mode_e getInjectorCompensationMode() const = 0; + [[nodiscard]] virtual float getFuelReferencePressure() const = 0; + const injector_s* const m_cfg; }; -struct InjectorModelPrimary : public InjectorModelWithConfig { +struct InjectorModelPrimary : InjectorModelWithConfig { InjectorModelPrimary(); InjectorNonlinearMode getNonlinearMode() const override; @@ -67,9 +69,12 @@ struct InjectorModelPrimary : public InjectorModelWithConfig { // Ford small pulse model float getSmallPulseFlowRate() const override; float getSmallPulseBreakPoint() const override; +private: + [[nodiscard]] injector_compensation_mode_e getInjectorCompensationMode() const final; + [[nodiscard]] float getFuelReferencePressure() const final; }; -struct InjectorModelSecondary : public InjectorModelWithConfig { +struct InjectorModelSecondary : InjectorModelWithConfig { InjectorModelSecondary(); InjectorNonlinearMode getNonlinearMode() const override; @@ -77,4 +82,7 @@ struct InjectorModelSecondary : public InjectorModelWithConfig { // Ford small pulse model float getSmallPulseFlowRate() const override; float getSmallPulseBreakPoint() const override; +private: + [[nodiscard]] injector_compensation_mode_e getInjectorCompensationMode() const final; + [[nodiscard]] float getFuelReferencePressure() const final; }; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 31f593588f..54b7cbd1cb 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1718,7 +1718,10 @@ uint8_t autoscale knockFuelTrim;Fuel trim when knock, max 30%;"%", 1, 0, 0, 30, float knockSpectrumSensitivity;;"sense", 1, 0, 0, 1, 2 float knockFrequency;"Estimated knock frequency, ignore cylinderBore if this one > 0";"Hz", 1, 0, 0, 20000, 2 -#define END_OF_CALIBRATION_PADDING 116 + injector_compensation_mode_e secondaryInjectorCompensationMode;None = I have a MAP-referenced fuel pressure regulator\nFixed rail pressure = I have an atmosphere-referenced fuel pressure regulator (returnless, typically)\nSensed rail pressure = I have a fuel pressure sensor; + float secondaryInjectorFuelReferencePressure;This is the pressure at which your injector flow is known.\nFor example if your injectors flow 400cc/min at 3.5 bar, enter 350kpa here.;"kPa", 1, 0, 50, 700000, 0 + +#define END_OF_CALIBRATION_PADDING 111 uint8_t[END_OF_CALIBRATION_PADDING] unusedOftenChangesDuringFirmwareUpdate;;"units", 1, 0, 0, 1, 0 ! end of engine_configuration_s diff --git a/firmware/tunerstudio/tunerstudio.template.ini b/firmware/tunerstudio/tunerstudio.template.ini index 8e0233fdd9..db0c5c3930 100644 --- a/firmware/tunerstudio/tunerstudio.template.ini +++ b/firmware/tunerstudio/tunerstudio.template.ini @@ -2762,7 +2762,9 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_ dialog = stagedInjection, "", yAxis field = "Enable", enableStagedInjection, {isInjectionEnabled} field = "" - field = "Secondary injector flow", injectorSecondary_flow {isInjectionEnabled && enableStagedInjection} + field = "Secondary injector flow", injectorSecondary_flow, {isInjectionEnabled && enableStagedInjection} + field = "Secondary injector flow compensation mode", secondaryInjectorCompensationMode, { isInjectionEnabled && enableStagedInjection } + field = "Secondary injector reference pressure", secondaryInjectorFuelReferencePressure, { isInjectionEnabled && enableStagedInjection && secondaryInjectorCompensationMode != 0 } field = "" panel = injectorsSecondaryDeadTime, {isInjectionEnabled && enableStagedInjection}