Sequencer Input SQI
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 |
|---|---|
| SQI1 | LEN 8 POS 1 EN 1 DN 0 |
| SQI1_Data | [0, 0, 0, 0, 0, 0, 0, 0] |
| SQI1_Execute | 1 |
| SQI1_Match | 1 |
| SQI1_Reset | 0 |
How it works
Each time Execute turns on, compares Source with the step at POS under Mask, sets Match on if they agree and off if not, then moves POS to the next step. POS moves on at every Execute, whether or not they agree.
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 step it checks is the one at POS. POS then moves on at every Execute, whether or not Match is on, and returns to 0 after the last step.
- Match changes only when Execute turns on. In between, it keeps its last value.
- Reset sets POS to 0.
- 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 SQI to check that inputs arrive in the expected order, such as three sensors that must trip one after another.
1. Execute with Sensor 1. Step 0 is 1 and Sensor is 1, so Match is on. POS becomes 1.
2. Turn Next off. Execute is off. Match stays on: it changes only when Execute turns on.
3. Execute with Sensor 1 again. Step 1 is 2 and Sensor is 1, so Match goes off. POS becomes 2 anyway.
4. Turn Next off. Execute is off. Nothing moves.
5. Execute with Sensor 4. Step 2 is 4 and Sensor is 4, so Match is on. POS returns to 0.
| Step | Sensor | Same | Check.POS |
|---|---|---|---|
| 1. Execute with Sensor 1 | 1 | 1 | 1 |
| 2. Turn Next off | 1 | 1 | 1 |
| 3. Execute with Sensor 1 again | 1 | 0 | 2 |
| 4. Turn Next off | 1 | 0 | 2 |
| 5. Execute with Sensor 4 | 4 | 1 | 0 |
Match was on for step 0, off for step 1 (Source 1 is not 2) and on for step 2. POS moved on at every Execute, whether or not it matched, and wrapped to 0 after step 2.
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 |
| Source | The word compared with the current step. | DINT or a number | Reads |
| Match | On when the masked Source equals the current step. | BOOL | Writes |
Common mistakes
- Expecting Match to stay onMatch is checked against the current step only, each time Execute turns on.
- 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.