0% found this document useful (0 votes)
15 views24 pages

Program Control Instructions (1)

This document covers program control instructions used in PLC programming to alter the normal sequence of program scans, enhancing efficiency and flexibility. Key instructions include Master Control Reset (MCR), Jump (JMP), and subroutine management, which allow for conditional execution and control of output states. The chapter also discusses safety considerations and the differences between standard and safety PLCs.

Uploaded by

Joseph Mbugua
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views24 pages

Program Control Instructions (1)

This document covers program control instructions used in PLC programming to alter the normal sequence of program scans, enhancing efficiency and flexibility. Key instructions include Master Control Reset (MCR), Jump (JMP), and subroutine management, which allow for conditional execution and control of output states. The chapter also discusses safety considerations and the differences between standard and safety PLCs.

Uploaded by

Joseph Mbugua
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

9

Program Control Instructions

Image Used with Permission of Rockwell Automation, Inc.

Chapter Objectives
The program control instructions covered in this After completing this chapter, you will be able to:
chapter are used to alter the program scan from 9.1 State the purpose of program control instructions
its normal sequence. The use of program con-
9.2 Describe the operation of the master control reset
trol instructions can shorten the time required to instruction and develop an elementary program
complete a program scan. Portions of the pro- illustrating its use
gram not being utilized at any particular time can 9.3 Describe the operation of the jump instruction and the
be jumped over, and outputs in specific zones in label instruction
the program can be left in their desired states. 9.4 Explain the function of subroutines
Typical industrial program control applications 9.5 Describe the immediate input and output instructions
are explained. function
9.6 Describe the forcing capability of the PLC
9.7 Describe safety considerations built into PLCs and
programmed into a PLC installation
9.8 Explain the differences between standard and safety
PLCs
9.9 Describe the function of the selectable timed interrupt
and fault routine files
9.10 Explain how the temporary end instruction can be
used to troubleshoot a program

176

pet10882_ch09_176-199.indd 176 7/23/10 10:05 PM


9.1 Master Control Reset Instruction TND (Temporary End)—Makes a temporary end
that halts program execution.
Several output-type instructions, which are often referred
MCR (Master Control Reset)—Clears all set non-
to as override instructions, provide a means of execut-
retentive output rungs between the paired MCR
ing sections of the control logic if certain conditions are
instructions.
met. These program control instructions allow for greater
program flexibility and greater efficiency in the program SUS (Suspend)—Identifies conditions for debugging
scan. Portions of the program not being utilized at any and system troubleshooting.
particular time can be jumped over, and outputs in specific Hardwired master control relays are used in relay con-
zones in the program can be left in their desired states. trol circuitry to provide input/output power shutdown of
Program control instructions are used to enable or dis- an entire circuit. Figure 9-2 shows a typical hardwired
able a block of logic program or to move execution of a master control relay circuit. In this circuit, unless the mas-
program from one place to another place. Figure 9-1 shows ter control relay coil is energized, there is no power flow
the Program Control menu tab for the Allen-Bradley to the load side of the MCR contacts.
SLC 500 PLC and its associated RSLogix software. The PLC manufacturers offer a form of a master control relay
program control commands can be summarized as follows: as part of their instruction set. These instructions function
in a similar manner to the hardwired master control relay;
JMP (Jump to Label)—Jump forward/backward to a
that is, when the instruction is true, the circuit functions
corresponding label instruction.
normally, and when the instruction is false, nonretentive
LBL (Label)—Specifies label location. outputs are switched off. Because these instructions are not
JSR (Jump to Subroutine)—Jump to a designated hardwired but programmed, for safety reasons they should
subroutine instruction. not be used as a substitute for a hardwired master control
RET (Return from Subroutine)—Exits current sub- relay, which provides emergency I/O power shutdown.
routine and returns to previous condition. A Master Control Reset (MCR) instruction is an out-
SBR (Subroutine)—Identifies the subroutine program. put coil instruction that functions like a master control

JMP LBL JSR RET SBR TND MCR SUS

Program Control Ascii Control Ascii String Micro

Figure 9-1 Program Control menu tab.

L1 L2
Master start
Master stop
MCR
MCR

MCR MCR

CR

CR4 OL
M1
CR1
CR2 M1 OL
M2

Figure 9-2 Hardwired master control relay.


Source: This material and associated copyrights are proprietary to, and used with the permission of
Schneider Electric.

Program Control Instructions Chapter 9 177

pet10882_ch09_176-199.indd 177 7/23/10 10:05 PM


Inputs Ladder logic program Outputs
L1 L2
ON/OFF
MCR
ON/OFF
M When MCR
Stop Start M
is de-energized,
all nonretentive
Stop outputs
de-energize.
PL1
M
Start
Level switch PL1

Level SOL When MCR


switch LS1 SOL is de-energized,
all retentive
L outputs remain
LS1 in last state.
LS2 SOL
U
LS2

MCR

Figure 9-3 Master Control Reset (MCR) instruction.

relay. MCR coil instructions are used in pairs and can it has no address. Figure 9-4 shows the programming of
be programmed to control an entire circuit or to control an MCR fenced zone with the zone true. The operation
only selected rungs of a circuit. In the program of Fig- of the program can be summarized as follows:
ure 9-3, the MCR is programmed to control an entire • The MCR zone is enclosed by a start fence, which
circuit. The operation of the program can be summarized is a rung with a conditional MCR, and an end fence,
as follows: which is a rung with an unconditional MCR.
• When the MCR instruction is false, or de-energized, • Input A of the start rung is true so all outputs act
all nonretentive (nonlatched) rungs below the MCR according to their rung logic as if the zone did not
will be de-energized even if the programmed logic exist.
for each rung is true. Figure 9-5 shows the programmed MCR fenced zone
• All retentive rungs will remain in their last state. with the zone false. The operation of the program can be
• The MCR instruction establishes a zone in the user summarized as follows:
program in which all nonretentive outputs can be • When the MCR in the start fence is false, all rungs
turned off simultaneously. within the zone are treated as false. The scan ig-
• Retentive instructions should not normally be placed nores the inputs and de-energizes all nonretentive
within an MCR zone because the MCR zone main- outputs (that is, the output energize instruction, the
tains retentive instructions in the last active state on-delay timer, and the off-delay timer).
when the instruction goes false. • All retentive devices, such as latches, retentive tim-
• An off-delay timer will start timing when in a de- ers, and counters, remain in their last state.
energized MCR zone. • Input A of the start rung is false so output A and
Allen-Bradley SLC 500 controllers use the master T4:1 will be false and output B will remain in its last
control reset instruction to set up single or multiple zones state.
within a program. The MCR instruction is used in pairs • The input conditions in each rung will have no
to disable or enable a zone within a ladder program, and effect on the output conditions.

