PLC Sequencer Instructions
This article explains how the PLC sequencer functions operate and how they can be applied to control problems. The sequencer instruction evolved from the mechanical drum switch, and it can handle complex sequencing control problems more easily than does the drum switch.
Sequencer instructions are designed to operate much like the mechanical rotating cam limit switch shown in Figure 1.
These mechanical type sequencers are often referred to as drum switches, rotary switches, stepper switches, or cam switches. They are often used to control machinery that has a repetitive cycle of operation.
Figure 2 illustrates the operation of a cam-operated sequencer switch. An electric motor is used to drive the cams. A series of leaf-spring mounted contacts interacts with the cam so that in different degrees of rotation of the cam, various contacts are closed and opened to energize and de-energize various electrical devices. As the cams rotate, load devices connected to the contacts can change from an on to an off state, from an off to an on state, or remain at the same state.
Figure 3 illustrates a typical mechanical drum-operated sequencer switch. The switch consists of a series of normally open contact blocks that are operated by pegs located on the motor-driven drum. The operation of this sequencer can be summarized as follows:
- Pegs are placed at specific locations around the circumference of the drum to operate the contact blocks.
- When the drum is rotated, contacts that align with the pegs will close, whereas the contacts where there are no pegs will remain open.
- The presence of a peg can be interpreted as logic 1, or on, and the absence of a peg as logic 0, or off.
- The equivalent sequencer data table illustrates the logic state for the first four steps of the drum cylinder.
- Each location where there was a peg is represented by a 1 (on), and the positions where there were no pegs are each represented by a 0 (off ).
Sequencer switches are useful whenever a repeatable operating pattern is required. One example is the timed sequencer switch used in dishwashers to pilot the machinery through a wash cycle.
The cycle is always the same with a fixed routine of actions at each step for a specific time to complete its specified task. The domestic washing machine is another example of the use of a sequencer, as are dryers and similar time-clock controlled devices. An example of the wiring and timing chart for a dishwasher that uses a cam-operated sequencer, commonly known as the timer, is shown in Figure 4.
A synchronous motor drives a mechanical train that, in turn, drives a series of cam wheels. The operation of this sequencer can be summarized as follows:
- The timer motor operates continuously throughout the cycle of operation.
- The cam advances in time increments of 45 seconds in duration.
- The data timing chart shows the sequence of operation of the timer.
- A total of sixty 45 second steps are used to complete the 45 minute operating cycle.
- Numbers in the active devices column refer to control devices active during each step of the cycle.
PLC Sequencer Instructions
PLC sequencer instructions replace the mechanical drum sequencer that is used to control machines that have a stepped sequence of repeatable operations. Programmed sequencers can perform the same specific on or off patterns of outputs that are continuously repeated with a drum switch, but with much more flexibility.
Sequencer instructions simplify your ladder program by allowing you to use a single instruction or pair of instructions to perform complex operations. For example, the on/off operation of 16 discrete outputs can be controlled, using a sequencer instruction, with only one ladder rung. By contrast, the equivalent contact-coil ladder control arrangement would need 16 rungs in the program. Depending on the PLC manufacturer, various sequencer instructions can be programmed.
Figure 5 shows the Sequencer menu tab for the Allen-Bradley SLC 500 PLC and its associated RSLogix software. For the AllenBradley line of controllers, sequencer commands may include the following:
- SQO (Sequencer Output) is an output instruction that uses a fi le to control various output devices.
- SQI (Sequencer Input) is an input instruction that compares bits from an input file to corresponding bits from a source address. The instruction is true if all pairs of bits are the same.
- SQC (Sequencer Compare) is an output instruction that compares bits from an input source file to corresponding bits from data words in a sequence file. If all pairs of bits are the same, then a bit in the control register is set to 1.
- SQL (Sequencer Load) is an output instruction used to capture reference conditions by manually stepping the machine through its operating sequences. It transfers data from the input source module to the sequencer file. The instruction functions much like a file-to-word transfer instruction.
Figure 6 shows an example of an SQO (Sequencer Output) instruction. The SQO instruction reads data file elements (words) one at a time, applies a mask word to enable or disable bits from the current data file element, and transfers the masked data file element to a designated output.
Parameters that may be required to be entered in sequencer instructions can be summarized as follows:
- File is the starting address for the registers in the sequencer file and you must use the indexed file indicator (#) for this address. The file contains the data that will be transferred to the destination address when the instruction undergoes a false-to-true transition. Each word in the file represents a position, starting with position 0 and continuing to the file length.
- Mask is the bit pattern through which the sequencer instruction moves source data to the destination address. Recall that in the mask bit pattern, a 1 passes values while a 0 blocks the data flow. You use a mask register or file name when you want to change the mask pattern under program control. An h is placed behind the parameter to indicate that the mask is a hexadecimal number or a B to indicate binary notation. Decimal notation is entered without any indicator.
- Source is the address of the input word or file from which the SQC and SQL instruction obtains data for comparison or input to its sequencer file.
- Destination is the address of the output word or file to which the SQO moves the data from its sequencer file.
Control is the address that contains the parameters with control information for the instruction. The control register stores the status byte of the instruction, the length of the sequencer file, and the instantaneous position in the file as follows:
- The enable bit (EN; bit 15) is set by a false-to-true rung transition and indicates that the instruction is enabled. It follows the rung condition.
- The done bit (DN; bit 13) is set after the last word in the sequencer file is transferred. On the next false-to-true transition of the rung with the done bit set, the position pointer is reset to 1.
- The error bit (ER; bit 11) is set when the processor detects a negative position value, or a negative or zero length value.
- Length is the number of steps of the sequencer file starting at position 1. Position 0 is the start-up position. The instruction resets (wraps) to position 1 at each cycle completion. The actual file length will be 1 plus the file length entered in the instruction.
- Position indicates the step that is desired to start the sequencer instruction. The position is the word location or step in the sequencer file from which the instruction moves data. Any value up to the file length may be entered, but the instruction will always reset to 1 on the true-to-false transition after the instruction has operated on the last position. Before we start the sequence, we need a starting point at which the sequencer is in a neutral position. The start position is all zeros, representing this neutral position; thus, all outputs will be off in position 0.
To program a sequencer, binary information is first entered into the sequencer file or register made up of a series of consecutive memory words. The sequencer file is typically a bit file that contains one bit file word representing the output action required for each step of the sequence. Data are entered for each sequencer step according to the requirements of the control application.
As the sequencer advances through the steps, binary information is transferred from the sequencer file to the output word. To illustrate the purpose and function of the sequencer file we will examine the operation of the four-step sequence process shown in Figure 7.
This sequencer is to be used to control traffic in two directions. The operation of the process can be summarized as follows:
- Six outputs are to be energized from one 16-point output module.
- Each light is controlled by one bit address of output word O:2.
The first 6 bits are programmed to execute the following sequence of light outputs:
- Step 1: Outputs O:2.0 (red) and O:2.5 (green) lights will be energized.
- Step 2: Outputs O:2.0 (red) and O:2.4 (yellow) will be energized.
- Step 3: Outputs O:2.2 (green) and O:2.3 (red) will be energized.
- Step 4: Outputs O:2.1 (yellow) and O:2.3 (red) will be energized.
- Words B3:0, B3:1, B3:2, B3:3 and B3:4 make up the sequencer file.
- Binary information (1s and 0s) that reflects the desired on or off light status for each of the four steps is entered into each word of the sequencer file.
- Before starting the sequence, you need a starting point where the sequencer is in a neutral position. This is provided by the start position which is all zeros.
Due to the way in which the sequencer instruction operates, all output points must be on a single output module. When a sequencer operates on an entire output word, there may be outputs associated with the word that do not need to be controlled by the sequencer.
In our example, bits 6 through 15 of output word O:2 are not used by the sequencer but could be used elsewhere in the program. To prevent the sequencer from controlling these bits of the output word, a mask word is used. The use of a mask word is illustrated in Figure 8.
The operation of the mask can be summarized as follows:
- The mask word selectively screens out data from the sequencer word file to the output word.
- The hex number 003Fh is entered as the mask parameter.
- For each bit of output word O:2 that the sequencer is to control, the corresponding bit of the mask word must be set to 1.
- The arrows in the figure indicate the unmasked bits that are passed through the mask and into the designation address.
- The dashes in the bits of the designation address indicate that those bits remain unchanged in the designation location during the sequencing.
- These unchanged bits therefore can be used independently of the sequencer.
The sequencer output instruction requires preceding logic on the rung where it is located. When this logic goes from false to true, it triggers the sequencer to perform its functions. Only when the logic preceding the sequencer instruction makes the transition from false to true will it go through its functions of reading the data file, applying the mask, and transferring the masked data file to the output destination. After this cycle, it waits for another false-to-true occurrence of the preceding logic to increment to the next step.
Figure 9 illustrates how the sequencer moves data from a file to an output. The operation of the logic rung can be summarized as follows:
- Pushbutton PB is used to send false-to-true trigger signals to the sequencer output instruction.
- The position of the sequencer instruction is incremented by one for each false-to-true transition of the sequencer rung.
- Whenever PB is momentarily closed the sequencer is both enabled and advanced to the next position.
- When the sequencer is at step 1, the binary information in word B3:1 (100001) of the sequencer file is transferred into word O:2 of the output.
- As a result output O:2/0 and O:2/5 will be on and all the rest will be off.
- Advancing the sequencer to step 2 will transfer the data from word B3:2 (010001) into word O:2.
- As a result output O:2/0 and O:2/4 will be on and all the rest will be off.
- Advancing the sequencer to step 3 will transfer the data from word B3:3 (001100) into word O:2.
- As a result output O:2/2 and O:2/3 will be on and all the rest will be off.
- Advancing the sequencer to step 4 will transfer the data from word B3:4 (001010) into word O:2.
- As a result output O:2/1 and O:2/3 will be on and all the rest will be off.
- When the position parameter reaches 4 (the value in the length parameter) all words would have been moved so the DN (done bit) in the instruction is set to 1.
- On the next false-to-true transition of the rung, with done bit set, the position pointer is automatically reset to 1.
Sequencer instructions are usually retentive, and there can be an upper limit to the number of external outputs and steps that can be operated on by a single instruction. Many sequencer 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.
PLC Sequencer Programs
A sequencer program can be event-driven or time-driven. An event-driven sequencer operates similarly to a mechanical stepper switch that increments by one step for each pulse applied to it. A time-driven sequencer operates similarly to a mechanical drum switch that increments automatically after a preset time period. A sequencer chart, such as the one shown in Figure 10 , is a table that lists the sequence of operation of the outputs controlled by the sequencer instruction.
These tables use a matrix-style chart format. A matrix is a two-dimensional, rectangular array of quantities. A time-driven sequencer chart usually indicates outputs on its horizontal axis and the time duration on its vertical axis. An event-driven sequencer indicates outputs on its horizontal axis and the input, or event, on its vertical axis. An example of a time-driven sequencer with timed steps that are not all the same is shown in Figure 11.
This sequencer program is used for automatic traffic light control at a four-way intersection. Output lights operate in a sequential fashion with variably timed steps. The system requires two SQO instructions: one for the light outputs and the other for the timed steps. Both SQOs have R6:0 for the control and 4 for the length. The first position is on for 25 seconds, the second for 5 seconds, the third for 25 seconds, and the fourth for 5 seconds.
The operation of the time-driven sequencer program can be summarized as follows:
- The bits controlling the traffic light outputs are stored in integer file #N7:0 of the first SQO instruction. The settings for the output bits for each position are entered and stored in binary table format as shown in Figure 12 . Each word of the #N7:0 file is moved from the file by the program to the destination output word O:2 as previously described.
- The second SQO instruction sequencer file, #N7:10, contains the stored preset timer values 25, 5, 25, 5 seconds. These settings are stored in words N7:11, N7:12, N7:13, and N7:15 as illustrated in Figure 13. Each word of the #N7:10 file is moved by the program to the destination address T4:1.PRE, which is the preset value for the timer. The program moves information from this file to timer T4:1’s preset. The mask allows the proper data to pass and blocks the unnecessary data.
- The timer cycles the two SQO instructions through their four states.
- Since both of the SQO instructions have R6:0 for control and 4 for length they are stepped in unison to provide a sequentially timed output.
An example of a time-driven sequencer program in which the time interval between sequencer steps is always a constant set value is shown in Figure 14. The operation of the program can be summarized as follows:
- The preset time of timer T4:0 is set for 3 seconds.
- The settings of the output bits for each sequencer position are entered and stored in bit file #B3:0.
- The timer is started by the closing switch SW and 3 seconds later the timer done bit is set to1.
- As a result the timer done bit increments the SQO instruction to the next position and resets the timer.
- The destination is O:2 and all 16 bits of this word are used for outputs.
- The mask is FFFF hexadecimal or 1111111111111111 binary, which allows all 16 bits to pass through.
- As long as input SW is closed the program continues operating with 3 seconds between sequencer steps.
With an event-driven sequencer, the SQO instruction advances to the next step by an external pulsed input event rather than a preset time. An example of an event-driven sequencer is shown in Figure 15.
The operation of the program can be summarized as follows:
- The sequencer SQO instruction uses two OR configured sensor switches (S1 and S2).
- Any one of the two parallel paths can make the SQO rung true.
- As each event occurs, that OR branch makes a false-to-true transition advancing the sequencer position.
- Data are copied from fi le #B3:0 at the bit locations through mask word, F0FF hex or 1111000011111111 binary, to the destination O:2. Mask bits are set to 1 to pass data and reset to 0 to mask data.
- Once the position reaches the last position on the true-to-false transition of the instruction the position will reset to 1.
- Note that the data in O:2 match the data in position 2 in the file, except for the data in bits 8 through 11.
- Bits 8 through 11 may be controlled from elsewhere in the program; they are not affected by the sequencer instruction because of the 0 in these bit positions in the mask.
The sequencer input (SQI) instruction allows input data to be compared for equality against data stored in the sequencer file. For example, it can make comparisons between the states of input devices and their desired states: if the conditions match, the instruction is true.
The SQI instruction is an input instruction available in Allen-Bradley PLC-5 and ControlLogix controllers. An example of a PLC sequencer input instruction is shown in Figure 16. The entries in the instruction are similar to those in the sequencer output instruction, except that the destination is replaced by the source. The operation of the program can be summarized as follows:
- The SQI instruction compares the input data in I:3 through the mask FFF0 with the data in the sequencer file N7:11 through N7:15 for equality.
- The specific data in the sequencer file used in the comparison is identified by the position parameter.
- When the unmasked source bits match those of the corresponding sequencer file word, the instruction goes true; otherwise, the instruction is false.
- In this example, the data at position 2 match the unmasked input data, so the SQI instruction is true, thus making the rung and output PL1 true.
- The input data can indicate the state of an input device, such as the combination of input switches shown in this example program.
- Anytime the combination of opened and closed switches is equal to the combination of 1s and 0s on a step in the sequencer reference file, the PL1 output of the sequencer becomes energized.
The SQI instruction uses a control register like the SQO instruction but does not have a done bit. In addition, the SQI instruction does not automatically increment its position each time its control logic makes a false-to-true transition at its input.
If the SQI instruction is used alone, the position value must be changed by another instruction (such as the move instruction) to select a new input file value to compare against the value from the source address. When the SQI is paired with an SQO instruction with identical control addresses the position is incremented by the SQO instruction for both.
The program of Figure 17 illustrates the use of the sequencer input and sequencer output instructions in pairs to monitor and control, respectively, a sequential operation. The operation of the program can be summarized as follows:
- The same control address, length value, and position value is used for each instruction.
- The sequencer input instruction is indexed by the sequencer output instruction because both control elements have the same address, R6:5.
- This type of programming technique allows input and output sequences to function in unison, causing a specific output sequence to occur when a specific input sequence takes place.
The Allen-Bradley SLC 500’s sequencer compare (SQC) instructions are similar but not identical to the SQI instruction. Differences between the two include:
- The SQC instruction is an output rather than an input instruction.
- The SQC instruction increments the position parameter
- The SQC instruction has an additional status bit — the found bit (FD). When the source pattern matches the sequencer file word the FD is set to 1. It is zero under all other conditions.
An example of an SLC 500 sequencer compare (SQC) instruction program is shown in Figure 18. The operation of the program can be summarized as follows:
- The data in the highest 4 bits of the source (I:1) are compared to the data in file #B3:22.
- In this example, the highest 4 bits in I:1 match the status of the highest 4 bits in B3:25 at step position 3.
- If the pushbutton input I:1/0 is true at this point, the found (FD) bit is set, which turns output PL1 on.
- Whenever the combination of opened and closed switches connected to I:1/12, I:1/13, I:1/14, and I:1/15 is equal to the combination of 1s and 0s on a step in the sequencer reference file and the input I:1/0 is true, the PL1 output will become energized.
- The mask (F000h) allows unused bits of the sequencer instruction to be used independently. In this example, unused bit I:1/0 is used for the conditional input of the sequencer compare rung.
The sequencer load (SQL) instruction is used to read the PLC input module and store the input data in the sequencer file. Loading input conditions for a large number of process steps is prone to errors. In such instances the sequencer load instruction can be used to load data into a sequencer file one step at a time.
For example, a robot may be jogged manually through its sequence of operation, with its input devices read at each step. At each step, the status of the input devices is written to the data file in the sequencer compare instruction. As a result, the file is loaded with the desired input status at each step, and these data are then used for comparison with the input devices when the machine is run in automatic mode.
An example of an SLC 500 sequencer load (SQL) instruction program is shown in Figure 19. The operation of the program can be summarized as follows:
- The sequencer load instruction is used to load the file and does not function during the machine’s normal operation.
- It replaces the manual loading of data into the file with the programming terminal.
- The sequencer load instruction does not use a mask. It copies data directly from the source address to the sequencer file.
- When the instruction goes from false to true, the instruction indexes to the next position and copies the data.
- When the instruction has operated on the last position and has a true-to-false transition, it resets to position 1.
- It transfers data in position 0 only if it is at position 0 and the instruction is true and the processor goes from the program to run mode.
- By manually jogging the machine through its cycle, the switches connected to input I:2 of the source can be read at each position and written into the file by momentarily pressing PB1. Otherwise, the data would have to be entered into the file manually.
- Introduction to Programmable Logic Controllers
- Parts of Programmable Logic Controller
- Input Output Section of PLC
- Discrete I/O Modules of PLC
- Analog I/O Modules of PLC
- I/O Module Specifications of PLC
- Central Processing Unit of PLC
- Boolean Equation for Logic Gate Circuits
- Memory Map for PLC Processor
- PLC Program Scan Cycle
- PLC Programming Languages
- Entering Ladder Diagram
- PLC Ladder Logic Programs
- Timer Instructions in PLC
- Counter Instructions in PLC
- Control Instructions in PLC
- Data Manipulation Instructions in PLC
- PLC Math Instructions
- PLC Sequencer Instructions & Programs
- PLC Shift Register Instructions & Programs
- Installation and Commissioning of PLC
- Troubleshooting of PLC
- Process Control Systems
- PLC Data Communication System