test for noisy triggers and another fix

This commit is contained in:
Matthew Kennedy 2024-04-12 11:29:38 -07:00 committed by rusefillc
parent 48feb535af
commit b06d16a548
5 changed files with 2111 additions and 0 deletions

View File

@ -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
}

View File

@ -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 \

View File

@ -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
1 0 0
2 8e-05 1
3 0.00383033 0
4 0.00654333 1
5 0.009637 0
6 0.012213 1
7 0.0153067 0
8 0.018751 1
9 0.0211483 0
10 0.0238613 1
11 0.0259747 0
12 0.0283137 1
13 0.0314077 0
14 0.0341207 1
15 0.036415 0
16 0.038651 1
17 0.0410487 0
18 0.043388 1
19 0.0456823 0
20 0.0491263 1
21 0.0515237 0
22 0.0542367 1
23 0.057739 0
24 0.0600783 1
25 0.0627123 0
26 0.0651643 1
27 0.0672777 0
28 0.0697293 1
29 0.0718427 0
30 0.0745557 1
31 0.07719 0
32 0.079903 1
33 0.0825373 0
34 0.084989 1
35 0.0873863 0
36 0.0898383 1
37 0.0924727 0
38 0.0959167 1
39 0.0990107 0
40 0.102455 1
41 0.105957 0
42 0.107932 1
43 0.110226 0
44 0.113092 1
45 0.116186 0
46 0.118525 1
47 0.120819 0
48 0.122794 1
49 0.124907 0
50 0.127049 1
51 0.130143 0
52 0.133178 1
53 0.136272 0
54 0.139716 1
55 0.143219 0
56 0.145558 1
57 0.14906 0
58 0.151926 1
59 0.15422 0
60 0.166579 1
61 0.170081 0
62 0.172533 1
63 0.176035 0
64 0.179479 1
65 0.182251 0
66 0.184702 1
67 0.186816 0
68 0.188958 1
69 0.191729 0
70 0.194764 1
71 0.197858 0
72 0.199833 1
73 0.202033 0
74 0.204485 1
75 0.207119 0
76 0.209571 1
77 0.211969 0
78 0.214308 1
79 0.217231 0
80 0.219373 1
81 0.221668 0
82 0.224381 1
83 0.226494 0
84 0.229207 1
85 0.232709 0
86 0.236154 1
87 0.239656 0
88 0.242108 1
89 0.244879 0
90 0.247331 1
91 0.249625 0
92 0.25307 1
93 0.255364 0
94 0.257816 1
95 0.26011 0
96 0.26245 1
97 0.265084 0
98 0.267536 1
99 0.27017 0
100 0.272145 1
101 0.274439 0
102 0.276891 1
103 0.280393 0
104 0.282845 1
105 0.28514 0
106 0.287479 1
107 0.289592 0
108 0.292048 1
109 0.295546 0
110 0.297886 1
111 0.300283 0
112 0.302622 1
113 0.304735 0
114 0.307075 1
115 0.309275 0
116 0.312719 1
117 0.31549 0
118 0.317829 1
119 0.320923 0
120 0.322898 1
121 0.325011 0
122 0.327463 1
123 0.329861 0
124 0.332574 1
125 0.334868 0
126 0.337207 1
127 0.340709 0
128 0.35643 1
129 0.359933 0
130 0.362272 1
131 0.365365 0
132 0.36881 1
133 0.370923 0
134 0.372898 1
135 0.3764 0
136 0.378739 1
137 0.381374 0
138 0.384818 1
139 0.386931 0
140 0.38927 1
141 0.392364 0
142 0.39494 1
143 0.39714 0
144 0.399855 1
145 0.402624 0
146 0.406068 1
147 0.408363 0
148 0.41083 1
149 0.413926 0
150 0.416376 1
151 0.419878 0
152 0.421853 1
153 0.425355 0
154 0.427807 1
155 0.430441 0
156 0.433017 1
157 0.435789 0
158 0.438364 1
159 0.441458 0
160 0.443797 1
161 0.446092 0
162 0.448067 1
163 0.451569 0
164 0.454282 1
165 0.457785 0
166 0.46036 1
167 0.463454 0
168 0.465596 1
169 0.46869 0
170 0.471142 1
171 0.473539 0
172 0.476252 1
173 0.479755 0
174 0.482468 1
175 0.484866 0
176 0.487578 1
177 0.489537 0
178 0.491989 1
179 0.495491 0
180 0.498935 1
181 0.502438 0
182 0.505473 1
183 0.508245 0
184 0.510584 1
185 0.512697 0
186 0.516141 1
187 0.518436 0
188 0.520888 1
189 0.524393 0
190 0.526729 1
191 0.530232 0
192 0.532571 1
193 0.535205 0
194 0.537544 1
195 0.540178 0
196 0.553445 1
197 0.555739 0
198 0.558191 1
199 0.560305 0
200 0.562756 1
201 0.565154 0
202 0.567493 1
203 0.570127 0
204 0.572269 1
205 0.574666 0
206 0.577242 1
207 0.580745 0
208 0.58272 1
209 0.584833 0
210 0.587409 1
211 0.589806 0
212 0.592258 1
213 0.595029 0
214 0.597368 1
215 0.600292 0
216 0.602744 1
217 0.605141 0
218 0.607481 1
219 0.610574 0
220 0.613026 1
221 0.61566 0
222 0.618526 1
223 0.62082 0
224 0.624264 1
225 0.627036 0
226 0.629749 1
227 0.633499 0
228 0.635951 1
229 0.638247 0
230 0.64022 1
231 0.642618 0
232 0.64507 1
233 0.648572 0
234 0.651024 1
235 0.653421 0
236 0.656865 1
237 0.65916 0
238 0.661612 1
239 0.663812 0
240 0.666264 1
241 0.668898 0
242 0.671934 1
243 0.675027 0
244 0.677479 1
245 0.680982 0
246 0.684426 1
247 0.686823 0
248 0.689162 1
249 0.691797 0
250 0.69451 1
251 0.69671 0
252 0.699286 1
253 0.701244 0
254 0.703696 1
255 0.705991 0
256 0.708567 1
257 0.711201 0
258 0.71354 1
259 0.717043 0
260 0.719279 1
261 0.721573 0
262 0.724025 1
263 0.726796 0
264 0.740317 1
265 0.742517 0
266 0.744969 1
267 0.747603 0
268 0.749942 1
269 0.752236 0
270 0.754688 1
271 0.756983 0
272 0.759435 1
273 0.761729 0
274 0.764442 1
275 0.767076 0
276 0.769415 1
277 0.77171 0
278 0.774049 1
279 0.776446 0
280 0.778421 1
281 0.780454 0
282 0.782794 1
283 0.785088 0
284 0.787063 1
285 0.78946 0
286 0.791912 1
287 0.794025 0
288 0.79747 1
289 0.800563 0
290 0.804007 1
291 0.807101 0
292 0.809553 1
293 0.811848 0
294 0.813822 1
295 0.816117 0
296 0.819564 1
297 0.823064 0
298 0.825515 1
299 0.82815 0
300 0.830601 1
301 0.832896 0
302 0.83634 1
303 0.83854 0
304 0.840515 1
305 0.842477 0
306 0.844926 1
307 0.84722 0
308 0.849934 1
309 0.852331 0
310 0.854783 1
311 0.85718 0
312 0.859322 1
313 0.86172 0
314 0.864171 1
315 0.866371 0
316 0.868348 1
317 0.87098 0
318 0.873217 1
319 0.875176 0
320 0.877888 1
321 0.881391 0
322 0.883366 1
323 0.885763 0
324 0.889207 1
325 0.892301 0
326 0.89464 1
327 0.898143 0
328 0.900719 1
329 0.902919 0
330 0.904894 1
331 0.907987 0
332 0.922155 1
333 0.925249 0
334 0.927485 1
335 0.930119 0
336 0.933563 1
337 0.935857 0
338 0.937999 1
339 0.939958 0
340 0.942297 1
341 0.944934 0
342 0.946906 1
343 0.950409 0
344 0.952384 1
345 0.954497 0
346 0.956836 1
347 0.960339 0
348 0.96279 1
349 0.965188 0
350 0.967764 1
351 0.970535 0
352 0.97251 1
353 0.974623 0
354 0.976598 1
355 0.980101 0
356 0.982552 1
357 0.984847 0
358 0.987712 1
359 0.989826 0
360 0.993273 1
361 0.99547 0
362 0.998335 1
363 1.00054 0
364 1.00277 1
365 1.00587 0
366 1.0089 1
367 1.0124 0
368 1.01585 1
369 1.01824 0
370 1.02058 1
371 1.02298 0
372 1.02643 1
373 1.02993 0
374 1.03227 1
375 1.03456 0
376 1.03701 1
377 1.04011 0
378 1.04268 1
379 1.04498 0
380 1.04842 1
381 1.05106 0
382 1.0534 1
383 1.0569 0
384 1.05887 1
385 1.06151 0
386 1.06422 1
387 1.06685 0
388 1.06919 1
389 1.07294 0
390 1.07492 1
391 1.07801 0
392 1.08073 1
393 1.08284 0
394 1.0857 1
395 1.08782 0
396 1.09016 1
397 1.09325 0
398 1.09612 1
399 1.09841 0
400 1.11118 1
401 1.11395 0
402 1.11667 1
403 1.11878 0
404 1.12112 1
405 1.12352 0
406 1.12696 1
407 1.12959 0
408 1.13205 1
409 1.13555 0
410 1.13812 1
411 1.1409 0
412 1.14304 1
413 1.14567 0
414 1.14812 1
415 1.15052 0
416 1.15286 1
417 1.15497 0
418 1.15842 1
419 1.16119 0
420 1.16364 1
421 1.16714 0
422 1.17059 1
423 1.17288 0
424 1.17633 1
425 1.17844 0
426 1.18078 1
427 1.18318 0
428 1.18563 1
429 1.18913 0
430 1.19257 1
431 1.19567 0
432 1.19911 1
433 1.20261 0
434 1.20495 1
435 1.20715 0
436 1.2106 1
437 1.21256 0
438 1.21559 1
439 1.21755 0
440 1.21953 1
441 1.22149 0
442 1.22435 1
443 1.22675 0
444 1.23019 1
445 1.23329 0
446 1.23543 1
447 1.23852 0
448 1.24076 1
449 1.24287 0
450 1.24501 1
451 1.24731 0
452 1.25075 1
453 1.25315 0
454 1.2556 1
455 1.25869 0
456 1.26214 1
457 1.26425 0
458 1.26697 1
459 1.27072 0
460 1.27343 1
461 1.27563 0
462 1.27808 1
463 1.28158 0
464 1.28403 1
465 1.28633 0
466 1.28878 1
467 1.29089 0
468 1.30358 1
469 1.30597 0
470 1.30942 1
471 1.31171 0
472 1.31417 1
473 1.31656 0
474 1.32001 1
475 1.3224 0
476 1.32585 1
477 1.32935 0
478 1.33279 1
479 1.33543 0
480 1.33777 1
481 1.33988 0
482 1.34222 1
483 1.34572 0
484 1.34817 1
485 1.35068 0
486 1.35302 1
487 1.35553 0
488 1.35857 1
489 1.36207 0
490 1.36452 1
491 1.36729 0
492 1.36927 1
493 1.37236 0
494 1.3747 1
495 1.37747 0
496 1.37981 1
497 1.38331 0
498 1.38565 1
499 1.38805 0
500 1.3905 1
501 1.39401 0
502 1.39646 1
503 1.39923 0
504 1.40137 1
505 1.40348 0
506 1.40582 1
507 1.40812 0
508 1.41083 1
509 1.41312 0
510 1.41558 1
511 1.41754 0
512 1.42025 1
513 1.42254 0
514 1.42599 1
515 1.42838 0
516 1.43084 1
517 1.43304 0
518 1.43549 1
519 1.43789 0
520 1.44133 1
521 1.44373 0
522 1.44607 1
523 1.44818 0
524 1.45063 1
525 1.45303 0
526 1.45574 1
527 1.45924 0
528 1.46158 1
529 1.46435 0
530 1.46669 1
531 1.46899 0
532 1.47133 1
533 1.47353 0
534 1.47697 1
535 1.47961 0
536 1.49356 1
537 1.49585 0
538 1.49819 1

File diff suppressed because it is too large Load Diff

View File

@ -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<efitick_t> 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(&eth);
}
// 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);
}