rusEFI
An attempt to build an Engine Control Unit
Public Member Functions | Data Fields | Private Member Functions | Private Attributes
TriggerState Class Reference

#include <trigger_decoder.h>

Inheritance diagram for TriggerState:
Inheritance graph
[legend]
Collaboration diagram for TriggerState:
Collaboration graph
[legend]

Public Member Functions

 TriggerState ()
 
int getCurrentIndex () const
 
int getTotalRevolutionCounter () const
 
void incrementTotalEventCounter ()
 
efitime_t getTotalEventCounter () const
 
void decodeTriggerEvent (const char *msg, const TriggerWaveform &triggerShape, const TriggerStateCallback triggerCycleCallback, TriggerStateListener *triggerStateListener, const TriggerConfiguration &triggerConfiguration, const trigger_event_e signal, const efitime_t nowUs)
 Trigger decoding happens here VR falls are filtered out and some VR noise detection happens prior to invoking this method, for Hall this method is invoked every time we have a fall or rise on one of the trigger sensors. This method changes the state of trigger_state_s data structure according to the trigger event. More...
 
bool validateEventCounters (const TriggerWaveform &triggerShape) const
 
void onShaftSynchronization (const TriggerStateCallback triggerCycleCallback, bool wasSynchronized, const efitick_t nowNt, const TriggerWaveform &triggerShape)
 
bool isValidIndex (const TriggerWaveform &triggerShape) const
 
void setTriggerErrorState ()
 
virtual void resetTriggerState ()
 
void setShaftSynchronized (bool value)
 
bool getShaftSynchronized ()
 
uint32_t findTriggerZeroEventIndex (TriggerWaveform &shape, const TriggerConfiguration &triggerConfiguration, const trigger_config_s &triggerConfig)
 

Data Fields

bool shaft_is_synchronized
 
efitick_t mostRecentSyncTime
 
Timer previousEventTimer
 
efitick_t lastDecodingErrorTime
 
bool someSortOfTriggerError
 
uint32_t toothDurations [GAP_TRACKING_LENGTH+1]
 
efitick_t toothed_previous_time
 
current_cycle_state_s currentCycle
 
const charname = nullptr
 
int expectedTotalTime [PWM_PHASE_MAX_WAVE_PER_PWM]
 
uint32_t totalTriggerErrorCounter
 
uint32_t orderingErrorCounter
 
efitick_t startOfCycleNt
 
- Data Fields inherited from trigger_state_s
uint32_t totalRevolutionCounter = (uint32_t)0
 
scaled_channel< float, 1, 1 > vvtSyncGapRatio = (float)0
 
scaled_channel< float, 1, 1 > vvtCurrentPosition = (float)0
 
scaled_channel< float, 1, 1 > triggerSyncGapRatio = (float)0
 
float triggerActualSyncGapRatio = (float)0
 
uint8_t triggerStateIndex = (uint8_t)0
 
uint8_t vvtCounter = (uint8_t)0
 
uint8_t vvtSyncCounter = (uint8_t)0
 
uint8_t vvtStateIndex = (uint8_t)0
 

Private Member Functions

void resetCurrentCycleState ()
 
bool isSyncPoint (const TriggerWaveform &triggerShape, trigger_type_e triggerType) const
 

Private Attributes

trigger_event_e curSignal
 
trigger_event_e prevSignal
 
int64_t totalEventCountBase
 
bool isFirstEvent
 

Detailed Description

See also
TriggerWaveform for trigger wheel shape definition

Definition at line 77 of file trigger_decoder.h.

Constructor & Destructor Documentation

◆ TriggerState()

TriggerState::TriggerState ( )

Definition at line 41 of file trigger_decoder.cpp.

41  {
43 }
Here is the call graph for this function:

Member Function Documentation

◆ decodeTriggerEvent()

void TriggerState::decodeTriggerEvent ( const char msg,
const TriggerWaveform triggerShape,
const TriggerStateCallback  triggerCycleCallback,
TriggerStateListener triggerStateListener,
const TriggerConfiguration triggerConfiguration,
const trigger_event_e  signal,
const efitime_t  nowUs 
)

Trigger decoding happens here VR falls are filtered out and some VR noise detection happens prior to invoking this method, for Hall this method is invoked every time we have a fall or rise on one of the trigger sensors. This method changes the state of trigger_state_s data structure according to the trigger event.

Parameters
signaltype of event which just happened
nowNtcurrent time

We are here if there is a time gap between now and previous shaft event - that means the engine is not running. That means we have lost synchronization since the engine is not running :)

