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.
| Tag | After two scans |
|---|---|
| SQO1 | LEN 8 POS 1 EN 1 DN 0 |
| SQO1_Data | [0, 0, 0, 0, 0, 0, 0, 0] |
| SQO1_Dest | 0 |
| SQO1_Execute | 1 |
| SQO1_Reset | 0 |
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.
| Bit | Meaning |
|---|---|
| .EN | On while Execute is on. |
| .DN | Done: 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. |
| .LEN | Length: how many steps the sequencer has. It cannot be more than the size of the array. |
| .POS | Position: 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
| Scan | Execute | .EN | .POS |
|---|---|---|---|
| 1 | Off | Off | 0 |
| 2 | On | On | 1 |
| 3 | On | On | 1 |
| 4 | Off | Off | 1 |
| 5 | On | On | 2 |
| 6 | On | On | 2 |
| 7 | On | On | 2 |
| 8 | Off | Off | 2 |
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.
2. Turn Next off. Execute is off. Nothing moves.
3. Execute. Step 1 goes out: Lamps is 2 and POS is 2.
4. Turn Next off. Execute is off. Nothing moves.
5. Execute. Step 2 is the last. Lamps is 4, DN is on and POS returns to 0.
6. Hold Execute on. Execute is still on. Lamps stays 4, POS stays 0 and DN stays on; no new step runs.
7. Turn Next off. Execute is off. DN turns off, and Lamps stays 4.
8. Execute. It starts again at step 0: Lamps is 1.
| Step | Lamps | Lights.POS | Lights.DN |
|---|---|---|---|
| 1. Execute | 1 | 1 | 0 |
| 2. Turn Next off | 1 | 1 | 0 |
| 3. Execute | 2 | 2 | 0 |
| 4. Turn Next off | 2 | 2 | 0 |
| 5. Execute | 4 | 0 | 1 |
| 6. Hold Execute on | 4 | 0 | 1 |
| 7. Turn Next off | 4 | 0 | 0 |
| 8. Execute | 1 | 1 | 0 |
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
| Operand | What it is for | Data type | Read or write |
|---|---|---|---|
| Execute | A BOOL that makes the instruction act once each time it turns on. | BOOL | Reads |
| Reset | A BOOL that, while on, clears the control tag and starts over. | BOOL | Reads |
| Array | The array holding one value for each step. | Array of DINT | Reads |
| Control | The CONTROL tag that tracks the position, length and status. | CONTROL | Reads and writes |
| Mask | Which bits count: only bits that are on in Mask are used. | DINT or a number | Reads |
| Dest | The word that receives the masked value of the current step. | DINT | Reads 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.