rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
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 260 of file trigger_structure.h.

Member Function Documentation

◆ prepareEventAngles()

void TriggerFormDetails::prepareEventAngles ( TriggerWaveform shape)

Definition at line 117 of file trigger_decoder.cpp.

117 {
118 int triggerShapeSynchPointIndex = shape->triggerShapeSynchPointIndex;
119 if (triggerShapeSynchPointIndex == EFI_ERROR_CODE) {
120 return;
121 }
122 angle_t firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
123 assertAngleRange(firstAngle, "firstAngle", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE);
124
125 size_t length = shape->getLength();
126
128
129 // this may be <length for some triggers like symmetrical crank Miata NB
130 size_t triggerShapeLength = shape->getSize();
131
132 assertAngleRange(triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE2);
133 efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, getTriggerCentral()->engineCycleEventCount != 0, "zero engineCycleEventCount");
134
135 for (size_t eventIndex = 0; eventIndex < length; eventIndex++) {
136 if (eventIndex == 0) {
137 // explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
138 eventAngles[0] = 0;
139 // this value would be used in case of front-only
140 eventAngles[1] = 0;
141 } else {
142 // Rotate the trigger around so that the sync point is at position 0
143 auto wrappedIndex = (triggerShapeSynchPointIndex + eventIndex) % length;
144
145 // Compute this tooth's position within the trigger definition
146 // (wrap, as the trigger def may be smaller than total trigger length)
147 auto triggerDefinitionIndex = wrappedIndex % triggerShapeLength;
148
149 // Compute the relative angle of this tooth to the sync point's tooth
150 float angle = shape->getAngle(wrappedIndex) - firstAngle;
151
152 efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, !std::isnan(angle), "trgSyncNaN");
153 // Wrap the angle back in to [0, 720)
155
156 if (shape->useOnlyRisingEdges) {
157 criticalAssertVoid(triggerDefinitionIndex < triggerShapeLength, "trigger shape fail");
158 assertIsInBounds(triggerDefinitionIndex, shape->isRiseEvent, "isRise");
159
160 // In case this is a rising event, replace the following fall event with the rising as well
161 if (shape->isRiseEvent[triggerDefinitionIndex]) {
162 eventAngles[eventIndex] = angle;
163 eventAngles[eventIndex + 1] = angle;
164 }
165 } else {
166 eventAngles[eventIndex] = angle;
167 }
168 }
169 }
170}
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:593
@ CUSTOM_TRIGGER_SYNC_ANGLE_RANGE
@ CUSTOM_TRIGGER_SYNC_ANGLE2
@ CUSTOM_TRIGGER_CYCLE
@ CUSTOM_TRIGGER_SYNC_ANGLE
float angle_t
void setArrayValues(TValue(&array)[TSize], float value)
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 268 of file trigger_structure.h.

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


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