178 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 178 7/23/10 10:05 PM


Inputs Ladder logic program Outputs
L1 L2
Input A Active
MCR Start fence

Input A Input B Output A Output A ON

Input C TON
Input B Output B ON
TIMER ON DELAY
EN
Timer T4:1
Time base 1.0 DN
Preset 10
Input C
Accumulated 0
Input D Latch output B
L
Input D
Input E Unlatch output B
U

Input E
MCR End fence

Figure 9-4 MCR fenced zone with the zone true.

A common application of an MCR zone control in- If you start instructions such as timers or counters in an
volves examining one or more fault bits as part of the start MCR zone, instruction operation ceases when the zone is
fence and enclosing the portion of the program you want disabled. The TOF timer will activate when placed inside
de-energized in case of a fault in the MCR zone. In case of a false MCR zone. When troubleshooting a program that
a detected fault condition, the outputs in that zone would contains an MCR zone, you need to be aware of which
be de-energized automatically. rungs are within zones in order to correctly edit the circuit.

Inputs Ladder logic program Outputs


L1 Input A L2
MCR Start fence

Input A Input B Output A

Output A OFF
Input C TON
Input B
TIMER ON DELAY
EN
Timer T4:1
Time base 1.0 Output B ON
DN
Preset 10
Input C
Accumulated 0
Input D Latch output B
L
Input D
Input E Unlatch output B
U

Input E
MCR End fence

Figure 9-5 MCR fenced zone with the zone false.

Program Control Instructions Chapter 9 179

pet10882_ch09_176-199.indd 179 7/23/10 10:05 PM


MCR-controlled areas must contain only two MCR The operation of the program can be summarized as
instructions—one to define the start and one to define the follows:
end. Never overlap or nest MCR zones. Any additional
• When the switch is open the jump instruction is not
MCR instructions, or a jump instruction programmed
activated.
to jump to an MCR zone, could produce unexpected
and damaging results to your program and to machine • With the switch open, closing PB turns on all three
operation. pilot lights.
• When the switch is closed the jump (JMP) instruc-
9.2 Jump Instruction tion will activate.
• With the switch closed, pressing PB turns on pilot
In PLC programming it is sometimes desirable to be able lights PL1 and PL3 only.
to jump over certain program instructions when certain
• Rung 3 is skipped over during the PLC program
conditions exist. The jump (JMP) instruction is an output
scan so PL2 is not turned on.
instruction used for this purpose. When the jump instruc-
tion is used, the PLC will not execute the instructions of a Figure 9-7 illustrates the effect on input and output in-
rung that is jumped. The jump instruction is often used to structions of jumped rungs in a program. The label in-
jump over instructions not pertinent to the machine’s op- struction is used to identify the ladder rung that is the
eration at that instant. In addition, sections of a program target destination but does not contribute to logic continu-
may be programmed to be jumped should a production ity. For practical purposes the label instruction is always
fault occur. considered to be logically true. The operation of the pro-
Some manufacturers provide a skip instruction, which gram can be summarized as follows:
is essentially the same as the jump instruction.
• When rung 4 has logic continuity, the processor is
The program of Figure 9-6 illustrates the use of a
instructed to jump to rung 8 and continue to execute
jump instruction in conjunction with Allen-Bradley
the main program from that point.
SLC 500 programmable controllers. Addresses Q2:0
through Q2:255 are the addresses used for the jump • Jumped rungs 5, 6, and 7 are not scanned by the
(JMP) instructions. The label (LBL) instruction is a processor.
target for the jump instruction. In addition, the jump • Input conditions for the jumped rungs are not exam-
instruction with its associated label must have the same ined and outputs controlled by these rungs remain in
address. The area of the program that the processor their last state.
jumps over is defined by the locations of the jump and • Any timers or counters programmed within the
label instructions in the program. If the jump coil is en- jump area cease to function and will not update
ergized, all logic between the jump and label instruc- themselves during this period. For this reason they
tions is bypassed and the processor continues scanning should be programmed outside the jumped section
after the LBL instruction. in the main program zone.
You can jump to the same label from multiple jump
Inputs Ladder logic program Outputs
locations, as illustrated in the program of Figure 9-8. In
L1 PB PL1 L2 this example, there are two jump instructions addressed
1 Q2:20. There is a single label instruction addressed
PB PL1 Q2:20. The scan can then jump from either jump instruc-
Switch Q2:0 tion to label Q2:20, depending on whether input A or
2 JMP input D is true.
Switch PL2 It is possible to jump backward in the program, but this
PB PL2 should not be done an excessive number of times. Care
3 PL3 must be taken that the scan does not remain in a loop too
long. The processor has a watchdog timer that sets the
Q2:0 PB PL3
maximum allowable time for a total program scan. If this
4 LBL time is exceeded, the processor will indicate a fault and
shut down.
The forward jump is similar to an MCR instruction in
that both permit an input logic condition to skip over a
Figure 9-6 Jump (JMP) operation. block of PLC ladder logic. The main difference between

180 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 180 7/23/10 10:05 PM


Inputs Ladder logic program Outputs
PB1 PB2 M
1
L1 L2
M

PB1 M PS1
TON M M
2 TIMER ON DELAY Timers should be
EN
Timer T4:6 programmed outside
Time base 1.0 the jumped section.
PB2 DN
Preset 5
Accumulated 0
PL1 PL1
PS1 T4:6 PL1
3
DN
SOL1
LLS1 Q2:1
LLS1
4 JMP Jumped program rungs
are not scanned by the
LS1 processor.
SOL1
LS1
5 SOL2
Input conditions are not
examined, and outputs
LS1 LS2 SOL2 remain in their last state.
LS2
6
PL2 PL2
LS3 PL2
LS3 7

PB3 T4:6 SOL3


Q2:1 SOL3
PB3 8 LBL
DN
SOL3

LS4 SOL4
SOL3 LS4 SOL4
9
TS1 TS1 Heater Heater Heater
10

Figure 9-7 Effect on input and output instructions of jumped rungs.

the two is in how the outputs are handled when the in-
9.3 Subroutine Functions
structions are executed. The MCR instruction sets all In addition to the main ladder logic program, PLC pro-
nonretentive outputs to the false state and keeps the reten- grams may also contain additional program files known as
tive outputs in their last state. The JMP instruction leaves subroutines. A subroutine is a short program that is used
all outputs in their last state. You should never jump into by the main program to perform a specific function. Large
a Master Control Reset zone. If you do, instructions that programs are often broken into subroutine program files,
are programmed within the MCR zone starting at the which are called and executed from the main program. In
LBL instruction and ending at the end MCR instruc- the SLC 500 series PLCs, the main ladder logic program
tion will always be evaluated as though the MCR zone is is in program file two (shown as LAD 2). Ladder logic
true, without consideration to the state of the start MCR programs for subroutines can be placed in file number
instruction. three (LAD 3) through file number 255 (LAD 255).

Program Control Instructions Chapter 9 181

pet10882_ch09_176-199.indd 181 7/23/10 10:05 PM


Ladder logic program JSR
JUMP-TO-SUBROUTINE
Input A Q2:5 SBR file number U:3
JMP

Input B Output A SBR


SUBROUTINE

TON RET
Input C
TIMER ON DELAY RETURN
Timer T4:1 EN
Time base 1.0 Figure 9-10 Allen-Bradley subroutine-related instructions.
DN
Preset 10
Accumulated 0

Input D Q2:5
The sequence of rungs could be programmed one time
JMP into a subroutine and just called when needed.
The subroutine concept is the same for all program-
Input E Output C
mable controllers, but the method used to call and return
from a subroutine uses different commands, depending on
Q2:5 Input F Output D the PLC manufacturer. The subroutine-related instructions
LBL used in the Allen-Bradley PLCs shown in Figure 9-10 are
the jump to subroutine (JSR) output instruction, the sub-
routine (SBR) input instruction, and the return (RET) out-
Figure 9-8 Jump-to-label from two locations. put instruction.
The subroutine instructions can be summarized as
Use of subroutines is a valuable tool in PLC program- follows:
ming. At times it is better to construct programs that con- Jump to Subroutine (JSR)—The JSR instruction is
sist of several subroutines than a lengthy single program. an output instruction that causes the scan to jump to
When programs are written with subroutines, each sub- the program file designated in the instruction. It is the
routine can be tested individually for functionality. These only parameter entered in the instruction. When rung
subroutines can then be called from the main program as conditions are true for this output instruction, it causes
illustrated in Figure 9-9. the processor to jump to the targeted subroutine file.
When a subroutine is called from the main program, Each subroutine must have a unique file number
the program is able to escape from the main program (decimal 3–255).
and go to a program subroutine to perform certain func-
Subroutine (SBR)—The SBR instruction is the first
tions and then return to the main program. In situations
input instruction on the first rung in the subroutine
in which a machine has a portion of its cycle that must be
file. It serves as an identifier that the program file is
repeated several times during one machine cycle, the sub-
a subroutine. This file number is used in the JSR in-
routine can save a great deal of duplicate programming.
struction to identify the target to which the program
should jump. It is always true, and although its use is
Main program rungs optional, it is still recommended.
Return (RET)—The RET instruction is an output
Subroutine area
SBR
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 ex-
ited 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
Jumps
RET
precedes the end of the subroutine. In this way, the
JSR
Unconditional return processor omits the balance of a subroutine only if its
rung condition is true.
Returns to next
instruction after JSR The jump to subroutine (JSR), subroutine (SBR), and
return (RET) instructions are used to direct the controller
Figure 9-9 Main program with a call from a subroutine. to execute a subroutine file. Figure 9-11 shows a materials

182 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 182 7/23/10 10:05 PM


Pilot light

Solenoid

Weight
sensor

(a)

Main program
Inputs file 2 Outputs

Sensor
JSR
L1 L2
JUMP-TO-SUBROUTINE
SBR file number U:3

Sensor PL1 Motor M1


OFF/ON

T4:1/EN
Stop PL1 PL1
Stop Start Motor

Start
Motor SOL

Sensor
OFF/ON Sensor SOL

Subroutine
file 3

T4:1/DN TON
SBR TIMER ON DELAY
SUBROUTINE Timer T4:0 EN
Time base 1.0 DN
Preset 1
Accumulated 0

T4:0/DN TON
TIMER ON DELAY
Timer T4:1 EN
Time base 1.0 DN
Preset 1
Accumulated 0

RET
RETURN

(b)

Figure 9-11 Flashing pilot light subroutine. (a) Process. (b) Program.

Program Control Instructions Chapter 9 183

pet10882_ch09_176-199.indd 183 7/23/10 10:05 PM


conveyor system with a flashing pilot light as a subrou- • At each ladder location where a subroutine is called,
tine. The operation of the program can be summarized as program a JSR instruction specifying the subroutine
follows: file number.
• If the weight on the conveyor exceeds a preset • The RET instruction is optional.
value, the solenoid is de-energized and pilot light – The end of a subroutine program will cause a re-
PL1will begin flashing. turn to the main program.
– If you want to end a subroutine program before it
• When the weight sensor switch closes, the JSR is
executes to the end of program file, a conditional
activated and directs the processor scan to jump to
return (RET) instruction may be used.
the subroutine U:3.
• The subroutine program is scanned and pilot light An optional SBR instruction is the header instruction
PL1 begins flashing. that stores incoming parameters. This feature lets you
• When the weight sensor switch opens, the proces- pass selected values to a subroutine before execution
sor will no longer scan the subroutine area and pilot so the subroutine can perform mathematical or logi-
light PL1 will return to its normal on state. cal operations on the data and return the results to the
main program. For example, the program shown in Fig-
The Allen-Bradley SLC 500 controller main program ure 9-13 will cause the scan to jump from the main pro-
is located in program file 2 whereas subroutines are as- gram file to program file 4 when input A is true. When
signed to program file numbers 3 to 255. Each subroutine the scan jumps to program file 4, data will also be passed
must be programmed in its own program file by assigning from N7:30 to N7:40. When the scan returns to the main
it a unique file number. Figure 9-12 illustrates the proce- program from program file 4, data will be passed from
dure for setting up a subroutine and can be summarized N7:50 to N7:60.
as follows: Nesting subroutines allows you to direct program flow
• Note each ladder location where a subroutine should from the main program to a subroutine and then to another
be called. subroutine, as illustrated in Figure 9-14. Nested subrou-
• Create a subroutine file for each location. Each sub- tines make complex programming easier and program op-
routine file should begin with an SBR instruction. eration faster because the programmer does not have to
continually return from one subroutine to enter another.
Programming nested subroutines may cause scan time
problems because while the subroutine is being scanned,
Main program the main program is not. Excessive delays in scanning the
file 2
main program may cause the outputs to operate later than
required. This situation may be avoided by updating criti-
cal I/O using immediate input and/or immediate output
instructions.
JSR
JUMP-TO-SUBROUTINE
SBR file number 3
9.4 Immediate Input and Immediate
Subroutine Output Instructions
file 3
The immediate input and immediate output instructions
SBR
SUBROUTINE 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
for time-critical I/O data.
The immediate input (IIN) Allen-Bradley PLC-5 in-
struction is used to read an input condition before the I/O
update is performed. This operation interrupts the pro-
gram scan when it is executed. After the immediate input
RET
RETURN instruction is executed, normal program scan resumes.
This instruction is used with critical input devices that re-
Figure 9-12 Setting up a subroutine file. quire updating in advance of the I/O scan.

