From 79dff236a4ce8f3cd5a390ca80d1c9a70280a313 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 28 Jun 2023 16:34:22 -0700 Subject: [PATCH] real test of 12+1 --- unit_tests/tests/tests.mk | 1 + .../resources/cas_nissan_24_plus_1.csv | 449 ++++++++++++++++++ .../tests/trigger/test_real_cas_24_plus_1.cpp | 64 +++ 3 files changed, 514 insertions(+) create mode 100644 unit_tests/tests/trigger/resources/cas_nissan_24_plus_1.csv create mode 100644 unit_tests/tests/trigger/test_real_cas_24_plus_1.cpp diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index f59e651f32..e151ce7398 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -11,6 +11,7 @@ TESTS_SRC_CPP = \ tests/trigger/test_real_cranking_miata_NA.cpp \ tests/trigger/test_real_cranking_miata_na6.cpp \ tests/trigger/test_real_cranking_nissan_vq40.cpp \ + tests/trigger/test_real_cas_24_plus_1.cpp \ tests/trigger/test_trigger_skipped_wheel.cpp \ tests/trigger/test_real_4b11.cpp \ tests/trigger/test_real_4g93.cpp \ diff --git a/unit_tests/tests/trigger/resources/cas_nissan_24_plus_1.csv b/unit_tests/tests/trigger/resources/cas_nissan_24_plus_1.csv new file mode 100644 index 0000000000..b40e8ad7c6 --- /dev/null +++ b/unit_tests/tests/trigger/resources/cas_nissan_24_plus_1.csv @@ -0,0 +1,449 @@ +timestamp,pri,sec +8.937617,1,0 +8.940322,0,0 +8.943855,1,0 +8.946542,0,0 +8.950059,1,0 +8.952713,0,0 +8.956174,1,0 +8.958801,0,0 +8.962274,1,0 +8.964871,0,0 +8.968273,1,0 +8.97086,0,0 +8.974244,1,0 +8.976776,0,0 +8.980122,1,0 +8.982656,0,0 +8.98595,1,0 +8.988429,0,0 +8.991714,1,0 +8.9942,0,0 +8.997441,1,0 +8.999913,0,0 +9.003146,1,0 +9.005591,0,0 +9.008795,1,0 +9.011229,0,0 +9.014393,1,0 +9.016801,0,0 +9.019959,1,0 +9.022345,0,0 +9.025471,1,0 +9.027858,0,0 +9.030973,1,0 +9.033345,0,0 +9.036436,1,0 +9.036453,1,0 +9.036456,1,0 +9.038789,0,0 +9.041863,1,0 +9.043581,1,1 +9.044232,0,1 +9.045688,0,0 +9.047325,1,0 +9.049667,0,0 +9.052764,1,0 +9.05512,0,0 +9.05818,1,0 +9.060501,0,0 +9.063539,1,0 +9.065865,0,0 +9.068908,1,0 +9.07121,0,0 +9.074194,1,0 +9.076471,0,0 +9.079485,1,0 +9.081775,0,0 +9.084792,1,0 +9.087073,0,0 +9.090081,1,0 +9.092347,0,0 +9.095342,1,0 +9.097615,0,0 +9.100608,1,0 +9.102871,0,0 +9.105835,1,0 +9.10808,0,0 +9.111051,1,0 +9.113295,0,0 +9.116238,1,0 +9.118473,0,0 +9.12144,1,0 +9.123696,0,0 +9.12665,1,0 +9.128885,0,0 +9.131805,1,0 +9.134014,0,0 +9.136925,1,0 +9.139134,0,0 +9.142013,1,0 +9.144209,0,0 +9.147095,1,0 +9.149276,0,0 +9.152151,1,0 +9.154355,0,0 +9.157222,1,0 +9.159417,0,0 +9.162306,1,0 +9.162323,1,0 +9.162326,1,0 +9.164505,0,0 +9.167362,1,0 +9.168955,1,1 +9.169557,0,1 +9.170915,0,0 +9.172439,1,0 +9.174624,0,0 +9.1775,1,0 +9.179671,0,0 +9.182513,1,0 +9.184695,0,0 +9.187535,1,0 +9.189694,0,0 +9.192531,1,0 +9.194711,0,0 +9.19756,1,0 +9.199707,0,0 +9.202535,1,0 +9.204697,0,0 +9.207539,1,0 +9.209694,0,0 +9.212523,1,0 +9.21465,0,0 +9.21748,1,0 +9.219632,0,0 +9.222457,1,0 +9.224588,0,0 +9.227414,1,0 +9.229568,0,0 +9.2324,1,0 +9.234544,0,0 +9.237382,1,0 +9.239545,0,0 +9.242387,1,0 +9.244523,0,0 +9.247338,1,0 +9.249473,0,0 +9.252262,1,0 +9.254372,0,0 +9.257163,1,0 +9.259285,0,0 +9.262046,1,0 +9.264156,0,0 +9.266941,1,0 +9.269059,0,0 +9.27184,1,0 +9.273976,0,0 +9.276768,1,0 +9.278891,0,0 +9.281655,1,0 +9.281674,1,0 +9.281676,1,0 +9.283768,0,0 +9.28654,1,0 +9.288081,1,1 +9.288662,0,1 +9.289956,0,0 +9.29141,1,0 +9.293517,0,0 +9.296308,1,0 +9.298404,0,0 +9.301169,1,0 +9.303294,0,0 +9.306082,1,0 +9.3082,0,0 +9.310982,1,0 +9.313096,0,0 +9.315838,1,0 +9.317928,0,0 +9.320701,1,0 +9.322807,0,0 +9.325562,1,0 +9.327657,0,0 +9.330424,1,0 +9.332503,0,0 +9.335259,1,0 +9.337373,0,0 +9.340174,1,0 +9.342285,0,0 +9.345053,1,0 +9.347155,0,0 +9.349943,1,0 +9.352051,0,0 +9.3548,1,0 +9.356893,0,0 +9.359678,1,0 +9.361763,0,0 +9.364493,1,0 +9.366583,0,0 +9.369345,1,0 +9.371441,0,0 +9.374206,1,0 +9.3763,0,0 +9.379032,1,0 +9.381124,0,0 +9.383883,1,0 +9.385974,0,0 +9.388702,1,0 +9.390794,0,0 +9.39354,1,0 +9.395632,0,0 +9.398357,1,0 +9.398375,1,0 +9.398377,1,0 +9.400441,0,0 +9.403164,1,0 +9.404667,1,1 +9.405233,0,1 +9.406507,0,0 +9.407949,1,0 +9.410042,0,0 +9.412814,1,0 +9.414893,0,0 +9.417629,1,0 +9.41973,0,0 +9.422472,1,0 +9.424542,0,0 +9.427269,1,0 +9.429352,0,0 +9.432057,1,0 +9.434112,0,0 +9.43684,1,0 +9.438912,0,0 +9.441628,1,0 +9.443687,0,0 +9.4464,1,0 +9.448466,0,0 +9.451215,1,0 +9.453288,0,0 +9.456027,1,0 +9.45811,0,0 +9.460841,1,0 +9.462908,0,0 +9.465636,1,0 +9.467705,0,0 +9.470415,1,0 +9.472482,0,0 +9.475204,1,0 +9.477254,0,0 +9.479978,1,0 +9.482068,0,0 +9.484803,1,0 +9.486864,0,0 +9.48959,1,0 +9.491665,0,0 +9.494355,1,0 +9.496401,0,0 +9.499116,1,0 +9.501184,0,0 +9.50389,1,0 +9.505949,0,0 +9.508647,1,0 +9.510717,0,0 +9.51342,1,0 +9.513438,1,0 +9.51344,1,0 +9.515482,0,0 +9.518196,1,0 +9.519716,1,1 +9.52029,0,1 +9.521578,0,0 +9.523021,1,0 +9.525097,0,0 +9.52783,1,0 +9.529905,0,0 +9.532637,1,0 +9.534727,0,0 +9.537436,1,0 +9.539497,0,0 +9.542209,1,0 +9.544278,0,0 +9.546987,1,0 +9.549046,0,0 +9.551775,1,0 +9.553853,0,0 +9.556589,1,0 +9.558648,0,0 +9.561369,1,0 +9.563429,0,0 +9.566165,1,0 +9.568231,0,0 +9.570969,1,0 +9.573039,0,0 +9.575739,1,0 +9.577801,0,0 +9.58054,1,0 +9.582614,0,0 +9.585336,1,0 +9.587418,0,0 +9.59017,1,0 +9.592253,0,0 +9.594983,1,0 +9.597075,0,0 +9.599817,1,0 +9.601879,0,0 +9.60458,1,0 +9.606634,0,0 +9.609345,1,0 +9.611412,0,0 +9.614115,1,0 +9.616172,0,0 +9.618886,1,0 +9.620961,0,0 +9.62368,1,0 +9.625759,0,0 +9.628485,1,0 +9.628503,1,0 +9.628505,1,0 +9.630569,0,0 +9.633305,1,0 +9.634817,1,1 +9.635386,0,1 +9.636661,0,0 +9.638091,1,0 +9.640162,0,0 +9.642911,1,0 +9.644975,0,0 +9.647684,1,0 +9.64977,0,0 +9.652508,1,0 +9.654576,0,0 +9.657287,1,0 +9.659374,0,0 +9.662116,1,0 +9.664198,0,0 +9.666913,1,0 +9.668979,0,0 +9.67171,1,0 +9.673771,0,0 +9.676491,1,0 +9.678549,0,0 +9.681278,1,0 +9.683341,0,0 +9.686078,1,0 +9.688154,0,0 +9.690892,1,0 +9.692982,0,0 +9.695743,1,0 +9.697826,0,0 +9.700568,1,0 +9.702654,0,0 +9.705395,1,0 +9.707474,0,0 +9.71021,1,0 +9.712288,0,0 +9.715014,1,0 +9.717077,0,0 +9.719783,1,0 +9.721845,0,0 +9.724563,1,0 +9.726647,0,0 +9.729371,1,0 +9.731449,0,0 +9.734172,1,0 +9.73624,0,0 +9.738958,1,0 +9.741047,0,0 +9.743765,1,0 +9.743782,1,0 +9.743785,1,0 +9.745828,0,0 +9.748548,1,0 +9.750056,1,1 +9.750626,0,1 +9.751901,0,0 +9.753332,1,0 +9.755398,0,0 +9.758145,1,0 +9.760222,0,0 +9.762954,1,0 +9.765045,0,0 +9.767772,1,0 +9.769846,0,0 +9.77258,1,0 +9.774655,0,0 +9.777358,1,0 +9.779424,0,0 +9.782146,1,0 +9.7842,0,0 +9.786895,1,0 +9.788949,0,0 +9.791672,1,0 +9.793733,0,0 +9.79644,1,0 +9.798496,0,0 +9.801232,1,0 +9.803315,0,0 +9.806042,1,0 +9.808106,0,0 +9.81084,1,0 +9.812906,0,0 +9.815611,1,0 +9.81766,0,0 +9.820372,1,0 +9.822437,0,0 +9.825159,1,0 +9.827213,0,0 +9.829919,1,0 +9.831982,0,0 +9.834686,1,0 +9.83674,0,0 +9.839434,1,0 +9.841492,0,0 +9.844191,1,0 +9.846241,0,0 +9.848928,1,0 +9.850984,0,0 +9.853681,1,0 +9.855738,0,0 +9.858414,1,0 +9.858431,1,0 +9.858434,1,0 +9.860461,0,0 +9.863141,1,0 +9.86463,1,1 +9.865194,0,1 +9.866461,0,0 +9.867891,1,0 +9.869958,0,0 +9.872688,1,0 +9.874751,0,0 +9.877467,1,0 +9.879533,0,0 +9.882227,1,0 +9.884286,0,0 +9.886998,1,0 +9.889044,0,0 +9.891724,1,0 +9.893765,0,0 +9.896442,1,0 +9.898487,0,0 +9.9012,1,0 +9.903256,0,0 +9.905954,1,0 +9.908,0,0 +9.910716,1,0 +9.912772,0,0 +9.915478,1,0 +9.917528,0,0 +9.920245,1,0 +9.922298,0,0 +9.924992,1,0 +9.927023,0,0 +9.929717,1,0 +9.931773,0,0 +9.934469,1,0 +9.936519,0,0 +9.939243,1,0 +9.941315,0,0 +9.944002,1,0 +9.946039,0,0 +9.948735,1,0 +9.950783,0,0 +9.953461,1,0 +9.955485,0,0 +9.958163,1,0 +9.960207,0,0 +9.962884,1,0 +9.964915,0,0 diff --git a/unit_tests/tests/trigger/test_real_cas_24_plus_1.cpp b/unit_tests/tests/trigger/test_real_cas_24_plus_1.cpp new file mode 100644 index 0000000000..18185ad436 --- /dev/null +++ b/unit_tests/tests/trigger/test_real_cas_24_plus_1.cpp @@ -0,0 +1,64 @@ +// Mitsubishi 4B11 trigger pattern +// Crank: 36-2-1 +// Cam: Single tooth (half moon) + +#include "pch.h" + +#include "logicdata_csv_reader.h" + +TEST(realCas24Plus1, spinningOnBench) { + CsvReader reader(1, /* vvtCount */ 1); + + reader.open("tests/trigger/resources/cas_nissan_24_plus_1.csv"); + EngineTestHelper eth(engine_type_e::TEST_ENGINE); + + engineConfiguration->isFasterEngineSpinUpEnabled = true; + engineConfiguration->alwaysInstantRpm = true; + + engineConfiguration->isPhaseSyncRequiredForIgnition = true; + + // 24 teeth at cam speed + 1 tooth + // AKA 12 teeth at crank speed + 1 cam tooth + engineConfiguration->vvtMode[0] = VVT_SECOND_HALF; + eth.setTriggerType(trigger_type_e::TT_12_TOOTH_CRANK); + + int eventCount = 0; + bool gotRpm = false; + bool gotFullSync = false; + + while (reader.haveMore()) { + reader.processLine(ð); + eventCount++; + engine->rpmCalculator.onSlowCallback(); + + // Expect that all teeth are in the correct spot + float angleError = getTriggerCentral()->triggerToothAngleError; + EXPECT_TRUE(angleError < 3 && angleError > -3) << "tooth angle of " << angleError << " at timestamp " << (getTimeNowNt() / 1e8); + + auto rpm = Sensor::getOrZero(SensorType::Rpm); + if (!gotRpm && rpm) { + gotRpm = true; + + // We should get first RPM on exactly the first (primary) sync point - this means the instant RPM pre-sync event copy all worked OK + EXPECT_EQ(eventCount, 7); + EXPECT_NEAR(rpm, 808.32f, 0.1); + } + + bool hasFullSync = getTriggerCentral()->triggerState.hasSynchronizedPhase(); + if (!gotFullSync && hasFullSync) { + gotFullSync = true; + + // Should get full sync on the first cam tooth + EXPECT_EQ(eventCount, 40); + EXPECT_NEAR(rpm, 915.08f, 0.1); + } + + float vvt = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); + if (vvt != 0) { + // cam position should never be reported outside of correct range + EXPECT_TRUE(vvt > -10 && vvt < -9); + } + } + + ASSERT_EQ(0, eth.recentWarnings()->getCount()); +}