2020-02-13 21:37:36 -08:00
|
|
|
/*
|
|
|
|
* @file test_symmetrical_crank.cpp
|
|
|
|
*
|
|
|
|
* @date Feb 14, 2020
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engine_test_helper.h"
|
|
|
|
|
2020-02-14 06:33:29 -08:00
|
|
|
static void postFourEvents(EngineTestHelper *eth, float mult) {
|
|
|
|
eth->fireFall(mult * 384);
|
|
|
|
eth->fireRise(mult * 16);
|
|
|
|
eth->fireFall(mult * 304);
|
|
|
|
eth->fireRise(mult * 16);
|
|
|
|
}
|
|
|
|
|
2021-07-17 14:47:13 -07:00
|
|
|
TEST(engine, testAngleLogicInSymmetricalCrankIssue2980) {
|
|
|
|
WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003);
|
|
|
|
|
|
|
|
TriggerFormDetails *triggerForm = &ENGINE(triggerCentral.triggerFormDetails);
|
|
|
|
|
|
|
|
TriggerWaveform * form = &ENGINE(triggerCentral.triggerShape);
|
|
|
|
|
2021-07-17 20:27:20 -07:00
|
|
|
#define EXPECT_FINDANGLE(angle, idx) EXPECT_EQ(form->findAngleIndex(triggerForm, angle) & 0xFFFF'FFFE, idx);
|
2021-07-17 16:43:17 -07:00
|
|
|
|
2021-07-17 20:27:20 -07:00
|
|
|
// Check one angle just after every trigger tooth, for two full revolutions (720 degrees, one engine cycle, 4 loops of the trigger)
|
2021-07-17 16:43:17 -07:00
|
|
|
|
2021-07-17 20:27:20 -07:00
|
|
|
// First quarter
|
|
|
|
EXPECT_FINDANGLE(0 * 180 + 5, 0); // 5
|
|
|
|
EXPECT_FINDANGLE(0 * 180 + 115, 2); // 115
|
2021-07-17 16:43:17 -07:00
|
|
|
|
2021-07-17 20:27:20 -07:00
|
|
|
// Second quarter
|
|
|
|
EXPECT_FINDANGLE(1 * 180 + 5, 4); // 180+5 = 185
|
|
|
|
EXPECT_FINDANGLE(1 * 180 + 115, 6); // 180+115 = 295
|
|
|
|
|
|
|
|
// Third quarter
|
|
|
|
EXPECT_FINDANGLE(2 * 180 + 5, 8); // 360+5 = 365
|
|
|
|
EXPECT_FINDANGLE(2 * 180 + 115, 10); // 360+115 = 475
|
|
|
|
|
|
|
|
// Fourth quarter
|
|
|
|
EXPECT_FINDANGLE(3 * 180 + 5, 12); // 540+5 = 545
|
|
|
|
EXPECT_FINDANGLE(3 * 180 + 115, 14); // 540+115 = 655
|
2021-07-17 14:47:13 -07:00
|
|
|
}
|
|
|
|
|
2020-02-13 21:37:36 -08:00
|
|
|
TEST(engine, testSymmetricalCrank) {
|
|
|
|
|
|
|
|
WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003);
|
|
|
|
|
2020-02-14 06:33:29 -08:00
|
|
|
// this test is not about isFasterEngineSpinUpEnabled so let's disable it to simplify things
|
|
|
|
CONFIG(isFasterEngineSpinUpEnabled) = false;
|
|
|
|
|
2020-02-14 07:49:22 -08:00
|
|
|
|
|
|
|
ASSERT_EQ(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE));
|
|
|
|
|
|
|
|
float mult = 0.02;
|
2020-02-13 21:37:36 -08:00
|
|
|
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
|
|
|
|
|
2020-02-14 07:49:22 -08:00
|
|
|
postFourEvents(ð, mult);
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
|
|
|
|
|
|
|
|
eth.fireFall(mult * 384);
|
|
|
|
eth.fireRise(mult * 16);
|
|
|
|
eth.fireFall(mult * 304);
|
2021-07-03 07:37:03 -07:00
|
|
|
ASSERT_FALSE(engine->triggerCentral.triggerState.getShaftSynchronized());
|
2020-02-14 07:49:22 -08:00
|
|
|
eth.fireRise(mult * 16);
|
2021-07-03 07:37:03 -07:00
|
|
|
ASSERT_TRUE(engine->triggerCentral.triggerState.getShaftSynchronized());
|
2020-02-14 07:49:22 -08:00
|
|
|
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 6 ; i++) {
|
|
|
|
postFourEvents(ð, mult);
|
2020-02-14 06:33:29 -08:00
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
|
|
|
|
}
|
2020-02-13 21:37:36 -08:00
|
|
|
|
2020-02-14 07:49:22 -08:00
|
|
|
mult = 0.1;
|
|
|
|
postFourEvents(ð, mult);
|
2020-12-05 21:11:57 -08:00
|
|
|
ASSERT_EQ( 1042, GET_RPM()) << "RPM#11";
|
2020-02-13 21:37:36 -08:00
|
|
|
|
2020-02-14 07:49:22 -08:00
|
|
|
postFourEvents(ð, mult);
|
2020-12-05 21:11:57 -08:00
|
|
|
ASSERT_EQ( 1042, GET_RPM()) << "RPM#11";
|
2020-02-13 21:37:36 -08:00
|
|
|
|
2020-02-14 07:49:22 -08:00
|
|
|
postFourEvents(ð, mult);
|
2020-12-05 21:11:57 -08:00
|
|
|
ASSERT_EQ( 1042, GET_RPM()) << "RPM#11";
|
2020-02-13 21:37:36 -08:00
|
|
|
}
|