From 6f5bed28d9205c58540348eaf2fe8dab25f39a51 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 25 Sep 2022 06:14:29 -0700 Subject: [PATCH] better k gaps (#4623) --- firmware/config/engines/honda_k_dbc.cpp | 1 + .../trigger/decoders/trigger_honda.cpp | 4 +-- unit_tests/tests/trigger/test_real_k20.cpp | 28 +++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index 94238c7e39..8e00eba37c 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -34,6 +34,7 @@ void setProteusHondaElement2003() { engineConfiguration->vvtMode[0] = VVT_HONDA_K_INTAKE; engineConfiguration->vvtMode[1] = VVT_HONDA_K_EXHAUST; engineConfiguration->vvtOffsets[0] = -41; + engineConfiguration->vvtOffsets[1] = 171; engineConfiguration->map.sensor.type = MT_DENSO183; engineConfiguration->injector.flow = 270; diff --git a/firmware/controllers/trigger/decoders/trigger_honda.cpp b/firmware/controllers/trigger/decoders/trigger_honda.cpp index 2e3b5fd94f..9b12ef7649 100644 --- a/firmware/controllers/trigger/decoders/trigger_honda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_honda.cpp @@ -102,8 +102,8 @@ void configureHondaK_12_1(TriggerWaveform *s) { void configureHondaK_4_1(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, SyncEdge::Rise); - s->setTriggerSynchronizationGap3(/*gapIndex*/0, 1.11, 2.38); - s->setTriggerSynchronizationGap3(/*gapIndex*/1, 0.28, 0.474); + s->setTriggerSynchronizationGap3(/*gapIndex*/0, 1.5, 4.5); // nominal 2.27 + s->setTriggerSynchronizationGap3(/*gapIndex*/1, 0.1, 0.5); // nominal 0.28 angle_t start = 55.5; angle_t end = 70.5; diff --git a/unit_tests/tests/trigger/test_real_k20.cpp b/unit_tests/tests/trigger/test_real_k20.cpp index e05b963e9f..f6525f791a 100644 --- a/unit_tests/tests/trigger/test_real_k20.cpp +++ b/unit_tests/tests/trigger/test_real_k20.cpp @@ -14,22 +14,22 @@ TEST(realk20, cranking) { EngineTestHelper eth (PROTEUS_HONDA_K); - while (reader.haveMore() && reader.lineIndex() < 101) { - reader.processLine(ð); - ASSERT_EQ(getExhaustIndex(), 0) << "Skipping until first exhaust event " << reader.lineIndex(); - } - - reader.haveMore(); - reader.processLine(ð); - ASSERT_EQ(getExhaustIndex(), 1) << "First exhaust event " << reader.lineIndex(); - - while (reader.haveMore()) { reader.processLine(ð); - ASSERT_TRUE(getExhaustIndex() != 0 ) << "At line " << reader.lineIndex(); + + // TODO + // float vvtI = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); + // if (vvtI != 0) { + // EXPECT_TRUE(vvtI > -10 && vvtI < 10); + // } + + float vvtE = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/1); + if (vvtE != 0) { + EXPECT_TRUE(vvtE > -10 && vvtE < 10); + } + } - ASSERT_EQ(173, getExhaustIndex()); // huh? not synching? - - ASSERT_EQ(1182, round(Sensor::getOrZero(SensorType::Rpm))); + EXPECT_EQ(1182, round(Sensor::getOrZero(SensorType::Rpm))); + EXPECT_TRUE(getTriggerCentral()->triggerState.hasSynchronizedPhase()); }