VVT miata trying to crank with random phase #1278

This commit is contained in:
rusefi 2020-04-26 20:50:49 -04:00
parent 6bd5cd1112
commit 88bbbb6c33
4 changed files with 23 additions and 2 deletions

View File

@ -264,11 +264,18 @@ static void doPeriodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
slowStartStopButtonCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_PROD_CODE */
efitick_t nowNt = getTimeNowNt();
if (nowNt - engine->triggerCentral.vvtSyncTimeNt >= NT_PER_SECOND) {
// loss of VVT sync
engine->triggerCentral.vvtSyncTimeNt = 0;
}
/**
* Update engine RPM state if needed (check timeouts).
*/
bool isSpinning = engine->rpmCalculator.checkIfSpinning(getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
bool isSpinning = engine->rpmCalculator.checkIfSpinning(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
if (!isSpinning) {
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
}
@ -746,6 +753,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20200422;
return 20200426;
}
#endif /* EFI_UNIT_TEST */

View File

@ -358,6 +358,14 @@ static void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEvent
(void) ckpSignalType;
if (engineConfiguration->vvtMode == MIATA_NB2 && 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
return;
}
if (hasFirmwareError()) {
/**
* In case on a major error we should not process any more events.

View File

@ -135,6 +135,9 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_
floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs;
if (cisnan(oneDegreeUs)) {
// todo: this code branch is slowing NB2 cranking since we require RPM sync for VVT sync!
// todo: smarter code
//
// we are here if we are getting VVT position signals while engine is not running
// for example if crank position sensor is broken :)
return;
@ -166,6 +169,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_
}
}
tc->vvtSyncTimeNt = nowNt;
efitick_t offsetNt = nowNt - tc->timeAtVirtualZeroNt;

View File

@ -56,6 +56,8 @@ public:
*/
efitick_t timeAtVirtualZeroNt = 0;
efitick_t vvtSyncTimeNt = 0;
TriggerWaveform triggerShape;
efitick_t previousVvtCamTime = DEEP_IN_THE_PAST_SECONDS * NT_PER_SECOND;