diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index ef651c4550..e8b418c75a 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -243,6 +243,7 @@ void PrimaryTriggerDecoder::onTriggerError() { if (engine) { // Instant RPM data is now also probably trash, discard it engine->triggerCentral.instantRpm.resetInstantRpm(); + engine->rpmCalculator.lastTdcTimer.init(); } #pragma GCC diagnostic pop } diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 31dc931ab3..d09df8586c 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -25,6 +25,7 @@ TESTS_SRC_CPP = \ tests/trigger/test_real_k24a2.cpp \ tests/trigger/test_real_k20.cpp \ tests/trigger/test_toyota_3_tooth_cam.cpp \ + tests/trigger/test_real_noisy_trigger.cpp \ tests/trigger/test_map_cam.cpp \ tests/trigger/test_rpm_multiplier.cpp \ tests/trigger/test_rpm_acceleration.cpp \ diff --git a/unit_tests/tests/trigger/resources/noisy-trigger-1.csv b/unit_tests/tests/trigger/resources/noisy-trigger-1.csv new file mode 100644 index 0000000000..57827fc518 --- /dev/null +++ b/unit_tests/tests/trigger/resources/noisy-trigger-1.csv @@ -0,0 +1,538 @@ +0,0 +8e-05,1 +0.00383033,0 +0.00654333,1 +0.009637,0 +0.012213,1 +0.0153067,0 +0.018751,1 +0.0211483,0 +0.0238613,1 +0.0259747,0 +0.0283137,1 +0.0314077,0 +0.0341207,1 +0.036415,0 +0.038651,1 +0.0410487,0 +0.043388,1 +0.0456823,0 +0.0491263,1 +0.0515237,0 +0.0542367,1 +0.057739,0 +0.0600783,1 +0.0627123,0 +0.0651643,1 +0.0672777,0 +0.0697293,1 +0.0718427,0 +0.0745557,1 +0.07719,0 +0.079903,1 +0.0825373,0 +0.084989,1 +0.0873863,0 +0.0898383,1 +0.0924727,0 +0.0959167,1 +0.0990107,0 +0.102455,1 +0.105957,0 +0.107932,1 +0.110226,0 +0.113092,1 +0.116186,0 +0.118525,1 +0.120819,0 +0.122794,1 +0.124907,0 +0.127049,1 +0.130143,0 +0.133178,1 +0.136272,0 +0.139716,1 +0.143219,0 +0.145558,1 +0.14906,0 +0.151926,1 +0.15422,0 +0.166579,1 +0.170081,0 +0.172533,1 +0.176035,0 +0.179479,1 +0.182251,0 +0.184702,1 +0.186816,0 +0.188958,1 +0.191729,0 +0.194764,1 +0.197858,0 +0.199833,1 +0.202033,0 +0.204485,1 +0.207119,0 +0.209571,1 +0.211969,0 +0.214308,1 +0.217231,0 +0.219373,1 +0.221668,0 +0.224381,1 +0.226494,0 +0.229207,1 +0.232709,0 +0.236154,1 +0.239656,0 +0.242108,1 +0.244879,0 +0.247331,1 +0.249625,0 +0.25307,1 +0.255364,0 +0.257816,1 +0.26011,0 +0.26245,1 +0.265084,0 +0.267536,1 +0.27017,0 +0.272145,1 +0.274439,0 +0.276891,1 +0.280393,0 +0.282845,1 +0.28514,0 +0.287479,1 +0.289592,0 +0.292048,1 +0.295546,0 +0.297886,1 +0.300283,0 +0.302622,1 +0.304735,0 +0.307075,1 +0.309275,0 +0.312719,1 +0.31549,0 +0.317829,1 +0.320923,0 +0.322898,1 +0.325011,0 +0.327463,1 +0.329861,0 +0.332574,1 +0.334868,0 +0.337207,1 +0.340709,0 +0.35643,1 +0.359933,0 +0.362272,1 +0.365365,0 +0.36881,1 +0.370923,0 +0.372898,1 +0.3764,0 +0.378739,1 +0.381374,0 +0.384818,1 +0.386931,0 +0.38927,1 +0.392364,0 +0.39494,1 +0.39714,0 +0.399855,1 +0.402624,0 +0.406068,1 +0.408363,0 +0.41083,1 +0.413926,0 +0.416376,1 +0.419878,0 +0.421853,1 +0.425355,0 +0.427807,1 +0.430441,0 +0.433017,1 +0.435789,0 +0.438364,1 +0.441458,0 +0.443797,1 +0.446092,0 +0.448067,1 +0.451569,0 +0.454282,1 +0.457785,0 +0.46036,1 +0.463454,0 +0.465596,1 +0.46869,0 +0.471142,1 +0.473539,0 +0.476252,1 +0.479755,0 +0.482468,1 +0.484866,0 +0.487578,1 +0.489537,0 +0.491989,1 +0.495491,0 +0.498935,1 +0.502438,0 +0.505473,1 +0.508245,0 +0.510584,1 +0.512697,0 +0.516141,1 +0.518436,0 +0.520888,1 +0.524393,0 +0.526729,1 +0.530232,0 +0.532571,1 +0.535205,0 +0.537544,1 +0.540178,0 +0.553445,1 +0.555739,0 +0.558191,1 +0.560305,0 +0.562756,1 +0.565154,0 +0.567493,1 +0.570127,0 +0.572269,1 +0.574666,0 +0.577242,1 +0.580745,0 +0.58272,1 +0.584833,0 +0.587409,1 +0.589806,0 +0.592258,1 +0.595029,0 +0.597368,1 +0.600292,0 +0.602744,1 +0.605141,0 +0.607481,1 +0.610574,0 +0.613026,1 +0.61566,0 +0.618526,1 +0.62082,0 +0.624264,1 +0.627036,0 +0.629749,1 +0.633499,0 +0.635951,1 +0.638247,0 +0.64022,1 +0.642618,0 +0.64507,1 +0.648572,0 +0.651024,1 +0.653421,0 +0.656865,1 +0.65916,0 +0.661612,1 +0.663812,0 +0.666264,1 +0.668898,0 +0.671934,1 +0.675027,0 +0.677479,1 +0.680982,0 +0.684426,1 +0.686823,0 +0.689162,1 +0.691797,0 +0.69451,1 +0.69671,0 +0.699286,1 +0.701244,0 +0.703696,1 +0.705991,0 +0.708567,1 +0.711201,0 +0.71354,1 +0.717043,0 +0.719279,1 +0.721573,0 +0.724025,1 +0.726796,0 +0.740317,1 +0.742517,0 +0.744969,1 +0.747603,0 +0.749942,1 +0.752236,0 +0.754688,1 +0.756983,0 +0.759435,1 +0.761729,0 +0.764442,1 +0.767076,0 +0.769415,1 +0.77171,0 +0.774049,1 +0.776446,0 +0.778421,1 +0.780454,0 +0.782794,1 +0.785088,0 +0.787063,1 +0.78946,0 +0.791912,1 +0.794025,0 +0.79747,1 +0.800563,0 +0.804007,1 +0.807101,0 +0.809553,1 +0.811848,0 +0.813822,1 +0.816117,0 +0.819564,1 +0.823064,0 +0.825515,1 +0.82815,0 +0.830601,1 +0.832896,0 +0.83634,1 +0.83854,0 +0.840515,1 +0.842477,0 +0.844926,1 +0.84722,0 +0.849934,1 +0.852331,0 +0.854783,1 +0.85718,0 +0.859322,1 +0.86172,0 +0.864171,1 +0.866371,0 +0.868348,1 +0.87098,0 +0.873217,1 +0.875176,0 +0.877888,1 +0.881391,0 +0.883366,1 +0.885763,0 +0.889207,1 +0.892301,0 +0.89464,1 +0.898143,0 +0.900719,1 +0.902919,0 +0.904894,1 +0.907987,0 +0.922155,1 +0.925249,0 +0.927485,1 +0.930119,0 +0.933563,1 +0.935857,0 +0.937999,1 +0.939958,0 +0.942297,1 +0.944934,0 +0.946906,1 +0.950409,0 +0.952384,1 +0.954497,0 +0.956836,1 +0.960339,0 +0.96279,1 +0.965188,0 +0.967764,1 +0.970535,0 +0.97251,1 +0.974623,0 +0.976598,1 +0.980101,0 +0.982552,1 +0.984847,0 +0.987712,1 +0.989826,0 +0.993273,1 +0.99547,0 +0.998335,1 +1.00054,0 +1.00277,1 +1.00587,0 +1.0089,1 +1.0124,0 +1.01585,1 +1.01824,0 +1.02058,1 +1.02298,0 +1.02643,1 +1.02993,0 +1.03227,1 +1.03456,0 +1.03701,1 +1.04011,0 +1.04268,1 +1.04498,0 +1.04842,1 +1.05106,0 +1.0534,1 +1.0569,0 +1.05887,1 +1.06151,0 +1.06422,1 +1.06685,0 +1.06919,1 +1.07294,0 +1.07492,1 +1.07801,0 +1.08073,1 +1.08284,0 +1.0857,1 +1.08782,0 +1.09016,1 +1.09325,0 +1.09612,1 +1.09841,0 +1.11118,1 +1.11395,0 +1.11667,1 +1.11878,0 +1.12112,1 +1.12352,0 +1.12696,1 +1.12959,0 +1.13205,1 +1.13555,0 +1.13812,1 +1.1409,0 +1.14304,1 +1.14567,0 +1.14812,1 +1.15052,0 +1.15286,1 +1.15497,0 +1.15842,1 +1.16119,0 +1.16364,1 +1.16714,0 +1.17059,1 +1.17288,0 +1.17633,1 +1.17844,0 +1.18078,1 +1.18318,0 +1.18563,1 +1.18913,0 +1.19257,1 +1.19567,0 +1.19911,1 +1.20261,0 +1.20495,1 +1.20715,0 +1.2106,1 +1.21256,0 +1.21559,1 +1.21755,0 +1.21953,1 +1.22149,0 +1.22435,1 +1.22675,0 +1.23019,1 +1.23329,0 +1.23543,1 +1.23852,0 +1.24076,1 +1.24287,0 +1.24501,1 +1.24731,0 +1.25075,1 +1.25315,0 +1.2556,1 +1.25869,0 +1.26214,1 +1.26425,0 +1.26697,1 +1.27072,0 +1.27343,1 +1.27563,0 +1.27808,1 +1.28158,0 +1.28403,1 +1.28633,0 +1.28878,1 +1.29089,0 +1.30358,1 +1.30597,0 +1.30942,1 +1.31171,0 +1.31417,1 +1.31656,0 +1.32001,1 +1.3224,0 +1.32585,1 +1.32935,0 +1.33279,1 +1.33543,0 +1.33777,1 +1.33988,0 +1.34222,1 +1.34572,0 +1.34817,1 +1.35068,0 +1.35302,1 +1.35553,0 +1.35857,1 +1.36207,0 +1.36452,1 +1.36729,0 +1.36927,1 +1.37236,0 +1.3747,1 +1.37747,0 +1.37981,1 +1.38331,0 +1.38565,1 +1.38805,0 +1.3905,1 +1.39401,0 +1.39646,1 +1.39923,0 +1.40137,1 +1.40348,0 +1.40582,1 +1.40812,0 +1.41083,1 +1.41312,0 +1.41558,1 +1.41754,0 +1.42025,1 +1.42254,0 +1.42599,1 +1.42838,0 +1.43084,1 +1.43304,0 +1.43549,1 +1.43789,0 +1.44133,1 +1.44373,0 +1.44607,1 +1.44818,0 +1.45063,1 +1.45303,0 +1.45574,1 +1.45924,0 +1.46158,1 +1.46435,0 +1.46669,1 +1.46899,0 +1.47133,1 +1.47353,0 +1.47697,1 +1.47961,0 +1.49356,1 +1.49585,0 +1.49819,1 diff --git a/unit_tests/tests/trigger/resources/noisy-trigger-2.csv b/unit_tests/tests/trigger/resources/noisy-trigger-2.csv new file mode 100644 index 0000000000..3716b9e344 --- /dev/null +++ b/unit_tests/tests/trigger/resources/noisy-trigger-2.csv @@ -0,0 +1,1507 @@ +0,0 +0.006916,1 +0.0173633,0 +0.0303587,1 +0.0564337,0 +0.0824523,1 +0.108527,0 +0.125863,1 +0.143256,0 +0.151911,1 +0.158451,0 +0.168843,1 +0.177554,0 +0.190549,1 +0.195787,0 +0.202271,1 +0.20664,0 +0.213124,1 +0.219665,0 +0.225425,1 +0.23019,0 +0.234503,1 +0.241044,0 +0.243916,1 +0.25041,0 +0.269408,1 +0.274127,0 +0.277578,1 +0.280215,0 +0.283656,1 +0.288375,0 +0.291826,1 +0.295327,0 +0.298772,1 +0.301405,0 +0.305385,1 +0.308669,0 +0.312649,1 +0.315933,0 +0.318273,1 +0.320782,0 +0.324227,1 +0.326737,0 +0.329077,1 +0.33171,0 +0.334746,1 +0.338031,0 +0.340371,1 +0.343655,0 +0.346692,1 +0.350193,0 +0.352646,1 +0.355416,0 +0.357757,1 +0.360527,0 +0.363563,1 +0.366848,0 +0.369884,1 +0.372083,0 +0.374321,1 +0.37683,0 +0.378973,1 +0.381482,0 +0.383935,1 +0.386705,0 +0.389282,1 +0.391481,0 +0.393314,1 +0.39571,0 +0.397853,1 +0.400946,0 +0.403183,1 +0.405692,0 +0.407929,1 +0.411022,0 +0.413736,1 +0.415935,0 +0.418172,1 +0.420943,0 +0.423086,1 +0.425595,0 +0.427832,1 +0.430925,0 +0.432757,1 +0.435528,0 +0.437765,1 +0.440161,0 +0.442398,1 +0.445169,0 +0.447622,1 +0.449734,0 +0.45171,1 +0.453909,0 +0.466083,1 +0.468195,0 +0.470432,1 +0.472465,0 +0.474702,1 +0.476814,0 +0.479154,1 +0.481266,0 +0.483409,1 +0.485522,0 +0.487759,1 +0.490268,0 +0.492324,1 +0.495094,0 +0.497331,1 +0.499156,0 +0.501132,1 +0.503641,0 +0.505617,1 +0.507911,0 +0.510363,1 +0.512476,0 +0.514308,1 +0.516705,0 +0.518606,1 +0.520565,0 +0.52262,1 +0.524578,0 +0.526635,1 +0.528592,0 +0.530568,1 +0.532457,0 +0.534694,1 +0.536519,0 +0.538757,1 +0.540715,0 +0.543055,1 +0.545451,0 +0.547791,1 +0.549616,0 +0.551759,1 +0.554268,0 +0.556101,1 +0.558497,0 +0.560553,1 +0.562378,0 +0.564521,1 +0.566346,0 +0.568583,1 +0.570979,0 +0.572812,1 +0.575011,0 +0.577249,1 +0.580019,0 +0.582359,1 +0.584184,0 +0.58624,1 +0.588439,0 +0.590495,1 +0.592607,0 +0.594844,1 +0.597138,0 +0.59897,1 +0.601003,0 +0.602835,1 +0.604948,0 +0.607185,1 +0.60901,0 +0.619621,1 +0.621446,0 +0.623684,1 +0.625508,0 +0.627341,1 +0.629373,0 +0.631429,1 +0.633461,0 +0.635698,1 +0.637992,0 +0.640229,1 +0.642261,0 +0.644094,1 +0.645919,0 +0.648156,1 +0.649981,0 +0.652037,1 +0.654069,0 +0.655971,1 +0.658367,0 +0.660269,1 +0.662094,0 +0.663803,1 +0.665835,0 +0.667891,1 +0.669849,0 +0.672086,1 +0.674285,0 +0.675994,1 +0.677554,0 +0.679791,1 +0.681616,0 +0.683327,1 +0.685283,0 +0.687339,1 +0.689297,0 +0.691006,1 +0.693038,0 +0.694939,1 +0.697052,0 +0.698884,1 +0.700709,0 +0.702542,1 +0.7045,0 +0.706556,1 +0.708755,0 +0.710464,1 +0.712229,0 +0.714466,1 +0.716291,0 +0.718531,1 +0.720353,0 +0.722062,1 +0.723827,0 +0.725883,1 +0.727915,0 +0.729624,1 +0.731656,0 +0.733712,1 +0.735368,0 +0.737201,1 +0.739597,0 +0.741836,1 +0.743793,0 +0.745848,1 +0.747673,0 +0.749911,1 +0.752204,0 +0.762511,1 +0.764469,0 +0.766302,1 +0.768501,0 +0.770644,1 +0.77304,0 +0.775017,1 +0.776974,0 +0.779211,1 +0.781036,0 +0.783376,1 +0.786147,0 +0.788289,1 +0.790489,0 +0.793525,1 +0.795922,0 +0.798262,1 +0.801354,0 +0.803807,1 +0.806007,0 +0.808348,1 +0.81144,0 +0.81378,1 +0.817064,0 +0.820509,1 +0.82401,0 +0.826351,1 +0.82886,0 +0.831896,1 +0.83453,0 +0.837975,1 +0.840745,0 +0.843611,1 +0.846896,0 +0.850341,1 +0.852974,0 +0.856953,1 +0.860238,0 +0.862578,1 +0.865862,0 +0.868729,1 +0.872013,0 +0.874879,1 +0.877513,0 +0.882174,1 +0.885464,0 +0.889157,1 +0.892906,0 +0.897175,1 +0.90093,0 +0.905593,1 +0.909634,0 +0.913327,1 +0.918519,0 +0.923701,1 +0.928465,0 +0.932779,1 +0.937543,0 +0.941242,1 +0.946435,0 +0.950748,1 +0.955986,0 +0.963401,1 +0.972111,0 +0.989448,1 +1.02153,0 +1.02802,1 +1.03383,0 +1.07887,1 +1.08541,0 +1.10275,1 +1.10857,0 +1.11505,1 +1.13244,0 +1.14978,1 +1.15849,0 +1.16498,1 +1.19105,0 +1.19754,1 +1.21493,0 +1.22792,1 +1.23446,0 +1.2518,1 +1.26225,0 +1.26873,1 +1.28612,0 +1.29912,1 +1.30566,0 +1.323,1 +1.34907,0 +1.37509,1 +1.39248,0 +1.40982,1 +1.42027,0 +1.44628,1 +1.45499,0 +1.46799,1 +1.47844,0 +1.48709,1 +1.51317,0 +1.52616,1 +1.55224,0 +1.57826,1 +1.5887,0 +1.6017,1 +1.61041,0 +1.62774,1 +1.65382,0 +1.66682,1 +1.68421,0 +1.71023,1 +1.72762,0 +1.73628,1 +1.76235,0 +1.77535,1 +1.78579,0 +1.80313,1 +1.81358,0 +1.82223,1 +1.83962,0 +1.85696,1 +1.86741,0 +1.8804,1 +1.88911,0 +1.90211,1 +1.91256,0 +1.93858,1 +1.95597,0 +1.98199,1 +2.00806,0 +2.01455,1 +2.04062,0 +2.05796,1 +2.07535,0 +2.09269,1 +2.09923,0 +2.16649,1 +2.17125,0 +2.17596,1 +2.1812,0 +2.18861,1 +2.19298,0 +2.19729,1 +2.20253,0 +2.20771,1 +2.21248,0 +2.21719,1 +2.22195,0 +2.22936,1 +2.2346,0 +2.23784,1 +2.24076,0 +2.24474,1 +2.24946,0 +2.25377,1 +2.25814,0 +2.2639,1 +2.26719,0 +2.27146,1 +2.2767,0 +2.28068,1 +2.28331,0 +2.28758,1 +2.29087,0 +2.29432,1 +2.29695,0 +2.29982,1 +2.30274,0 +2.30701,1 +2.30994,0 +2.31251,1 +2.31626,0 +2.31913,1 +2.32241,0 +2.32668,1 +2.33192,0 +2.33479,1 +2.33854,0 +2.34141,1 +2.34613,0 +2.34871,1 +2.35343,0 +2.35741,1 +2.3607,0 +2.36536,1 +2.3694,0 +2.37227,1 +2.37519,0 +2.37917,1 +2.38389,0 +2.38734,1 +2.39138,0 +2.39424,1 +2.39687,0 +2.40057,1 +2.4032,0 +2.40665,1 +2.40928,0 +2.41326,1 +2.41589,0 +2.41847,1 +2.42319,0 +2.42664,1 +2.43067,0 +2.44679,1 +2.45029,0 +2.45315,1 +2.4569,0 +2.4606,1 +2.46323,0 +2.46692,1 +2.47067,0 +2.47354,1 +2.47631,0 +2.47889,1 +2.48166,0 +2.48563,1 +2.48938,0 +2.49225,1 +2.49697,0 +2.50067,1 +2.5033,0 +2.50728,1 +2.51103,0 +2.5153,1 +2.51859,0 +2.52203,1 +2.52578,0 +2.52923,1 +2.53186,0 +2.53555,1 +2.53848,0 +2.54134,1 +2.54463,0 +2.54807,1 +2.55071,0 +2.55393,1 +2.55722,0 +2.56066,1 +2.56441,0 +2.56786,1 +2.57114,0 +2.57372,1 +2.57747,0 +2.58005,1 +2.5838,0 +2.58777,1 +2.59106,0 +2.59364,1 +2.59714,0 +2.6,1 +2.60264,0 +2.60608,1 +2.60937,0 +2.61335,1 +2.61807,0 +2.62152,1 +2.62623,0 +2.63022,1 +2.63426,0 +2.63712,1 +2.64041,0 +2.6441,1 +2.64687,0 +2.6501,1 +2.65385,0 +2.65783,1 +2.66186,0 +2.66556,1 +2.66819,0 +2.67217,1 +2.67592,0 +2.69673,1 +2.69951,0 +2.70237,1 +2.70709,0 +2.71108,1 +2.71436,0 +2.71694,1 +2.72166,0 +2.72424,1 +2.72687,0 +2.72974,1 +2.73251,0 +2.73595,1 +2.73859,0 +2.74116,1 +2.7438,0 +2.74724,1 +2.74987,0 +2.75357,1 +2.75707,0 +2.75941,1 +2.76316,0 +2.76603,1 +2.77074,0 +2.77333,1 +2.77805,0 +2.78063,1 +2.78391,0 +2.78649,1 +2.78912,0 +2.7917,1 +2.79545,0 +2.79914,1 +2.80243,0 +2.80612,1 +2.80987,0 +2.81331,1 +2.81706,0 +2.82029,1 +2.82404,0 +2.82662,1 +2.83037,0 +2.83406,1 +2.8381,0 +2.84067,1 +2.84331,0 +2.84675,1 +2.84938,0 +2.85196,1 +2.85473,0 +2.85871,1 +2.86343,0 +2.8663,1 +2.86894,0 +2.87151,1 +2.87526,0 +2.87813,1 +2.88285,0 +2.88683,1 +2.89012,0 +2.89335,1 +2.89627,0 +2.89914,1 +2.90317,0 +2.90604,1 +2.90867,0 +2.91212,1 +2.91587,0 +2.93507,1 +2.93882,0 +2.94168,1 +2.94431,0 +2.94718,1 +2.95093,0 +2.9538,1 +2.95755,0 +2.96153,1 +2.96528,0 +2.96814,1 +2.97189,0 +2.97587,1 +2.9785,0 +2.98317,1 +2.98581,0 +2.98925,1 +2.99329,0 +2.99615,1 +3.00087,0 +3.00518,1 +3.00894,0 +3.01239,1 +3.01613,0 +3.019,1 +3.02177,0 +3.02522,1 +3.02773,0 +3.03142,1 +3.03405,0 +3.03692,1 +3.0402,0 +3.04307,1 +3.04779,0 +3.05177,1 +3.05649,0 +3.06019,1 +3.06394,0 +3.06717,1 +3.07189,0 +3.07587,1 +3.07879,0 +3.08277,1 +3.08749,0 +3.0922,1 +3.09513,0 +3.09882,1 +3.10146,0 +3.10544,1 +3.10872,0 +3.11216,1 +3.11509,0 +3.11853,1 +3.12117,0 +3.12486,1 +3.12861,0 +3.13147,1 +3.1344,0 +3.13809,1 +3.14101,0 +3.14388,1 +3.14763,0 +3.1505,1 +3.15327,0 +3.15753,1 +3.16129,0 +3.16498,1 +3.16827,0 +3.18646,1 +3.19118,0 +3.19549,1 +3.19827,0 +3.20113,1 +3.20488,0 +3.20886,1 +3.21358,0 +3.21829,1 +3.22204,0 +3.22671,1 +3.22935,0 +3.23279,1 +3.23751,0 +3.24222,1 +3.24745,0 +3.25091,1 +3.25383,0 +3.25727,1 +3.25991,0 +3.2636,1 +3.26623,0 +3.26881,1 +3.274,0 +3.27745,1 +3.28217,0 +3.28562,1 +3.28839,0 +3.29209,1 +3.29728,0 +3.30159,1 +3.30535,0 +3.30879,1 +3.31254,0 +3.31599,1 +3.31974,0 +3.32401,1 +3.32924,0 +3.33323,1 +3.33698,0 +3.33956,1 +3.34219,0 +3.34645,1 +3.35021,0 +3.35308,1 +3.35571,0 +3.35915,1 +3.3629,0 +3.36577,1 +3.36952,0 +3.37296,1 +3.377,0 +3.38045,1 +3.38308,0 +3.38774,1 +3.39103,0 +3.39569,1 +3.39898,0 +3.40243,1 +3.40715,0 +3.40973,1 +3.4125,0 +3.41619,1 +3.41994,0 +3.42461,1 +3.42836,0 +3.43123,1 +3.43642,0 +3.45801,1 +3.46078,0 +3.46364,1 +3.46739,0 +3.47026,1 +3.49636,0 +3.50034,1 +3.50298,0 +3.50584,1 +3.50988,0 +3.51386,1 +3.51649,0 +3.52019,1 +3.52282,0 +3.5254,1 +3.53011,0 +3.53482,1 +3.53746,0 +3.54144,1 +3.54616,0 +3.54903,1 +3.55307,0 +3.55878,1 +3.56207,0 +3.56577,1 +3.56905,0 +3.57303,1 +3.57595,0 +3.5794,1 +3.58315,0 +3.58659,1 +3.59131,0 +3.5953,1 +3.59905,0 +3.60249,1 +3.60768,0 +3.61056,1 +3.61384,0 +3.61753,1 +3.62225,0 +3.62595,1 +3.63114,0 +3.63585,1 +3.63989,0 +3.64276,1 +3.64651,0 +3.64937,1 +3.65312,0 +3.65682,1 +3.66153,0 +3.66498,1 +3.6679,0 +3.67077,1 +3.67549,0 +3.67948,1 +3.68211,0 +3.68555,1 +3.68884,0 +3.6917,1 +3.69434,0 +3.699,1 +3.70229,0 +3.70516,1 +3.70808,0 +3.71177,1 +3.71506,0 +3.71972,1 +3.72236,0 +3.74122,1 +3.74497,0 +3.74895,1 +3.75298,0 +3.75765,1 +3.76288,0 +3.76576,1 +3.77048,0 +3.77417,1 +3.77694,0 +3.78092,1 +3.78356,0 +3.78642,1 +3.79114,0 +3.79401,1 +3.79873,0 +3.80243,1 +3.80618,0 +3.80963,1 +3.81366,0 +3.81736,1 +3.82064,0 +3.82433,1 +3.82697,0 +3.82983,1 +3.83503,0 +3.83973,1 +3.84497,0 +3.84968,1 +3.85297,0 +3.85584,1 +3.85958,0 +3.86425,1 +3.86901,0 +3.87332,1 +3.87596,0 +3.87966,1 +3.88294,0 +3.8876,1 +3.89038,0 +3.89465,1 +3.89869,0 +3.90238,1 +3.9071,0 +3.91055,1 +3.91384,0 +3.9181,1 +3.92334,0 +3.92622,1 +3.93025,0 +3.93394,1 +3.93914,0 +3.94312,1 +3.94687,0 +3.95114,1 +3.95638,0 +3.96109,1 +3.96401,0 +3.96688,1 +3.9698,0 +3.97378,1 +3.97753,0 +3.98098,1 +3.98426,0 +3.98892,1 +3.99156,0 +3.99554,1 +4.00026,0 +4.01826,1 +4.02298,0 +4.02668,1 +4.02996,0 +4.03365,1 +4.03769,0 +4.04056,1 +4.04459,0 +4.04886,1 +4.05362,0 +4.05938,1 +4.06314,0 +4.06601,1 +4.07073,0 +4.0736,1 +4.07735,0 +4.08079,1 +4.08371,0 +4.08838,1 +4.09362,0 +4.09707,1 +4.10081,0 +4.10451,1 +4.10923,0 +4.11321,1 +4.11585,0 +4.11954,1 +4.12473,0 +4.12871,1 +4.13135,0 +4.13562,1 +4.13826,0 +4.14195,1 +4.14667,0 +4.15037,1 +4.15509,0 +4.1594,1 +4.16315,0 +4.16685,1 +4.17204,0 +4.17574,1 +4.17837,0 +4.18235,1 +4.18512,0 +4.18799,1 +4.19271,0 +4.19558,1 +4.19821,0 +4.20219,1 +4.20738,0 +4.21108,1 +4.21512,0 +4.21856,1 +4.22328,0 +4.2276,1 +4.23135,0 +4.2348,1 +4.23743,0 +4.24066,1 +4.24469,0 +4.24839,1 +4.25358,0 +4.25645,1 +4.25937,0 +4.26404,1 +4.26808,0 +4.27274,1 +4.27678,0 +4.29369,1 +4.29845,0 +4.30191,1 +4.30468,0 +4.31039,1 +4.31516,0 +4.31774,1 +4.32102,0 +4.32472,1 +4.32876,0 +4.3322,1 +4.33483,0 +4.33806,1 +4.34069,0 +4.34356,1 +4.34731,0 +4.35075,1 +4.35479,0 +4.35823,1 +4.36116,0 +4.36513,1 +4.3679,0 +4.37188,1 +4.37517,0 +4.37803,1 +4.38178,0 +4.38548,1 +4.3902,0 +4.3949,1 +4.39895,0 +4.40152,1 +4.40527,0 +4.40993,1 +4.41369,0 +4.41714,1 +4.42185,0 +4.42473,1 +4.42944,0 +4.43232,1 +4.43582,0 +4.44009,1 +4.44485,0 +4.44916,1 +4.45292,0 +4.45579,1 +4.4605,0 +4.46396,1 +4.46915,0 +4.47386,1 +4.47715,0 +4.48084,1 +4.48556,0 +4.48843,1 +4.49171,0 +4.49638,1 +4.50042,0 +4.50468,1 +4.50761,0 +4.51105,1 +4.51368,0 +4.51713,1 +4.52088,0 +4.52486,1 +4.52814,0 +4.53072,1 +4.53349,0 +4.53636,1 +4.53964,0 +4.55865,1 +4.56384,0 +4.56754,1 +4.57226,0 +4.57624,1 +4.57953,0 +4.5824,1 +4.58568,0 +4.58995,1 +4.59259,0 +4.59657,1 +4.60032,0 +4.60498,1 +4.60874,0 +4.6116,1 +4.61535,0 +4.61822,1 +4.62471,0 +4.6287,1 +4.63147,0 +4.63613,1 +4.63942,0 +4.64287,1 +4.64662,0 +4.65031,1 +4.65323,0 +4.65668,1 +4.65996,0 +4.66394,1 +4.66769,0 +4.67113,1 +4.67585,0 +4.68056,1 +4.68334,0 +4.68732,1 +4.69135,0 +4.69422,1 +4.6975,0 +4.7012,1 +4.70639,0 +4.70926,1 +4.71301,0 +4.71728,1 +4.72204,0 +4.72549,1 +4.72813,0 +4.73099,1 +4.73376,0 +4.73663,1 +4.73926,0 +4.74296,1 +4.74671,0 +4.74957,1 +4.75361,0 +4.75827,1 +4.76351,0 +4.76696,1 +4.77345,0 +4.77744,1 +4.78147,0 +4.78517,1 +4.7878,0 +4.79246,1 +4.7951,0 +4.79855,1 +4.80374,0 +4.80719,1 +4.80996,0 +4.82843,1 +4.83136,0 +4.83534,1 +4.84006,0 +4.84404,1 +4.84779,0 +4.85206,1 +4.85535,0 +4.85822,1 +4.86099,0 +4.86385,1 +4.86857,0 +4.87289,1 +4.87582,0 +4.87868,1 +4.88197,0 +4.88541,1 +4.88833,0 +4.89203,1 +4.89606,0 +4.90072,1 +4.90448,0 +4.90846,1 +4.91109,0 +4.91432,1 +4.91807,0 +4.92177,1 +4.92551,0 +4.92838,1 +4.93166,0 +4.93536,1 +4.93911,0 +4.94197,1 +4.94716,0 +4.95004,1 +4.95476,0 +4.95845,1 +4.96317,0 +4.96716,1 +4.96979,0 +4.97266,1 +4.97738,0 +4.98025,1 +4.98497,0 +4.98784,1 +4.99112,0 +4.9951,1 +4.99982,0 +5.00352,1 +5.00644,0 +5.00989,1 +5.01461,0 +5.01748,1 +5.02123,0 +5.0241,1 +5.02738,0 +5.03136,1 +5.03428,0 +5.03895,1 +5.04158,0 +5.04416,1 +5.04888,0 +5.05175,1 +5.05695,0 +5.05982,1 +5.06385,0 +5.06672,1 +5.06923,0 +5.08608,1 +5.08937,0 +5.09281,1 +5.09801,0 +5.10271,1 +5.10647,0 +5.11017,1 +5.11391,0 +5.11789,1 +5.12081,0 +5.12451,1 +5.12922,0 +5.13393,1 +5.13797,0 +5.14084,1 +5.14556,0 +5.14926,1 +5.15329,0 +5.15699,1 +5.16027,0 +5.16372,1 +5.16844,0 +5.17242,1 +5.17534,0 +5.17904,1 +5.18167,0 +5.18454,1 +5.18926,0 +5.19271,1 +5.19646,0 +5.1999,1 +5.20462,0 +5.20832,1 +5.21207,0 +5.21778,1 +5.22042,0 +5.22469,1 +5.22798,0 +5.23167,1 +5.23542,0 +5.238,1 +5.24129,0 +5.24473,1 +5.24736,0 +5.25023,1 +5.25398,0 +5.2597,1 +5.26247,0 +5.26713,1 +5.27089,0 +5.27434,1 +5.27762,0 +5.28049,1 +5.28312,0 +5.28599,1 +5.28927,0 +5.29214,1 +5.29589,0 +5.29958,1 +5.30286,0 +5.30544,1 +5.30872,0 +5.31444,1 +5.31968,0 +5.32399,1 +5.32775,0 +5.33144,1 +5.33519,0 +5.35252,1 +5.35724,0 +5.36011,1 +5.36386,0 +5.36852,1 +5.37329,0 +5.37674,1 +5.38049,0 +5.38515,1 +5.38891,0 +5.39289,1 +5.39664,0 +5.4009,1 +5.40567,0 +5.40937,1 +5.41409,0 +5.41778,1 +5.4225,0 +5.42595,1 +5.42888,0 +5.43354,1 +5.43758,0 +5.44127,1 +5.44502,0 +5.44789,1 +5.45261,0 +5.45548,1 +5.4584,0 +5.46306,1 +5.46682,0 +5.47051,1 +5.47343,0 +5.4763,1 +5.47958,0 +5.48356,1 +5.48649,0 +5.48993,1 +5.49512,0 +5.49911,1 +5.50174,0 +5.50461,1 +5.50724,0 +5.51011,1 +5.51483,0 +5.51853,1 +5.52181,0 +5.52526,1 +5.52929,0 +5.53216,1 +5.53591,0 +5.53877,1 +5.54281,0 +5.54568,1 +5.55039,0 +5.5551,1 +5.55774,0 +5.56061,1 +5.56436,0 +5.56805,1 +5.57068,0 +5.57535,1 +5.58011,0 +5.58381,1 +5.58673,0 +5.5914,1 +5.59515,0 +5.5986,1 +5.60235,0 +5.62014,1 +5.62485,0 +5.62917,1 +5.63292,0 +5.63719,1 +5.64123,0 +5.6418,1 +5.64457,0 +5.64923,1 +5.65298,0 +5.65668,1 +5.66043,0 +5.66412,1 +5.6674,0 +5.67085,1 +5.67557,0 +5.67815,1 +5.68107,0 +5.68574,1 +5.6905,0 +5.69449,1 +5.6992,0 +5.70208,1 +5.70611,0 +5.70981,1 +5.71452,0 +5.7174,1 +5.72017,0 +5.72414,1 +5.72743,0 +5.7303,1 +5.73501,0 +5.73846,1 +5.74366,0 +5.74653,1 +5.74981,0 +5.75448,1 +5.75712,0 +5.76178,1 +5.76455,0 +5.76742,1 +5.77214,0 +5.77559,1 +5.78031,0 +5.78429,1 +5.78693,0 +5.78979,1 +5.79383,0 +5.79781,1 +5.80156,0 +5.805,1 +5.80764,0 +5.8105,1 +5.8157,0 +5.81939,1 +5.82217,0 +5.82642,1 +5.83119,0 +5.83489,1 +5.84008,0 +5.84295,1 +5.8467,0 +5.84957,1 +5.85429,0 +5.85716,1 +5.86091,0 +5.86435,1 +5.86699,0 +5.88755,1 +5.89019,0 +5.89417,1 +5.89709,0 +5.90079,1 +5.90454,0 +5.9092,1 +5.91324,0 +5.9179,1 +5.92267,0 +5.92738,1 +5.93214,0 +5.93645,1 +5.94021,0 +5.9439,1 +5.94765,0 +5.9511,1 +5.95582,0 +5.95927,1 +5.9633,0 +5.96675,1 +5.97194,0 +5.97539,1 +5.97943,0 +5.98409,1 +5.98785,0 +5.99071,1 +5.99446,0 +5.99791,1 +6.00054,0 +6.00481,1 +6.00957,0 +6.01428,1 +6.01757,0 +6.02102,1 +6.02365,0 +6.02652,1 +6.02944,0 +6.03313,1 +6.03785,0 +6.04184,1 +6.04512,0 +6.0491,1 +6.05427,0 +6.05715,1 +6.05992,0 +6.06361,1 +6.06833,0 +6.07304,1 +6.0778,0 +6.08251,1 +6.0858,0 +6.08866,1 +6.09159,0 +6.09625,1 +6.10101,0 +6.10471,1 +6.10846,0 +6.11273,1 +6.11649,0 +6.12018,1 +6.12281,0 +6.12568,1 +6.1304,0 +6.1351,1 +6.13886,0 +6.14313,1 +6.14789,0 +6.16371,1 +6.16746,0 +6.17115,1 +6.1749,0 +6.17859,1 +6.18136,0 +6.18423,1 +6.18895,0 +6.19265,1 +6.19737,0 +6.20135,1 +6.20607,0 +6.20894,1 +6.21366,0 +6.21736,1 +6.22111,0 +6.22509,1 +6.22837,0 +6.23124,1 +6.23499,0 +6.23843,1 +6.2412,0 +6.24407,1 +6.24879,0 +6.25277,1 +6.25749,0 +6.26094,1 +6.26387,0 +6.26673,1 +6.27145,0 +6.27432,1 +6.27696,0 +6.28018,1 +6.28282,0 +6.28626,1 +6.2903,0 +6.29457,1 +6.29933,0 +6.3022,1 +6.30595,0 +6.31022,1 +6.31397,0 +6.31767,1 +6.3203,0 +6.32428,1 +6.32832,0 +6.33176,1 +6.33453,0 +6.33822,1 +6.34151,0 +6.34549,1 +6.34826,0 +6.35112,1 +6.35441,0 +6.35728,1 +6.36199,0 +6.36631,1 +6.36895,0 +6.37239,1 +6.37643,0 +6.37929,1 +6.38193,0 +6.38562,1 +6.39034,0 +6.39404,1 +6.39876,0 +6.40221,1 +6.40693,0 +6.42556,1 +6.42833,0 +6.43202,1 +6.43674,0 +6.44105,1 +6.44398,0 +6.44767,1 +6.45096,0 +6.45465,1 +6.4584,0 +6.46184,1 +6.46588,0 +6.46957,1 +6.47221,0 +6.47507,1 +6.47882,0 +6.48227,1 +6.48699,0 +6.49044,1 +6.49476,0 +6.49907,1 +6.50384,0 +6.50729,1 +6.51104,0 +6.5157,1 +6.51899,0 +6.52365,1 +6.52741,0 +6.53027,1 +6.53291,0 +6.5366,1 +6.54035,0 +6.54462,1 +6.54837,0 +6.55264,1 +6.55668,0 +6.56135,1 +6.5651,0 +6.56879,1 +6.57208,0 +6.57577,1 +6.57906,0 +6.58372,1 +6.58636,0 +6.59005,1 +6.59268,0 +6.59735,1 +6.59999,0 +6.60465,1 +6.60941,0 +6.61228,1 +6.617,0 +6.62171,1 +6.62648,0 diff --git a/unit_tests/tests/trigger/test_real_noisy_trigger.cpp b/unit_tests/tests/trigger/test_real_noisy_trigger.cpp new file mode 100644 index 0000000000..3928dc605f --- /dev/null +++ b/unit_tests/tests/trigger/test_real_noisy_trigger.cpp @@ -0,0 +1,64 @@ +#include "pch.h" +#include "logicdata_csv_reader.h" + +static void testNoOverdwell(const char* file, bool instantRpm) { + CsvReader reader(1, /* vvtCount */ 0); + + reader.open(file); + EngineTestHelper eth(engine_type_e::TEST_ENGINE); + engineConfiguration->isFasterEngineSpinUpEnabled = true; + engineConfiguration->alwaysInstantRpm = instantRpm; + + engineConfiguration->cylindersCount = 6; + engineConfiguration->firingOrder = FO_1_5_3_6_2_4; + engineConfiguration->globalTriggerAngleOffset = 155; + engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; + + // engineConfiguration->cylindersCount = 1; + // engineConfiguration->firingOrder = FO_1; + // engineConfiguration->globalTriggerAngleOffset = 35; + + engineConfiguration->timingMode = TM_FIXED; + engineConfiguration->fixedTiming = 14.69; + + engineConfiguration->trigger.customTotalToothCount = 36; + engineConfiguration->trigger.customSkippedToothCount = 2; + eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL); + + engineConfiguration->isIgnitionEnabled = true; + engineConfiguration->isInjectionEnabled = false; + + std::vector coilStartTimes(12); + + engine->onIgnitionEvent = [&](IgnitionEvent* event, bool state) { + if (state) { + coilStartTimes[event->cylinderNumber] = getTimeNowNt(); + } else { + auto actualDwell = 1e-3 * NT2USF(getTimeNowNt() - coilStartTimes[event->cylinderNumber]); + + EXPECT_LT(actualDwell, 50) << "Overdwell on cylinder " << (int)event->cylinderNumber; + } + }; + + while (reader.haveMore()) { + reader.processLine(ð); + } + + // nothing to check here, just that no coils got stuck on +} + +TEST(RealNoisyTrigger, AvoidOverdwell1NoInstant) { + testNoOverdwell("tests/trigger/resources/noisy-trigger-1.csv", false); +} + +TEST(RealNoisyTrigger, AvoidOverdwell1WithInstant) { + testNoOverdwell("tests/trigger/resources/noisy-trigger-1.csv", true); +} + +TEST(RealNoisyTrigger, AvoidOverdwell2NoInstant) { + testNoOverdwell("tests/trigger/resources/noisy-trigger-2.csv", false); +} + +TEST(RealNoisyTrigger, AvoidOverdwell2WithInstant) { + testNoOverdwell("tests/trigger/resources/noisy-trigger-2.csv", true); +}