diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index 5368cf9b90..7dabcb5a13 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -28,6 +28,8 @@ All notable user-facing or behavior-altering changes will be documented in this ## Month 202x Release - "Release Name" ### Fixed - LCD screen works again #2576 +### Added + - Per-bank closed loop fuel correction (each cylinder corrected by the sensor that sees its exhaust) ## April 2021 Release - "Malbec" ### Added diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index bf417ebbb2..9a74fdf2dd 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -32,7 +32,8 @@ public: */ bool isSimultanious = false; InjectorOutputPin *outputs[MAX_WIRES_COUNT]; - int ownIndex = 0; + uint8_t ownIndex = 0; + uint8_t cylinderNumber = 0; DECLARE_ENGINE_PTR; event_trigger_position_s injectionStart; diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index 69faa71a5c..9562a39e0c 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -106,6 +106,8 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF ev->outputs[0] = output; ev->outputs[1] = secondOutput; ev->isSimultanious = isSimultanious; + // Stash the cylinder number so we can select the correct fueling bank later + ev->cylinderNumber = injectorIndex; if (!isSimultanious && !output->isInitialized()) { // todo: extract method for this index math diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 4f4435d565..b3ea328d94 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -204,7 +204,7 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now } // Select fuel mass from the correct bank - uint8_t bankIndex = CONFIG(cylinderBankSelect[this->ownIndex]); + uint8_t bankIndex = CONFIG(cylinderBankSelect[this->cylinderNumber]); float injectionMassGrams = ENGINE(injectionMass)[bankIndex]; // Perform wall wetting adjustment on fuel mass, not duration, so that