0% found this document useful (0 votes)
296 views

Chapter 09 - Program Control Instructions

This document discusses program control instructions used in programmable logic controllers (PLCs). It describes common program control instructions like jump (JMP), subroutine call (JSR), return (RET), master control reset (MCR), and temporary label (LBL). These instructions allow altering the normal program scan sequence by jumping or calling subroutines to execute sections of logic conditionally. The document provides examples of using instructions like JMP, JSR, RET and MCR to control program flow and fenced zones within the program.

Uploaded by

Hoàng Mạnh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views

Chapter 09 - Program Control Instructions

This document discusses program control instructions used in programmable logic controllers (PLCs). It describes common program control instructions like jump (JMP), subroutine call (JSR), return (RET), master control reset (MCR), and temporary label (LBL). These instructions allow altering the normal program scan sequence by jumping or calling subroutines to execute sections of logic conditionally. The document provides examples of using instructions like JMP, JSR, RET and MCR to control program flow and fenced zones within the program.

Uploaded by

Hoàng Mạnh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 70

Programmable

Logic Controllers
Third Edition

Frank D. Petruzella
McGraw-Hill
Chapter 9
Program
Control
Instructions
Program Control Instructions
Program control instructions
are used to alter the program
scan from its normal
sequence. Sometimes referred
to as override instructions,
they provide a means of
executing sections of the
control logic if certain
conditions are met. They
allow for greater program
flexibility and greater
efficiency in the program
scan.
Typical Program Control Instructions Based
On The SLC 500 And Associated RSLogix
Software

JMP LBL JSR RET SBR TND MCR SUS

Program Control

MCR
SUS
TND
RET
JSR
LBL
JMP Master
Suspend
Return
Jump Control
Temporary
LabeltoEnd
from
Jump Reset
Subroutine
toSubroutine
Label Clears
Identifies
Makes
Jump aall
Specifies
Exits
Jumpcurrent
to set
specific
outputs
temporary
alabel
designatedend
subroutine
location
forward/backward
SBR Subroutine Identifies the subroutine
between
conditions
that
to ahalts
subroutine
and the
returns for
paired
toprogram
program MCR
instruction
correspondingprevious
label
program
instruction
debugging
instructionand system
execution
condition
troubleshooting
Hardwired Master Control Relay Circuit

Hardwired master control relays are used in relay


circuitry to provide input/output power shutdown of
an entire circuit.
Hardwired Master Control Relay Circuit
MCR Instruction MCR

The master control reset (MCR) instruction can be


programmed to control an entire circuit or to control
only selected rungs of a circuit. When the MCR
instruction is false, or de-energized, all nonretentive
(nonlatched) rungs below the 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. Therefore, 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.
MCR Instruction Programmed To Control An
Entire Circuit
MCR Instruction Programmed To Control A
Fenced Zone
The Master Control Reset
(MCR) instruction is used
in pairs to disable or
enable a zone within a
ladder program and has
Fenced
Zone
no address. You program
the first MCR with input
instructions in the rung
and the ending MCR
without any other
instructions in the rung.
MCR Instruction Programmed To Control A
Fenced Zone
MCR Zone True
MCR Instruction Programmed To Control A
Fenced Zone
MCR Zone False
Programming MCR Instructions
If you start instructions such as timers and counters
in an MCR zone, instruction operation ceases when the
zone is disabled.
The TOF timer will activate when placed inside a false
MCR zone.

When troubleshooting a program that contains an


MCR zone you need to be aware of which rungs are
within zones in order to correctly edit the circuit.

MCR controlled areas must contain only two MCR


instructions – one to define the start and one to
define the end.
Jump Instruction JMP

As in computer programming, it is sometimes desirable


to be able to jump over certain program instructions.
The jump instruction (JMP) is an output instruction
used for this purpose. The advantages to the jump
instruction include:
 the ability to reduce the processor scan time by
jumping over instructions not pertinent to the
machines operation at that instant
 The PLC can hold more than one program and scan
only the program appropriate to operator
requirements
 Sections of a program can be jumped when a
production fault occurs
Jump Operation
By using the jump instruction, you can branch or skip
to different portions of a program and freeze all
affected outputs in their last state.

Jumps are normally allowed


in both the forward and
backward directions.

Jumping over counters and


timers will stop them from
being incremented.
Jump-To-Label
With Allen-Bradley PLCs the jump (JMP) instruction and the
label (LBL) instruction are employed together so the scan can
jump over a portion of the program.

