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.

TagAfter two scans
SQI1LEN 8 POS 1 EN 1 DN 0
SQI1_Data[0, 0, 0, 0, 0, 0, 0, 0]
SQI1_Execute1
SQI1_Match1
SQI1_Reset0

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.

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 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

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 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.

StepSensorSameCheck.POS
1. Execute with Sensor 1111
2. Turn Next off111
3. Execute with Sensor 1 again102
4. Turn Next off102
5. Execute with Sensor 4410

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

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
SourceThe word compared with the current step.DINT or a numberReads
MatchOn when the masked Source equals the current step.BOOLWrites

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.

Related