weird: happy running car shows repetitive pattern of unrealistic vvtSyncGapRatio fix #5152

This commit is contained in:
rusefillc 2023-03-21 19:39:39 -04:00
parent aa088a1c43
commit 3031818f3e
2 changed files with 11 additions and 4 deletions

View File

@ -47,6 +47,10 @@
*/
#include "trigger_simulator.h"
#ifndef NOISE_RATIO_THRESHOLD
#define NOISE_RATIO_THRESHOLD 3000
#endif
TriggerDecoderBase::TriggerDecoderBase(const char* name)
: name(name)
{
@ -90,9 +94,9 @@ void TriggerDecoderBase::resetState() {
isFirstEvent = true;
}
void TriggerDecoderBase::setTriggerErrorState() {
void TriggerDecoderBase::setTriggerErrorState(int errorIncrement) {
m_timeSinceDecodeError.reset();
totalTriggerErrorCounter++;
totalTriggerErrorCounter += errorIncrement;
}
void TriggerDecoderBase::resetCurrentCycleState() {
@ -447,6 +451,10 @@ expected<TriggerDecodeResult> TriggerDecoderBase::decodeTriggerEvent(
if (triggerShape.isSynchronizationNeeded) {
triggerSyncGapRatio = (float)toothDurations[0] / toothDurations[1];
if (wasSynchronized && triggerSyncGapRatio > NOISE_RATIO_THRESHOLD) {
setTriggerErrorState(100);
}
isSynchronizationPoint = isSyncPoint(triggerShape, triggerConfiguration.TriggerType.type);
if (isSynchronizationPoint) {
enginePins.debugTriggerSync.toggle();

View File

@ -124,8 +124,6 @@ public:
Timer previousEventTimer;
void setTriggerErrorState();
/**
* current duration at index zero and previous durations are following
*/
@ -172,6 +170,7 @@ protected:
virtual void onTooManyTeeth(int, int) { }
private:
void setTriggerErrorState(int errorIncrement = 1);
void resetCurrentCycleState();
bool isSyncPoint(const TriggerWaveform& triggerShape, trigger_type_e triggerType) const;