wow, it's easy to support odd-fire too

This commit is contained in:
Matthew Kennedy 2024-08-31 02:05:22 -07:00
parent b23a6f8943
commit e755e4bcc4
4 changed files with 21 additions and 6 deletions

View File

@ -24,6 +24,8 @@ public:
*/
angle_t engineCycle;
bool useOddFireWastedSpark = false;
/**
* this is based on sensorChartMode and sensorSnifferRpmThreshold settings
*/

View File

@ -105,10 +105,10 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
auto ignitionMode = getCurrentIgnitionMode();
// On an odd cylinder wasted spark engine, map outputs as if in sequential.
// On an odd cylinder (or odd fire) wasted spark engine, map outputs as if in sequential.
// During actual scheduling, the events just get scheduled every 360 deg instead
// of every 720 deg.
if (ignitionMode == IM_WASTED_SPARK && (engineConfiguration->cylindersCount % 2 == 1)) {
if (ignitionMode == IM_WASTED_SPARK && engine->engineState.useOddFireWastedSpark) {
ignitionMode = IM_INDIVIDUAL_COILS;
}
@ -475,9 +475,8 @@ void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPha
// - current mode is wasted spark
// - four stroke
bool enableOddCylinderWastedSpark =
(engineConfiguration->cylindersCount % 2 == 1)
&& getCurrentIgnitionMode() == IM_WASTED_SPARK
&& engine->engineState.engineCycle == 720;
engine->engineState.useOddFireWastedSpark
&& getCurrentIgnitionMode() == IM_WASTED_SPARK;
if (engine->ignitionEvents.isReady) {
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {

View File

@ -404,7 +404,20 @@ ignition_mode_e getCurrentIgnitionMode() {
* This heavy method is only invoked in case of a configuration change or initialization.
*/
void prepareOutputSignals() {
getEngineState()->engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode());
auto operationMode = getEngineRotationState()->getOperationMode();
getEngineState()->engineCycle = getEngineCycle(operationMode);
bool isOddFire = false;
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
if (engineConfiguration->timing_offset_cylinder[i] != 0) {
isOddFire = true;
break;
}
}
// Use odd fire wasted spark logic if not two stroke, and an odd fire or odd cylinder # engine
getEngineState()->useOddFireWastedSpark = operationMode != TWO_STROKE
&& (isOddFire | (engineConfiguration->cylindersCount % 2 == 1));
#if EFI_UNIT_TEST
if (verboseMode) {

View File

@ -193,6 +193,7 @@ TEST(ignition, oddCylinderWastedSpark) {
// dwell should start at 15 degrees ATDC and firing at 25 deg ATDC
engine->ignitionState.dwellAngle = 10;
engine->engineState.timingAdvance[0] = -25;
engine->engineState.useOddFireWastedSpark = true;
engineConfiguration->minimumIgnitionTiming = -25;
// expect to schedule the on-phase dwell and spark (not the wasted spark copy)