← All exercises

Single-Trigger Sequencer

medium

Advances through three steps using one shared Next button.

What it teaches

Your first explicit state sequencer: one state number, three mutually exclusive active-step flags, and one shared edge-triggered input that advances every step. The manual-advance skeleton — an operator stepping a machine through setup positions one press at a time.

Inputs and outputs

TagTypeDefaultDescription
In_NextBOOLEach press advances to the next step
In_ResetBOOLReturns the sequencer to Idle
Sts_Step1ActiveBOOL1 only while step 1 is active
Sts_Step2ActiveBOOL1 only while step 2 is active
Sts_Step3ActiveBOOL1 only while step 3 is active
Sts_StepDINT0=Idle, 1=Step1, 2=Step2, 3=Step3

Required behavior

  • A fresh block starts in Idle with Sts_Step at 0 and all active-step flags off.
  • Each 0-to-1 transition of In_Next advances one position: Idle to Step1, then Step2, then Step3.
  • Exactly one active-step flag is on in steps 1-3; holding In_Next does not skip steps.
  • Step3 holds until In_Reset returns the sequencer to Idle.
  • In_Reset wins if it is on in the same scan as a new In_Next press. That press is discarded; releasing Reset while Next remains high does not advance.