From f5576b05d9c4eac403fa8f3f8bff0e443fd7abf9 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 23 Aug 2022 23:32:14 -0400 Subject: [PATCH] VQ trigger gaps improvement fix #4469 nice, unit test is happier! --- firmware/CHANGELOG.md | 1 + firmware/controllers/trigger/decoders/trigger_nissan.cpp | 6 +++++- .../tests/trigger/test_real_cranking_nissan_vq40.cpp | 7 +++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index a9131502fd..7276eeac59 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -31,6 +31,7 @@ Release template (copy/paste this for new release): - Inverted vvt control #4464 - Lua canRxAdd bus parameter handling #4467 - STM32Bootloader driver install from console requests elevation #4313 + - VQ trigger gaps improvement #4469 ### Removed diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index 53c91fe7e7..d953315c75 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -64,7 +64,6 @@ void initializeNissanVQvvt(TriggerWaveform *s) { } void makeNissanPattern(TriggerWaveform* s, size_t halfCylinderCount, size_t totalWheel, size_t missing) { - s->setTriggerSynchronizationGap(0.33); auto toothAngle = 360.0f / totalWheel; @@ -83,9 +82,13 @@ void initializeNissanVQ35crank(TriggerWaveform *s) { s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR); s->tdcPosition = 675; + s->useRiseEdge = true; // 6 cylinder = 36 tooth wheel, missing 2 teeth in 3 spots makeNissanPattern(s, 3, 36, 2); + s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.2, 0.5); + s->setTriggerSynchronizationGap3(/*gapIndex*/1, 2, 4); + s->setTriggerSynchronizationGap3(/*gapIndex*/2, 0.6, 1.4); } void initializeNissanMR18crank(TriggerWaveform *s) { @@ -95,6 +98,7 @@ void initializeNissanMR18crank(TriggerWaveform *s) { // 4 cylinder = 36 tooth wheel, missing 2 teeth in 2 spots makeNissanPattern(s, 2, 36, 2); + s->setTriggerSynchronizationGap(0.33); } void initializeNissanQR25crank(TriggerWaveform *s) { diff --git a/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp b/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp index 0f2c155321..1bd0053ae7 100644 --- a/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp +++ b/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp @@ -34,8 +34,7 @@ TEST(realCrankingVQ40, normalCranking) { ASSERT_EQ(101, round(Sensor::getOrZero(SensorType::Rpm)))<< reader.lineIndex(); // TODO: why warnings? - ASSERT_EQ(3, eth.recentWarnings()->getCount()); - ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, eth.recentWarnings()->get(0).Code); - ASSERT_EQ(CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(1).Code); // this is from a coil being protected by overdwell protection - ASSERT_EQ(CUSTOM_SYNC_ERROR, eth.recentWarnings()->get(2).Code); + ASSERT_EQ(2, eth.recentWarnings()->getCount()); + ASSERT_EQ(CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(0).Code); // this is from a coil being protected by overdwell protection + ASSERT_EQ(CUSTOM_SYNC_ERROR, eth.recentWarnings()->get(1).Code); }