From f53937ae879ea900903eaeb5ba4cb33dd589ab65 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 29 Mar 2023 22:57:31 -0400 Subject: [PATCH] K only:hellen-honda-k --- firmware/config/engines/honda_k_dbc.cpp | 2 +- .../controllers/trigger/trigger_central.cpp | 22 +++++++++---------- unit_tests/tests/trigger/test_real_k20.cpp | 9 ++++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index cd29d1658a..c03fbb1804 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -24,7 +24,7 @@ void setHondaK() { engineConfiguration->vvtMode[0] = VVT_HONDA_K_INTAKE; // also known as 'CAM sync'? i am pretty confused at this point engineConfiguration->vvtMode[1] = VVT_HONDA_K_EXHAUST; - engineConfiguration->vvtOffsets[0] = -41; + engineConfiguration->vvtOffsets[0] = -21; engineConfiguration->vvtOffsets[1] = 171 + magic; // set cranking_fuel 15 diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 987101ffcf..740c88af31 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -358,6 +358,17 @@ void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) { auto vvtPosition = engineConfiguration->vvtOffsets[bankIndex * CAMS_PER_BANK + camIndex] - currentPosition; + // this could be just an 'if' but let's have it expandable for future use :) + switch(engineConfiguration->vvtMode[camIndex]) { + case VVT_HONDA_K_INTAKE: + // honda K has four tooth in VVT intake trigger, so we just wrap each of those to 720 / 4 + vvtPosition = wrapVvt(vvtPosition, 180); + break; + default: + // else, do nothing + break; + } + // Only do engine sync using one cam, other cams just provide VVT position. if (index == engineConfiguration->engineSyncCam) { angle_t crankOffset = adjustCrankPhase(camIndex); @@ -366,17 +377,6 @@ void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) { vvtPosition -= crankOffset; vvtPosition = wrapVvt(vvtPosition, FOUR_STROKE_CYCLE_DURATION); - // this could be just an 'if' but let's have it expandable for future use :) - switch(engineConfiguration->vvtMode[camIndex]) { - case VVT_HONDA_K_INTAKE: - // honda K has four tooth in VVT intake trigger, so we just wrap each of those to 720 / 4 - vvtPosition = wrapVvt(vvtPosition, 180); - break; - default: - // else, do nothing - break; - } - if (absF(angleFromPrimarySyncPoint) < 7) { /** * we prefer not to have VVT sync right at trigger sync so that we do not have phase detection error if things happen a bit in diff --git a/unit_tests/tests/trigger/test_real_k20.cpp b/unit_tests/tests/trigger/test_real_k20.cpp index 82146b420b..12654b8dd9 100644 --- a/unit_tests/tests/trigger/test_real_k20.cpp +++ b/unit_tests/tests/trigger/test_real_k20.cpp @@ -17,11 +17,10 @@ TEST(realk20, cranking) { while (reader.haveMore()) { reader.processLine(ð); - // TODO - // float vvtI = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); - // if (vvtI != 0) { - // EXPECT_TRUE(vvtI > -10 && vvtI < 10); - // } + 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) {