The label is a target for the jump, it is the first instruction in


the rung, and it is always true.

A jump jumps to a label with the same address. The area 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.
Jump
To Label Timers should be
Program programmed
outside the
jumped section

Input conditions
are not examined Jumped program
and outputs remain rungs (5,6,7) are
in their last state
not scanned by
the processor
Jump-To-Label From Two Locations
20

20

20
Jump-To-Label Instructions
In a SLC 500 or PLC-5 the JMP will have a number from 0 to 255,
and the corresponding LBL will have the same number. In the
ControlLogix controller the JMP and LBL have the same number.

Avoid jumping backwards in the program too many times as this


may increase the scan beyond the maximum allowable time. The
processor has a watchdog timer that sets the maximum time for a
total program scan. If this time is exceeded, the processor will
indicate a fault and shut down.

You should never jump into an MCR zone. Instructions that are
programmed within the MCR zone starting at the LBL
instruction and ending at the end MCR instruction will always
be evaluated as though the MCR zone is true, without
consideration to the state of the start MCR instruction.
Jump - To - Subroutine
Another valuable tool in PLC programming is to be able
to escape from the main program and go to a program
subroutine to perform certain functions and then return
to the main program.
Allen-Bradley Subroutine-Related Instructions

The JSR instruction causes the scan to jump to the


program file 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).
Allen-Bradley Subroutine-Related Instructions

The SBR instruction is the first instruction on the first


rung in the subroutine file. It serves as an identifier
that the program file is a subroutine. This is the file
number that is used in the JSR instruction to identify
the target to which the program should jump. It
always true and although its use is optional, it is still
recommended.
Allen-Bradley Subroutine-Related Instructions

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.
Flashing Pilot Light Subroutine
If the weight on the conveyor exceeds a preset value, the solenoid is
de-energized and the alarm light will begin flashing.
Process
When the weight sensor switch
closes, the JSR is activated and
the processor scan jumps to the
subroutine area. The subroutine
is continually scanned and the
light flashes.

When the sensor switch opens,


the processor will no longer scan
the subroutine area and will
return to the on state.
Flashing
Pilot
Light
Subroutine
Program
Setting Up A Subroutine File
PLC-5 and SLC-500 controller subroutines are located in
different program files from the main program. The main
program is located in program file 2, whereas subroutines
are assigned to program file numbers 3 to 255.
Note each ladder location where a subroutine should be called.
Create a subroutine file for each location. Each subroutine file
should begin with an SBR instruction.

At each ladder location where a subroutine is called, program


a JSR instruction specifying the subroutine file number.

The RET instruction is optional as the end of a subroutine


program will cause a return to the main program.
Setting Up A Subroutine File
Passing Subroutine Parameters

An optional SBR instruction is the header instruction


that stores incoming parameters. This feature lets you
pass selected values to a subroutine before execution so
the subroutine can perform mathematical or logical
operations on the data and return the results to the
main program.
Passing Subroutine Parameters
Nested Subroutines

Nesting subroutines allow you to direct program flow


from the main program to a subroutine and then to
another subroutine.

Nested subroutines make complex programming easier


and program operation faster because the programmer
does not have to continually return from one
subroutine to enter another.
Nested Subroutines
1. Program control instructions are used to alter
the program scan from its normal sequence.
(True/False)

2. Hardwired master control relays are used in


relay circuitry to provide input/output power
shutdown of an entire circuit. (True/False)

3. The master control reset (MCR) instruction


can be programmed to control an entire circuit or
to control only selected rungs of a circuit.
(True/False)
4. When the MCR in the start fence is false
a. all rungs within the zone are treated as
false
b. all non-retentive outputs within the zone
are de-energized
c. the scan ignores all of the inputs within the
zone
d. all of these
5. When the MCR instruction in the start rung is
true, all rung outputs below the MCR
will be controlled by their respective input
conditions. (True/False)

6. The MCR instruction requires no address.


(True/False)

7. Jumps are normally only allowed in the


forward direction. (True/False)
8. The label (LBL) instruction is :

(a) always logically true.

(b) has the same address as the jump instruction


with which it is used.

(c) is used to identify the ladder rung that is the


target destination of the JMP instruction.

(d) all of these.


9. A subroutine is a section of program that is not
scanned unless there is:
a. a fault
b. a request for the scan to go to that particular
subroutine.
c. a need to execute a section of the program on a
time basis rather than on an event basis
d. a forced input or output condition
10. Which of the following instructions would
most likely be programmed outside the jumped
area of a program?

