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 262 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 float lastAnglePrimary = 0.0;
136 float lastAngleSecondary = 0.0;
137
138 for (size_t eventIndex = 0; eventIndex < length; eventIndex++) {
139 if (eventIndex == 0) {
140 // explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
141 eventAngles[0] = 0;
142 // this value would be used in case of front-only
143 eventAngles[1] = 0;
144 } else {
145 // Rotate the trigger around so that the sync point is at position 0
146 auto wrappedIndex = (triggerShapeSynchPointIndex + eventIndex) % length;
147
148 // Compute this tooth's position within the trigger definition
149 // (wrap, as the trigger def may be smaller than total trigger length)
150 auto triggerDefinitionIndex = wrappedIndex % triggerShapeLength;
151
152 // Compute the relative angle of this tooth to the sync point's tooth
153 float angle = shape->getAngle(wrappedIndex) - firstAngle;
154
155 efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, !std::isnan(angle), "trgSyncNaN");
156 // Wrap the angle back in to [0, 720)
158
159 if (shape->useOnlyRisingEdges) {
160 criticalAssertVoid(triggerDefinitionIndex < triggerShapeLength, "trigger shape fail");
161 assertIsInBounds(triggerDefinitionIndex, shape->isRiseEvent, "isRise");
162 bool primary = shape->getWheel(triggerDefinitionIndex) == TriggerWheel::T_PRIMARY ? true : false;
163 // In case this is a rising event, store the angle to be used for the next falling event.
164 if (shape->isRiseEvent[triggerDefinitionIndex]) {
165 eventAngles[eventIndex] = angle;
166 if (primary) {
167 lastAnglePrimary = angle;
168 } else {
169 lastAngleSecondary = angle;
170 }
171 // If this is a falling event, apply the angle of the last rising event on this channel.
172 } else if (primary) {
173 eventAngles[eventIndex] = lastAnglePrimary;
174 } else {
175 eventAngles[eventIndex] = lastAngleSecondary;
176 }
177 } else {
178 eventAngles[eventIndex] = angle;
179 }
180 }
181 }
182}
angle_t eventAngles[2 *PWM_PHASE_MAX_COUNT]
bool isRiseEvent[PWM_PHASE_MAX_COUNT]
size_t getLength() const
angle_t getAngle(int phaseIndex) const
TriggerWheel getWheel(size_t index)
size_t getSize() const
TriggerCentral * getTriggerCentral()
Definition engine.cpp:592
@ 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 270 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: