remove vvtSyncTimeNt (#3722)

* s

* poke

* poke again for science

* kick for science

* kick

* kick

* comment kick

* s

* don't try to compare the array decay pointer to 0 (!)

* collateral damage

* adjust miata sync

* reset trigger states correctly on engine stop

* s

* check synchronized bit

* now we don't need it at all?!

* and *NOT* synced

* start VVT sync earlier
This commit is contained in:
Matthew Kennedy 2021-12-27 23:00:26 -06:00 committed by GitHub
parent 9ff0dc335e
commit c3b712aa3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 28 deletions

View File

@ -198,18 +198,6 @@ static void doPeriodicSlowCallback() {
slowStartStopButtonCallback();
efitick_t nowNt = getTimeNowNt();
for (int bankIndex = 0; bankIndex < BANKS_COUNT; bankIndex++) {
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;
}
}
}
engine->rpmCalculator.onSlowCallback();
if (engine->directSelfStimulation || engine->rpmCalculator.isStopped()) {

View File

@ -351,7 +351,8 @@ static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
ScopePerf perf(PE::MainTriggerCallback);
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0]) && engine->triggerCentral.vvtSyncTimeNt[0][0] == 0) {
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0])
&& !engine->triggerCentral.vvtState[0][0].getShaftSynchronized()) {
// Any engine that requires cam-assistance for a full crank sync (symmetrical crank) can't schedule until we have cam sync
// examples:
// NB2, Nissan VQ/MR: symmetrical crank wheel and we need to make sure no spark happens out of sync

View File

@ -41,8 +41,7 @@ static scheduling_s debugToggleScheduling;
TriggerCentral::TriggerCentral() :
vvtEventRiseCounter(),
vvtEventFallCounter(),
vvtPosition(),
vvtSyncTimeNt()
vvtPosition()
{
memset(&hwEventCounters, 0, sizeof(hwEventCounters));
triggerState.resetTriggerState();
@ -264,14 +263,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
logFront(isImportantFront, nowNt, index);
auto currentPhase = tc->getCurrentEnginePhase(nowNt);
if (!currentPhase) {
// 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 :)
// If the main trigger is not synchronized, don't decode VVT yet
if (!tc->triggerState.getShaftSynchronized()) {
return;
}
@ -291,6 +284,13 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
tc->vvtCamCounter++;
auto currentPhase = tc->getCurrentEnginePhase(nowNt);
if (!currentPhase) {
// If we couldn't resolve engine speed (yet primary trigger is sync'd), this
// probably means that we have partial crank sync, but not RPM information yet
return;
}
angle_t currentPosition = currentPhase.Value;
// convert engine cycle angle into trigger cycle angle
currentPosition -= tdcPosition();
@ -332,8 +332,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
break;
}
tc->vvtSyncTimeNt[bankIndex][camIndex] = nowNt;
auto vvtPosition = engineConfiguration->vvtOffsets[bankIndex * CAMS_PER_BANK + camIndex] - currentPosition;
if (index != 0) {

View File

@ -93,9 +93,6 @@ 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;
TriggerWaveform triggerShape;