diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 972215c0b0..16b03f6682 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -95,7 +95,9 @@ void initializeMazdaMiataNb2Crank(TriggerWaveform *s) { s->tdcPosition = 60 + 655; s->setTriggerSynchronizationGap2(0.35f, 0.98f); + // 384 s->addEvent720(o + 4 * 56.0f, T_PRIMARY, TV_FALL); + // 400 s->addEvent720(o + 4 * 60.0f, T_PRIMARY, TV_RISE); s->addEvent720(o + 4 * 136.0f, T_PRIMARY, TV_FALL); s->addEvent720(o + 4 * 140.0f, T_PRIMARY, TV_RISE); diff --git a/unit_tests/tests/test_symmetrical_crank.cpp b/unit_tests/tests/test_symmetrical_crank.cpp new file mode 100644 index 0000000000..12b63af470 --- /dev/null +++ b/unit_tests/tests/test_symmetrical_crank.cpp @@ -0,0 +1,45 @@ +/* + * @file test_symmetrical_crank.cpp + * + * @date Feb 14, 2020 + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#include "engine_test_helper.h" + +static void postFourEvents(EngineTestHelper *eth, float mult) { + eth->fireFall(mult * 384); + eth->fireRise(mult * 16); + eth->fireFall(mult * 304); + eth->fireRise(mult * 16); +} + +TEST(engine, testSymmetricalCrank) { + + WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003); + + // this test is not about isFasterEngineSpinUpEnabled so let's disable it to simplify things + CONFIG(isFasterEngineSpinUpEnabled) = false; + + + ASSERT_EQ(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)); + + float x = 0.02; + + ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; + + for (int i = 0; i < 8 ; i++) { + postFourEvents(ð, x); + ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; + } + + x = 0.1; + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; + + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; + + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; +} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index f3f3b35a19..61e1d94923 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -11,6 +11,7 @@ TESTS_SRC_CPP = \ tests/test_miata_na6_real_cranking.cpp \ tests/test_fasterEngineSpinningUp.cpp \ tests/test_dwell_corner_case_issue_796.cpp \ + tests/test_symmetrical_crank.cpp \ tests/test_idle_controller.cpp \ tests/test_trigger_decoder.cpp \ tests/test_trigger_noiseless.cpp \