toyota 3 tooth cam decoder #237

This commit is contained in:
Matthew Kennedy 2023-09-13 22:30:14 -07:00
parent a47bc88eae
commit a6a25ba020
4 changed files with 1632 additions and 6 deletions

View File

@ -299,14 +299,15 @@ void hwHandleVvtCamSignal(bool isRising, efitick_t nowNt, int index) {
}
switch(engineConfiguration->vvtMode[camIndex]) {
case VVT_2JZ:
// we do not know if we are in sync or out of sync, so we have to be looking for both possibilities
if ((currentPosition < engineConfiguration->scriptSetting[4] || currentPosition > engineConfiguration->scriptSetting[5]) &&
(currentPosition < engineConfiguration->scriptSetting[4] + 360 || currentPosition > engineConfiguration->scriptSetting[5] + 360)) {
// outside of the expected range
case VVT_2JZ: {
// Consider the tooth in the first 1/3 of the engine phase
bool inRange = angleFromPrimarySyncPoint > 0 && angleFromPrimarySyncPoint < (720 / 3);
if (!inRange) {
return;
}
break;
} break;
default:
// else, do nothing
break;

View File

@ -20,6 +20,7 @@ TESTS_SRC_CPP = \
tests/trigger/test_real_gm_24x.cpp \
tests/trigger/test_real_k24a2.cpp \
tests/trigger/test_real_k20.cpp \
tests/trigger/test_real_toyota_3_tooth_cam.cpp \
tests/trigger/test_map_cam.cpp \
tests/trigger/test_rpm_multiplier.cpp \
tests/trigger/test_quad_cam.cpp \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
#include "pch.h"
#include "logicdata_csv_reader.h"
TEST(realToyota3ToothCam, running) {
CsvReader reader(1, /* vvtCount */ 1);
reader.open("tests/trigger/resources/toyota_3_tooth_cam.csv");
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->isFasterEngineSpinUpEnabled = true;
engineConfiguration->alwaysInstantRpm = true;
engineConfiguration->vvtMode[0] = VVT_2JZ;
engineConfiguration->vvtOffsets[0] = 152.583f;
engineConfiguration->trigger.customTotalToothCount = 36;
engineConfiguration->trigger.customSkippedToothCount = 2;
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
bool hasSeenFirstVvt = false;
while (reader.haveMore()) {
reader.processLine(&eth);
float vvt1 = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0);
if (vvt1 != 0) {
if (!hasSeenFirstVvt) {
EXPECT_NEAR(vvt1, 0, /*precision*/1);
hasSeenFirstVvt = true;
}
// cam position should never be reported outside of correct range
EXPECT_TRUE(vvt1 > -3 && vvt1 < 3);
}
}
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0), 0, 1);
ASSERT_EQ(3078, round(Sensor::getOrZero(SensorType::Rpm)));
// TODO: why warnings?
ASSERT_EQ(1, eth.recentWarnings()->getCount());
ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(0).Code);
}