diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 57f630babd..b145dcc4b8 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -69,7 +69,11 @@ void initializeMazdaMiataNb2Crank(TriggerWaveform *s) { s->tdcPosition = 60 + 655; + // Nominal gap 70/110 = 0.636 s->setTriggerSynchronizationGap2(0.35f, 0.98f); + // Nominal gap 110/70 = 1.571 + s->setSecondTriggerSynchronizationGap2(1.05f, 1.8f); + // todo: NB2 fronts are inverted comparing to NB1, life is not perfect :( s->addEventAngle(180.0f - NB_CRANK_MAGIC - 4, T_PRIMARY, TV_FALL); s->addEventAngle(180.0f - NB_CRANK_MAGIC, T_PRIMARY, TV_RISE); diff --git a/unit_tests/tests/trigger/test_real_nb2_cranking.cpp b/unit_tests/tests/trigger/test_real_nb2_cranking.cpp index 1fb4499790..7985c1df1e 100644 --- a/unit_tests/tests/trigger/test_real_nb2_cranking.cpp +++ b/unit_tests/tests/trigger/test_real_nb2_cranking.cpp @@ -25,7 +25,7 @@ TEST(realCrankingNB2, normalCranking) { ASSERT_EQ(942, GET_RPM()); // TODO: why warnings? - ASSERT_EQ(2, eth.recentWarnings()->getCount()); + ASSERT_EQ(3, eth.recentWarnings()->getCount()); } TEST(realCrankingNB2, crankingMissingInjector) { @@ -42,7 +42,7 @@ TEST(realCrankingNB2, crankingMissingInjector) { // VVT position nearly zero! EXPECT_NEAR(engine->triggerCentral.getVVTPosition(0, 0), -7.1926f, 1e-4); - ASSERT_EQ(209, GET_RPM()); + ASSERT_EQ(668, GET_RPM()); // TODO: why warnings? ASSERT_EQ(2, eth.recentWarnings()->getCount()); diff --git a/unit_tests/tests/trigger/test_symmetrical_crank.cpp b/unit_tests/tests/trigger/test_symmetrical_crank.cpp index b77d5f4110..6bf6f48653 100644 --- a/unit_tests/tests/trigger/test_symmetrical_crank.cpp +++ b/unit_tests/tests/trigger/test_symmetrical_crank.cpp @@ -8,9 +8,9 @@ #include "engine_test_helper.h" static void postFourEvents(EngineTestHelper *eth, float mult) { - eth->fireFall(mult * 384); + eth->fireFall(mult * 394); eth->fireRise(mult * 16); - eth->fireFall(mult * 304); + eth->fireFall(mult * 294); eth->fireRise(mult * 16); } @@ -59,9 +59,9 @@ TEST(engine, testSymmetricalCrank) { postFourEvents(ð, mult); ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; - eth.fireFall(mult * 384); + eth.fireFall(mult * 394); eth.fireRise(mult * 16); - eth.fireFall(mult * 304); + eth.fireFall(mult * 294); ASSERT_FALSE(engine->triggerCentral.triggerState.getShaftSynchronized()); eth.fireRise(mult * 16); ASSERT_TRUE(engine->triggerCentral.triggerState.getShaftSynchronized()); @@ -70,18 +70,17 @@ TEST(engine, testSymmetricalCrank) { - for (int i = 0; i < 6 ; i++) { + for (int i = 0; i < 6; i++) { postFourEvents(ð, mult); ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; } - mult = 0.1; postFourEvents(ð, mult); - ASSERT_EQ( 1042, GET_RPM()) << "RPM#11"; + ASSERT_EQ(2084, GET_RPM()) << "RPM#11"; postFourEvents(ð, mult); - ASSERT_EQ( 1042, GET_RPM()) << "RPM#11"; + ASSERT_EQ(2084, GET_RPM()) << "RPM#11"; postFourEvents(ð, mult); - ASSERT_EQ( 1042, GET_RPM()) << "RPM#11"; + ASSERT_EQ(2084, GET_RPM()) << "RPM#11"; }