rusEFI
The most advanced open source ECU
Public Member Functions | Data Fields
TriggerFormDetails Class Reference

#include <trigger_structure.h>

Collaboration diagram for TriggerFormDetails:
Collaboration graph
[legend]

Public Member Functions

void prepareEventAngles (TriggerWaveform *shape)
 

Data Fields

angle_t eventAngles [2 *PWM_PHASE_MAX_COUNT]
 

Detailed Description

Misc values calculated from TriggerWaveform

Definition at line 270 of file trigger_structure.h.

Member Function Documentation

◆ prepareEventAngles()

void TriggerFormDetails::prepareEventAngles ( TriggerWaveform shape)

Definition at line 109 of file trigger_decoder.cpp.

109  {
110  int triggerShapeSynchPointIndex = shape->triggerShapeSynchPointIndex;
111  if (triggerShapeSynchPointIndex == EFI_ERROR_CODE) {
112  return;
113  }
114  angle_t firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
115  assertAngleRange(firstAngle, "firstAngle", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE);
116 
117  int riseOnlyIndex = 0;
118 
119  size_t length = shape->getLength();
120 
121  memset(eventAngles, 0, sizeof(eventAngles));
122 
123  // this may be <length for some triggers like symmetrical crank Miata NB
124  size_t triggerShapeLength = shape->getSize();
125 
126  assertAngleRange(shape->triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE2);
127  efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, getTriggerCentral()->engineCycleEventCount != 0, "zero engineCycleEventCount");
128 
129  for (size_t eventIndex = 0; eventIndex < length; eventIndex++) {
130  if (eventIndex == 0) {
131  // explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
132  eventAngles[0] = 0;
133  // this value would be used in case of front-only
134  eventAngles[1] = 0;
135  } else {
136  // Rotate the trigger around so that the sync point is at position 0
137  auto wrappedIndex = (shape->triggerShapeSynchPointIndex + eventIndex) % length;
138 
139  // Compute this tooth's position within the trigger definition
140  // (wrap, as the trigger def may be smaller than total trigger length)
141  auto triggerDefinitionIndex = wrappedIndex % triggerShapeLength;
142 
143  // Compute the relative angle of this tooth to the sync point's tooth
144  float angle = shape->getAngle(wrappedIndex) - firstAngle;
145 
146  efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, !cisnan(angle), "trgSyncNaN");
147  // Wrap the angle back in to [0, 720)
149 
150  if (shape->useOnlyRisingEdges) {
151  criticalAssertVoid(triggerDefinitionIndex < triggerShapeLength, "trigger shape fail");
152  assertIsInBounds(triggerDefinitionIndex, shape->isRiseEvent, "isRise");
153 
154  // In case this is a rising event, replace the following fall event with the rising as well
155  if (shape->isRiseEvent[triggerDefinitionIndex]) {
156  riseOnlyIndex += 2;
157  eventAngles[riseOnlyIndex] = angle;
158  eventAngles[riseOnlyIndex + 1] = angle;
159  }
160  } else {
161  eventAngles[eventIndex] = angle;
162  }
163  }
164  }
165 }
angle_t eventAngles[2 *PWM_PHASE_MAX_COUNT]
bool isRiseEvent[PWM_PHASE_MAX_COUNT]
size_t getLength() const
angle_t getAngle(int phaseIndex) const
size_t getSize() const
TriggerCentral * getTriggerCentral()
Definition: engine.cpp:589
@ CUSTOM_TRIGGER_SYNC_ANGLE_RANGE
@ CUSTOM_TRIGGER_SYNC_ANGLE2
@ CUSTOM_TRIGGER_CYCLE
@ CUSTOM_TRIGGER_SYNC_ANGLE
float angle_t
Definition: rusefi_types.h:58
static TriggerWheel eventIndex[4]
void wrapAngle(angle_t &angle, const char *msg, ObdCode code)

Referenced by TriggerCentral::prepareTriggerShape().

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

Field Documentation

◆ eventAngles

angle_t TriggerFormDetails::eventAngles[2 *PWM_PHASE_MAX_COUNT]

These angles are in event coordinates - with synchronization point located at angle zero. These values are pre-calculated for performance reasons.

Definition at line 278 of file trigger_structure.h.

Referenced by InstantRpmCalculator::calculateInstantRpm(), TriggerWaveform::findAngleIndex(), TriggerCentral::handleShaftSignal(), prepareEventAngles(), refreshMapAveragingPreCalc(), triggerShapeInfo(), and InstantRpmCalculator::updateInstantRpm().


The documentation for this class was generated from the following files: