diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 3b39cc4b0a..8c7f1ba3e9 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -176,6 +176,7 @@ void configureMazdaProtegeSOHC(TriggerWaveform *s) { s->addEvent720(a, T_PRIMARY, TV_FALL); s->isSynchronizationNeeded = false; + s->shapeWithoutTdc = true; } void configureMazdaProtegeLx(TriggerWaveform *s) { diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 61164180bf..f6d259edc2 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -2,7 +2,7 @@ * @file trigger_structure.cpp * * @date Jan 20, 2014 - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2020 * * This file is part of rusEfi - see http://rusefi.com * @@ -69,6 +69,7 @@ void TriggerWaveform::initialize(operation_mode_e operationMode) { isSynchronizationNeeded = true; // that's default value bothFrontsRequired = false; needSecondTriggerInput = false; + shapeWithoutTdc = false; memset(expectedDutyCycle, 0, sizeof(expectedDutyCycle)); memset(eventAngles, 0, sizeof(eventAngles)); // memset(triggerIndexByAngle, 0, sizeof(triggerIndexByAngle)); @@ -175,6 +176,13 @@ extern bool printTriggerDebug; void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger) { UNUSED(useOnlyRisingEdgeForTrigger); + + bool isSingleToothOnPrimaryChannel = useOnlyRisingEdgeForTrigger ? expectedEventCount[0] == 1 : expectedEventCount[0] == 2; + // todo: next step would be to set 'isSynchronizationNeeded' automatically based on the logic we have here + if (!shapeWithoutTdc && isSingleToothOnPrimaryChannel != !isSynchronizationNeeded) { + firmwareError(ERROR_TRIGGER_DRAMA, "trigger constraint violation"); + } + // todo: move the following logic from below here // if (!useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) { // expectedEventCount[channelIndex]++; @@ -526,10 +534,12 @@ void TriggerWaveform::initializeTriggerWaveform(Logging *logger, operation_mode_ case TT_HONDA_4_24_1: configureHonda_1_4_24(this, true, true, T_CHANNEL_3, T_PRIMARY, 0); + shapeWithoutTdc = true; break; case TT_HONDA_4_24: configureHonda_1_4_24(this, false, true, T_NONE, T_PRIMARY, 0); + shapeWithoutTdc = true; break; case TT_HONDA_1_24: diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 2273e556e3..11ac4b4cbd 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -86,6 +86,11 @@ public: * one primary channel tooth each raising (or falling depending on configuration) front would synchronize */ bool isSynchronizationNeeded; + /** + * special case for triggers which do not provide exact TDC location + * For example pick-up in distributor with mechanical ignition firing order control. + */ + bool shapeWithoutTdc = false; /** * this flag tells us if we should ignore events on second input channel * that's the way to ignore noise from the disconnected wire diff --git a/firmware/controllers/trigger/decoders/trigger_universal.cpp b/firmware/controllers/trigger/decoders/trigger_universal.cpp index 5d544b5b8b..cca3ac2945 100644 --- a/firmware/controllers/trigger/decoders/trigger_universal.cpp +++ b/firmware/controllers/trigger/decoders/trigger_universal.cpp @@ -39,8 +39,10 @@ void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeeth s->initialize(operationMode); s->setTriggerSynchronizationGap(skippedCount + 1); + s->shapeWithoutTdc = (totalTeethCount > 2) && (skippedCount == 0); s->isSynchronizationNeeded = (totalTeethCount > 2) && (skippedCount != 0); + addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0.5, 0, getEngineCycle(operationMode), NO_LEFT_FILTER, NO_RIGHT_FILTER); }