184 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 184 7/23/10 10:05 PM


Main ladder program

Input A JSR
JUMP-TO-SUBROUTINE
Program file 4 Input parameter passed to the
Input parameter N7:30 SBR instruction when execution
jumps to the subroutine file.
Return parameter N7:60

Execution resumes

Subroutine
file 4
SBR
SUBROUTINE
Input parameter N7:40

RET
RETURN ( )
Return parameter returned to the Return parameter N7:50
address that you specified in the
JSR instruction when execution
returns to the main ladder program.

Figure 9-13 Passing subroutine parameters.

Main program
file 2

JSR
JUMP-TO-SUBROUTINE
SBR file 3
Level 1 Level 2 Level 3
file 3 file 4 file 5
SBR SBR SBR
SUBROUTINE SUBROUTINE SUBROUTINE

JSR JSR
JUMP-TO-SUBROUTINE JUMP-TO-SUBROUTINE
SBR file 4 SBR file 5

RET RET RET


RETURN RETURN RETURN

Figure 9-14 Nested subroutines.

Program Control Instructions Chapter 9 185

pet10882_ch09_176-199.indd 185 7/23/10 10:05 PM


Ι/O scan The immediate output (IOT) Allen-Bradley PLC-5 in-
struction is a special version of the output energize in-
struction used to update the status of an output device
Program scan before the I/O update is performed. The immediate output
is used with critical output devices that require updating in
advance of the I/O scan. When the program scan reaches
12 the immediate output instruction, the scan is interrupted
IIN and the bits of the addressed word are updated. The opera-
tion of the immediate output instruction is illustrated in
Figure 9-16 and can be summarized as follows:
Immediate input instruction
interrupts program scan • When the program scan reaches a true IOT instruc-
and examines bits in word
I:012 here in program
tion, the scan is interrupted and the data in the
output image table at the word address on the in-
struction are transferred to the real-world outputs.
Module 2 • In this example, the IOT instruction follows the out-
Returns to group put energize instruction.
program (input)
scan • Thus, the output image table word is updated first,
and then the data are transferred to the real-world
Word I:012
outputs.

I/O scan

12
Program scan IIN
I:012 O:013
Rack 1

Figure 9-15 Immediate input instruction. 07 11


13
IOT
The operation of the immediate input instruction is il-
lustrated in Figure 9-15. When the program scan reaches
the immediate input instruction, the scan is interrupted Immediate output instruction
and the bits of the addressed word are updated. The interrupts program scan
immediate input is most useful if the instruction asso-
ciated with the critical input device is at the middle or
toward the end of the program. The immediate input is
not needed near the beginning of the program since the Returns to Word O:013
I/O scan has just occurred at that time. Although the im- program
scan
mediate input instruction speeds the updating of bits, its
scan-time interruption increases the total scan time of the Module 3
program. The operation of the program can be summa- group
rized as follows: (output)

• When the scan reaches a true IIN instruction, the


scan is interrupted.
• The processor updates 16 bits in the input
image table at the location indicated on the IIN
instruction.
• The two-digit address on the IIN instruction is com-
posed of the rack number (first digit) and the I/O
Rack 1
group number (second digit) containing the input or
inputs and needs immediate updating. Figure 9-16 Immediate output instruction.

186 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 186 7/23/10 10:05 PM


The Allen-Bradley SLC 500 PLC’s immediate I/O
instructions contain a few improvements over those of IIM IOM SYC MSG IIE IID RPI REF

the PLC-5. The SLC 500’s instructions, which are called Input/Output Compare Compute/Math Move/Logic
immediate input with mask (IIM) and immediate out-
put with mask (IOM), allow the programmer to specify IOM
which of the 16 bits are to be copied from an input mod- Immediate Output w/ Mask
ule to the input image data table (or from the output Slot O:4.0
image table to an output module). The other bits in the Mask 0FFFh
input image table or output module are not affected by Length 2

these instructions. In addition, the SLC 500 instructions


allow you to input or output a series of data words from Figure 9-18 Immediate output with mask (IOM) instruction.
a single input module or output a series of data words to
an output module.
• This allows the programmer to update only sections
The immediate input with mask (IIM) instruction is
of the inputs to be used throughout the rest of the
shown in Figure 9-17. The IIM instruction operates on
program.
the inputs assigned to a particular word of a slot. When
the IIM rung is true, the program scan is interrupted, and The immediate output with mask (IOM) instruction is
data from a specific input slot are transferred through shown in Figure 9-18. The IOM operates on the physi-
the mask to the input data file. These data are then avail- cal outputs assigned to a particular word of a slot. When
able to the commands in the ladder following the IIM the IOM rung is true, the program scan is interrupted to
instruction. The following parameters are entered in the update output data to the module located in the slot speci-
instruction: fied in the instruction. These data are then available to the
commands in the ladder following the IOM instruction.
Slot Specifies the slot and word that contain the data
The parameters entered are basically the same as those
to be updated. For example, I:3.0 means the input of
entered for the IIM instruction.
slot 3, word 0.
Processor communication with the local chassis is
Mask Specifies either a hex constant or a register many times faster than communication with the remote
address. For the mask, a 1 in the bit position passes chassis. This is due to the fact that local I/O scan is
data from the source to the destination. A 0 inhibits synchronous with the program scan and communication
or blocks bits from passing from the source to the is in parallel with the processor, whereas the remote
destination. I/O scan is asynchronous with the program scan and
Length Used to transfer more than one word per communication with remote I/O is serial. For this rea-
slot. son, fast-acting devices should be wired into the local
The program operation of the instruction is summarized chassis.
as follows:
• The IIM instruction retrieves data from I:1.0 and 9.5 Forcing External I/O Addresses
passes it through the mask. The force function is essentially a manual override con-
• The mask permits only the four least significant bits trol function. Forcing allows the PLC user to turn an ex-
to be moved to the input register I:1.0. ternal input or output on or off from the keyboard of the
programming device. This is accomplished regardless of
the actual state of the field device. The forcing capability
IIM IOM SYC MSG IIE IID RPI REF
allows a machine or process to continue operation until a
Input/Output Compare Compute/Math Move/Logic faulty field device can be repaired. It is also valuable dur-
ing start-up and troubleshooting of a machine or process
to simulate the action of portions of the program that have
IIM
Immediate Input w/ Mask not yet been implemented.
Forcing inputs manipulates the input image table file
Slot I:1.0
Mask 000Fh bits and thus affects all areas of the program that use those
Length 1 bits. The forcing of inputs is done just after the input scan.
When we force an input address, we are forcing the sta-
Figure 9-17 Immediate input with mask (IIM) instruction. tus bit of the instruction at the I/O address to an on or

Program Control Instructions Chapter 9 187

pet10882_ch09_176-199.indd 187 7/23/10 10:05 PM


Input module
Actual state of input
OFF I:1/3 device (0) ignored

Field input Input image table


device

ONLINE Forces Exist Programming terminal


forces the state of Ladder
Forces Enabled
input I:1/3 ON (1) logic
program

Input Ladder logic program Outputs


L1 I:1/3 O:2/5 L2
I:1/3
O:2/5
OFF Force> ON
ON

O:2/5 O:2/6
O:2/6 M
ON

Figure 9-19 Forcing an input on.

off state. Figure 9-19 illustrates how an input is forced bit of the output instruction at the address is usually not
on. The operation of the program can be summarized as affected. Figure 9-20 illustrates how an output is forced
follows: on. The operation of the program can be summarized as
• The processor ignores the actual state of input limit follows:
switch I:1/3. • The processor ignores the actual state of solenoid
• Although limit switch I:1/3 is off (0 or false) the output O:2/5.
processor considers it as being in the on (1 or true) • The programming device sets the force state in the
state. output force data file and the PLC implements the
• The program scan records this, and the program is force to turn solenoid output O:2/5 on even though
executed with this forced status. the output image table file indicates that the user
• In other words, the program is executed as if the logic is setting the point to off.
limit switch were actually closed. • M output O:2/6 remains off because the status
Forcing outputs affects only the addressed output ter- bit of output O:2/5 is not affected by the force
minal. Therefore, since the output image table file bits are instruction.
unaffected, your program will be unaffected. The forcing • Not all brands of PLCs operate this way. For ex-
of outputs is done just before the output image table file is ample, forcing an output with a GE Fanuc controller
updated. When we force an output address, we are forcing will cause the contacts that have the same address as
only the output terminal to an on or off state. The status the output to also change to the appropriate state.

188 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 188 7/23/10 10:05 PM


Output module
Status of bit
O:2/5 remains
Output image table at 0
ON
O:2/5

0 0 OFF
O:2/6
M
Field output
devices

Ladder
ONLINE Forces Exist logic
Forces Enabled program

Input Ladder logic program Outputs


L1 I:1/3 O:2/5 L2
I:1/3
O:2/5
OFF Force> ON
ON

O:2/5 O:2/6 O:2/6 M


OFF
Force> ON

Figure 9-20 Forcing an output on.

Overriding of physical inputs on conventional relay Data File I1 (bin) . . INPUT Forces
control systems can be accomplished by installing
Offset 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
hardwire jumpers. With PLC control hardwire jumpers I:1.0 . . . . . . . . . . . . 1 . . .
are not necessary because the input data table values I:2.0
. . . .

can be forced to an on or off state. The force func-


tion allows you to override the actual status of external
input circuits by forcing external data bits on or off.
I:1.0/3 Radix:
Similarly, you can override the processor logic and Symbol: Columns:
status of output data file bits by forcing output bits Desc:
on or off. By forcing outputs off, you can prevent the Enable Remove All Data File Help
controller from energizing those outputs even though
the ladder logic, which normally controls them, may Figure 9-21 Forces version of the data table with bit I:1/3
be true. In other instances, outputs may be forced on forced on.
even though logic for the rungs controlling those out-
puts may be false.
file online. With RSLogix 500 software, the steps are as
Figure 9-21 shows the forces version of the data table
follows:
with bit I:1/3 forced on. You can enter and enable or
disable forces while you are monitoring your file off- 1. Open the program file in which you want to force
line, or in any processor mode while monitoring your the logic on or off.

Program Control Instructions Chapter 9 189

pet10882_ch09_176-199.indd 189 7/23/10 10:05 PM


2. With the right mouse button, click the I/O bit you example, if maintenance personnel are performing rou-
want to force. tine maintenance on a de-energized motor, the machine
3. From the menu that appears, select Go to Data Table may suddenly become energized by someone forcing the
or select Force On or Force Off. motor to turn on. This is why a hardwired master control
4. From the associated data table that appears, click on circuit is required for the I/O rack. The hardwired circuit
the Forces button. will provide a method of physically removing power to
the I/O system, thereby ensuring that it is impossible to
5. The Forces version of the data table appears with
energize any inputs or outputs when the master control
the selected bit highlighted. Click on this bit with
is off.
the right mouse button.
6. From the menu that appears, you can force the se-
lected bit on or off.
9.6 Safety Circuitry
Sufficient emergency circuits must be provided to stop ei-
Exercise care when you use forcing functions. If
ther partially or totally the operation of the controller or
used incorrectly, force functions can cause injuries
the controlled machine or process. These circuits should
to persons working around a system, and/or equip-
be hardwired outside the controller so that in the event of
ment damage. For this reason, forcing functions should
total controller failure, independent and rapid shutdown
be used only by personnel who completely understand
is available.
the circuit and the process machinery or driven equip-
Figure 9-23 shows typical safety wiring requirements
ment (Figure 9-22). You must understand the potential
for a PLC installation. The safety requirements of this in-
effect that forcing given inputs or outputs will have on
stallation can be summarized as follows:
machine operation in order to avoid possible personal
injury and equipment damage. Before using a force • A main disconnect switch is installed on the
function, check whether the force acts on the I/O point incoming power lines as a means of removing
only or whether it acts on the user logic as well as on the power from the entire programmable controller
I/O point. Most programming terminals and PLC CPUs system.
provide some visible means of alerting the user that a • The main power disconnect switch should be lo-
force is in effect. cated where operators and maintenance personnel
In situations in which rotating equipment is involved, have quick and easy access to it. Ideally, the discon-
the force instruction can be extremely dangerous. For nect switch is mounted on the outside of the PLC
enclosure so that it can be accessed without opening
the enclosure.
• In addition to disconnecting electrical power, you
should de-energize, lock out, and tag all other
sources of power (pneumatic and hydraulic) before
you work on a machine or process controlled by the
controller.
• An isolation transformer is used to isolate the con-
troller from the main power distribution system and
step the voltage down to 120 VAC.
• A hardwired master control relay is included to pro-
vide a convenient means for emergency controller
shutdown. Because the master control relay allows
the placement of several emergency-stop switches
in different locations, its installation is important
from a safety standpoint.
• Overtravel limit switches or mushroom head emer-
gency stop pushbuttons are wired in series so that
when one of them opens, the master control is
de-energized.
Figure 9-22 Exercise care when you use forcing functions. • This removes power to input and output device
Source: Courtesy Givens Engineering Inc. circuits. Power continues to be supplied to the

190 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 190 7/23/10 10:05 PM


L1
Power
L2
mains
L3

Main disconnect switch

Step-down
isolation transformer

L1 Fuse L2
120
VAC PLC Control Panel
Machine Master
start/stop control
Emergency stop switches
buttons relay
MCR
Emergency Overtravel Stop Start
stop limit
switch
MCR

L1 L2 GND PLC power


supply

MCR
PLC input module
L1 1 2 3 4 5 6 7 8 L2

PLC output module


L1 1 2 3 4 5 6 7 8 L2

Figure 9-23 Safety wiring requirements for a PLC installation.


Source: Courtesy Minarik Automation & Control.

controller power supply so that any diagnostic electromechanical component must not be dependent on
indicators on the processor module can still be electronic components (hardware or software). Any part
observed. can fail, including the switches in a master control relay
• Note that the master control relay is not a substitute circuit. The failure of one of these switches would most
for a disconnect switch. When you are replacing likely cause an open circuit, which would be a safe power-
any module, replacing output fuses, or working on off failure. However, if one of these switches shorts out, it
equipment, the main disconnect switch should be no longer provides any safety protection. These switches
pulled and locked out. should be tested periodically to ensure that they will stop
machine motion when needed. Never alter these circuits
The master control relay must be able to inhibit all to defeat their function. Serious injury or machine dam-
machine motion by removing power to the machine I/O age could result.
devices when the relay is de-energized. This hardwired

Program Control Instructions Chapter 9 191

pet10882_ch09_176-199.indd 191 7/23/10 10:05 PM


1 2 3 7

Number Feature
1 Module status indicators
2 Alphanumeric display
3 Node address switches
4 Baud rate switches
8 5 USB port
6 DeviceNet communication connector
10
7 Terminal connectors
5 8 Input status indicators
9 Output status indicators
9 10 IP address desplay switch
11 Ethernet connector
12 Service switch
11

6 4 12 7

Figure 9-24 Safety PLC.


Source: Image Used with Permission of Rockwell Automation, Inc.

Safety PLCs, such as the one shown in Figure 9-24, • Safety PLCs use power supplies designed specifi-
are now available for applications that require more ad- cally for use in safety control systems and redun-
vanced safety functionality. A safety PLC is typically dant backplane circuitry between the controller and
certified by third parties to meet rigid safety and reliabil- I/O modules.
ity requirements of international standards. Both stan-
dard and safety PLCs have the ability to perform control Safety considerations should be developed as part
functions but a standard PLC was not initially designed of the PLC program. A PLC program for any applica-
to be fault tolerant and fail-safe. That is the fundamental tion will be only as safe as the time and thought spent
difference. on both personnel and hardware considerations make
Some of the differences between standard and safety it. One such consideration involves the use of a motor
PLCs include the following: starter auxiliary seal-in contact, shown in Figure 9-25,
in place of the programmed contact referenced to the
• A standard PLC has one microprocessor that output coil instruction. The use of the field-generated
executes the program, Flash memory area that starter auxiliary contact status in the program is more
stores the program, RAM for making calcula- costly in terms of field wiring and hardware, but it is
tions, ports for communications, and I/O for safer because it provides positive feedback to the pro-
detection and control of the machine. In contrast, cessor about the exact status of the motor. Assume,
a safety PLC has redundant microprocessors, for example, that the OL contact of the starter opens
Flash and RAM that are continuously moni- under an overload condition. The motor, of course,
tored by a watchdog circuit, and a synchronous would stop operating because power would be lost to
detection circuit. Redundancy is duplication. The the starter coil. If the program was written using an
probability of hazards arising from one malfunc- examine-on contact instruction referenced to the out-
tion in an electrical circuit can be minimized put coil instruction as the seal-in for the circuit, the
by creating partial or complete redundancy processor would never know that power had been lost
(duplication). to the motor. When the OL was reset, the motor would
• Standard PLC inputs provide no internal means for restart instantly, creating a potentially unsafe operating
testing the functionality of the input circuitry. By condition.
contrast, safety PLCs have an internal output circuit Another safety consideration concerns the wiring
associated with each input for the purpose of testing of stop buttons. A stop button is generally considered
the input circuitry. Inputs are driven both high and a safety function as well as an operating function. As
low for very short cycles during runtime to verify such, all stop buttons should be wired using a nor-
their functionality. mally closed contact programmed to examine for an on

192 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 192 7/23/10 10:06 PM


Inputs Ladder logic program Output
L1 L2
Stop Start M

OL
Stop
M M

Start Starter
auxiliary Main power
contact contact
Starter
auxiliary
contact

Auxiliary
contact

Figure 9-25 Motor starter programmed using the starter auxiliary seal-in contact.
Source: Image Used with Permission of Rockwell Automation, Inc.

condition (Figure 9-26). Using a normally open contact


