SequenceSelector
SequenceSelector holds several Sequencer patterns and picks between them by ID.6 minute read
SequenceSelector holds several Sequencer patterns and picks
between them by ID. Give it a number and whichever sequencer lists that
number in its ids drives the output. If none matches, a configured default is
emitted.
Use it to map a machine state to an indicator pattern, or an error code to a beep sequence.
flowchart LR
i1(["input — the ID to select"]) --> B["SequenceSelector"]
B --> o1(["output — the selected pattern's values"])
Every sequencer runs every cycle. The ones that do not match are held at their element 0 and their timers reset — so a pattern always starts from the beginning when it is selected, never part-way through.
If two sequencers list the same ID, the later one wins and the earlier one runs invisibly. Nothing warns about it.
Sequencer IDs default to −1, so an unconfigured selector driven with −1 matches every sequencer at once. Give each one a real ID.
This block has no enable and no disable. To emit the default, send an ID that no sequencer lists.
Signals
Inputs
| Path | Unit | Range | Description |
|---|---|---|---|
input |
- | any integer | The ID to select on. Every sequencer is asked whether this number is in its ids list. |
Outputs
| Path | Unit | Description |
|---|---|---|
output |
whatever the patterns contain | The selected sequencer’s output, one value per channel — or defaultOutput when nothing matches. |
Parameters
| Path | Unit | Default | Range | Effect |
|---|---|---|---|---|
defaultOutput |
pattern unit | all 0 | any | What every channel shows when no sequencer matches the input. |
defaultOutput is persistent and survives a controller restart.
The patterns live below this block, in sub-trees named Sequencer01,
Sequencer02 and so on — one per sequencer, numbered from 1. Each carries its
own ids, durations and channel_NN rows. See
sequencer.md for how to fill one in.
All sequencers share one shape: the same number of elements, the same number of channels and the same ID-list length, fixed when the machine is built.
Setup
-
Read how many sequencers this instance has by looking for the
SequencerNNsub-trees, and note they are numbered from 1. -
Give every sequencer a distinct ID. They default to −1, so an unconfigured set all match the same input and only the last one shows.
-
Configure each sequencer’s
durationsandchannel_NNrows, persequencer.md. Remember each pattern starts at its element 1, and element 0 is its rest value. -
Set
defaultOutputto what the machine should show when nothing is selected — usually the same as the sequencers' element 0. -
Send an ID that no sequencer lists and confirm every channel reads
defaultOutput. -
Send each configured ID in turn and confirm the right pattern runs.
Step 6 is the only check that the IDs are distinct. If two sequencers share an ID you will see the later one and never know the earlier one is also running.
Tuning
There is nothing to tune. The work is assigning IDs and filling in the patterns.
- Keep the IDs distinct across sequencers. Nothing checks this and nothing reports a clash.
- Choose an ID that means “nothing” and make sure no sequencer lists it. That is how you get the default.
- A sequencer may list several IDs, so one pattern can serve several machine states.
- Adding an unused sequencer costs the same processing time as a used one — they all run every cycle. Size the instance to what you need.
- Nothing here depends on the task rate; the sequencers' own durations are in seconds.
The flat section is the default. Each pattern restarts from its first element
whenever its id is selected — see sequencer.md for how a
single sequence steps.
| Symptom | Cause | Action |
|---|---|---|
| Every ID produces the same pattern | The sequencers' ids are all at their default of −1, so they all match |
Give each a distinct ID |
| An ID produces the wrong pattern | Two sequencers list it, and the later one wins | Make the IDs distinct |
| A pattern seems to run but is not visible | It matched, but a later sequencer matched too and overwrote it | Check every ids list for duplicates |
| The output sits at the default for a valid ID | No sequencer lists that ID | Check the ids arrays |
| A pattern starts part-way through | Not possible — non-matching sequencers are reset, so a selected pattern always starts at the beginning | Check what consumes the output |
| The pattern flickers rapidly | That sequencer’s durations are zero |
Set positive durations in its sub-tree |
| The first value of a pattern never appears | Expected: a sequence starts at its element 1 | Put the first step in element 1 |
| Switching IDs restarts the new pattern from the beginning | Expected, and deliberate | This is the designed behaviour |
| I cannot tell which sequencer is selected | The block does not publish it | Compare input against each sub-tree’s ids |
| I need more patterns | The count is fixed when the machine is built | It needs a configuration change |
| I need a longer pattern than the others | All sequencers share one shape | It needs a configuration change |
A starting point for three patterns selected by machine state, with state 0 meaning idle:
defaultOutput = 0.0
Sequencer01/ids = 1, -1, -1, ...
Sequencer02/ids = 2, -1, -1, ...
Sequencer03/ids = 3, -1, -1, ...
Sending 0 gives the default; 1, 2 and 3 give the three patterns. Note the unused ID slots are left at −1, so do not send −1 as a selection.
Limits and errors
| Limit | Set by | What happens | Reported |
|---|---|---|---|
| ID uniqueness | Nothing | Not checked. If two sequencers list the same ID, the later one’s output wins and the earlier one runs unseen | Not reported |
| Unconfigured IDs | Fixed | Sequencer IDs default to −1, so an ID of −1 matches every unconfigured sequencer | Not reported |
| Selected sequencer | Not published | Which pattern is running cannot be read from the parameter tree | Not reported |
| No match | defaultOutput |
Every channel takes the default. This is the only way to select “nothing” | Not reported |
| Sequencer shape | Machine configuration | Element count, channel count and ID-list length are the same for every sequencer and fixed when the machine is built | Not reported |
| Processing cost | Fixed | Every sequencer runs every cycle whether selected or not | Not reported |
output |
Nothing | Whatever the patterns contain. Bound it downstream if the consumer needs a limit | Not reported |
| Block state | None at this level | Each sequencer resets itself as soon as it stops matching | Not reported |
The block raises no errors or warnings and logs nothing. Every failure above shows as a value on a trace, not as a message.
Verified against motorcortex-control3 3.30.0 (bc348fd).