2. Sections 11-1, 11-2, 11-3, 11-4 to 11-4-3, 11-5
to 11-8 (Focus on the Sequencer Out (SQO))
Sequencers
Chapter 11
3. 3
Sequencers can be used whenever a repeatable
operating pattern is required.
Sequencers are used for controlling any machine
or process that requires discrete repetitive and
sequential operations. Examples would be:
Dishwashers
Material handling mechanisms,
Mechanical presses,
Packaging machines,
Rotary tables
…and in many other applications where accurate.
Sequencers
Wash Machine Cam Switch on How It Works
4. Mechanical
Sequencers
Mechanical sequencers
are often referred to
as drum switches,
rotary switches,
stepper switches or
cam switches.Typical cam switch
The mechanical cam-operated sequencer switch
uses an electric motor to drive the cams. A series of
leaf-spring-mounted contacts or micro switches
interact with the cam so that, in different degrees
of rotation of the cam, various contacts are closed
and opened to energize and/or de-energize various
electrical devices.
6. 6
A mechanical drum-operated sequencer
switch consists of a series of contacts that
are operated by pegs located on a motor
driven drum.
The pegs can be placed at predetermined
locations around the circumference of the
drum to operate contacts.
Mechanical Drum
Operated Switch
7. 7
When the drum is rotated, Microswitch®
actuators that align with the pegs will
close or open the contacts of the Micro
switch®, while the Microswitch® contacts
where there are no pegs will remain open.
The presence of a peg can be thought of
as a logic ‘1’ or ON. The absence of a peg
can be thought of as a logic ‘0’ or OFF.
Mechanical Drum
Operated Switch
9. Programmed
Sequencer Control
Sequencer instructions can
make programming many
applications a much easier
task.
The ON/OFF operation of
multiple discrete outputs
can be controlled using a
sequencer instruction,
often with one ladder rung.
By contrast, the equivalent
contact-coil ladder control
arrangement would need
many rungs of code.
Picture – Unknown source
10. 10
The advantage of sequencer programming over
the conventional program is the large savings of
memory words. Typically, the sequencer program
can do in 20-words what a standard program
does in 100-words.
By setting up a sequence of events, sequencers
make programming simpler and any future
changes easier to make.
The sequencer output (SQO) instruction can be
used to control output devices sequentially. The
desired sequence of operation is stored in a data
file or array, and this information is then
transferred sequentially to the outputs.
Programmed
Sequencer Control
11. 11
Sequencer instructions are usually retentive.
Some sequencer instructions have an upper limit
to the number of external outputs and steps that
can be operated on by a single instruction.
Many sequencers instructions reset the sequencer
automatically to step 1 on completion of the last
sequence step. Other instructions provide an
individual reset control line or a combination of
both.
Programmed
Sequencer Control
12. 12
To program a sequencer, data is entered into a
series of consecutive memory words. These
consecutive memory words are referred to as a
word file, or simply a file, or an array.
The SQO instruction can be used to sequentially
control output devices. The desired sequence of
operation is stored in a data file or array and this
information is then transferred sequentially to the
outputs.
As the sequencer advances through the steps,
data is transferred from the File or Array, through
a Mask to the Destination; one word at-a-time on
every index of the sequencer.
Programmed
Sequencer Control
14. 14
The PLC Sequencer Out Instruction (SQO) can be used to
replace electromechanical drum switches.
The SQO instruction is an output instruction.
SQO instructions can perform the same specific “ON” or
“OFF” patterns of outputs that are continuously repeated,
exactly like a mechanical drum switch, but the SQO offers
more flexibility.
In some ways, the SQO functions as a glorified MVM
instruction. This will be shown in the next series of slides.
Sequencer Out
Instruction
15. 15
The SQO instruction has six parameters:
File – Address of the data file that stores the “cam lobe or
peg” data
Mask – Word or hexadecimal program constant (same as
MVM)
Dest (Destination) – Output of the sequencer. (Any valid word
level address)
Control – Address of the instruction. Uses the control file,
default file 6
Length – Stores the number of positions or steps
Position – Stores the current position of the sequencer
Sequencer Out
Instruction (SQO)
16. 16
SQO Control Block
The SQO instruction uses the Control File, Default File 6,
(R6). The control block for the SQO is shown above with
the SQO status bits in red. Following is a description of the
functions:
Enable bit 15 (EN)
Sets to a logic ‘1’ when the rung containing the SQO instruction is
true, otherwise it is a logic ‘0’.
Done bit 13 (DN)
Sets to a logic ‘1’ when the SQO has operated on the last word in
the SQO file. This occurs when the value stored in the length (LEN)
parameter, Word 1, is equal to the value stored in the position
(POS) parameter, Word 2), (POS = LEN), otherwise it is a logic ‘0’.
It is set to a logic ‘0’ on the next false-to-true rung transition.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length of Sequencer File
Word 2 Position
17. 17
SQO Control Block
The SQO instruction uses the Control File, Default File 6,
(R6). The control block for the SQO is shown above.
Following is a description of the functions:
Error bit 11 (ER)
Sets to a logic ‘1’ if the instruction generates an error such as a
negative or zero value being entered, moved or copied into the
Length (LEN) parameter.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length of Sequencer File
Word 2 Position
18. 18
SQO Control Block
The SQO instruction uses the Control File, Default File 6,
(R6). The control block for the SQO is shown above.
Following is a description of the functions:
Word 1 Length (LEN)
Stores the value of the length parameter. It is the number of steps
or the number of positions that the sequencer will make. The
range of value for the SLC-500 series is 1 to 255.
Word 2 Position (POS)
Stores the current position, or step, of the sequencer.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length of Sequencer File
Word 2 Position
19. 19
Word level addresses are used to address the
value of a 16-bit word. Therefore, to read the
value of the length or position word of the control
file being used to address an SQO instruction,
use a word level address as follows:
R6:0.1 or R6:0.LEN = Length of the sequencer file
R6:0.2 or R6:0.POS = Value of the current position or
step
Any word in the AB memory structure can be
addressed to bit level, here is an example:
R6:0.LEN/8
This is the bit level address that is referencing bit-8 in the
length word of the instruction addressed to element zero.
Control File Address
20. 20
As mentioned earlier, the SQO instruction has
6-parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
Control
This is the address of the instruction. It is a control
structure that stores the status bits, the length and the
position. Ex. SLC500 address R6:5.
Dest
This is a word level address where the data from the
instruction will be sent. It is the instruction output
destination.
SQO Parameters
21. 21
As mentioned earlier, the SQO instruction has 6-
parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
Mask
The mask works exactly like the mask in the MVM
instruction. It can be a word level address or a
hexadecimal program constant. The Source (File or Array)
of the SQO will be passed through the mask before it is
stored in the destination word.
If the mask is a file or array, the length of the file or array
must be equal to the length of the sequencer data file or
array. The two files or arrays will track automatically.
When SQO transfers 16-bits of data to an output word
there might be outputs associated with the word that do
not need to be controlled by the SQO. By masking these
bits the SQO will not control them and they could be used
for other purposes in the program.
SQO Parameters
22. 22
As mentioned earlier, the SQO instruction has 6-
parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
File or Array
This is a word level address that defines the starting
word of the sequencer data file or array. The
sequencer file or array is where the “Source” data of
the SQO is stored. (Cam lobes high = 1, Cam lobes
low = 0). These 1’s and 0’s must be entered into the
file or array before the program is downloaded to the
processor.
In the SLC500, this is an indexed address, therefore
the index symbol (#) must be used in the address.
SQO Parameters
23. 23
File instructions such as the SQO require the use
of a user-defined file that is positioned within one
of the data table files. These user defined files
are addressed using an indexed word. They store
an offset value in word S:24. They can also be
thought of as a file-within-a-file.
SQO Parameters
24. 24
SQO Parameters
Bit file B3
The address #B3:2, along with the LEN
parameter, defines a number of words
within a data file. The number of words
used is the LEN + 1 therefore,
with LEN = 4, the number of words is
LEN + 1 = 5
These numbers are
the SQO position
25. 25
File
The file parameter is an indexed (#) word level
address, as an example: #B23:0. The address
is the starting word of the sequencer data file.
When assigning the address of this word and
the length of the file that it is to define, make
sure that none of the words overlap with bits
and words that are already being used other
places in the program. It is most often a good
practice to create a user defined file of the
appropriate data type for this address
The number of words that are used in the file
being defined will be equal to the value of the
Length (LEN) parameter + 1.
SQO Parameters
26. 26
Length (LEN)
The length (LEN) parameter stores the value that defines the
number of steps the sequencer should make.
This parameter also defines the length of the sequencer data
file starting at the indexed address referenced in the file
parameter.
Valid input to this parameter is a program constant that is: >0
and ≤255.
The number of words used in the sequencer data file is the
LEN + 1 therefore, if the LEN parameter is 5, the number of
words used in the sequencer data file is LEN + 1 = 6
Example: #B23:0 with a length of 5 would assign a sequencer
data file that consists of: B23:0, B23:1, B23:2, B23:3, B23:4, &
B23:5
A length value that points past the end of a data file will cause
a run-time error. The data file can not cross file boundaries.
SQO Parameters
27. 27
Position (POS)
The position parameter stores the current step of the
sequencer. Steps are numbered starting at zero.
In the previous example, with a length of 5, there are
6-words used in the file. Each of the 6-words correspond
to a sequencer position. In this example:
B23:0 = Step 0
B23:1 = Step 1
B23:2 = Step 2
B23:3 = Step 3
B23:4 = Step 4
B23:5 = Step 5
Position zero is the startup position of the sequencer.
(More on this later).
SQO Parameters
28. 28
Sequencers, sequence on false-to-true
rung transitions.
When the rung containing the sequencer
transitions from false-to-true the POS
value increments by one and is indexed to
the word in the sequencer data file for
that position.
The data from the sequencer data file for
that position is than transferred through
the mask to the destination address.
SQO Functionality
29. 29
When the value stored in the POS is equal
to the value stored in the LEN, the
sequencer is done and the Done (DN) bit
sets to a logic ‘1’.
Done (DN) when POS = LEN
When the SQO is DN, on the next false-to-
true transition, the position value will
return to 1 and the Done (DN) bit resets
to a logic ‘0’.
SQO Functionality
30. SQO Functionality
1
Data from
Position 1 is
moved to the
destination
2
Data from
Position 2 is
moved to the
destination
3
Data from
Position 3 is
moved to the
destination
4
Data from
Position 4 is
moved to the
destination
Click to animate
31. 31
A sequencer instruction can be:
Event-driven
Time-driven
An event-driven sequencer operates in a similar
manner to a mechanical stepper switch that
increments by one step for each pulse (input
signal) applied to it.
A time-driven sequencer operates similar to a
mechanical drum switch that increments
automatically after a preset time period.
For a sequencer to be incremented automatically
through each step the program must have some sort of
timed element or element that transitions from false-to-
true incorporated into the ladder program.
SQP Program
34. 34
So far the data from position zero has not been
used
Why?
When is it used?
Position zero is the start-up position of the
sequencer. On start-up (processor being switched
from PROG to RUN or First-Scan), there might be
outputs or other data that need to be set to a
start-up condition. This data is placed in the
start-up position of the sequencer data file.
But…on the first false-to-true rung transition the
SQO indexes to position one and transfers the
data from position one to the output destination.
SQO – Position Zero
Operation
35. 35
To use the data stored in position zero:
The rung containing the sequencer must be true and the
position parameter must be zero when the processor is
switched from PROG mode to RUN mode (first-scan of
the program).
If the rung is true on the first scan of the program and
the position is set to zero, the data from position zero
will be transferred from the position zero word of the
SQO data file or array through the Mask to the
Destination.
To summarize:
The only way to get the data from position zero to be
transferred to the destination is if the position parameter is
equal to zero (POS = 0) and the rung containing the SQO
is true on the first-scan of the program.
SQO – Position Zero
Operation
37. 37
Sequencer instructions use a structure of data
type Control.
The Control structure is used for a variety of
instruction including but not limited to:
Sequencer Out (SQO), Sequencer Compare (SQC),
Sequencer Load (SQL)
Bit Shift Left (BSL), Bit Shift Right (BSR)
Many other instructions
Control Data Type
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
38. 38
The Control Structure consists of 3-words of data
type DINT:
Word 0 – Status word. Contains the status bits for the
instruction being addressed. Not all status bits are used
for all instructions that use the Control data type.
Word 1 – Stores the length of the array.
Word 2 – Stores the position pointer.
Control Data Type
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
39. 39
The PLC Sequencer Out Instruction (SQO) can be used to
replace electromechanical drum switches.
The SQO instruction is an output instruction.
SQO instructions can perform the same specific “ON” or
“OFF” patterns of outputs that are continuously repeated,
exactly like a mechanical drum switch, but the SQO offers
more flexibility.
In some ways, the SQO functions as a glorified MVM
instruction. This will be shown in the next series of slides.
ControlLogix SQO
40. 40
The SQO instruction has six parameters:
Array – An array tag of type DINT that is the data
location that stores the “cam lobe or peg” data; 1’s and
0’s. This data must be manually entered before
downloading the program to the processor.
Mask – Tag of type DINT, SINT, INT or a hexadecimal
program constant that acts like a filter (same as MVM)
Dest (Destination) – Tag of type DINT that is the output
of the sequencer
ControlLogix SQO
41. 41
The SQO instruction has six parameters:
Control – Tag of data type CONTROL and is the control
structure for the instruction operation
Length – A program constant that is the number of
elements in the array; number of steps or positions. The
array size must be at least one element larger than the
size of the length.
Position – A program constant that stores the current
position of the sequencer
ControlLogix SQO
42. 42
The SQO instruction uses the CONTROL structure
data type. Following is a description of the
functions:
Enable bit 31 (.EN) Type BOOL
Sets to a logic ‘1’ when the rung containing the SQO
instruction is true, otherwise it is a logic ‘0’.
SQO Control Block
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
43. 43
The SQO instruction uses the CONTROL structure
data type. Following is a description of the
functions:
Done bit 29 (.DN) Type BOOL
Sets to a logic ‘1’ when the SQO has operated on the last
word in the SQO array. This occurs when the value stored
in the length (LEN) parameter, Word 1, is equal to the
value stored in the position (POS) parameter, Word 2,
(POS = LEN), otherwise it is a logic ‘0’. It is set to a logic
‘0’ on the next false-to-true rung transition.
SQO Control Block
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
44. 44
The SQO instruction uses the CONTROL structure
data type. Following is a description of the
functions:
Error bit 27 (.ER) BOOL
Sets to a logic ‘1’ if the instruction generates an error such
as a negative or zero value being entered, moved or copied
into the Length (LEN) parameter.
SQO Control Block
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
45. 45
The SQO instruction uses the CONTROL structure
data type. Following is a description of the
functions:
Word 1 Length (.LEN) DINT
Must be entered as a program constant.
Stores the value of the length parameter. It is the number
of steps or positions that the sequencer will make; the
number of steps in the sequencer array.
SQO Control Block
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
46. 46
The SQO instruction uses the CONTROL structure
data type. Following is a description of the
functions:
Word 2 Position (.POS) DINT
Must be entered as a program constant and will usually
start at zero.
Stores the current position, or step, of the sequencer.
SQO Control Block
31 30 29 28 27 26 25 24 Bits 23 to 16 15 0
Word 0 EN EU DN EM ER UL IN FD Reserved
Word 1 Length (LEN)
Word 2 Position (POS)
47. 47
Word level tags are used to address the value of
a binary word. Therefore, to read the value of the
length or position word of the control structure
being used for a SQO instruction, use a word
level tag as follows, assuming the tag name is;
ControlTag:
ControlTag.LEN = Length of the sequencer array
ControlTag.POS = Value of the current position or step
Control Tags
48. 48
Any word in the ControlLogix tag structure can be
addressed to bit level, here is an example:
ControlTag.LEN.8
This is bit 8 of the Length word for the SQO instruction
with the Control tag named: ControlTag.
ControlTag.DN
This is the done bit for the SQO instruction with the Control
tag named: ControlTag.
Control Tags
49. 49
As mentioned earlier, the SQO instruction has
6-parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
Control (Tag of data type Control)
This is the control structure of the instruction. It is a tag of
data type Control that stores the status bits, the length and
the position.
Dest (Tag of data type DINT)
This is a word level tag where the data from the instruction
will be sent. It is the instruction output destination. This
can be any valid word level tag of type DINT with or
without an alias.
SQO Parameters
50. 50
As mentioned earlier, the SQO instruction has 6-
parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
Mask (Tag of data type SINT, INT, or DINT, or a
hexadecimal constant)
The mask works exactly like the mask in the MVM
instruction. It can be a word level tag or a hexadecimal
program constant. The Source Array of the SQO will be
passed through the mask before it is stored in the
destination word.
If the mask is an array, the length of the mask array must
be equal to the length of the sequencer data array. The
two arrays will track automatically.
When the SQO transfers 32-bits of data to an output word
there might be outputs associated with the word that do
not need to be controlled by the SQO. By masking these
bits the SQO will not control them and they could be used
for other purposes in the program.
SQO Parameters
51. 51
As mentioned earlier, the SQO instruction has
6-parameters. The function of each parameter is
outlined here but not in the order that they
appear in the instruction:
Array (Tag of data type DINT)
This is a word level tag that defines the starting word of
the sequencer data array. The sequencer array is where
the “Source” data of the SQO is stored. (Cam lobes high =
1, Cam lobes low = 0)
Before proceeding with the explanation of the Array
parameter an understanding of array operations must be
achieved. Review the section in your text or in the
appropriate PowerPoint for arrays and indexing through
arrays.
SQO Parameters
52. 52
Array instructions such
as the SQO require the
use of an array in the
Array parameter.
SQO Parameters
SQOArray elements at word level SQOArray element at bit level
53. 53
Array
The array parameter is a word level array tag,
as an example: a tag named SQOArray is
configured as a one dimensional array having
ten elements:
SQOArray[0] through SQOArray[9].
The tag SQOArray[0] is the starting array
element of the sequencer data array. When
assigning the array tag of this word and the
length of the array that it is to define, make
sure that the number of elements in the array
are at least one more than the value of the
instructions LEN parameter.
SQO Parameters
54. 54
Array
The number of words that are used in the
array being defined will be equal to the value
of the Length (LEN) parameter + 1. Therefore,
the array referenced in the Array parameter
must have one element more than the value
referenced in the length parameter.
SQO Parameters
55. 55
Length (LEN)
The length (LEN) parameter stores the value
that defines the number of steps the
sequencer should make.
This parameter also defines the number of
words required in the sequencer array.
Valid input to this parameter is a program
constant that is: >0 with the upper limit
restricted to the size of the available memory.
SQO Parameters
56. 56
Length (LEN)
The number of words used in the sequencer
data array is the LEN + 1 therefore, if the LEN
parameter is 9, the number of words used in
the sequencer data array is LEN + 1 = 10
Example: SQOArray needs to be a 1-dimensional
array of size ten. SQOArray[0], SQOArray[1],
SQOArray[2], SQOArray[3], SQOArray[4],
SQOArray[5], SQOArray[6], SQOArray[7],
SQOArray[8], SQOArray[9]
A length value that points past the end of a
data array will cause a run-time error.
SQO Parameters
57. 57
Position (POS)
The position parameter stores the current step of the
sequencer. Steps are numbered starting at zero.
In the previous example, with a length of 9, there are
10-array elements used. Each of the 10-words
correspond to a sequencer position. In this example:
SQO_Array[0] = Step 0
SQO_Array[1] = Step 1
SQO_Array[2] = Step 2
SQO_Array[10] = Step 9
Position zero is the startup position of the sequencer.
(More on this later).
SQO Parameters
58. 58
Sequencers, sequence on false-to-true
rung transitions.
When the rung containing the sequencer
transitions from false-to-true the POS
value increments by one and indexes to
that array element in the sequencer Array.
The data from the sequencer array for
that position is than transferred through
the mask to the destination tag.
SQO Functionality
59. 59
When the value stored in the POS is equal
to the value stored in the LEN, the
sequencer is done and the Done (.DN) bit
sets to a logic ‘1’.
Done (.DN) when POS = LEN
On the next false-to-true transition, the
position value will return to 1 and the
Done (.DN) bit resets to a logic ‘0’.
SQO Functionality
60. 60
A sequencer program can be:
Event-driven
Time-driven
An event-driven sequencer operates in a similar
manner to a mechanical stepper switch that
increments by one step for each pulse (input
signal) applied to it.
A time-driven sequencer operates similar to a
mechanical drum switch that increments
automatically after a preset time period.
For a sequencer to be incremented automatically
through each step the program must have some sort of
timed element incorporated into the ladder program.
SQO Program
63. 63
So far the data from position zero has not been
used
Why?
When is it used?
Position zero is the start-up position of the
sequencer. On start-up (processor being switched
from PROG to RUN or first-pass), there might be
outputs or other data that need to be set to a
start-up condition. This data is placed in the
start-up position of the sequencer data file.
But…on the first false-to-true rung transition the
SQO indexes to position one and transfers the
data from position one to the output destination.
SQO – Position Zero
Operation
64. 64
To use the data stored in position zero:
The rung containing the sequencer must be true and the
Position parameter must be zero when the processor is
switched from PROG mode to RUN mode, (first-pass, or
first-scan of the program).
If the rung is true on the first-scan of the program and
the position is set to zero, the data from position zero
will be transferred from the position zero word of the
SQO data file through the Mask to the Destination.
To summarize:
The only way to get the data from position zero to be
transferred to the destination is if the position parameter is
equal to zero (POS = 0) and the rung containing the SQO
is true on the first scan of the program.
SQO – Position Zero
Operation