log tooth angle difference (#4613)

This commit is contained in:
Matthew Kennedy 2022-09-23 20:49:28 -07:00 committed by GitHub
parent 7139ddcda2
commit dd41cf0a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -704,7 +704,15 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
// todo: what is broken _exactly_?
currentEngineDecodedPhase = currentPhase;
// Record precise time and phase of the engine. This is used for VVT decode.
// Check that the expected next phase (from the last tooth) is close to the actual current phase:
// basically, check that the tooth width is correct
auto estimatedCurrentPhase = getCurrentEnginePhase(timestamp);
if (estimatedCurrentPhase) {
triggerToothAngleError = expectedNextPhase - estimatedCurrentPhase.Value;
}
// Record precise time and phase of the engine. This is used for VVT decode, and to check that the
// trigger pattern selected matches reality (ie, we check the next tooth is where we think it should be)
{
// under lock to avoid mismatched tooth phase and time
chibios_rt::CriticalSectionLocker csl;
@ -744,6 +752,8 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
wrapAngle(nextPhase, "nextEnginePhase", CUSTOM_ERR_6555);
} while (nextPhase == currentPhase);
expectedNextPhase = nextPhase + tdcPosition();
wrapAngle(expectedNextPhase, "nextEnginePhase", CUSTOM_ERR_6555);
#if EFI_CDM_INTEGRATION
if (trgEventIndex == 0 && isBrainPinValid(engineConfiguration->cdmInputPin)) {

View File

@ -188,6 +188,10 @@ private:
Timer m_lastToothTimer;
// Phase of the last tooth relative to the sync point
float m_lastToothPhaseFromSyncPoint;
// At what engine phase do we expect the next tooth to arrive?
// Used for checking whether your trigger pattern is correct.
float expectedNextPhase;
};
void triggerInfo(void);

View File

@ -13,5 +13,7 @@ int vvtCamCounter
float autoscale currentEngineDecodedPhase;Engine Phase;"deg",1, 0, 0, 0, 0
float triggerToothAngleError;;"deg", 1, 0, -30, 30, 2
end_struct