Sequencer Output SQO

At the right of a rung in a program's ladder routine. Not in a Logic Class. Placing it creates its control tag.

TagAfter two scans
SQO1LEN 8 POS 1 EN 1 DN 0
SQO1_Data[0, 0, 0, 0, 0, 0, 0, 0]
SQO1_Dest0
SQO1_Execute1
SQO1_Reset0

How it works

Each time Execute turns on, copies the bits selected by Mask from the step at POS to Dest. Bits outside Mask keep their values in Dest. POS then moves to the next step. The first Execute writes step 0 and POS becomes 1. After the last step, POS returns to 0.

Status bits

The Control tag holds the state. Read a bit with the tag name and a dot, such as Control.DN.

BitMeaning
.ENOn while Execute is on.
.DNDone: on when Execute takes the sequencer past its last step. POS returns to 0, and DN stays on until Execute turns off or Reset is on.
.LENLength: how many steps the sequencer has. It cannot be more than the size of the array.
.POSPosition: the step the next Execute uses, from 0 to LEN - 1. Reset sets it to 0.

Rules

  • The first Execute writes step 0 and POS becomes 1. After the last step, POS returns to 0.
  • It acts once when Execute turns on, not on every scan.
  • Reset sets POS to 0 and leaves Dest as it was.
  • A sequencer has no EU, EM or FU bits.

Over time

A FIFO Load with Execute on for scans 2 and 3, off at scan 4, then on for scans 5 to 7. POS moves one step at scan 2 and one at scan 5, each time Execute turns on. Holding Execute on adds no steps.Scan12345678Execute.EN.POS011122222 Execute turns on: one step3 Held on: no step5 Turns on again: next step
ScanExecute.EN.POS
1OffOff0
2OnOn1
3OnOn1
4OffOff1
5OnOn2
6OnOn2
7OnOn2
8OffOff2

The chart shows a FIFO Load; the others act on Execute the same way. One step happens on the scan where Execute turns on. Holding Execute on does nothing more, so turn it off and on for the next step.

How it's used

Use SQO to step outputs through a fixed pattern, such as three lamps one after another.

1. Execute. The first Execute writes step 0: Lamps is 1. POS becomes 1.

StepLampsLights.POSLights.DN
1. Execute110
2. Turn Next off110
3. Execute220
4. Turn Next off220
5. Execute401
6. Hold Execute on401
7. Turn Next off400
8. Execute110

Lamps went 1, 2, 4 and back to 1 as Execute turned on four times. POS went 1, 2, 0, 1: after the last step it returns to 0.

Operands

OperandWhat it is forData typeRead or write
ExecuteA BOOL that makes the instruction act once each time it turns on.BOOLReads
ResetA BOOL that, while on, clears the control tag and starts over.BOOLReads
ArrayThe array holding one value for each step.Array of DINTReads
ControlThe CONTROL tag that tracks the position, length and status.CONTROLReads and writes
MaskWhich bits count: only bits that are on in Mask are used.DINT or a numberReads
DestThe word that receives the masked value of the current step.DINTReads and writes

Common mistakes

  • Masking out the bits you want to driveOnly the bits that are on in Mask reach Dest. A Mask of -1 passes them all.
  • Rung already true on the first scanA rung that is already true on the first scan after a reset acts once, the same as any other scan where Execute turns on.

Related