diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 9a4f48dfa6..7356d38ec4 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..26c49ff9ce --- /dev/null +++ b/unit_tests/tests/test_symmetrical_crank.cpp @@ -0,0 +1,67 @@ +/* + * @file test_symmetrical_crank.cpp + * + * @date Feb 14, 2020 + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#include "engine_test_helper.h" + +TEST(engine, testSymmetricalCrank) { + + WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003); + + float x = 0.02; + + ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 0, GET_RPM()) << "RPM#1"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 0, GET_RPM()) << "RPM#2"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#2.5"; + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#3"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#4"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#5"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#6"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 374, GET_RPM()) << "RPM#7"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 374, GET_RPM()) << "RPM#8"; + +} 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 \