For performance reasons, we want to work with 32 bit values. If there has been more then 10 seconds since previous trigger event we do not really care.

For less important events we simply increment the index.

todo: technically we can afford detailed logging even with 60/2 as long as low RPM todo: figure out exact threshold as a function of RPM and tooth count? Open question what is 'triggerShape.getSize()' for 60/2 is it 58 or 58*2 or 58*4?

We are here in case of a wheel without synchronization - we just need to count events, synchronization point simply happens once we have the right number of events

in case of noise the counter could be above the expected number of events, that's why 'more or equals' and not just 'equals'

Definition at line 483 of file trigger_decoder.cpp.

490  {
492 
494  /**
495  * We are here if there is a time gap between now and previous shaft event - that means the engine is not running.
496  * That means we have lost synchronization since the engine is not running :)
497  */
498  setShaftSynchronized(false);
499  if (triggerStateListener) {
500  triggerStateListener->OnTriggerSynchronizationLost();
501  }
502  }
503 
504  bool useOnlyRisingEdgeForTrigger = triggerConfiguration.UseOnlyRisingEdgeForTrigger;
505 
506  efiAssertVoid(CUSTOM_TRIGGER_UNEXPECTED, signal <= SHAFT_3RD_RISING, "unexpected signal");
507 
508  trigger_wheel_e triggerWheel = eventIndex[signal];
509  trigger_value_e type = eventType[signal];
510 
513  }
514 
516  curSignal = signal;
517 
518  currentCycle.eventCount[triggerWheel]++;
519 
520  if (toothed_previous_time > nowNt) {
521  firmwareError(CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%d now=%d", msg, toothed_previous_time, nowNt);
522  }
523 
524  efitick_t currentDurationLong = isFirstEvent ? 0 : nowNt - toothed_previous_time;
525 
526  /**
527  * For performance reasons, we want to work with 32 bit values. If there has been more then
528  * 10 seconds since previous trigger event we do not really care.
529  */
530  toothDurations[0] =
531  currentDurationLong > 10 * NT_PER_SECOND ? 10 * NT_PER_SECOND : currentDurationLong;
532 
533  bool isPrimary = triggerWheel == T_PRIMARY;
534 
535  if (needToSkipFall(type) || needToSkipRise(type) || (!considerEventForGap())) {
536 #if EFI_UNIT_TEST
537  if (printTriggerTrace) {
538  printf("%s isLessImportant %s now=%d index=%d\r\n",
539  getTrigger_type_e(triggerConfiguration.TriggerType),
540  getTrigger_event_e(signal),
541  (int)nowNt,
543  }
544 #endif /* EFI_UNIT_TEST */
545 
546  /**
547  * For less important events we simply increment the index.
548  */
549  nextTriggerEvent()
550  ;
551  } else {
552 #if !EFI_PROD_CODE
553  if (printTriggerTrace) {
554  printf("%s event %s %d\r\n",
555  getTrigger_type_e(triggerConfiguration.TriggerType),
556  getTrigger_event_e(signal),
557  nowNt);
558  printf("decodeTriggerEvent ratio %.2f: current=%d previous=%d\r\n", 1.0 * toothDurations[0] / toothDurations[1],
560  }
561 #endif
562 
563  isFirstEvent = false;
564  bool isSynchronizationPoint;
565  bool wasSynchronized = getShaftSynchronized();
566 
567  if (triggerShape.isSynchronizationNeeded) {
569 
570  isSynchronizationPoint = isSyncPoint(triggerShape, triggerConfiguration.TriggerType);
571  if (isSynchronizationPoint) {
573  }
574 
575  /**
576  * todo: technically we can afford detailed logging even with 60/2 as long as low RPM
577  * todo: figure out exact threshold as a function of RPM and tooth count?
578  * Open question what is 'triggerShape.getSize()' for 60/2 is it 58 or 58*2 or 58*4?
579  */
580  bool silentTriggerError = triggerShape.getSize() > 40 && engineConfiguration->silentTriggerError;
581 
582 #if EFI_UNIT_TEST
584 #endif /* EFI_UNIT_TEST */
585 
586 #if EFI_PROD_CODE || EFI_SIMULATOR
587  if (triggerConfiguration.VerboseTriggerSynchDetails || (someSortOfTriggerError && !silentTriggerError)) {
588 
590  floatms_t engineCycleDuration = getEngineCycleDuration(rpm);
592  int time = currentCycle.totalTimeNt[0];
593  efiPrintf("%s duty %f %d",
594  name,
595  time / engineCycleDuration,
596  time
597  );
598  }
599 
600  for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
601  float ratioFrom = triggerShape.syncronizationRatioFrom[i];
602  if (cisnan(ratioFrom)) {
603  // we do not track gap at this depth
604  continue;
605  }
606 
607  float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
608  if (cisnan(gap)) {
609  efiPrintf("index=%d NaN gap, you have noise issues?",
610  i);
611  } else {
612  efiPrintf("%srpm=%d time=%d eventIndex=%d gapIndex=%d: gap=%.3f expected from %.3f to %.3f error=%s",
613  triggerConfiguration.PrintPrefix,
615  /* cast is needed to make sure we do not put 64 bit value to stack*/ (int)getTimeNowSeconds(),
617  i,
618  gap,
619  ratioFrom,
620  triggerShape.syncronizationRatioTo[i],
622  }
623  }
624  }
625 #else
626  if (printTriggerTrace) {
627  float gap = 1.0 * toothDurations[0] / toothDurations[1];
628  for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
629  float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
630  printf("%sindex=%d: gap=%.2f expected from %.2f to %.2f error=%s\r\n",
631  triggerConfiguration.PrintPrefix,
632  i,
633  gap,
634  triggerShape.syncronizationRatioFrom[i],
635  triggerShape.syncronizationRatioTo[i],
637  }
638  }
639 #endif /* EFI_PROD_CODE */
640  } else {
641  /**
642  * We are here in case of a wheel without synchronization - we just need to count events,
643  * synchronization point simply happens once we have the right number of events
644  *
645  * in case of noise the counter could be above the expected number of events, that's why 'more or equals' and not just 'equals'
646  */
647 
648  unsigned int endOfCycleIndex = triggerShape.getSize() - (triggerConfiguration.UseOnlyRisingEdgeForTrigger ? 2 : 1);
649 
650  isSynchronizationPoint = !getShaftSynchronized() || (currentCycle.current_index >= endOfCycleIndex);
651 
652 #if EFI_UNIT_TEST
653  if (printTriggerTrace) {
654  printf("decodeTriggerEvent sync=%d isSynchronizationPoint=%d index=%d size=%d\r\n",
656  isSynchronizationPoint,
658  triggerShape.getSize());
659  }
660 #endif /* EFI_UNIT_TEST */
661  }
662 #if EFI_UNIT_TEST
663  if (printTriggerTrace) {
664  printf("decodeTriggerEvent %s isSynchronizationPoint=%d index=%d %s\r\n",
665  getTrigger_type_e(triggerConfiguration.TriggerType),
666  isSynchronizationPoint, currentCycle.current_index,
667  getTrigger_event_e(signal));
668  }
669 #endif /* EFI_UNIT_TEST */
670 
671  if (isSynchronizationPoint) {
672  if (triggerStateListener) {
673  triggerStateListener->OnTriggerSyncronization(wasSynchronized);
674  }
675 
676  setShaftSynchronized(true);
677  // this call would update duty cycle values
678  nextTriggerEvent()
679  ;
680 
681  onShaftSynchronization(triggerCycleCallback, wasSynchronized, nowNt, triggerShape);
682 
683  } else { /* if (!isSynchronizationPoint) */
684  nextTriggerEvent()
685  ;
686  }
687 
688  for (int i = triggerShape.gapTrackingLength; i > 0; i--) {
689  toothDurations[i] = toothDurations[i - 1];
690  }
691 
692  toothed_previous_time = nowNt;
693  }
694  if (getShaftSynchronized() && !isValidIndex(triggerShape) && triggerStateListener) {
695  triggerStateListener->OnTriggerInvalidIndex(currentCycle.current_index);
696  return;
697  }
699  if (getTimeNowNt() - lastDecodingErrorTime > NT_PER_SECOND) {
700  someSortOfTriggerError = false;
701  }
702  }
703 
704 
705  // Needed for early instant-RPM detection
706  if (triggerStateListener) {
707  triggerStateListener->OnTriggerStateProperState(nowNt);
708  }
709 }

