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