fix 36-2-1 trigger (#4645)

* fix

* test files

* test real 4b11

* test.mk

* better angle error math

* test GM too

* changelog
This commit is contained in:
Matthew Kennedy 2022-10-09 18:22:05 -07:00 committed by GitHub
parent 83cdbdd0b4
commit aa881efe89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2111 additions and 7 deletions

View File

@ -39,6 +39,7 @@ Release template (copy/paste this for new release):
### Fixed
- Fuel Priming reset fix #4627
- Slower than expected RPM information was slowing engine start #4629
- Fix 36-2-1 trigger (Mitsubishi 4B11, etc) #4635
## September 2022 Release - "Day 203"

View File

@ -84,6 +84,7 @@ void initialize36_2_1_1(TriggerWaveform *s) {
s->setSecondTriggerSynchronizationGap(1); // redundancy
}
// Mitsubishi 4B11
void initialize36_2_1(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CRANK_SENSOR, SyncEdge::RiseOnly);
s->tdcPosition = 90;
@ -94,16 +95,16 @@ void initialize36_2_1(TriggerWaveform *s) {
float oneTooth = 720 / totalTeethCount;
float offset = (36 - 17 - 2 - 16) * oneTooth;
addSkippedToothTriggerEvents(TriggerWheel::T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
NO_LEFT_FILTER, offset + 17 * oneTooth + 1);
offset += (17 + 2) * oneTooth;
float offset = (36 - 16 - 2 - 17) * oneTooth;
addSkippedToothTriggerEvents(TriggerWheel::T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
NO_LEFT_FILTER, offset + 16 * oneTooth + 1);
offset += (16 + 2) * oneTooth;
addSkippedToothTriggerEvents(TriggerWheel::T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
NO_LEFT_FILTER, offset + 17 * oneTooth + 1);
s->setTriggerSynchronizationGap(3);
s->setSecondTriggerSynchronizationGap(1); // redundancy

View File

@ -703,7 +703,14 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
// basically, check that the tooth width is correct
auto estimatedCurrentPhase = getCurrentEnginePhase(timestamp);
if (estimatedCurrentPhase) {
triggerToothAngleError = expectedNextPhase - estimatedCurrentPhase.Value;
float angleError = expectedNextPhase - estimatedCurrentPhase.Value;
float cycle = getEngineState()->engineCycle;
while (angleError < -cycle / 2) {
angleError += cycle;
}
triggerToothAngleError = angleError;
}
// Record precise time and phase of the engine. This is used for VVT decode, and to check that the

View File

@ -13,6 +13,7 @@ TESTS_SRC_CPP = \
tests/trigger/test_real_cranking_miata_na6.cpp \
tests/trigger/test_real_cranking_nissan_vq40.cpp \
tests/trigger/test_trigger_skipped_wheel.cpp \
tests/trigger/test_real_4b11.cpp \
tests/trigger/test_real_volkswagen.cpp \
tests/trigger/test_real_nb2_cranking.cpp \
tests/trigger/test_real_gm_24x.cpp \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
// Mitsubishi 4B11 trigger pattern
// Crank: 36-2-1
// Cam: Single tooth (half moon)
#include "pch.h"
#include "logicdata_csv_reader.h"
TEST(real4b11, running) {
CsvReader reader(1, /* vvtCount */ 0);
reader.open("tests/trigger/resources/4b11-running.csv");
EngineTestHelper eth(TEST_ENGINE);
engineConfiguration->isFasterEngineSpinUpEnabled = true;
engineConfiguration->alwaysInstantRpm = true;
eth.setTriggerType(TT_36_2_1);
int eventCount = 0;
bool gotRpm = false;
while (reader.haveMore()) {
reader.processLine(&eth);
eventCount++;
engine->rpmCalculator.onSlowCallback();
// Expect that all teeth are in the correct spot
float angleError = getTriggerCentral()->triggerToothAngleError;
EXPECT_TRUE(angleError < 3 && angleError > -3) << "tooth angle of " << angleError << " at timestamp " << (getTimeNowNt() / 1e8);
auto rpm = Sensor::getOrZero(SensorType::Rpm);
if (!gotRpm && rpm) {
gotRpm = true;
// We should get first RPM on exactly the first sync point - this means the instant RPM pre-sync event copy all worked OK
EXPECT_EQ(eventCount, 30);
EXPECT_NEAR(rpm, 1436.23f, 0.1);
}
}
ASSERT_EQ(0, eth.recentWarnings()->getCount());
}

View File

@ -21,6 +21,10 @@ TEST(crankingGm24x, gmRealCrankingFromFile) {
engine->rpmCalculator.onSlowCallback();
// Expect that all teeth are in the correct spot
float angleError = getTriggerCentral()->triggerToothAngleError;
EXPECT_TRUE(angleError < 3 && angleError > -3) << "tooth angle of " << angleError << " at timestamp " << (getTimeNowNt() / 1e8);
auto rpm = Sensor::getOrZero(SensorType::Rpm);
if (!gotRpm && rpm) {
gotRpm = true;