(a) Latch and unlatch instructions

(b) Timer and counter instructions

(c) Immediate inputs and outputs

(d) Forced inputs and outputs


Fault Routine
PLC-5 and SLC-500 controllers allow you to design a
subroutine file as a fault routine. If used, it determines how
the processor responds to a programming error.

There are two kinds of major faults that result in a


processor fault: recoverable and nonrecoverable faults.

When there is a fault routine, and the fault is recoverable, the


fault routine is executed.

If the fault is nonrecoverable, the fault routine is scanned


once and shuts down.

Either way, the fault routine allows for an orderly shutdown.


Immediate Input And
Immediate Output Instructions

Allen-Bradley PLC-5 immediate input and immediate


output instructions interrupt the normal program scan to
update the input image table file with current input data
or to update an output module group with the current
output image table file data. These instructions are
intended to be used only in areas where time or timing is
critical.
Immediate
Input
Instruction
(IIN)
Immediate
Output
Instruction
(IOT)
Immediate Input With Mask And
Immediate Output With Mask Instructions
The SLC-500 immediate I/O instructions are called
immediate input with mask (IIM) and immediate
output with mask (IOM).
They allow the programmer to specify which of the 16
bits are to be copied from an input module to the input
image data table (or from the output image table to an
output module). The other bits in the input image table
or output module are not affected by these instructions.
In addition the SLC-500 instructions allow you to
input or output a series of data words from a single
input module or output a series of data words to an
output module.
Immediate Input With Mask Instruction

The IIM instruction operates on the inputs assigned to a


particular word of a slot. When the IIM rung is true, the program
scan is interrupted, and data from a specific input slot is
transferred through the mask to an input data file. This data is
then available to the commands in the ladder, following the IIM
instruction.
Immediate Output With Mask Instruction

The IOM operates on the physical outputs assigned to a


particular word of a slot. When the IOM rung is true, the
program scan is interrupted, to update output data to the
module located in the slot specified in the instruction. This
data is then available to the commands in the ladder, following
the IOM instruction.
Forcing External I/O Addresses
The forcing capability of a PLC allows the user to
turn an external input or output "on" or "off" from
the keyboard of the programmer.

L1 L2
Program

Input False Output


"off"
Forced
"on"
Forcing Inputs
Overriding of physical inputs on conventional relay
control systems can be accomplished by installing
hardwire jumpers. With PLC control this is not
necessary as the input data table values can be
forced to an "on" or "off" state.

Forcing inputs manipulates the input image table file bits


and thus affects all areas of the program that uses those
bits.

The forcing of inputs is done just after the input scan.


Forcing An Input Address On

10
Forcing An Input Address On

Force> ON

Forcing inputs affects all areas of the program that


uses that bit.
Forcing Outputs
Forcing outputs affects only the addressed output
terminal. When we force an output address we are forcing
only the output terminal to an on or off state.

The output image table file bits are unaffected,


therefore, your program will be unaffected.

The forcing of outputs is done just before the output


image table file is updated.

By forcing outputs "off" you can prevent the controller


from energizing those outputs, even though the ladder
logic, which normally controls them, may be true.
Forcing An Output Address On
Forcing An Output Address On

Forcing outputs affects only the addressed output


terminal.
Using Forcing Functions

The Force function can not be applied when the


processor is in the run mode.

An understanding of the potential effect that forcing


given inputs or outputs will have on the machine
operation is essential to avoid possible personal injury
and equipment damage.

Most programming terminals provide some visible


means of alerting the user that a force is in effect.
Enter And Enable Or Disable Forces
Using RSLogix software the steps are as follows:
Open the program file in which you want to force the logic on or off.
With the right mouse button, click the I/O bit you want to force.
From the menu that appears select "Goto Data Table".
From the associated data table that appears click on the "Forces"
button.

The Forces version of the data table appears with the selected bit
highlighted. Click on this bit with the right mouse button.

From the menu that appears you can force the selected bit
"on“ or "off".
Enter And Enable Or Disable Forces

Forced Version Of The Data Table


Safety Circuitry
Sufficient emergency circuits must be provided to stop
either partially or totally the operation of the controller
or the controlled machine or process.

These circuits should be


hardwired outside the
controller so that, in the event
of total controller failure,
independent and rapid
shutdown is available.
Typical PLC Safety
Wiring Diagram

