Nissan VVT trigger decoder #2887

This commit is contained in:
Andrey 2021-07-21 23:08:56 -04:00
parent 39b9211588
commit 2a07c3df27
6 changed files with 36 additions and 4 deletions

View File

@ -12,6 +12,9 @@ void setHellen121nissan(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ;
// we have this here and not in board_configuration.cpp so that unit test would get this value
engineConfiguration->invertCamVVTSignal = true;
engineConfiguration->vvtOffsets[0] = NISSAN_VQ_VVT_OFFSET;
engineConfiguration->vvtOffsets[1 * CAMS_PER_BANK] = NISSAN_VQ_VVT_OFFSET - NISSAN_VQ_CAM_OFFSET;
}

View File

@ -633,7 +633,8 @@ void TriggerState::decodeTriggerEvent(
float gap = 1.0 * toothDurations[0] / toothDurations[1];
for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
printf("index=%d: gap=%.2f expected from %.2f to %.2f error=%s\r\n",
printf("%sindex=%d: gap=%.2f expected from %.2f to %.2f error=%s\r\n",
triggerConfiguration.PrintPrefix,
i,
gap,
triggerShape.syncronizationRatioFrom[i],

View File

@ -72,6 +72,7 @@ void CsvReader::processLine(EngineTestHelper *eth) {
}
efitick_t nowNt = getTimeNowNt();
// todo: we invert VVT but we do not invert trigger input!!!
hwHandleShaftSignal(index, newState[index], nowNt PASS_ENGINE_PARAMETER_SUFFIX);
currentState[index] = newState[index];
@ -83,7 +84,7 @@ void CsvReader::processLine(EngineTestHelper *eth) {
}
efitick_t nowNt = getTimeNowNt();
trigger_value_e event = newVvtState[vvtIndex] ? TV_RISE : TV_FALL;
trigger_value_e event = newVvtState[vvtIndex] ^ engineConfiguration->invertCamVVTSignal ? TV_RISE : TV_FALL;
hwHandleVvtCamSignal(event, nowNt, vvtIndex PASS_ENGINE_PARAMETER_SUFFIX);
currentVvtState[vvtIndex] = newVvtState[vvtIndex];

View File

@ -8,6 +8,7 @@ TESTS_SRC_CPP = \
tests/trigger/test_2jz_vvt.cpp \
tests/trigger/test_real_cranking_miata_NA.cpp \
tests/trigger/test_real_cranking_miata_na6.cpp \
tests/trigger/test_real_cranking_nissan_vq40.cpp \
tests/trigger/test_real_volkswagen.cpp \
tests/trigger/test_real_nb2_cranking.cpp \
tests/trigger/test_rpm_multiplier.cpp \

View File

@ -0,0 +1,27 @@
/*
* @file test_real_cranking_nissan_vq40.cpp
*
* @date Jul 21, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#include "engine_test_helper.h"
#include "logicdata_csv_reader.h"
TEST(realCrankingVQ40, normalCranking) {
CsvReader reader(1, /* vvtCount */ 2);
int indeces[] = {0};
reader.open("tests/trigger/resources/nissan_vq40_cranking-1.csv", indeces);
WITH_ENGINE_TEST_HELPER (ET_HELLEN_121_NISSAN);
while (reader.haveMore()) {
reader.processLine(&eth);
}
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0), -46.817, 1e-2);
// todo: read second channel
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/0), 0, 1e-2);
ASSERT_EQ(241, GET_RPM())<< reader.lineIndex();
}

View File

@ -5,7 +5,6 @@
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "engine_test_helper.h"
#include "logicdata_csv_reader.h"