MAP phase sensing #3544

This commit is contained in:
Andrey 2021-11-24 23:06:52 -05:00
parent 670bd74376
commit 7fa2fa5707
6 changed files with 27 additions and 4 deletions

View File

@ -205,8 +205,8 @@ static void doPeriodicSlowCallback() {
for (int camIndex = 0; camIndex < CAMS_PER_BANK; camIndex++) {
if (nowNt - engine->triggerCentral.vvtSyncTimeNt[bankIndex][camIndex] >= NT_PER_SECOND) {
// loss of VVT sync
// todo: this code would get simpler if we convert vvtSyncTimeNt to Timer
engine->triggerCentral.vvtSyncTimeNt[bankIndex][camIndex] = 0;
}
}
}

View File

@ -330,6 +330,10 @@ static void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm,
uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
#endif
static bool noFiringUntilVvtSync(vvt_mode_e mode) {
return mode == VVT_MIATA_NB2 || mode == VVT_MAP_V_TWIN;
}
/**
* This is the main trigger event handler.
* Both injection and ignition are controlled from this method.
@ -337,10 +341,11 @@ uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
ScopePerf perf(PE::MainTriggerCallback);
if (engineConfiguration->vvtMode[0] == VVT_MIATA_NB2 && engine->triggerCentral.vvtSyncTimeNt == 0) {
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0]) && engine->triggerCentral.vvtSyncTimeNt == 0) {
// this is a bit spaghetti code for sure
// do not spark & do not fuel until we have VVT sync. NB2 is a special case
// due to symmetrical crank wheel and we need to make sure no spark happens out of sync
// do not spark & do not fuel until we have VVT sync.
// NB2 is a special case due to symmetrical crank wheel and we need to make sure no spark happens out of sync
// VTwin is another special case where we really need to know phase before firing
return;
}

View File

@ -8,6 +8,19 @@
#include "trigger_misc.h"
#include "trigger_universal.h"
void configureVvt45VTwin(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
s->setTriggerSynchronizationGap(0.78);
s->setSecondTriggerSynchronizationGap(1.29);
s->addEvent720(315 - 1, T_PRIMARY, TV_RISE);
s->addEvent720(315, T_PRIMARY, TV_FALL);
s->addEvent720(720 - 1, T_PRIMARY, TV_RISE);
s->addEvent720(720, T_PRIMARY, TV_FALL);
}
// TT_FIAT_IAW_P8
void configureFiatIAQ_P8(TriggerWaveform * s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);

View File

@ -16,4 +16,5 @@ void configureFordST170(TriggerWaveform * s);
void configureTriTach(TriggerWaveform * s);
// TT_VVT_BARRA_3_PLUS_1
void configureBarra3plus1cam(TriggerWaveform *s);
void configureVvt45VTwin(TriggerWaveform *s);

View File

@ -527,6 +527,9 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat
break;
case TT_VVT_MAP_45_V_TWIN:
configureVvt45VTwin(this);
break;
case TT_NISSAN_QR25:
initializeNissanQR25crank(this);
break;

View File

@ -110,6 +110,7 @@ public:
// synchronization event position
angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK];
// todo: convert to Timer!
efitick_t vvtSyncTimeNt[BANKS_COUNT][CAMS_PER_BANK];
TriggerStateWithRunningStatistics triggerState;