Skip to content

Commit

Permalink
fix odd fire offset lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 18, 2025
1 parent 33da746 commit e516fde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion firmware/controllers/engine_cycle/spark_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
// Negate because timing *before* TDC, and we schedule *after* TDC
- finalIgnitionTiming
// Offset by this cylinder's position in the cycle
+ getCylinderAngle(event->cylinderIndex, event->cylinderNumber);
+ getCylinderAngle(event->cylinderIndex, realCylinderNumber);

efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !std::isnan(sparkAngle), "sparkAngle#1");
wrapAngle(sparkAngle, "findAngle#2", ObdCode::CUSTOM_ERR_6550);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ TEST(OddFireRunningMode, hd) {
// send fake crank signal events so that ignition events are updated
eth.fireTriggerEvents2(2 /* count */ , 60 /* ms */);

// TODO: these numbers are wrong, they're both using the offset for cyl 1! (+19 deg)
// Cyl 1 fires 19 degrees late
EXPECT_EQ(engine->ignitionEvents.elements[0].sparkAngle, 18);
EXPECT_EQ(engine->ignitionEvents.elements[1].sparkAngle, 378);

// should be
// EXPECT_EQ(engine->ignitionEvents.elements[1].sparkAngle, 346);
// Cyl 2 fires 13 degrees early
EXPECT_EQ(engine->ignitionEvents.elements[1].sparkAngle, 346);
}

0 comments on commit e516fde

Please sign in to comment.