A main disconnect switch


is installed on the incoming
power lines as a means of
An isolation transformer
removing power from the
is used to isolate the
Aentire programmable
hardwired master control
controller from the main
controller
relay is system.
included to provide
power distribution system a
convenient
and step the means
voltagefordown
emergency
to 120 VAC.controller
shutdown.
Motor Starter Program Using The Auxiliary Contact
An important safety consideration involves the use of a
motor starter seal-in contact in place of a programmed
contact referenced to the output coil instruction.

The use of the field-generated


starter auxiliary contact status in
the program is more costly in terms
of field wiring and hardware, but is
safer because it provides a positive
feedback to the processor about the
exact status of the motor.
Motor Starter Program Using The Auxiliary Contact

Motor
Motoroperating
overload
normally
occurs

If a programmed NO contact referenced to the M coil is used


for the seal-in contact (in place of starter auxiliary contact)
the processor would never know power has been lost to the
motor. When the OL was reset, the motor would restart
instantly, creating a potentially unsafe operating condition.
Wiring of Stop Pushbuttons

The wiring of stop buttons is another important safety


consideration. A stop button is generally considered a
safety function as well as an operating function.

As such, it should be wired


using a NC contact and
Always use programmed to examine for
a NC button an on condition. Using an NO
for a stop contact programmed to
button examine for an off condition
NC Pushbutton
will produce the same logic,
but is not considered to be as
safe.
Wiring of Stop Pushbuttons
Normally open pushbutton stop configuration

NEVER use the NO button for a stop button.


If a NO button is used and the circuit between
the button and the input point were to be
broken the PLC logic control could never react
to the stop command - since the input would
NO Pushbutton
never be true.
Selectable Timed Interrupt
The selectable timed interrupt (STI) function allows
you to interrupt the scan of the main program file
automatically, on a time basis, in order to scan a
specified subroutine file.

Selectable Timed Interrupt File Programming the STI is


done when a section of the
program needs to executed
on a time basis rather than
on an event basis. For
example, a program may
require certain calculations
to be executed at a
repeatable time interval for
accuracy.
Selectable Timed Disable (STD) And Selectable
Timed Enable (STE) Instructions
The selectable
timed disable
(STD) instruction
is generally
paired with the
selectable timed
enable (STE)
instruction to
create zones in
which the STI
interrupts cannot
occur.
Temporary End (TND) Instruction
The temporary end (TND) instruction is an output
instruction used to progressively debug a program or
conditionally omit the balance of your current program
file or subroutines.

When rung conditions are true,


this instruction stops the program
scan, updates the I/O, and resumes
scanning at rung 0 of the main
program.
Temporary
End (TND)
Instruction

Switch SW 13 is closed to
energize the TND
Normal program scan
instruction and stop all
scanning beyond this point.
11. Immediate instructions are used
a. to provide a pulse for timing or counting
b. to lock in a condition
c. when the input or output being
controlled is very time dependent
d. to control blocks of a logic ladder
program
12. The forcing function of a PLC allows the user
to turn an external input or output on or off
from the programming device regardless
of its actual state. (True/False)

13. The force function can not be applied when


the processor is in the run mode. (True/False)

14. Forcing outputs affects only the addressed


output terminal. (True/False)
15. The purpose of the main disconnect switch
installed on the incoming power lines of a PLC is
to control power to the output modules.
(True/False)

16. It is safer to use a programmed NO contact


referenced to the M coil for the seal-in contact
than a field-generated starter auxiliary contact.
(True/False)
17. The safest way to wire a stop button to a PLC
system is to:

(a) use a normally closed contact examined for an


"on" condition.
(b) use a normally open contact examined for an
"on" condition.
(c) use a normally closed contact examined for an
"off" condition.
(d) use a normally open contact examined for an
"off" condition.
18. A selectable timed interrupt (STI) function
allows you to:
(a) freeze outputs in their last state
(b) interrupt the scan of the main program on a
time basis
(c) latch outputs when de-energized
(d) interrupt the scan of the main program on an
event basis
19. A fault routine, if used, determines how
the processor responds to:
(a) a blown input module fuse
(b) a fault in wiring to a field device
(b) a blown output module fuse
(d) a programming error
20. When rung conditions are true, the temporary
end instruction stops the program scan, updates
the I/O, and resumes scanning at the ___________
of the program.

(a) subroutine portion

(b) label instruction

(c) start

(d) half-way point

You might also like