Referenced by TriggerCentral::handleShaftSignal(), and hwHandleVvtCamSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findTriggerZeroEventIndex()

uint32_t TriggerState::findTriggerZeroEventIndex ( TriggerWaveform shape,
const TriggerConfiguration triggerConfiguration,
const trigger_config_s triggerConfig 
)

Trigger shape is defined in a way which is convenient for trigger shape definition On the other hand, trigger decoder indexing begins from synchronization event.

This function finds the index of synchronization event within TriggerWaveform

Now that we have just located the synch point, we can simulate the whole cycle in order to calculate expected duty cycle

todo: add a comment why are we doing '2 * shape->getSize()' here?

Definition at line 776 of file trigger_decoder.cpp.

779  {
780  UNUSED(triggerConfig);
781 #if EFI_PROD_CODE
782  efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
783 #endif
784 
785 
787 
788  if (shape.shapeDefinitionError) {
789  return 0;
790  }
791 
793 
794  uint32_t syncIndex = helper.findTriggerSyncPoint(shape,
795  triggerConfiguration,
796  *this);
797  if (syncIndex == EFI_ERROR_CODE) {
798  return syncIndex;
799  }
800 
801  // Assert that we found the sync point on the very first revolution
802  efiAssert(CUSTOM_ERR_ASSERT, getTotalRevolutionCounter() == 0, "findZero_revCounter", EFI_ERROR_CODE);
803 
804 #if EFI_UNIT_TEST
805  if (printTriggerDebug) {
806  printf("findTriggerZeroEventIndex: syncIndex located %d!\r\n", syncIndex);
807  }
808 #endif /* EFI_UNIT_TEST */
809 
810  /**
811  * Now that we have just located the synch point, we can simulate the whole cycle
812  * in order to calculate expected duty cycle
813  *
814  * todo: add a comment why are we doing '2 * shape->getSize()' here?
815  */
816 
817  helper.assertSyncPositionAndSetDutyCycle(onFindIndexCallback, triggerConfiguration,
818  syncIndex, *this, shape);
819 
820  return syncIndex % shape.getSize();
821 }
Here is the call graph for this function:

