Mechatronics Eng.
PLC Course
ME554: Programmable Logic Control
(PLC)
Program Control Instructions
Prepared By: Dr. Hani Muhsen
7/24/2019 Dr. Hani Muhsen 1
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢Several output-type instructions, which are often referred to as override instructions,
provide a means of executing sections of the control logic if certain conditions are met.
➢ These program control instructions allow for greater program flexibility and greater
efficiency in the program scan.
➢ Portions of the program not being utilized at any particular time can be jumped over,
and outputs in specific zones in the program can be left in their desired states.
7/24/2019 Dr. Hani Muhsen 2
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢Program control instructions are used to enable or disable a block of logic program or
to move execution of a program from one place to another place.
➢Next Figure shows the Program Control menu tab for the Allen- Bradley SLC 500 PLC
and its associated RSLogix software.
➢The program control commands can be summarized as follows:
7/24/2019 Dr. Hani Muhsen 3
Mechatronics Eng. PLC Course
Master Control Reset Instruction
• JMP (Jump to Label)—Jump forward/backward to a corresponding label instruction.
• LBL (Label)—Specifies label location.
• JSR (Jump to Subroutine)—Jump to a designated subroutine instruction.
• RET (Return from Subroutine)—Exits current subroutine and returns to previous condition.
• SBR (Subroutine)—Identifies the subroutine program.
• TND (Temporary End)—Makes a temporary end that halts program execution.
• MCR (Master Control Reset)—Clears all set nonretentive output rungs between the paired
MCR instructions.
• SUS (Suspend)—Identifies conditions for debugging and system troubleshooting.
7/24/2019 Dr. Hani Muhsen 4
Mechatronics Eng. PLC Course
Master Control Reset Instruction
7/24/2019 Dr. Hani Muhsen 5
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢Hardwired master control relays are used in
relay control circuitry to provide
input/output power shutdown of an entire
circuit. Next Figure shows a typical
hardwired master control relay circuit. In this
circuit, unless the master control relay coil is
energized, there is no power flow to the load
side of the MCR contacts.
7/24/2019 Dr. Hani Muhsen 6
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢PLC manufacturers offer a form of a master control relay as part of their instruction
set. These instructions function in a similar manner to the hardwired master control
relay; that is, when the instruction is true, the circuit functions normally, and when
the instruction is false, nonretentive outputs are switched off.
➢Because these instructions are not hardwired but programmed, for safety reasons
they should not be used as a substitute for a hardwired master control relay, which
provides emergency I/O power shutdown.
7/24/2019 Dr. Hani Muhsen 7
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢A Master Control Reset (MCR) instruction is an output coil instruction that functions
like a master control relay.
➢MCR coil instructions are used in pairs and can be programmed to control an entire
circuit or to control only selected rungs of a circuit.
➢ In the program in the next figure, the MCR is programmed to control an entire
circuit. The operation of the program can be summarized as follows:
7/24/2019 Dr. Hani Muhsen 8
Mechatronics Eng. PLC Course
Master Control Reset Instruction
➢ When the MCR instruction is false, or de-energized, all nonretentive (nonlatched) rungs
below the MCR will be de-energized even if the programmed logic for each rung is true.
➢ All retentive rungs will remain in their last state.
➢ The MCR instruction establishes a zone in the user program in which all nonretentive
outputs can be turned off simultaneously.
➢ Retentive instructions should not normally be placed within an MCR zone because the MCR
zone maintains retentive instructions in the last active state when the instruction goes false.
➢ An off-delay timer will start timing when in a deenergized MCR zone.
7/24/2019 Dr. Hani Muhsen 9
Mechatronics Eng. PLC Course
Master Control Reset Instruction
7/24/2019 Dr. Hani Muhsen 10
Mechatronics Eng. PLC Course
MCR fenced zone with the zone true
➢Next Figure shows the programming of an MCR fenced
zone with the zone true. The operation
of the program can be summarized as follows:
➢The MCR zone is enclosed by a start fence, which is a
rung with a conditional MCR, and an end fence, which
is a rung with an unconditional MCR.
➢Input A of the start rung is true so all outputs act
according to their rung logic as if the zone did not
exist.
7/24/2019 Dr. Hani Muhsen 11
Mechatronics Eng. PLC Course
MCR fenced zone with the zone false.
➢ When the MCR in the start fence is false, all rungs within
the zone are treated as false. The scan ignores the inputs
and de-energizes all nonretentive outputs (that is, the
output energize instruction, the on-delay timer, and the off-
delay timer).
➢ All retentive devices, such as latches, retentive timers, and
counters, remain in their last state.
➢ Input A of the start rung is false so output A and T4:1 will be
false and output B will remain in its last state.
➢ The input conditions in each rung will have no effect on the
output conditions.
7/24/2019 Dr. Hani Muhsen 12
Mechatronics Eng. PLC Course
Jump Instruction
➢In PLC programming it is sometimes desirable to be able to jump over certain program
instructions when certain conditions exist.
➢ The jump (JMP) instruction is an output instruction used for this purpose. When the jump
instruction is used, the PLC will not execute the instructions of a rung that is jumped.
➢The jump instruction is often used to jump over instructions not pertinent to the machine’s
operation at that instant. In addition, sections of a program may be programmed to be
jumped should a production fault occur.
➢Some manufacturers provide a skip instruction, which is essentially the same as the jump
instruction.
7/24/2019 Dr. Hani Muhsen 13
Mechatronics Eng. PLC Course
Jump Instruction
➢The program in the next figure illustrates the use of a jump instruction in conjunction with
Allen-Bradley SLC 500 programmable controllers. Addresses Q2:0 through Q2:255 are the
addresses used for the jump (JMP) instructions. The label (LBL) instruction is a target for the
jump instruction.
➢ In addition, the jump instruction with its associated label must have the same address. The
area of the program that the processor jumps over is defined by the locations of the jump
and label instructions in the program. If the jump coil is energized, all logic between the jump
and label instructions is bypassed and the processor continues scanning after the LBL
instruction.
7/24/2019 Dr. Hani Muhsen 14
Mechatronics Eng. PLC Course
Jump Instruction
The operation of the program can be summarized as
follows:
• When the switch is open the jump instruction is not
activated.
• With the switch open, closing PB turns on all three
pilot lights.
• When the switch is closed the jump (JMP) instruction
will activate.
• With the switch closed, pressing PB turns on pilot
lights PL1 and PL3 only.
• Rung 3 is skipped over during the PLC program
scan so PL2 is not turned on.
7/24/2019 Dr. Hani Muhsen 15
Mechatronics Eng. PLC Course
Subroutine Functions
➢In addition to the main ladder logic program, PLC programs may also contain additional
program files known as subroutines.
➢A subroutine is a short program that is used by the main program to perform a specific
function.
➢Large programs are often broken into subroutine program files, which are called and
executed from the main program.
➢ In the SLC 500 series PLCs, the main ladder logic program is in program file two (shown as
LAD 2). Ladder logic programs for subroutines can be placed in file number three (LAD 3)
through file number 255 (LAD 255).
7/24/2019 Dr. Hani Muhsen 16
Mechatronics Eng. PLC Course
Subroutine Functions
➢Use of subroutines is a valuable tool in PLC programming.
➢At times it is better to construct programs that consist of several subroutines than a
lengthy single program.
➢When programs are written with subroutines, each subroutine can be tested
individually for functionality.
➢These subroutines can then be called from the main program as illustrated in the
next Figure.
7/24/2019 Dr. Hani Muhsen 17
Mechatronics Eng. PLC Course
Subroutine Functions
The subroutine instructions can be summarized as follows:
➢ Jump to Subroutine (JSR)—The JSR instruction is an output instruction that causes the scan to
jump to the program fi le designated in the instruction. It is the only parameter entered in the
instruction. When rung conditions are true for this output instruction, it causes the processor to
jump to the targeted subroutine file. Each subroutine must have a unique file number ( decimal
3–255).
➢ Subroutine (SBR)—The SBR instruction is the first input instruction on the first rung in the
subroutine file. It serves as an identifier that the program file is a subroutine. This fi le number
is used in the JSR instruction to identify the target to which the program should jump. It is
always true, and although its use is optional, it is still recommended.
➢ Return (RET)—The RET instruction is an output instruction that marks the end of the subroutine
file. It causes the scan to return to the main program at the instruction following the JSR
instruction where it exited the program. The scan returns from the end of the file if there is no
RET instruction. The rung containing the RET instruction may be conditional if this rung
precedes the end of the subroutine. In this way, the processor omits the balance of a
subroutine only if its rung condition is true.
7/24/2019 Dr. Hani Muhsen 18
Mechatronics Eng. PLC Course
Subroutine Functions Example
➢ Next Figure shows a materials conveyor system with a flashing pilot light as a subroutine.
The operation of the program can be summarized as follows:
➢ If the weight on the conveyor exceeds a preset value, the solenoid is de-energized and pilot
light PL1will begin flashing.
➢ When the weight sensor switch closes, the JSR is activated and directs the processor scan to
jump to the subroutine U:3.
➢ The subroutine program is scanned and pilot light PL1 begins flashing.
➢ When the weight sensor switch opens, the processor will no longer scan the subroutine area
and pilot light PL1 will return to its normal on state.
7/24/2019 Dr. Hani Muhsen 19
Mechatronics Eng. PLC Course
Subroutine Functions Example
7/24/2019 Dr. Hani Muhsen 20