Correct trigger decoding comes before fuel or spark. RT-STACK timestamps trigger edges with the STM32 DWT cycle counter and feeds them into the configurable decoder. The current source is set for a 60-2 crank wheel and optional cam-based phase recognition.
Where settings live
Use Core/Inc/trigger_decoder_config.h to adapt the decoder. It contains the crank channel, tooth count, missing-tooth count, gap ratio, angular offset, interpolation choice and cam-pattern tables.
Crank setup
- Select the physical timing channel used by the crank sensor.
- Set total tooth positions and missing-tooth count.
- Tune the period ratio used to recognise the missing-tooth gap.
- Set the first tooth after the gap relative to the engine TDC convention.
- Validate the selected interpolation method across cranking, acceleration and high RPM.
Cam and phase
Optional cam channels use long/short interval pattern recognition. When phase fusion is enabled, the firmware forms a 0 to 720 degree engine-cycle angle from the crank position plus the recognised cam phase. Cam-table angles must use the same origin as the crank configuration.
Validation sequence
- Capture raw crank and cam signals with an oscilloscope.
- Confirm electrical behaviour, edge polarity and noise margin.
- Use a signal generator or motored engine to validate tooth count, RPM and absolute angle.
- Deliberately prove loss-of-sync and recovery behaviour.
- Only then validate phase-dependent outputs with passive loads.
Suggested screenshot: full 60-2 oscilloscope capture with decoded angle/RPM trace after the validation sequence.