◆ getCurrentIndex()

int TriggerState::getCurrentIndex ( ) const

current trigger processing index, between zero and size

Definition at line 382 of file trigger_decoder.cpp.

382  {
384 }

Referenced by TriggerCentral::handleShaftSignal().

Here is the caller graph for this function:

◆ getShaftSynchronized()

bool TriggerState::getShaftSynchronized ( )

◆ getTotalEventCounter()

int64_t TriggerState::getTotalEventCounter ( ) const

Definition at line 212 of file trigger_decoder.cpp.

212  {
214 }

Referenced by updateDevConsoleState().

Here is the caller graph for this function:

◆ getTotalRevolutionCounter()

int TriggerState::getTotalRevolutionCounter ( ) const

◆ incrementTotalEventCounter()

void TriggerState::incrementTotalEventCounter ( )

this is important for crank-based virtual trigger and VVT magic

Definition at line 420 of file trigger_decoder.cpp.

420  {
422 }

Referenced by onShaftSynchronization(), and TriggerStateWithRunningStatistics::syncEnginePhase().

Here is the caller graph for this function:

◆ isSyncPoint()

bool TriggerState::isSyncPoint ( const TriggerWaveform triggerShape,
trigger_type_e  triggerType 
) const
private

Definition at line 711 of file trigger_decoder.cpp.

711  {
712  // Miata NB needs a special decoder.
713  // The problem is that the crank wheel only has 4 teeth, also symmetrical, so the pattern
714  // is long-short-long-short for one crank rotation.
715  // A quick acceleration can result in two successive "short gaps", so we see
716  // long-short-short-short-long instead of the correct long-short-long-short-long
717  // This logic expands the lower bound on a "long" tooth, then compares the last
718  // tooth to the current one.
719 
720  // Instead of detecting short/long, this logic first checks for "maybe short" and "maybe long",
721  // then simply tests longer vs. shorter instead of absolute value.
722  if (triggerType == TT_MIATA_VVT) {
723  auto secondGap = (float)toothDurations[1] / toothDurations[2];
724 
725  bool currentGapOk = isInRange(triggerShape.syncronizationRatioFrom[0], (float)triggerSyncGapRatio, triggerShape.syncronizationRatioTo[0]);
726  bool secondGapOk = isInRange(triggerShape.syncronizationRatioFrom[1], secondGap, triggerShape.syncronizationRatioTo[1]);
727 
728  // One or both teeth was impossible range, this is not the sync point
729  if (!currentGapOk || !secondGapOk) {
730  return false;
731  }
732 
733  // If both teeth are in the range of possibility, return whether this gap is
734  // shorter than the last or not. If it is, this is the sync point.
735  return triggerSyncGapRatio < secondGap;
736  }
737 
738  for (int i = 0; i < triggerShape.gapTrackingLength; i++) {
739  auto from = triggerShape.syncronizationRatioFrom[i];
740  auto to = triggerShape.syncronizationRatioTo[i];
741 
742  if (cisnan(from)) {
743  // don't check this gap, skip it
744  continue;
745  }
746 
747  // This is transformed to avoid a division and use a cheaper multiply instead
748  // toothDurations[i] / toothDurations[i+1] > from
749  // is an equivalent comparison to
750  // toothDurations[i] > toothDurations[i+1] * from
751  bool isGapCondition =
752  (toothDurations[i] > toothDurations[i + 1] * from
753  && toothDurations[i] < toothDurations[i + 1] * to);
754 
755  if (!isGapCondition) {
756  return false;
757  }
758  }
759 
760  return true;
761 }

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidIndex()

bool TriggerState::isValidIndex ( const TriggerWaveform triggerShape) const

Definition at line 346 of file trigger_decoder.cpp.

346  {
347  return currentCycle.current_index < triggerShape.getSize();
348 }

Referenced by decodeTriggerEvent(), and TriggerCentral::handleShaftSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onShaftSynchronization()

void TriggerState::onShaftSynchronization ( const TriggerStateCallback  triggerCycleCallback,
bool  wasSynchronized,
const efitick_t  nowNt,
const TriggerWaveform triggerShape 
)

Definition at line 443 of file trigger_decoder.cpp.

447  {
448 
449 
450  if (triggerCycleCallback) {
451  triggerCycleCallback(this);
452  }
453 
454  startOfCycleNt = nowNt;
456 
457  if (wasSynchronized) {
459  } else {
460  // We have just synchronized, this is the zeroth revolution
462  }
463 
464  totalEventCountBase += triggerShape.getSize();
465 
466 #if EFI_UNIT_TEST
467  if (printTriggerDebug) {
468  printf("onShaftSynchronization index=%d %d\r\n",
471  }
472 #endif /* EFI_UNIT_TEST */
473 }

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetCurrentCycleState()

void TriggerState::resetCurrentCycleState ( )
private

Definition at line 90 of file trigger_decoder.cpp.

90  {
91  memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount));
93 #if EFI_UNIT_TEST
95 #endif
98 }

Referenced by onShaftSynchronization(), and resetTriggerState().

Here is the caller graph for this function:

◆ resetTriggerState()

void TriggerState::resetTriggerState ( )
virtual

Reimplemented in TriggerStateWithRunningStatistics.

Definition at line 62 of file trigger_decoder.cpp.

62  {
63  setShaftSynchronized(false);
65 
66  memset(toothDurations, 0, sizeof(toothDurations));
67 
71  lastDecodingErrorTime = US2NT(-10000000LL);
72  someSortOfTriggerError = false;
73 
76  startOfCycleNt = 0;
77 
79  memset(expectedTotalTime, 0, sizeof(expectedTotalTime));
80 
82  isFirstEvent = true;
83 }

Referenced by findTriggerZeroEventIndex(), Engine::OnTriggerSynchronizationLost(), TriggerStateWithRunningStatistics::resetTriggerState(), and TriggerState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShaftSynchronized()

void TriggerState::setShaftSynchronized ( bool  value)

Definition at line 49 of file trigger_decoder.cpp.

49  {
50  if (value) {
51  if (!shaft_is_synchronized) {
52  // just got synchronized
54  }
55  } else {
56  // sync loss
58  }
60 }

Referenced by decodeTriggerEvent(), and resetTriggerState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTriggerErrorState()

void TriggerState::setTriggerErrorState ( )

Definition at line 85 of file trigger_decoder.cpp.

85  {
88 }

Referenced by Engine::OnTriggerInvalidIndex(), and Engine::OnTriggerStateDecodingError().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateEventCounters()

bool TriggerState::validateEventCounters ( const TriggerWaveform triggerShape) const

Definition at line 424 of file trigger_decoder.cpp.

424  {
425  bool isDecodingError = false;
426  for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
427  isDecodingError |= (currentCycle.eventCount[i] != triggerShape.getExpectedEventCount(i));
428  }
429 
430 
431 #if EFI_UNIT_TEST
432  printf("sync point: isDecodingError=%d\r\n", isDecodingError);
433  if (isDecodingError) {
434  for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
435  printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[i], triggerShape.getExpectedEventCount(i));
436  }
437  }
438 #endif /* EFI_UNIT_TEST */
439 
440  return isDecodingError;
441 }

Referenced by Engine::OnTriggerSyncronization().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ currentCycle

current_cycle_state_s TriggerState::currentCycle

◆ curSignal

trigger_event_e TriggerState::curSignal
private

Definition at line 162 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetTriggerState().

◆ expectedTotalTime

int TriggerState::expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]