programmed to examine for an off condition will pro-
9.7 Selectable Timed Interrupt
duce the same logic but is not considered to be as safe. The selectable timed interrupt (STI) instruction is used
Assume that the latter configuration is used. If, by some to interrupt the scan of the main program file automati-
chain of events, the circuit between the button and the cally, on a time basis, to scan a specified subroutine file.
input point were to be broken, the stop button could be For Allen-Bradley SLC 500 controllers, the time base at
depressed forever, but the PLC logic could never react which the program file is executed and the program file
to the stop command because the input would never assigned as the selectable timed interrupt file are deter-
be true. The same holds true if power were lost to the mined by the values stored in words S:30 and S:31 of the
stop button control circuit. If the normally closed wir- status section of the data files. The value in S:30 stores
ing configuration is used, the input point receives power the time base, which may be from 1 through 32,767, at
continuously unless the stop function is desired. Any 10 millisecond increments. Word S:31 stores the program
faults occurring with the stop circuit wiring, or a loss file assigned as the selectable interrupt file, which may be
of circuit power, would effectively be equivalent to an any program file from 3 through 999. Entering a 0 in the
intentional stop. time-base word disables the selectable timed interrupt.

Inputs Ladder logic program Output


L1 Stop Start L2
M
OL
Stop
M M
M

Start

Figure 9-26 Wiring of stop buttons.

Program Control Instructions Chapter 9 193

pet10882_ch09_176-199.indd 193 7/23/10 10:06 PM


Programming the selectable timed interrupt is done Program file 3 S:1
STE
when a section of program needs to be executed on a 0 SELECTABLE TIMED ENABLE
time basis rather than on an event basis. For example, a 15
program may require certain calculations to be executed 1
at a repeatable time interval for accuracy. These calcula-
tions can be accomplished by placing this programming 2
in the selectable timed-interrupt file. This instruction can 3
also be used for process applications that require periodic
4
lubrication.
The immediate input and immediate output instruc- 5
tions are often located in a selectable timed interrupt STD
6 SELECTABLE TIMED DISABLE
file, so that a particular section of program is updated
on a timed basis. This process could be done on a high-
7
speed line, when items on the line are being examined
and the rate at which they pass the sensor is faster than 8
STΙ execution
the scan time of the program. In this way, the item can will not occur 9
be scanned multiple times during the program scan, and between STD
and STE. 10
the appropriate action may be taken before the end of
the scan. 11
The selectable timed disable (STD) instruction
STE
is generally paired with the selectable timed enable 12 SELECTABLE TIMED ENABLE
(STE) instruction to create zones in which STI inter-
rupts cannot occur. Figure 9-27 illustrates the use of 13
the STD and STE instructions and can be summarized
14
as follows:
15
• In this program, the STI instruction is assumed to be
in effect. 16

• The STD and STE instructions in rungs 6 and 12 17 End


are included in the ladder program to avoid having
STI subroutine execution at any point in rungs 7 Figure 9-27 Selectable timed disable (STD) and selectable
through 11. timed enable (STE) instructions.
• The STD instruction (rung 6) resets the STI enable
bit, and the STE instruction (rung 12) sets the does not exist, the processor shuts down. When there is a
enable bit again. fault routine, and the fault is recoverable, the fault routine
• The first pass bit S:1/15 and the STE instruction in is executed. If the fault is nonrecoverable, the fault rou-
rung 0 are included to ensure that the STI function tine is scanned once and shuts down. Either way, the fault
is initialized after a power cycle. routine allows for an orderly shutdown.

9.8 Fault Routine 9.9 Temporary End Instruction


Allen-Bradley SLC 500 controllers allow you to des- The temporary end (TND) instruction is an output in-
ignate a subroutine file as a fault routine. If used, it struction used to progressively debug a program or
determines how the processor responds to a program- conditionally omit the balance of your current program
ming error. The program file assigned as the fault rou- file or subroutines. When rung conditions are true, this
tine is determined by the value stored in word S:29 of instruction stops the program scan, updates the I/O, and
the status file. Entering a 0 in word S:29 disables the resumes scanning at rung 0 of the main program file.
fault routine. Figure 9-28 illustrates the use of the TND instruction
There are two kinds of major faults that result in a in troubleshooting a program. The TND instruction lets
processor fault: recoverable and nonrecoverable faults. your program run only up to this instruction. You can
When the processor detects a major fault, it looks for a move it progressively through your program as you debug
fault routine. If a fault routine exists, it is executed; if one each new section. You can program the TND instruction

194 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 194 7/23/10 10:06 PM


Main program unconditionally, or you can condition its rung according
to your debugging needs.
Inputs
L1
SW 12 9.10 Suspend Instruction
TON EN
TIMER ON DELAY The suspend (SUS) instruction is used to trap and identify
Timer T4:2 DN specific conditions during system troubleshooting and
SW 13 Time base (sec) 1.0
Preset 5
program debugging. Figure 9-29 shows a suspend instruc-
Accumulated 0 tion in a ladder logic rung. The execution of the instruc-
tion can be summarized as follows:
T4:2 LT4
• When you program the SUS instruction, you must
DN enter a suspend ID number (number 100 is used in
SW 13 Temporary end this example).
TND • When the rung is true, the SUS output
instruction places the controller in the suspend
SW 1 LT1
mode and the PLC immediately terminates
L
scan cycling.
• All ladder logic outputs are de-energized, but other
SW 2 LT1
status files have the data present when the suspend
U
instruction is executed.
SW 3
• The SUS instruction writes the suspend ID number
RTO (100) to S:7 as it executes.
EN
RETENTIVE TIMER ON • You can include several SUS instructions in a pro-
Timer T4:3 DN
Time base (sec) 1.0 gram, each with a different suspend ID and read S:7
Preset 50 to determine which SUS instruction caused the PLC
Accumulated 0 to halt.
PB 1 T4:3
• Status file S:8 will contain the number of the pro-
RES
gram file that was executing when the SUS instruc-
Remainder of main program tion executed.
SUS
Suspend
Suspend ID 100

Figure 9-28 Temporary end (TND) instruction. Figure 9-29 Suspend (SUS) instruction.

Program Control Instructions Chapter 9 195

pet10882_ch09_176-199.indd 195 7/23/10 10:06 PM


CHAPTER 9 REVIEW QUESTIONS

1. a. Two MCR output instructions are to be pro- 8. a. What does the forcing capability of a PLC allow
grammed to control a section of a program. the user to do?
Explain the programming procedure to be b. Outline two practical uses for forcing functions.
followed. c. Why should extreme care be exercised when
b. State how the status of the output devices within using forcing functions?
the fenced zone will be affected when the MCR 9. Why should emergency stop circuits be hardwired
instruction makes a false-to-true transition. instead of programmed?
c. State how the status of the output devices within
10. State the function of each of the following in the
the fenced zone will be affected when the MCR
basic safety wiring for a PLC installation:
instruction makes a true-to-false transition.
a. Main disconnect switch
2. What is the main advantage of the jump b. Isolation transformer
instruction? c. Emergency stops
3. What types of instructions are not normally in- d. Master control relay
cluded inside the jumped section of a program? 11. Compare standard and safety PLCs with regard to:
Why? a. Processors
4. a. What is the purpose of the label instruction in b. Input circuitry
the jump-to-label instruction pair? c. Output circuitry
b. When the jump-to-label instruction is executed, d. Power supplies
in what way are the jumped rungs affected? 12. When programming a motor starter circuit, why is
5. a. Explain what the jump-to-subroutine instruction it safer to use the starter seal-in auxiliary contact
allows the program to do. in place of a programmed contact referenced to the
b. In what type of machine operation can this output coil instruction?
instruction save a great deal of duplicate 13. When programming stop buttons, why is it safer
programming? to use an NC pushbutton programmed to examine
6. What advantage is there to the nesting of for an on condition than an NO pushbutton pro-
subroutines? grammed to examine for an off condition?
7. a. When are the immediate input and immediate 14. Explain the selectable timed interrupt function.
output instructions used? 15. Explain the function of the fault routine file.
b. Why is it of little benefit to program an immedi-
16. How is the temporary end instruction used to trou-
ate input or immediate output instruction near
bleshoot a program?
the beginning of a program?

CHAPTER 9 PROBLEMS

1. Answer the questions, in sequence, for the MCR c. With switches S2 and S3 still on, switch S1 is
program in Figure 9-30, assuming the program has turned off. Will both outputs PL1 and PL2 de-
just been entered and the PLC is placed in the RUN energize? Why?
mode with all switches turned off. d. With all other switches off, switch S6 is turned
a. Switches S2 and S3 are turned on. Will outputs on. Will the timer time? Why?
PL1 and PL2 come on? Why? e. With switch S6 still on, switch S5 is turned on.
b. With switches S2 and S3 still on, switch S1 is Will the timer time? Why?
turned on. Will output PL1 or PL2 or both come f. With switch S6 still on, switch S5 is turned off.
on? Why? What happens to the timer? If the timer was an

196 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 196 30/07/10 2:07 PM


Inputs Ladder logic program Outputs
L1 L2
S1
1 MCR
S1 PL1
S2 PL1
S2 2
PL2

S3 S3 PL2
3 L

S4
S4 PL2
4 U
S5

S6 5 MCR
S5

6 MCR

S6 TON
TIMER ON DELAY EN
7
Timer T4:1
Time base 1:0 DN
Preset 10
Accumulated 0

8 MCR

Figure 9-30 Program for Problem 1.

Inputs Ladder logic program Outputs


RTO type instead of a TON, what would happen L1 S1 PL3 L2
to the accumulated value? 1
2. Answer the questions, in sequence, for the jump-to- PL1
S1
label program in Figure 9-31. Assume all switches S2 10
are turned off after each operation. 2 JMP
S2
a. Switch S3 is turned on. Will output PL1 be ener- PL2
gized? Why? S3 PL1
b. Switch S2 is turned on first, then switch S5 S3
3
is turned on. Will output PL4 be energized?
PL3
Why? S4 S5 PL4
c. Switch S3 is turned on and output PL1 is ener-
4
gized. Next, switch S2 is turned on. Will output S5 PL4
PL1 be energized or de-energized after turning
S4 PL2
on switch S2? Why? 10
5 LBL
d. All switches are turned on in order according
to the following sequence: S1, S2, S3, S5, S4.
Which pilot lights will turn on? Figure 9-31 Program for Problem 2.

Program Control Instructions Chapter 9 197

pet10882_ch09_176-199.indd 197 7/23/10 10:06 PM


3. Answer the questions, in sequence, for the jump- 4. Answer the questions, in sequence, for Figure 9-33.
to-subroutine and return program in Figure 9-32. Assume all switches are turned off after each
Assume all switches are turned off after each operation.
operation. a. Switches S2, S12, and S5 are turned on in order.
a. Switches S1, S3, S4, and S5 are all turned Will output PL5 be energized? Why?
on. Which pilot light will not be turned on? b. All switches except S7 are turned off. Will RTO
Why? start timing? Why?
b. Switch S2 is turned on and then switch S4 c. Switches S3 and S8 are turned on in order. Will
is turned on. Will output PL3 be energized? pilot light PL2 come on? Why?
Why? d. When will timer TON function?
c. To what rung does the RET instruction return the e. Assume all switches are turned on. In what order
program scan? will the rungs be scanned?
f. Assume all switches are turned off. In what
order will the rungs be scanned?

Ladder logic program


Inputs Main program file 2 Outputs
L1
S1 L2
PL1
S1 PL1
S2 JSR
S2 JUMP-TO-SUBROUTINE
SBR file number U:3 PL2
S3
S3 PL2
PL3
S4
S5 PL4
S5 PL4

Subroutine file 3
S4 PL3
SBR
SUBROUTINE
RET
RETURN

Figure 9-32 Program for Problem 3.

198 Chapter 9 Program Control Instructions

pet10882_ch09_176-199.indd 198 7/23/10 10:06 PM


Ladder logic program
Inputs Main program file 2 Outputs

S1 PL1 L2
L1
1
PL1
S1
S2 JSR
S2 JUMP-TO-SUBROUTINE PL2
2
SBR file number U:3

S3 S3 20
3 JMP PL3
S4
S4 PL6
4 PL4
S5
S9 20
S6 5 JMP
PL5
S8 PL2
S7
6
PL6
S8 S10 20
7 JMP
S9
S11 PL4
8
S10
RTO
20 S7 RETENTIVE TIMER ON EN
S11 Timer T4:3
9 LBL Time base (sec) 1.0 DN
Preset 50
S12 Accumulated 0
T4:3/DN
T4:3
S13 10 RES

Subroutine file 3
S13 PL3
SBR
11 SUBROUTINE

S12 12
12 JMP

S5 PL5
13

12 S6
TON
14 LBL TIMER ON DELAY EN
Timer T4:6
Time base 1.0
Preset 5 DN
Accumulated 0

RET
15 RETURN

Figure 9-33 Program for Problem 4.

Program Control Instructions Chapter 9 199

pet10882_ch09_176-199.indd 199 7/23/10 10:06 PM

You might also like