Definition at line 134 of file trigger_decoder.h.

Referenced by resetTriggerState().

◆ isFirstEvent

bool TriggerState::isFirstEvent
private

Definition at line 166 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetTriggerState().

◆ lastDecodingErrorTime

efitick_t TriggerState::lastDecodingErrorTime

◆ mostRecentSyncTime

efitick_t TriggerState::mostRecentSyncTime

Definition at line 114 of file trigger_decoder.h.

Referenced by setShaftSynchronized().

◆ name

const char* TriggerState::name = nullptr

Definition at line 132 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and Engine::updateTriggerWaveform().

◆ orderingErrorCounter

uint32_t TriggerState::orderingErrorCounter

◆ previousEventTimer

Timer TriggerState::previousEventTimer

Definition at line 116 of file trigger_decoder.h.

Referenced by decodeTriggerEvent().

◆ prevSignal

trigger_event_e TriggerState::prevSignal
private

Definition at line 163 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetTriggerState().

◆ shaft_is_synchronized

bool TriggerState::shaft_is_synchronized

TRUE if we know where we are

Definition at line 113 of file trigger_decoder.h.

Referenced by getShaftSynchronized(), and setShaftSynchronized().

◆ someSortOfTriggerError

bool TriggerState::someSortOfTriggerError

◆ startOfCycleNt

efitick_t TriggerState::startOfCycleNt

this is start of real trigger cycle for virtual double trigger see timeAtVirtualZeroNt

Definition at line 150 of file trigger_decoder.h.

Referenced by onShaftSynchronization(), and resetTriggerState().

◆ toothDurations

uint32_t TriggerState::toothDurations[GAP_TRACKING_LENGTH+1]

current duration at index zero and previous durations are following

Definition at line 127 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), isSyncPoint(), and resetTriggerState().

◆ toothed_previous_time

efitick_t TriggerState::toothed_previous_time

Definition at line 129 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetTriggerState().

◆ totalEventCountBase

int64_t TriggerState::totalEventCountBase
private

◆ totalTriggerErrorCounter

uint32_t TriggerState::totalTriggerErrorCounter

how many times since ECU reboot we had unexpected number of teeth in trigger cycle

Definition at line 139 of file trigger_decoder.h.

Referenced by canDashboardHaltech(), Engine::OnTriggerStateDecodingError(), resetTriggerState(), triggerInfo(), and updateTunerStudioState().


The documentation for this class was generated from the following files:
TriggerStimulatorHelper
Definition: trigger_simulator.h:17
getTimeNowSeconds
efitimesec_t getTimeNowSeconds(void)
Current system time in seconds.
Definition: engine_controller.cpp:180
Sensor::getOrZero
static float getOrZero(SensorType type)
Definition: sensor.h:92
triggerType
triggerType
Definition: trigger_input.cpp:67
UNUSED
UNUSED(samplingTimeSeconds)
TriggerState::getTotalRevolutionCounter
int getTotalRevolutionCounter() const
Definition: trigger_decoder.cpp:216
OutputPin::toggle
void toggle()
Definition: efi_gpio.cpp:398
Timer::getElapsedSecondsAndReset
float getElapsedSecondsAndReset(efitick_t nowNt)
Definition: timer.cpp:73
TriggerState::totalEventCountBase
int64_t totalEventCountBase
Definition: trigger_decoder.h:164
boolToString
const char * boolToString(bool value)
Definition: efilib.cpp:18
trigger_state_s::totalRevolutionCounter
uint32_t totalRevolutionCounter
Definition: trigger_state_generated.h:12
TriggerState::expectedTotalTime
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]
Definition: trigger_decoder.h:134
T_PRIMARY
@ T_PRIMARY
Definition: rusefi_enums.h:54
engineConfiguration
engine_configuration_s * engineConfiguration
Definition: persistent_store.cpp:35
TriggerState::totalTriggerErrorCounter
uint32_t totalTriggerErrorCounter
Definition: trigger_decoder.h:139
TriggerState::isFirstEvent
bool isFirstEvent
Definition: trigger_decoder.h:166
eventIndex
static trigger_wheel_e eventIndex[6]
Definition: trigger_decoder.cpp:350
TriggerWaveform::getExpectedEventCount
size_t getExpectedEventCount(int channelIndex) const
Definition: trigger_structure.cpp:170
useOnlyRisingEdgeForTrigger
This is needed if your coils are individually wired and you wish to use batch injection nenable two_wire_batch_injection bit useOnlyRisingEdgeForTrigger
Definition: rusefi_config.txt:1063
TriggerConfiguration::PrintPrefix
const char *const PrintPrefix
Definition: trigger_decoder.h:32
PE::DecodeTriggerEvent
@ DecodeTriggerEvent
SHAFT_PRIMARY_FALLING
@ SHAFT_PRIMARY_FALLING
Definition: rusefi_enums.h:63
TriggerStateListener::OnTriggerInvalidIndex
virtual void OnTriggerInvalidIndex(int currentIndex)=0
current_cycle_state_s::eventCount
size_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM]
Definition: trigger_decoder.h:55
TriggerStateListener::OnTriggerSynchronizationLost
virtual void OnTriggerSynchronizationLost()=0
CUSTOM_TRIGGER_UNEXPECTED
@ CUSTOM_TRIGGER_UNEXPECTED
Definition: obd_error_codes.h:1992
TriggerState::resetCurrentCycleState
void resetCurrentCycleState()
Definition: trigger_decoder.cpp:90
to
This parameter sets the latest that the last multispark can occur after the main ignition event For if the ignition timing is degrees and this parameter is set to
Definition: rusefi_config.txt:435
TriggerConfiguration::UseOnlyRisingEdgeForTrigger
bool UseOnlyRisingEdgeForTrigger
Definition: trigger_decoder.h:33
getTrigger_type_e
const char * getTrigger_type_e(trigger_type_e value)
Definition: auto_generated_enginetypes.cpp:365
printTriggerTrace
bool printTriggerTrace
Definition: trigger_decoder.cpp:110
current_cycle_state_s::totalTimeNt
uint32_t totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM]
Definition: trigger_decoder.h:67
msg
static const char * msg
Definition: microsecond_timer.cpp:42
EnginePins::debugTriggerSync
OutputPin debugTriggerSync
Definition: efi_gpio.h:195
engine_configuration_s::silentTriggerError
bool silentTriggerError
Definition: engine_configuration_generated_structures.h:2543
TriggerState::setShaftSynchronized
void setShaftSynchronized(bool value)
Definition: trigger_decoder.cpp:49
printTriggerDebug
bool printTriggerDebug
Definition: trigger_decoder.cpp:109
TriggerState::mostRecentSyncTime
efitick_t mostRecentSyncTime
Definition: trigger_decoder.h:114
helper
static TriggerEmulatorHelper helper
Definition: trigger_emulator_algo.cpp:115
getTrigger_event_e
const char * getTrigger_event_e(trigger_event_e value)
Definition: auto_generated_commonenum.cpp:635
type
air_pressure_sensor_type_e type
Definition: rusefi_config.txt:382
TriggerWaveform::shapeDefinitionError
bool shapeDefinitionError
Definition: trigger_structure.h:107
TriggerState::lastDecodingErrorTime
efitick_t lastDecodingErrorTime
Definition: trigger_decoder.h:120
CUSTOM_ERR_ASSERT
@ CUSTOM_ERR_ASSERT
Definition: obd_error_codes.h:1841
TriggerState::someSortOfTriggerError
bool someSortOfTriggerError
Definition: trigger_decoder.h:122
floatms_t
float floatms_t
Definition: rusefi_types.h:87
TriggerState::name
const char * name
Definition: trigger_decoder.h:132
TriggerState::previousEventTimer
Timer previousEventTimer
Definition: trigger_decoder.h:116
SensorType::Rpm
@ Rpm
TriggerWaveform::syncronizationRatioTo
float syncronizationRatioTo[GAP_TRACKING_LENGTH]
Definition: trigger_structure.h:138
TriggerState::startOfCycleNt
efitick_t startOfCycleNt
Definition: trigger_decoder.h:150
TriggerState::orderingErrorCounter
uint32_t orderingErrorCounter
Definition: trigger_decoder.h:140
TriggerConfiguration::TriggerType
trigger_type_e TriggerType
Definition: trigger_decoder.h:35
CUSTOM_OBD_93
@ CUSTOM_OBD_93
Definition: obd_error_codes.h:1780
eventType
static trigger_value_e eventType[6]
Definition: trigger_decoder.cpp:351
TriggerState::prevSignal
trigger_event_e prevSignal
Definition: trigger_decoder.h:163
TriggerStateListener::OnTriggerSyncronization
virtual void OnTriggerSyncronization(bool wasSynchronized)=0
TriggerWaveform::getSize
size_t getSize() const
Definition: trigger_structure.cpp:92
current_cycle_state_s::timeOfPreviousEventNt
uint32_t timeOfPreviousEventNt[PWM_PHASE_MAX_WAVE_PER_PWM]
Definition: trigger_decoder.h:63
TriggerState::onShaftSynchronization
void onShaftSynchronization(const TriggerStateCallback triggerCycleCallback, bool wasSynchronized, const efitick_t nowNt, const TriggerWaveform &triggerShape)
Definition: trigger_decoder.cpp:443
efitick_t
efitime_t efitick_t
Definition: rusefi_types.h:78
TriggerState::resetTriggerState
virtual void resetTriggerState()
Definition: trigger_decoder.cpp:62
TriggerWaveform::gapTrackingLength
int gapTrackingLength
Definition: trigger_structure.h:93
rpm
rpm
Definition: output_channels.txt:272
value
value
Definition: output_channels.txt:44
silentTriggerError
This options enables data for engine sniffer tab in which comes at some CPU price bit silentTriggerError
Definition: rusefi_config.txt:1013
engine_configuration_s::useOnlyRisingEdgeForTrigger
bool useOnlyRisingEdgeForTrigger
Definition: engine_configuration_generated_structures.h:2722
TriggerState::isValidIndex
bool isValidIndex(const TriggerWaveform &triggerShape) const
Definition: trigger_decoder.cpp:346
current_cycle_state_s::current_index
uint32_t current_index
Definition: trigger_decoder.h:49
trigger_wheel_e
trigger_wheel_e
Definition: rusefi_enums.h:53
SHAFT_3RD_RISING
@ SHAFT_3RD_RISING
Definition: rusefi_enums.h:68
trigger_value_e
trigger_value_e
Definition: rusefi_enums.h:46
getEngineCycleDuration
floatms_t getEngineCycleDuration(int rpm)
Definition: engine_math.cpp:32
firmwareError
void firmwareError(obd_code_e, const char *,...)
Definition: rusefi_stubs.cpp:21
getTimeNowNt
efitick_t getTimeNowNt()
Definition: engine_controller_misc.cpp:51
onFindIndexCallback
static void onFindIndexCallback(TriggerState *state)
Definition: trigger_decoder.cpp:763
TriggerState::incrementTotalEventCounter
void incrementTotalEventCounter()
Definition: trigger_decoder.cpp:420
current_cycle_state_s::totalTimeNtCopy
uint32_t totalTimeNtCopy[PWM_PHASE_MAX_WAVE_PER_PWM]
Definition: trigger_decoder.h:70
TriggerWaveform::syncronizationRatioFrom
float syncronizationRatioFrom[GAP_TRACKING_LENGTH]
Definition: trigger_structure.h:137
enginePins
EnginePins enginePins
Definition: efi_gpio.cpp:28
TriggerState::curSignal
trigger_event_e curSignal
Definition: trigger_decoder.h:162
TriggerStateListener::OnTriggerStateProperState
virtual void OnTriggerStateProperState(efitick_t nowNt)=0
TriggerWaveform::isSynchronizationNeeded
bool isSynchronizationNeeded
Definition: trigger_structure.h:84
TriggerState::currentCycle
current_cycle_state_s currentCycle
Definition: trigger_decoder.h:131
TT_MIATA_VVT
@ TT_MIATA_VVT
Definition: engine_types.h:409
TriggerState::shaft_is_synchronized
bool shaft_is_synchronized
Definition: trigger_decoder.h:113
TriggerState::toothDurations
uint32_t toothDurations[GAP_TRACKING_LENGTH+1]
Definition: trigger_decoder.h:127
ScopePerf
Definition: perf_trace.h:92
TriggerConfiguration::VerboseTriggerSynchDetails
bool VerboseTriggerSynchDetails
Definition: trigger_decoder.h:34
TriggerState::isSyncPoint
bool isSyncPoint(const TriggerWaveform &triggerShape, trigger_type_e triggerType) const
Definition: trigger_decoder.cpp:711
TriggerState::toothed_previous_time
efitick_t toothed_previous_time
Definition: trigger_decoder.h:129
trigger_state_s::triggerSyncGapRatio
scaled_channel< float, 1, 1 > triggerSyncGapRatio
Definition: trigger_state_generated.h:25
time
The idea of mightResetPid is to reset PID only once each time when TPS idlePidDeactivationTpsThreshold nThe throttle pedal can be pressed for a long time
Definition: idle_state.txt:11
actualSynchGap
float actualSynchGap
Definition: trigger_decoder.cpp:111
TriggerState::getShaftSynchronized
bool getShaftSynchronized()
Definition: trigger_decoder.cpp:45
isInRange
bool isInRange(T min, T val, T max)
Definition: efilib.h:176