Professional Documents
Culture Documents
1
OPERATION 2. MicroLogix specifications
3. I/O structure and memory system
4. Addressing notation
After finishing this module, you will:
2 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 3
A rc h i t e c t u r e a n d O p e r a t i o n
PLC Operation
All PLCs, including the MicroLogix 1000, perform a three-step
operation called a scan (see Figure 1-5). The scan consists of:
Write Read
1. reading the input data that the PLC receives from the
input devices
2. executing the control program stored in memory
3. updating, or writing, the status of the output devices based
on the outcome of the control program execution
A PLC performs the scan over and over again, constantly updat-
ing the outputs based on how new input conditions affect the Program Execution
control program.
Figure 1-5. A PLCs scan consists of reading the inputs, executing the control program,
and updating the outputs.
4 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
The scan can be broken up into two different parts, the I/O scan
and the program scan (see Figure 1-6). During the I/O scan,
Write Read the PLC reads inputs and updates the outputs. During the pro-
I/O Scan gram scan, the PLC executes the control program.
The scan time is the specific amount of time required for a PLC
to perform both the I/O scan and the program scan. Each PLCs
Program Scan
scan time is different. A MicroLogix 1000 can perform a scan in
milliseconds. However, when it is on-line with a programming
device, the MicroLogix experiences two delays during its scan
Program Execution (see Figure 1-7). These are:
the service communications delay
Figure 1-6. A PLCs total scan consists of two different scans: the I/O scan and the
program scan. the overhead delay
The service communications delay is the time required for
the MicroLogix 1000 to send data to the programming or moni-
toring device, which may be a personal computer or a handheld
Service programmer. The overhead delay is the time required for house-
Communications Overhead keeping operations, like memory management and updating
Delay Delay
timer information. Although both of these delays add to the
MicroLogix 1000s scan time, it still performs its scan very quickly.
Write Read
Program Execution
Figure 1-7. The MicroLogix experiences two scan delays, a service communications
delay and an overhead delay, when it is on-line with a programming
device.
Module 1 5
A rc h i t e c t u r e a n d O p e r a t i o n
6 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 7
A rc h i t e c t u r e a n d O p e r a t i o n
Number Systems
Number systems are used to represent data in a PLC. The Micro-
Logix 1000 PLC uses several different types of number systems to
represent program data, address data, and internal data. They are:
binary
decimal
hexadecimal
octal PLC Memory
PB
binary codes
(a) 1
Binary. The MicroLogix 1000 uses the binary number system
to represent program data. The binary number system uses only
two numbers, 0 and 1, to represent data. PLCs, including the
MicroLogix 1000, use the binary system to represent I/O data PLC Memory
because PLCs are discrete devices capable of recognizing only PB
two states, ON and OFF.
(b) 0
Using the binary system, a PLC indicates that a device is ON, or
activated, by placing a value of 1 in the appropriate bit in memory
(see Figure 1-11). Conversely, a PLC indicates that a device is
OFF, or not activated, by placing a value of 0 in the appropriate Figure 1-11. (a) If a device is ON, a PLC will store a 1 in memory. (b) If a device is
bit in memory. OFF, a PLC will store a 0 in memory.
8 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
PB1 SOL
1 1 3 7 7 which terminal. Figure 1-12 shows an example of address nota-
tion. An address instructs a contact or coil to examine a terminal
PB2 to see whether the device connected to it is ON or OFF.
2 8 PL
2
Hexadecimal. The hexadecimal number system is different
from other number systems because it uses both numbers and
LS1 3 4 8 9 M
letters to represent data. The MicroLogix 1000 uses this number
system to represent constants and other internal values. The
1 2
hexadecimal system uses 16 numbers. It represents the num-
LS2 4 3 9 bers 0 through 9 by the digits 09. It represents the numbers 10
through 15 by the letters AF (see Figure 1-13).
Figure 1-12. The numbers above the contacts, terminals, and coils are addresses Octal. The MicroLogix 1000 uses the octal number system as
expressed by decimal numbers. a shorthand way to express binary data. The octal number sys-
tem uses eight numbers, 0 through 7, to represent data. It groups
binary numbers into groups of three and then uses one of the
numbers 0 through 7 to represent the group of numbers (see
0 1 2 3 4 5 6 7 8 9 Figure 1-14).
10 11 12 13 14 15 Binary Code. A binary code is a code that lets a PLC commu-
nicate with the outside world. Since PLCs are discrete devices
A B C D E F and the rest of the world is not, PLCs must have a way to inter-
pret and communicate nonbinary information from devices like
Figure 1-13. In hexadecimal, the numbers 0 through 9 are represented by the thumbwheel switches and seven-segment indicators. The Micro-
digits 09 and the numbers 10 through 15 by the letters AF. Logix 1000 uses binary codes to do just that. A binary code
translates nonbinary data, like letters, into a binary coded for-
mat that the PLC can understand. It also communicates binary
information from the PLC to nonbinary outside devices. The
010 000 110 MicroLogix 1000 uses two binary codes, ASCII and BCD, to per-
form these functions.
2 0 6
Figure 1-14. The octal number system groups binary numbers into groups of three
and then represents each group with a number.
Module 1 9
A rc h i t e c t u r e a n d O p e r a t i o n
Configurations
A MicroLogix 1000 PLC comes in many configurations. These
configurations differ by:
the number of inputs and outputs
the type of power supply
the type of I/O interfaces
Inputs and Outputs. The number of inputs and outputs deter-
mines the size of a MicroLogix PLC. The MicroLogix 1000 comes
in two sizes: 16 I/O and 32 I/O. A 16 I/O MicroLogix can con-
nect with up to 10 input devices and 6 output devices (see
Figure 1-15). A 32 I/O model can connect with up to 20 input
Figure 1-15. A 16 I/O MicroLogix.
devices and 12 output devices (see Figure 1-16). The size of a
MicroLogix 1000 should be chosen based on the amount of I/O
required for its application.
Power Supply. The MicroLogix 1000 also has two types of power
supplies. These are 24 VDC (volts DC) and 120/240 VAC (volts
AC). The power supply should be chosen based on the power
requirements and the power availability for the application.
I/O Interfaces. A MicroLogix 1000 PLC has many options available
for both its input and output interfaces. A MicroLogix 1000 can
have one of two types of input interfaces, either 24 VDC or 120
VAC. These input interfaces allow the MicroLogix 1000 to connect
with either 24 VDC or 120 VAC input devices, respectively.
Just as a MicroLogix 1000 has a choice of inputs, it has a choice
of outputs as well. The MicroLogix 1000 uses three types of
outputs:
Figure 1-16. A 32 I/O MicroLogix.
relay
transistor
triac
10 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
MicroLogix 1000 A relay output allows the MicroLogix to interface with output
Inputs/Outputs devices that must receive a signal ranging between either 5 and
264 VAC or 5 and 125 VDC. A transistor output is specifically
designed for outputs requiring a 24 VDC output signal. A triac
specifically supplies a 120/240 VAC signal to its output devices.
Inputs Outputs Figure 1-17 shows the types of input and output interfaces avail-
24 volts DC Relay able in the MicroLogix 1000.
120 volts AC Transistor
Triac
Micro Logix
1000
Module 1 11
A rc h i t e c t u r e a n d O p e r a t i o n
Memory System
The memory system of a MicroLogix 1000 consists of four units File
(see Figure 1-19): Section
12 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 13
A rc h i t e c t u r e a n d O p e r a t i o n
Data File Section. The data file section stores all of the pro-
gram and I/O data used by the MicroLogix 1000. This section is Figure 1-22. The data file section of the MicroLogix 1000.
divided into eight files numbered 0 through 7, as shown in Fig-
ure 1-22. Each file stores a different type of information. Follow-
ing is an outline of the data files:
File 0 is the output file. It stores data about the status
of each output device connected to the MicroLogixs
output terminals. Each of the PLCs outputs is mapped
to an address bit in this file. File 0 is also known as the
output image table. The output file contains one word.
File 1 is the input file. It stores data about the status of
each input device. The input file is also known as the
input image table. As with the output file, each of
14 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 15
A rc h i t e c t u r e a n d O p e r a t i o n
16 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 17
A rc h i t e c t u r e a n d O p e r a t i o n
Special Addressing Situations Figure 1-25. This address indicates that the data is stored in the integer file in word
6, bit 14.
The timer, counter, and control files also use the addressing
system just explained. However, they add two extra characters
to the word labela period and a number.
The first number in this special word label identifies the timer, Timer File Word
counter, or special instruction number. The period acts as a de- 0 T4:0
limiter. The last number in the word label refers to one of the 1 T4:0.1
three words associated with the timer, counter, or special in- 2 T4:0.2
struction. Figure 1-26 shows an example of the addresses for 0 T4:1
three timers. 1 T4:1.1
2 T4:1.2
Like the timer, counter, and control files, the input file also has a
unique address code. It also adds two extra characters, a period 0 T4:2
and a number, to the word label. This is done to account for the 1 T4:2.1
2 T4:2.2
additional input word needed for a 32 I/O MicroLogix (see Fig-
ure 1-27). The first input word is labeled I:0.0. It holds the data
for the first 16 inputs. The second word is labeled I:0.1. It holds Figure 1-26. Three timers, each with three word addresses. Note that the period/
word number extension is dropped from each timers first word address.
the data for the remaining 4 inputs.
Addressing Examples
Following are some examples of the addressing scheme used in 32 I/O MicroLogix20 inputs
a MicroLogix 1000 programmable controller: Input File
Example 1Output Device. Figure 1-28 shows a pilot light 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
connected to output terminal 4 of a 16 I/O MicroLogix 1000. I: 0.0
Since the pilot light is an output, its address will start with the I: 0.1
letter O followed by a colon (O:). The output file has only one
word, so the pilot lights status data will be stored in word 0 Figure 1-27. The MicroLogix 1000s input file with the two words contained in it.
18 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Module 1 19
A rc h i t e c t u r e a n d O p e r a t i o n
1-5 Review
PLCs make it cheaper and easier to make changes to a control system.
The MicroLogix 1000, like other PLCs, is an industrial computer that controls a machine or process.
PLCs consist of two basic parts: the CPU and the I/O system.
All PLCs perform a three-step operation called a scan, which involves reading the inputs, executing the control program
stored in memory, and updating the status of the output devices.
The MicroLogixs control program, which is represented by ladder diagrams, implements the softwired logic connections
between the PLCs input and output devices.
The MicroLogix 1000 uses several different number systemsbinary, decimal, hexadecimal, and octal, as well as binary
codesto represent data.
The MicroLogix comes in two sizes16 I/O and 32 I/Oand has two types of power supplies24 VDC and
120/240 VAC.
The MicroLogix is available with two types of input interfaces24 VDC or 120 VACand three types of outputsrelay,
transistor, and triac.
The I/O structure of the MicroLogix is directly related to the way the memory system is organized.
The MicroLogixs memory system, which stores all of the information the PLC needs to operate, is divided into four units:
file sections, files, words, and bits.
The MicroLogix 1000 has two file sections: the program file section and the data file section.
The program file section contains 16 files, while the data file section contains 8 files.
PLCs use addresses to keep track of their data and to specify which contacts and coils reference which input and
output devices.
A MicroLogixs address has three parts: a file label, a word label, and a bit label.
Most of the files in the MicroLogixs memory system use the same addressing notation; however, some files use a special
word labeling mnemonic.
20 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
FILE FILE
# NAME FUNCTION
Executive Controls the function of the PLC and contains processor data: type, configuration, and passwords.
1
2 Main Ladder Program Controls the machine or process.
Program 3 Error Fault Routine Executed when a recoverable, or fixable, fault error occurs.
Section 4 High-Speed Counter Executed when a high-speed counter instruction causes an interruption in the control program.
Interrupt File
Selectable Timed
5 Interrupt Program Used to interrupt the normal program scan of the MicroLogix so a subroutine can be executed.
6 Subroutine Ladder
Called by the main ladder control program. Can store up to ten subroutines.
Programs
15
Holds three types of data: basic status data, dynamic configuration data and
static configurations data. S2:32
B3:0
Data 3 Binary B3 Stores data about the status of internal coils and contacts. 32
B3:31
Section 4 Timers T4
Contains data about the timers used in the control program. Keeps data 40
about each timer s status, preset value, and accumulated value in 3 separate 40 120
T4:0, T4:0.1, T4:0.2
words. 40 T4:39, T4:39.1, T4:39.2
Contains data about the counters used in the control program. Keeps data 32 C5:0, C5:0.1, C5:0.2
5 Counters C5 about each counter s status, preset value, and accumulated value. Can store 32 96
up to 32 counters and uses 3 words for each counter. 32 C5:31, C5:31.1, C5:31.2
1 6 R6:0, R6:0.1, R6:0.2
Stores information used by specialized instruction. Can hold data for 16
6 Control R6 16 48
instructions, using 3 words for each instruction. 16 R6:15, R6:15.1, R6:15.2
Stores miscellaneous numerical data: constant and variable data used by N7:0
7 Integer N7 105
arithmetic instructions, binary codes, and mask patterns.
N7:104
Module 1 21
A rc h i t e c t u r e a n d O p e r a t i o n
Job Aid 1-2: Differences Between the RSLogix And Handheld Programmer Addressing Notations
The RSLogix software program and a handheld programmer use slightly different notations for displaying an address. The follow-
ing example illustrates two of these differences.
The address B3:3/2 is shown as follows on an RSLogix screen, depending on the properties settings:
B3:3/2
P001
B/50 0
Note that the handheld programmer drops the number from the word label (B3). It also expresses the addressed bit according to
which bit it is in the total file (50), rather than which bit it is in which word (3/2).
22 Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Job Aid 1-3: Addressing Notations Used with the RSLogix Software
An address, such as the address I:0.1/2 can be shown several different ways on an RSLogix programming screen, depending on the
way the softwares properties are set up (View/Properties/Ladder):
Module 1 23
M O D U L E T W O
THE In the first module, you learned about the basic architecture and
operation of the Allen-Bradley Micrologix 1000, including a brief
introduction to its I/O system. This second module goes into more
detail about the I/O system of the Micrologix 1000 PLC. It includes
INPUT/OUTPUT four sections:
1. Types of input/output devices
2
SYSTEM
2. Input interfaces
3. Output interfaces
4. System and I/O power distribution wiring
Ke y Po i n t s After finishing this module, you will:
know the difference between the two types of I/O devices,
including which type works with the Micrologix 1000
understand the input interface configurations available in the
Micrologix 1000, their functional differences, and their different
wiring requirements
understand the various output interface configurations and the
wiring requirements of each
have an overview of how to hook up a Micrologix 1000 and its
I/O devices to the incoming power source
The Input/Output System
Discrete Devices
Discrete devices are input or output devices that provide or
receive discrete digital signals. A discrete digital signal is one
that can report only two states, such as ON/OFF or open/closed.
ON
A limit switch is an example of a discrete input device because, 1
at any given time, it is either open or closed. It sends a discrete PL
digital signal to a PLC. This signal can have one of only two
values, 0 or 1, indicating that the device is either OFF or ON,
respectively (see Figure 2-1).
A pilot light is an example of a discrete output device (see Fig-
ure 2-2). It can only be ON or OFF. A discrete output device OFF Discrete
receives a discrete digital signal from a PLC telling it to be in 0
either one state or the other. A discrete output can never be in a
state in between ON and OFF. Figure 2-2. A pilot light receives a discrete signal from a PLC.
2 Module 2
The Input/Output System
Analog Devices
In contrast to discrete devices, analog devices are input or out-
put devices that provide or receive analog signals. Analog sig-
Input nals are continuous and can have any number of statesnot
just two, as with discrete digital signals.
Temperature A temperature transducer is an example of an analog input de-
PLC
Transducer
vice. It sends a continuous stream of temperature data to a PLC
(see Figure 2-3). This temperature data is expressed in varying
Analog degreesnot simply as hot or cold.
Signal
An analog control valve is an example of an analog output de-
Figure 2-3. A temperature transducer sends a continuous stream of data to a PLC.
vice. It receives a continuous analog signal from a PLC telling it
how much to open or close (see Figure 2-4). If it was a discrete
device, it could only be either totally open or closed, but never
in between.
PLCs can interface with both discrete and analog devices. How-
ever, discrete devices are much more prevalent in PLC applica-
tions. The MicroLogix 1000 is designed to interface only with
discrete I/O devices.
Output
Analog
PLC Control
Valve
Analog
Signal
Figure 2-4. An analog control valve receives a continuous signal from a PLC.
Module 2 3
The Input/Output System
4 Module 2
The Input/Output System
Figure 2-6. The three components of a 120 VAC input interface. Logic Section. After the isolation section, the signal enters the
logic section of the input interface. This section sends the newly
converted and isolated input signal to the PLCs processor.
The MicroLogix 1000s 120 VAC input interface also includes a
power LED indicator. This LED indicates whether the interface
is receiving a valid signal from the input device. If both the
input device and the LED are ON, then everything is working
properly. However, if the input device is ON but the LED is OFF,
then a problem exists somewhere between the input device and
the MicroLogixs input terminal.
Module 2 5
The Input/Output System
6 Module 2
The Input/Output System
Module 2 7
The Input/Output System
of inputs will then be connected to the PLCs negative DC termi- PLC Sinking
nal, which is grounded.
Figure 2-14.Sourcing input device wiring for a MicroLogix with a built-in DC power
supply.
8 Module 2
The Input/Output System
V V
Com +V Com +V The previous examples of sourcing input wiring connections
are for two-wire devices. These are devices that have just two
Devices electrical connectionsone that goes to the supply power line
Sourcing
and one that goes to the PLC input terminal. Some PLCs, how-
ever, use three-wire devices (see Figure 2-15). These devices
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 have three electrical connectionsone to the supply power line,
USED USED COM COM
one to the PLC input terminal, and one to the common return
PLC Sinking
line. The connection to the common return line gives the device
Figure 2-15. A MicroLogix with sourcing three-wire input devices. the power to perform its required function when it is not switch-
ing power to the PLC.
Sinking Input Devices. Sinking input devices receive current
V
from the PLC when they are on. Sinking inputs operate just like
Com +V sourcing inputs, but in reverse. Figure 2-16 shows a sinking de-
PLC vice connected to a PLCs input interface. The supply side of the
Current Input input device is connected to the negative DC common line, and
i Interface
the other side of the device is connected to the MicroLogixs
input interface. The interface, in turn, is connected to the posi-
tive DC voltage line. When the device closes, power from the
Sinks Sources positive DC power line flows through the PLCs input terminal,
through the input device, and out to the common line, thereby
Figure 2-16. A sinking input device connected to a PLCs input interface. closing the circuit. Thus, as the PLC sources (provides) current,
the input device sinks (receives) it.
Figure 2-17 shows the wiring of sinking input devices to a Micro-
V V
+V Com +V Com Logix that uses an external DC power supply. The wiring con-
nections here are similar to those for sourcing inputs, except
Devices that the power line connections are reversed. In a sinking con-
Sinking figuration, the input devices are connected to the negative volt-
age line, and the MicroLogixs DC common terminals are con-
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 nected to the positive voltage line.
USEDUSED COM COM
PLC Sourcing
Figure 2-17. Sinking input device wiring to a MicroLogix that uses an external DC
power supply.
Module 2 9
The Input/Output System
it is not switching power to the PLC (see Figure 2-19). PLC Sourcing
Job Aid 2-1, located at the end of this module, provides detailed
Figure 2-18.Sinking input device wiring to a MicroLogix with a built-in DC power
diagrams of two-wire and three-wire sinking/sourcing wiring supply.
configurations.
V V
+V Com +V Com
Devices
Sinking
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
USED USED COM COM
PLC Sourcing
10 Module 2
The Input/Output System
Module 2 11
The Input/Output System
Power Section. After the isolation section, the control signal en-
ters the power section. In this section, the switching mechanism
sends the PLCs control signal to the output device. The control
signal, however, passes through a filter before it actually reaches
the device. This filter eliminates the electrical noise in the power
lines and the electrical noise generated by the output load.
The MicroLogixs output interface also has an LED in its power
section. When this light is ON, it indicates that the interface is 5265 VAC
receiving a control signal from the PLC and switching power to 5125 VDC
the output device. 2 A (max current)
relay
transistor
triac
Each of these outputs is used to communicate with a different
type of output device.
Relay Outputs. Relay outputs (see Figure 2-21) are used in
applications in which the PLCs output devices require a control
signal of either 5265 VAC or 5125 VDC. The maximum current
at each output is 2 A (amps) for both AC and DC devices.
20.426.4 VDC
Transistor Outputs. Transistor outputs (see Figure 2-22) are 24 VDC
1 A (max current)
used only with output devices that require a 20.426.4 VDC
MOSFET
control signal from the PLC. A transistor output is most com-
monly used with 24 VDC devices. A transistors maximum cur-
rent at the output is 1 A. In a MicroLogix 1000, a transistor out-
Figure 2-22. Transistor output.
put is sometimes called a MOSFET, which is an acronym for
metal-oxide semiconductor field effect transistor.
12 Module 2
The Input/Output System
Triac Outputs. Triac outputs (see Figure 2-23) work with out-
put devices that must receive a 85264 VAC control signal. For a
triac, the maximum output current to each device is 0.5 A.
Module 2 13
The Input/Output System
AC IN
VAC VAC
L1 L2/N VDC O/0 VDC O/1 VAC O/2 O/3 VAC O/4 O/5 O/6 O/7 VAC O/8 O/9 O/10 O/11
14 Module 2
The Input/Output System
Module 2 15
The Input/Output System
DC MicroLogix 1000, just as the L1 and L2 lines connect to the
L1 and L2 terminals of the AC model. A DC MicroLogixs power
wiring should also include a disconnect switch located between Figure 2-30. DC source power wiring to a MicroLogix 1000.
the DC power supply and the PLC.
16 Module 2
The Input/Output System
L1 L2/N
VAC VAC VAC VAC VAC
VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5 power supply. This is necessary because the negative terminal
of the built-in power supply is connected to chassis ground and,
VAC 1 thus, cannot be connected to the common line of any other DC
MCR VAC 2 VDC 1 VDC 2 VDC 3 power source.
VAC 1 VAC 2 VDC 1 VDC 2 VDC 3
COM COM COM COM COM
Figure 2-32. DC I/O power distribution wiring for MicroLogix models that provide
a built-in DC power supply. Other supply output voltages are shown
after the MCR.
Module 2 17
The Input/Output System
VAC 1
MCR VAC 2
VAC 2
VAC 1 COM
COM
MCR
+V V
DC Supply
L1 L2
Figure 2-33. DC I/O power distribution wiring for MicroLogix models that use an
external DC power supply. Positive voltage supply to inputs and the
secondary AC supply to outputs are shown after the MCR.
18 Module 2
The Input/Output System
2-5 Review
There are two types of I/O devices: discrete devices and analog devices.
The MicroLogix 1000 is designed to work with discrete devices only.
A discrete signal has only two possible statesON and OFFwhile an analog signal can have an infinite number of
possible states.
There are two types of input interfaces available with the MicroLogix 1000: 120 VAC and 24 VDC.
A 120 VAC input interface has three components: the power section, the isolation section, and the logic section.
Devices can be wired to a 120 VAC input interface either directly or via a terminal block.
A 24 VDC interface can connect with input devices in either a sourcing or sinking configuration.
Sourcing devices provide current when they are on; sinking devices receive current when they are on.
Sourcing and sinking input devices can be either two-wire or three-wire devices.
The MicroLogix 1000s output interface consists of three components: the logic section, the isolation section, and the
power section.
The MicroLogix 1000 can interface with three types of outputs: relay, transistor, and triac.
A MicroLogix 1000 comes with three possible output interface configurations: all-relay, transistor/relay, and triac/relay.
The power wiring for a MicroLogix 1000 depends on whether the controller requires a 120/240 VAC power source or a
24 VDC power source.
AC and DC I/O devices require different power wiring schemes, which depend on whether the devices are being
powered by an internal or external source.
Both AC and DC devices require an MCR in their power wiring circuitry.
Module 2 19
The Input/Output System
Job Aid 2-1:Two-Wire and Three-Wire Sinking and Sourcing Wiring Diagrams
The following examples provide detailed diagrams of both two-wire and three-wire sinking and sourcing input configurations.
Two-Wire Two-Wire
Devices Sourcing V V
V Com +V Com +V
Com Devices
+V Sourcing
Devices
Sourcing
+24 DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
DC OUT COM COM
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
USED USED COM COM
PLC Sinking
PLC Sinking
Three-Wire Three-Wire
V V V
Com Devices Sourcing
Devices +V Com +V
Com
+V Sourcing
Devices
Sourcing
+24 DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
DC OUT COM COM USED USED COM COM
20 Module 2
The Input/Output System
Two-Wire Two-Wire
Devices V V
V +V Com +V Com
Com Sinking
+V
Devices
Sinking
+ 24 DC
DC OUT COM I/0 I/1 I/2 I/3 DC
COM I/4 I/5 I/6 I/7 I/8 I/9 NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
USEDUSED COM COM
Three-Wire Three-Wire
Devices
V V V
Com
Sinking +V Com +V Com
+V
Devices
Sinking
+24 DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
DC OUT COM COM NOT NOT DC I/0 I/1 I/2 I/3 DC
COM
I/4 I/5 I/6 I/7 I/8 I/9
USED USED COM
Module 2 21
The Input/Output System
Bulletin Number Base Unit I/O Count Input Type Output Type Power Supply
Therefore, the example model number shown above (1761-L16BBB) refers to a 16 I/O MicroLogix 1000 with a 24 VDC input
interface. This model has an output interface with both 24 VDC MOSFET (transistor) outputs and relay outputs. It also requires a
24 VDC power source.
Following is a list of the nine different MicroLogix models, along with their specifications:
1761-L16AWA 10 inputs120/240 VAC 6 outputs4 isolated relays/2 shared relays 120 VAC
1761-L32AWA 20 inputs120/240 VAC 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 120 VAC
1761-L16BWA 10 inputs24 VDC 6 outputs4 isolated relays/2 shared relays 120 VAC
1761-L32BWA 20 inputs24 VDC 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 120 VAC
1761-L32BWB 20 inputs24 VDC 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 24 VDC
1761-L16BBB 10 inputs24 VDC 6 outputs2 isolated relays/4 shared transistors (MOSFET) 24 VDC
1761-L32BBB 20 inputs24 VDC 12 outputs2 isolated relays/10 shared transistors (MOSFET) 24 VDC
1761-L32AAA 20 inputs120/240 VAC 12 outputs2 isolated relays/2 shared triacs/4 shared triacs/4 shared triacs 120 VAC
22 Module 2
M O D U L E T H R E E
BASIC So far, you have learned about the components of the MicroLogix 1000
PLC, including the CPU, the memory system, the power supply, and the
input/output system.This module teaches you about the control program
that links all of these components together.
3
RELAY There are five sections:
1. Ladder programming
After finishing this module, you will:
understand the basics of ladder programming and the types of
relay instructions available in the MicroLogix 1000
Ke y Po i n t s know the two types of contact instructions used to program a
MicroLogix 1000, how they operate, and their reference
addresses
know the four basic output instructions commonly used with
the MicroLogix 1000
understand key points concerning the ladder scan evaluation,
the programming of normally closed input devices, and safety
device programming
be able to apply techniques learned from specific programming
examples
B a s i c R e l ay I n s t r u c t i o n s
2 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 3
B a s i c R e l ay I n s t r u c t i o n s
Relay Instructions
Relay instructions form the category of programming instruc-
tions that deals with the simple energizing and de-energizing of
inputs and outputs. Contacts and coils fall into this category.
There are two kinds of relay contact input instructions:
examine-if-closed
examine-if-open
There are four kinds of relay coil output instructions:
simple output
internal output
latch/unlatch output
one-shot rising instructions
Other instructions, in addition to simple relay, are available in
the MicroLogix 1000. These instructions, which include the fol-
lowing, will be discussed in Modules 4 and 5:
timing instructions: timer ON-delay, timer OFF-delay,
and retentive timer
counting instructions: count up, count down, and reset
data-handling instructions: convert-from-BCD, con-
vert-to-BCD, move, and masked move
comparison instructions: equal, masked comparison
for equal, and limit test
flow control instructions: jump, jump to subroutine,
master control reset, temporary end, suspend, imme-
diate input with mask, and immediate output with mask
4 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 5
B a s i c R e l ay I n s t r u c t i o n s
Examine-If-Open Contacts
The examine-if-open contact instruction, also called a nor- Examine-If-Open
mally closed instruction, is represented by the symbol shown in
Figure 3-6. It is abbreviated as XIO. An XIO instruction works XIO
the opposite of an XIC instruction. An XIO contact checks the
status of its reference address for an OFF, or open, condition. If
the reference address is OFF, then the contact remains closed, Figure 3-6. An examine-if open instruction.
providing continuity to the ladder rung.
Figure 3-7 illustrates how an XIO contact instruction works. The
limit switch in this diagram is connected to terminal 1 of the
MicroLogixs input interface, which means that it has an address
of I:0.0/1. The XIO instruction in the ladder diagram references L1 L2
this address. When the limit switch is open (see Figure 3-7a), bit
1 of the input file will contain a 0. When the XIO contact detects LS I/1 I:0.0/1
the 0, the contact will stay in its normally closed condition, re-
(a)
sulting in continuity to the rung. When the limit switch is closed,
the opposite will occur (see Figure 3-7b). The XIO contact will
detect a 1 in the address bit, which will cause the contact to 1
open and break continuity to the rung. 0 Word 0.0
Input File
The RSLogix software can be used to monitor the status of the
contacts in a ladder program. If the software shows a contact as L1 L2
highlighted, then the contact is providing power continuity. If a
contact is unhighlighted, then it is not providing continuity. LS I/1 I:0.0/1
(b)
1
1 Word 0.0
Input File
Figure 3-7. (a) When an XIO instruction detects a 0 in its address bit, it closes,
resulting in continuity to the ladder rung. (b) When an XIO instruction
detects a 1 in its address bit, it opens, breaking continuity in the rung.
6 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 7
B a s i c R e l ay I n s t r u c t i o n s
L U
Latch/Unlatch Output Coils
A latch/unlatch output coil instruction, which is actually
composed of two separate coil instructions, is represented by
Figure 3-11. The latch and unlatch output coil symbols.
the symbols shown in Figure 3-11. These coil instructions are
always used together in a ladder program and always share the
same address.
8 Module 3
B a s i c R e l ay I n s t r u c t i o n s
The function of a latch coil is to turn on and stay on, even if its
input condition turns off. The function of an unlatch coil is to
L1 L2 L1 L2 turn off a latched output. A latch coil instruction is abbreviated
PB1
I: 0.0/0 O: 0/0 O/0 PL as OTL, and an unlatch coil is abbreviated as OTU.
I/0
L Figure 3-12 illustrates a latch/unlatch ladder circuit. When push
LS1 I/1 I: 0.0/1 O: 0/0 button PB1 in the first rung is pressed, the latch output coil will
U turn on, causing pilot light PL to turn on. However, if the push
button is released, the latch output coil and pilot light will re-
0 main on even though the first rung no longer has power conti-
Word 0
nuity. When LS1 closes, the unlatch output coil in the second
Output File rung will be energized. This will change the status of address bit
O:0/0 from a 1 to a 0. As a result, the latch output coil and pilot
Figure 3-12. A latch/unlatch ladder circuit. light will turn off. An unlatch coil instruction is the only way to
turn off a latched output coil. Note that the output cannot be
latched again until the unlatch coil instruction turns off.
Module 3 9
B a s i c R e l ay I n s t r u c t i o n s
LS
I:0.0/3
B3:1/7
(b)
OSR
O:0/3
1 Scan
Figure 3-14. (a) Ladder diagrams showing a one-shot rising instruction, which will
be energized for only one scan even if its input logic remains energized.
(b) The timing diagram for a one-shot rising instruction.
10 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Figure 3-15. The three parts of a PLCs scan: reading the inputs, executing the control 3. updating the outputs
program, and updating the outputs.
Once the PLC reads the status of the input devices, it begins to
execute the ladder control program. It starts its execution at the
top left corner of the ladder program and proceeds from left to
right down the control program until it reaches the end of the
last ladder rung. The PLC evaluates the ladder program once
per scan. After the control program has been executed, the con-
troller updates the status of the outputs according to the results
of the control program.
Module 3 11
B a s i c R e l ay I n s t r u c t i o n s
grammed differently. The first program will require only one O: 0/2 O: 0/3 O/3 PL4
scan to turn on all of the outputs. The second program, how-
ever, will require four scans before all the pilot lights will be on. L1 PB1 L2 L1 L2
O: 0/2 O: 0/3 O/3 PL4
I/0
Programming Normally Closed Devices O: 0/1 O: 0/2 O/2 PL3
When a normally open input device is connected to a PLC, it is (b)
O: 0/0 O: 0/1 O/1 PL2
programmed with an XIC contact instruction for the device to
act like a normally open one in the ladder program. Conse- I: 0.0/0 O: 0/0 O/0 PL1
quently, the contact will energize if the input device closes and
de-energize if the device opens.
Normally closed devices are programmed differently. Instead of Figure 3-16. Ladder programs in which (a) all of the outputs will turn on after one
scan and (b) all of the outputs will be on after four scans.
programming a normally closed device with an XIO contact,
you must program it with an XIC contact instead. This is neces-
sary for the device to function like a normally closed one in the
PLC program. Following are examples of a normally closed de-
vice programmed with XIO and XIC contacts to explain why.
L1 L2
XIO Contact. If an XIO contact is used to program a normally LS PL
closed input device, the ladder diagram will look like Figure
3-17. Logically, this is the way you would expect a normally
closed device to be programmed to function properly in a lad-
der diagram. A closer inspection, however, reveals this to be L1 L2 L1 L2
incorrect. In the figure, the limit switch normally provides a LS I/0 I: 0.0/0 O: 0/0 O/0 PL
voltage signal to the PLC in the same manner as it would in an
electromechanical circuit, meaning that the pilot light should be
on. However, in the PLC program, the XIO contact looks for the
input device to be open, or OFF, in order to provide continuity
Figure 3-17. A normally closed input device programmed with an XIO contact,
to the output. Since the limit switch is closed, the XIO contact
along with its equivalent hardwired circuit.
12 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 13
B a s i c R e l ay I n s t r u c t i o n s
14 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 15
B a s i c R e l ay I n s t r u c t i o n s
Note that, since the motors PLC output coil is still on, the motor
will turn on again as soon as the overload contact recloses (i.e.,
when the thermal overload heater cools off). Consequently, this L1 L2 L1 L2
circuit does not provide low-voltage protection. This can be Stop I: 0.0/0 I: 0.0/1 O: 0/2 O/2 Motor OL
I/0
undesirable and, in fact, dangerous in some applications. For M
instance, someone may be troubleshooting the motor to find
Start
out why it stopped. During this time, the overload contact may I/1 I: 0.0/2
cool off and close again, causing the motor to start up again
without warning.
M I/2
Low-Voltage Protection. To provide low-voltage protection in
this circuit (see Figure 3-23), you must connect the auxiliary
contact from the motor starter as a real input to the PLC at input
Figure 3-23.A star t/stop motor circuit with low-voltage release and low-voltage
terminal 2 (I:0.0/2). Then use an XIC contact to implement the protection.
auxiliary contact in the PLC. This replaces the internal contact
used before. Now the motor is sealed after the start button is
pushed because the auxiliary contact stays on as long as the
motor starters coil is on. Therefore, this circuit still provides
low-voltage release, since the motor will turn off when the over-
load opens. However, it also provides low-voltage protection,
since the auxiliary contact will turn off when the motor starters L1 FWD L2
Stop OL
R2
coil turns off. This means that the motor will stay off even after F
the overload recloses. You must press the start button for the
motor to turn on again. F1
FWD
16 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 17
B a s i c R e l ay I n s t r u c t i o n s
first two triac output terminals, which are terminals 2 and 3. The
PLC will be connected to the L1 and L2 power lines. The input
and output devices will also be connected to the L1 and L2
power lines.
Ladder Programming. Figure 3-26 shows the ladder program
that will implement the forward/reverse motor circuit. The top
two lines of the diagram control the forward motor starter and
forward pilot light. The coils and contacts in the first line turn
on the forward starter. This line starts out with an XIC contact L1 L2 L1 L2
that references the stop push button. The next contact is an XIC Stop I/0 I:0.0/0 I:0.0/1 O:0/1 O:0/0 O/0 OL
contact that maps the forward start push button. The final con- F
ward starter will not turn on while the reverse starter is ener-
gized. When all of these inputs conditions are satisfied, the for- F1 I/2 I:0.0/3 O:0/0 O:0/1 O/1
R
ward starter and the forward pilot light will turn on. When they
REV
turn on, the F1 auxiliary contact mapped to input I:0.0/2 will I:0.0/4 O:0/3 O/3 REV PL
I/3
seal the circuit so that the forward starter remains on even if the
forward push button is released. Pushing the stop push button
R1 I/4
will stop the forward motion of the motor.
The bottom two lines of the ladder diagram control the reverse
starter and pilot light. They operate just like the first two lines
Figure 3-26. Ladder program that implements the forward/reverse circuit.
do. Line three contains contacts referencing the reverse start
push button and the forward motor starter. These are programmed
in series with the stop push button contact located in line one.
When all of these contacts are energized, the reverse motor
starter and pilot light will turn on. The XIC contact in line four
will seal the circuit. Again, pushing the stop button will remove
power to the motor.
Compelling Circuits. In the circuit shown in Figure 3-26, the
forward and reverse starters are interlocked so that one cannot
turn on while the other is operating. However, the way the
18 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Module 3 19
B a s i c R e l ay I n s t r u c t i o n s
3-6 Review
A ladder diagram consists of many rungs formed by contacts and coils.
The ladder rung matrix determines how many branches, contacts, and coils can be used to program a ladder rung.
Power must flow through a ladder rung in a left-to-right direction.
There are two types of contact instructions used to program inputs in a MicroLogix 1000: examine-if-closed (XIC) and
examine-if-open (XIO).
An examine-if-closed contact provides power to the ladder rung when the contacts reference device is closed, or ON.
An examine-if-open contact provides power to the ladder rung when the contacts reference device is open, or OFF.
Four basic output instructions are used with the MicroLogix 1000: the standard output coil, the internal output coil, the
latch/unlatch coil, and the one-shot rising instruction.
A standard output coil is used to energize a real field output device connected to the PLC.
An internal output coil is used to implement interlocking in a ladder program.
Latch/unlatch coils are used to turn an output on and keep it on, even if its input logic turns off.
A one-shot rising instruction is used to turn an output on for one scan.
In ladder scan evaluation, a PLC only evaluates the ladder program once during each scan, and it does so from left to
right and from top to bottom.
When programming a normally closed input device, you must use an examine-if-closed instruction for the device to
behave like a normally closed one in the PLC program.
When programming a safety stop device in a PLC, never use a normally open device programmed with an examine-if-
open contact.
You should approach the programming of all PLC applications the same way: (1) identify the control requirements, (2)
determine which I/O devices will be connected to the PLC, (3) determine which terminals the I/O devices will be
connected to, (4) determine how the I/O devices and PLC will be powered, and (5) develop a ladder program that
implements the required control.
20 Module 3
B a s i c R e l ay I n s t r u c t i o n s
A B C Y
D E
If the reverse condition is not a required part of the outputs logic, then the ladder rung can be reprogrammed as follows to avoid
the reverse power flow condition:
A B C Y
D E
F E
If the reverse condition is a required part of the outputs logic, then the ladder rung can be reprogrammed as follows to avoid the
reverse power flow condition:
A B C Y
A D E
F E
D B C
Module 3 21
M O D U L E F O U R
This module is a fur ther exploration of the MicroLogix 1000s
4
DATA-HANDLING 2. Counting instructions
3. Data-handling instructions
INSTRUCTIONS
Ke y Po i n t s After finishing this module, you will:
understand the three timing instructions used in a MicroLogix
1000timer ON-delay, timer OFF-delay, and retentive timer
as well as the values and special programming issues associated
with each
understand the count up and count down counting instructions
and the reset instruction, including the values and special
programming issues associated with each
know how to use data-handling instructions to move and convert
data in a MicroLogix 1000 PLC
Timing, Counting, and Data-Handling Instructions
2 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 3
Timing, Counting, and Data-Handling Instructions
Word 2 holds the accumulated value. This value indi- T4:0/15 (or T4:0/EN) set when timers input turns ON
T4:0/14 (or T4:0/TT) set when timer is timing
cates how much time has actually elapsed since the T4:0/15 (or T4:0/DN) set when timer has timed out
timer was energized.
Figure 4-4. The data stored in each word of a timers address.
In the RSLogix software, the labels PRE and ACC are used to
denote timer words 1 and 2, respectively. Thus, timer words
T4:0.0, T4:0.1, and T4:0.2 are represented as T4:0, T4:0.PRE, and
T4:0.ACC in the RSLogix software.
4 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 5
Timing, Counting, and Data-Handling Instructions
6 Module 4
Timing, Counting, and Data-Handling Instructions
I:0.0/0 RTO
Retentive Timer Instruction
RETENTIVE TIMER ON EN A retentive timer instruction, pictured in Figure 4-10, oper-
Timer T4:7 ates much like a timer ON-delay instruction. A retentive timer,
Timer Base 1.0 however, can stop timing and then start timing again without its
Preset 10 DN accumulated value resetting to 0.
Accum 0
T4:7/DN O:0/0 Figure 4-11 shows a retentive timer circuit and its timing dia-
gram, which work as follows:
When the input logic turns on, the enable output will
Timer Input 1 turn on, and the timer will start timing.
0
T4:7/EN 1 If the input logic turns off, the enable output will turn
0
off, and the timer will stop timing. The accumulated
T4:7/TT 1 value, however, will not reset to 0.
0
Delay 1 Delay 2 Reset
T4:7/DN 1 When the timer starts timing again, it will pick up where
0
it left off.
Delay 1 + Delay 2 = Total Timer Delay
When the accumulated value finally reaches the pre-
Figure 4-11. A retentive timer circuit and its associated timing diagram. set value, the done output will turn on.
Module 4 7
Timing, Counting, and Data-Handling Instructions
Once a retentive timer has timed out, its done output will re-
main on even if its input logic and enable output turn off. A
reset instruction must be used to turn the done output off and
reset the timers accumulated value. The operation of a reset
instruction is explained in the counter section of this module.
Trapping
Trapping is a special timer programming issue. The electrome- Electromechanical MicroLogix
chanical timers used in hardwired circuits have two kinds of
contacts: TMR
TON/TOF
Timer Coil
time-delayed
Instantaneous TMR
N/A
instantaneous Contacts
T4:XX/DN
The time-delayed contact is used to turn on the output after ON-Delay TMR
the timer has timed out. The instantaneous contact is used to (Energize) Contacts
seal the timers input so that, once the timer has started timing, TMR
T4:XX/DN
OFF-Delay
it will continue to time even if its input logic turns off. This
(De-Energize) Contacts
provides interlocking in the circuit.
Figure 4-12 illustrates how the two types of timer contacts are Figure 4-12. Instantaneous and time-delayed timer contacts as represented in both
represented in an electromechanical diagram. An instantaneous an electromechanical system and a MicroLogix system. The XX in the
contact is represented by a contact symbol, and a time-delayed MicroLogix timer labels symbolizes the timer address.
contact is represented by a timer switch symbol. The symbol for
an ON-delay timers time-delayed contact has an arrow that points
up. This indicates that the contact energizes, or closes, after the
delay following the inputs OFF-to-ON transition. In contrast,
the time-delayed contact for an OFF-delay timer points down,
indicating that it turns off, or opens, after the delay following
the inputs ON-to-OFF transition.
In contrast to electromechanical timers, PLC timers have only
one type of contacta time-delayed contact. This contact must
not be confused with an instantaneous contact when replacing
relay logic. Consequently, you must use trapping to implement
8 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 9
Timing, Counting, and Data-Handling Instructions
float switch and pressure switch turn on, the internal coil will L1 L2 L1 L2
I:0.0/0 I:0.0/1 TON O/0 O:0/0
turn on. Because contact B3:0/0 seals the input, the internal coil FS1 I/0
Timer T4:0 EN
will stay on even if the float switch turns off. Thus, contact Timer Base 1.0
B3:0/0 performs the function of an instantaneous contact. T4:0/EN Preset 10
DN
Accum 0
Rung 2. Rung two actually implements the timer. When the in-
I/1 T4:0/DN O:0/0
ternal output coil in the first rung energizes, the timer will start PS1
to time because its input logic will be satisfied. Once the accu-
mulated value equals the preset value, the timers done output
will turn on because the 10-second delay will be satisfied. Figure 4-15. The timer circuit from Figure 4-13 implemented in a ladder program
using the enable output to trap the timer.
Rung 3. Rung three controls the solenoid output. When the
done output in rung two turns on, the solenoid output will turn
on because its input logic references the done output coil. There-
fore, this PLC circuit implements both the instantaneous and
time-delayed contacts of the hardwired circuit through the use
of internal contacts. T4 L1 L2 L3
after being in low speed, the motor will run at high speed. The CR TMR L High
timer in this circuit ensures that a 10.8-second delay occurs be- T3 T5 T2
Delta (Low)
fore the motor will run in high speed. Thus, if the high push
button is pressed, the motor will first start out at low speed and Figure 4-16. A multispeed motor circuit.
10 Module 4
Timing, Counting, and Data-Handling Instructions
rev up to high speed after 10.8 seconds. Notice that the circuit
uses interlocking motor starter contacts so that the high-speed
starter coil will not turn on until the time delay has occurred.
When this circuit is implemented in a MicroLogix, the stop, low,
and high push buttons will be connected to the PLC as real
inputs. The low (L) and high (H) motor starter contacts will also
be brought in as inputs to provide low-voltage protection. The
low- and high-speed starter coils will be connected as outputs.
The rest of the circuit, including the timer, will be implemented
L1 L2 L1 L2 using programming instructions.
Stop I/0 I:0.0/0 I:0.0/1 T4:0/DN I:0.0/4 O:0/0 O/0 L OLs
The completed PLC program will look like Figure 4-17. The
Low
I/1
B3:0/0 B3:0/0 O/1
H timer trap is implemented using the timers enable output. Inter-
High T4:0/EN nal contact B3:0/0 is used to implement the control relay for the
I/2
I:0.0/3 high-speed starter, which is driven by the high push button. The
L I/3 I:0.0/0 I:0.0/1 I:0.0/3
TON EN
two rungs of this program perform the following functions:
B3:0/0 T4:0
H I/4 DN Rung one controls the low-speed motor starter.
T4:0/EN
I:0.0/2 B3:0/0
Rung two controls the high-speed motor starter and
implements the 10.8-second delay through the use of
B3:0/0 T4:0/DN I:0.0/3 O:0/1
a timer ON-delay instruction.
Rung 1. The first rung of the ladder program controls the low-
Figure 4-17.Multispeed motor ladder program using the timers enable output to
trap the timer. speed starter coil and provides interlocking with the high-speed
starter coil. When the low push button is pressed, the motor will
start at low speed. At the same time, the timer will start timing
and its done output will turn on after 10.8 seconds.
Rung 2. The second rung controls the high-speed starter coil.
The fourth line of this rung turns the low-speed coil on when
the high push button is pressed. It does this using an internal
coil (B3:0/0) that bypasses the activation of the low push button
contact I:0:0/1 in the first rung. Once the high push button has
been pushed and the low-speed coil is on, the top three lines of
the second rung enable the timer, which begins the 10.8-second
Module 4 11
Timing, Counting, and Data-Handling Instructions
time delay. The timer is trapped using the T4:0/EN contact, which
references the enable coil. When the timer times out, its done
output will turn on. This will turn off the low-speed coil by
breaking continuity to it. At the same time, the high-speed starter
coil in line five of rung two will turn on because the done out-
put will be on and the low-speed coil will be off. The high-
speed push button in this rung is trapped on by contact B3:0/0
when the high push button is pushed. Thus, if the high-speed
push button is pressed, the motor will start at low speed and
then change to high speed after a 10.8-second delay.
12 Module 4
Timing, Counting, and Data-Handling Instructions
32 counters C5:0.0
the structure and operation of a MicroLogixs counting
0.1 instructions
0.2
special counter programming issues
C5:31.0
31.1
31.2 General Counter Information
Counter Values. A counter instruction has two values associ-
Figure 4-18. (a) The counter file and (b) its addressing scheme. ated with it:
the preset value
the accumulated value
These values perform the same function as they do in timer
Count Up instructions. The preset value specifies the target number of
Count Down
Done counts, while the accumulated value indicates the actual num-
Overflow ber of counts that have already occurred. In a counter, the pre-
Underflow set and accumulated values always increase or decrease in in-
15 14 13 12 11 crements of one.
C5:0.0 Control
Addressing. Data about a MicroLogix 1000s counters is stored
C5:0.1 Preset in file 5 of the data file section. The counter file can store the
C5:0.2 Accumulated data of up to 32 counters, numbered 0 through 31 (see Figure 4-
18). As with timers, each counter is allotted three words, which
Figure 4-19. The data stored in each word of a counters address.
are numbered 0, 1, and 2. Each of these three words stores
particular data about the counter instruction (see Figure 4-19):
Module 4 13
Timing, Counting, and Data-Handling Instructions
14 Module 4
Timing, Counting, and Data-Handling Instructions
Figure 4-21. A count up circuit in which a limit switch and a solenoid are connected When the switch makes its third OFF-to-ON transition,
to a MicroLogix 1000. the accumulated value will increase to 3 and the done
output will turn on because the accumulated value is
equal to the preset value.
When the done output turns on, the solenoid output
in the second rung will be energized.
In a counter circuit, the counter will continue to count even
after the accumulated value has reached the preset value. The
done output will remain on as long as the accumulated count is
CTD
greater than or equal to the preset count. The only way to reset
COUNT DOWN CD
the accumulated value and turn off the done output is to use a
Counter C5:2
Preset 2 reset instruction, which will be discussed later in this section.
Accum 4 DN
Count Down Instruction
A count down instruction (see Figure 4-22) decreases its ac-
De-Energizes
OFF-to-ON cumulated value by one every time the blocks input makes an
Transition Decreases OFF-to-ON transition. When the accumulated value becomes
by 1
less than the preset value, the count down instruction de-ener-
Figure 4-22. A count down instruction. gizes its output. When the counters accumulated value is greater
than or equal to its preset value, the counters output will be on.
Module 4 15
Timing, Counting, and Data-Handling Instructions
COUNT DOWN CD
a count down output, which indicates that the counter
is energized Counter C5:2
Preset 2
a done output, which signals that the target count value Accum 4 DN
has been reached
Figure 4-23 shows a count down circuit, which works as fol- O:0/0
C5:2/DN
lows:
In this circuit, the count down blocks done output
will already be on because the accumulated value is
greater than the preset value. Figure 4-23. A ladder program containing a count down circuit.
16 Module 4
Timing, Counting, and Data-Handling Instructions
Reset Instruction
A reset instruction is a coil instruction that can reset either a
timing or counting instruction. When a reset instruction is ener-
gized, it sets the accumulated value of its corresponding timer
or counter to 0. It also resets all of the control bits in word 0 of
the timer or counters memory location.
I:0.0/0 CTU The ladder program shown in Figure 4-25 illustrates a reset in-
COUNT UP CU
struction being used to reset a count up instruction. The reset
Counter C5:10
coil shares the count up instructions addressC5:10. The count
Preset 7 up instruction has already counted up to 10, which is several
Accum 10 DN counts past its preset value. Consequently, the counters done
output is on. When the reset coils input is energized, the reset
C5:10/DN O:0/0 instruction will set the up counters accumulated value to 0. At
the same time, it will reset all of the bits in the counters control
word. This will turn the done output off.
I:0.1/1 C5:10
A reset instruction can be used with all types of timing and
RES
counting instructions except a timer OFF-delay instruction. It
CU CD DN OV UN
15 14 13 12 11
cannot be used with a timer OFF-delay instruction because a
reset instruction resets the done, timer timing, and enable bits of
0 0 1 0 0 C5:10.0
the timers control word. If the status of these bits is altered
while a timer OFF-delay instruction is timing, a machine mal-
Figure 4-25. A reset instruction being used to reset a count up instruction.
function could occur.
Module 4 17
Timing, Counting, and Data-Handling Instructions
Figure 4-27. The self-resetting counter circuit after several subsequent scans.
18 Module 4
Timing, Counting, and Data-Handling Instructions
Figure 4-28 shows what will happen after the counters done bit
turns on. When the done output turns on, the reset bit will also
turn on since the done bit provides the input logic to the reset
coil. The reset instruction will reset the accumulated value, as
well as the count up and done bits, to 0 at the end of the scan.
The reset instruction sets the count up bit to 0 (point A), but the
I:0.0/0 input signal has not turned off (point B). This means that in the
CTU
CU
next scan the PLC will sense an OFF-to-ON transition as it com-
COUNT UP pares the input signal to the count up value (point C), even
Counter C5:2 though no transition has occurred. As a result, the PLC will in-
Preset 2 crease the counters accumulated value, despite the fact that no
Accum 1 DN
actual input transition has occurred.
C5:2/DN C5:2
Thus, using a reset instruction to implement a self-resetting
RES
counter will result in an inaccurate accumulated count value. To
B avoid this situation, you can use one of the following program-
1
Input 1 A
ming methods to create a self-resetting counter:
0
0 C
CU (Bit 15) 1 Use a clear instruction instead of a reset instruction to
0
DN 1
set the counters accumulated value to 0.
0
Reset 1 Use a move instruction to move a value of 0 into the
0 accumulated word at the end of the scan.
Scan 1 2 3 4 5 6 7
Use a reset instruction, but with a one-shot rising in-
Figure 4-28. An illustration of what will happen after the count up instructions
accumulated value is reset. struction programmed at the input to the counter. This
one-shot instruction will ensure that the input must
turn off and then on again before the PLC will incre-
ment its count value.
Job Aid 4-1 provides examples of each of these self-resetting
counter programming methods.
Counting Past The Maximum Count Value. A counter
instructions accumulated value has a range from 32,768 to
+32,767. Once a counter reaches a count of +32,767, it cannot
Module 4 19
Timing, Counting, and Data-Handling Instructions
20 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 21
Timing, Counting, and Data-Handling Instructions
22 Module 4
Timing, Counting, and Data-Handling Instructions
MSB LSB faceone connection for each BCD code bit. If more than one
3 2 1 0 input device is used, then each device requires its own four
1 0 1 0 I:0.0 separate input connections.
Figure 4-33. A thumbwheel switch connected to the first four input terminals of a
After the PLC has received the thumbwheel switchs BCD data,
MicroLogix PLC. the data must be stored in the integer file in the correct order of
significance. The ladder program shown in Figure 4-34 performs
this task. Each rung of this program contains an examine-if-
closed instruction that references one of the inputs. Each rung
also contains an internal coil that references a bit in the integer
I:0.0/3 N7:0/0
file, which is where the input data will be transferred. This pro-
gram operates as follows:
I:0.0/2 N7:0/1 MSB LSB The thumbwheels inputs are programmed to transfer
3 2 1 0 their data to the appropriate bit of the integer word to
1 0 1 0 I:0.0 maintain the proper bit significance (i.e., input 3 to bit
I:0.0/1 N7:0/2 0, input 2 to bit 1, input 1 to bit 2, and input 0 to bit 3).
3 2 1 0
0 1 0 1 N7:0
When the MicroLogix receives the BCD code equiva-
N7:0/3 lent to the number 5, the contacts referencing inputs 1
I:0.0/0
and 3 will energize. As a result, the internal outputs
corresponding to integer word bits 0 and 2 will be on.
At the same time, inputs 0 and 2, corresponding to
Figure 4-34. Ladder program used to store the BCD data in the integer file in the internal outputs 1 and 3, will be off.
correct order of significance.
Module 4 23
Timing, Counting, and Data-Handling Instructions
24 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 25
Timing, Counting, and Data-Handling Instructions
26 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 27
Timing, Counting, and Data-Handling Instructions
Figure 4-46. The thumbwheel switchs value changing from 7 to the number 8.
28 Module 4
Timing, Counting, and Data-Handling Instructions
Figure 4-47. A circuit with ladder logic filtering. The third rung contains an examine-if-open instruc-
tion that also references the overflow bit. If the con-
vert-from-BCD instruction has received a valid BCD
code, then the overflow bit will not be on. Accord-
ingly, this rung will energize, moving the converted
BCD value in word N7:1 to word N7:10.
When this type of ladder logic programming is used, the desti-
nation word of the move instruction (in the previous case, word
N7:10) will hold the converted valid BCD value. This destina-
tion word should be used when referencing the converted BCD
number in the ladder program.
Module 4 29
Timing, Counting, and Data-Handling Instructions
4-4 Review
A timer ON-delay instruction energizes its output after its input turns on and a certain amount of time has elapsed.
A timer OFF-delay instruction de-energizes its output after its input turns off and a certain amount of time has elapsed.
A retentive timer instruction works like a timer ON-delay instruction, except that its accumulated value is retained even
if the timers input turns off.
A trapping circuit is used to implement the instantaneous timer contact in a PLC program.
A count up instruction increases its accumulated value by one every time its input makes an OFF-to-ON transition.
A count down instruction decreases its accumulated value by one every time its input makes an OFF-to-ON transition.
A count down instruction is usually used with a count up instruction to form an up/down counter.
A reset instruction is used to reset the accumulated value and control bits of counter instructions, as well as timer ON-
delay and retentive timer instructions.
A reset instruction cannot be used alone (unless some precautions are taken) to create a self-resetting counter circuit
because an incorrect count value will result.
A cascaded counter circuit must be created for a counter to count past its maximum count value.
A high-speed counter instruction must be used to count fast input signals.
BCD input devices require four input terminal connections and four bits of memory, to send their BCD data to the PLC.
BCD output devices require four output terminal connections and four bits of memory, to receive BCD data from a PLC.
A convert-from-BCD instruction takes the BCD value stored in the source word and stores it in the destination word in
binary equivalent form.
A convert-to-BCD instruction takes the binary data stored in the source word and stores it in the destination word in
BCD-equivalent form.
A move instruction moves data from one word location to another without manipulating it.
A masked move instruction moves only the source word data bits indicated by ones in the mask to the destination word.
Ladder logic filtering is a special type of circuit that prevents the PLC control program from halting operation due to an
overflow fault resulting from an invalid BCD value.
30 Module 4
Timing, Counting, and Data-Handling Instructions
Method 1: Use a clear instruction to Method 2: Use a move instruction to Method 3: Use a reset instruction in
set the counters accumulated count move a source value of 0 into the conjunction with a one-shot rising in-
value to 0. counters accumulated word at the struction programmed at the input to
end of the scan. the counter.
Module 4 31
Timing, Counting, and Data-Handling Instructions
To count past the maximum count, you must cascade two counters in a ladder circuit. You cannot try to trick a counter by setting
its preset value to the opposite end of the range because the done bit will not behave properly. For example, you could try to
count to +32,770 by setting a counters preset value to 32,766, since this value is three counts past the maximum limit once the
counter wraps its accumulated value around. However, this will not work for the following reasons:
Once the counter wraps back around to 32,768, its overflow bit will turn on.
When the overflow bit turns on, the counters done output will turn on, even though its accumulated value is less than
its preset value.
At this point, the done bit will stay on until the overflow bit is reset or the counter counts back down to +32,767.
32 Module 4
Timing, Counting, and Data-Handling Instructions
5
+
0 1 0 1
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
USED USED COM COM
To filter and move this BCD data, you could use a masked move instruction to mask out all but the thumbwheel switchs input data
and move it to an integer word location. You could then use a bit shift right instruction to shift the BCD data into the integer words
first four bits before performing a convert-from-BCD instruction.
The next page shows a ladder program that would implement this action in a MicroLogix PLC. This ladder diagram contains a
masked move (MVM) instruction in rung 0 to read the thumbwheel switchs input data (inputs I/2 through I/5). The MVM
instruction uses a hexadecimal mask value of 003C to move only the desired bits into word N7:0. The bits in this word must then
be shifted two positions to the right for the word to contain the correct BCD number in the correct position. The shifting of the two
bits is accomplished in rungs 1 through 5. Rung 6 implements a BCD-to-decimal conversion.
Module 4 33
Timing, Counting, and Data-Handling Instructions
Read Data
Input Signal
I:0.0/9 TON
MVM
0 MASKED MOVE
Source I:0.0
Mask 003C
Dest N7:0
Shift Command
B3:0/2 TON
FRD
TON
BSR
3 BIT SHIFT RIGHT EN 6 FROM BCD
File N7:0 Source N7:0
Control R6:0 DN Dest N7:1
Bit Address N7:0/15
Length 6 Processor
Arithmetic
Underflow/ Overflow
TON
CTU OverflowFlag Trap
S2:0/1 S2:5/0
COUNT UP CU
Counter C5:0 U
Preset 2 DN
Accum 0
Processor
Arithmetic
Underflow/
Read Data Not Overflow Flag
Shifted 2 Times Input Signal Shifted 2 Times S2:0/1 TON
MOV
C5:0/DN I:0.0/9 Q2:99 MOVE
4 JMP Source N7:1
Dest N7:10
Finished 2 Shifts
Shifted 2 Times Reset Counter
C5:0/DN C5:0 7 END
5
34 Module 4
Timing, Counting, and Data-Handling Instructions
Module 4 35
M O D U L E F I V E
5
program. This module contains four sections:
1. Comparison instructions
After finishing this module, you will:
understand the different comparison instructions available in
Ke y Po i n t s the MicroLogix 1000including equal, masked comparison for
equal, and the limit test instructions
know the flow control instructions that alter the sequence of
program executionincluding the jump, jump to subroutine, and
master control reset instructions
understand temporary end and suspend flow control instructions,
which halt the execution of the control program
grasp the two flow control instructions that alter the I/O scan
the immediate input with mask instruction and the immediate
output with mask instruction
Comparison and Flow Control Instructions
Equal Instruction
The equal instruction is a block instruction that looks like the
one shown in Figure 5-1. This instruction compares the data
values specified by the source A and source B parameters. If
these data values are equal, then the equal blocks output will
energize, providing continuity to the rest of the rung. EQU
The value specified by source A must be a word location in EQUAL
Source A Word
memory (see Figure 5-2). This word location may specify the
accumulated value for a timer or counter, the contents of an Source B Word
or
integer file word, or any other data stored in memory. The value Constant
specified by source B may be either a word location or a con-
stant. If source B contains a word location, then it specifies the Figure 5-2. In an equal instruction, the value specified by source A must be a word
location of particular data in memory, just as the source A pa- location.The value specified by source B may be either a word location
rameter does. If source B is a constant, then this parameter con- or a constant.
tains a fixed decimal value to which the instruction compares
the source A data.
2 Module 5
Comparison and Flow Control Instructions
Module 5 3
Comparison and Flow Control Instructions
4 Module 5
Comparison and Flow Control Instructions
Module 5 5
Comparison and Flow Control Instructions
parison is true, the output will turn on. If you used the decimal MEQ
value 5, it would generate the wrong binary comparison value Source N7:0 O:0/0
(0101 located in bits 0 through 3). Thus, the MEQ instruction Mask 00F0
would not work correctly because the masked source value would Compare 80
not be identical to the compare value.
5 3
TWS #2 TWS #1
Limit Test Instruction
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 N7:0
A limit test instruction, which is abbreviated as LIM, checks a
value to see whether it is within a certain range (see Figure 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 Mask 00F0
5-10). It compares the test value to the low and high limit val-
ues. If the test value is between the high and low values or 0 1 0 1
equal to them, the blocks output energizes or de-energizes ac- 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 Compare 80 10
cording to how the high and low parameters are defined.
Figure 5-9. A ladder program in which output O:0/0 turns on when the pressure
In a limit test instruction, the test value can be either a constant volume level is 5.
or a word (see Figure 5-11). If the test value is a constant, the
low and high limit values must be words. If the test value is a
word, then the low and high limits can be either words or con-
stants. The function of a limit test instruction depends on which LIM
is greater, the high limit value or the low limit value:
LIMIT TEST
If the high limit is greater than the low limit, the blocks Low Lim 0
output will be on if the test value is between the two Test N7:1
limits. The blocks output will be off if the test value is High Lim 100
lower than the low limit or greater than the high limit.
Figure 5-10. A limit test instruction.
If the low limit is greater than the high limit, the blocks
output will be off if the test value is between the two
limits. The blocks output will be on if the test value is
greater than the low limit or lower than the high limit.
LIM LIM
This high and low limit information is important to remember, LIMIT TEST LIMIT TEST
especially when using word addresses for the high and low Low Lim Word Low Lim Word or Constant
Test Constant Test Word
limit values. In this situation, the output continuity of the limit High Lim Word High Lim Word or Constant
test block may reverse if the contents of the high and low limit
words change. Figure 5-11. In a limit test instruction, the test value can be either a constant or a word.
6 Module 5
Comparison and Flow Control Instructions
Module 5 7
Comparison and Flow Control Instructions
Jump Instruction
A jump instruction (see Figure 5-13) is a coil instruction that
jumps the PLCs program execution to a specified rung, thereby
skipping those rungs programmed between the jump instruc-
tion and the destination rung. Because it does not reference a I:0.0/0 10
particular memory location, a jump instruction can have any JMP
numerical address between 0 and 999. A jump coil instruction I:0.0/1 O:0/0
works in conjunction with a label contact instruction, which
specifies which rung to jump to.
I:0.0/2 O:0/1
Figure 5-14 illustrates how a jump instruction works. In this
program, the output of the first rung is a jump coil with address
10. The fourth rung begins with a label contact that shares the 10 I:0.1/0 I:0.1/1 O:0/5
jump coils address. If input I:0.0/0 is true, jump coil 10 will be LBL
energized. This will cause the MicroLogix to jump to the rung
containing the label instruction with address 10 and resume pro-
gram execution from there. Thus, the jump instruction causes Figure 5-14. A ladder program containing a jump instruction.
the PLC to skip the execution of rungs two and three. If the
jump instruction is not energized, then the PLC will evaluate all
the rungs of the ladder program as it would normally.
8 Module 5
Comparison and Flow Control Instructions
Module 5 9
Comparison and Flow Control Instructions
10 Module 5
Comparison and Flow Control Instructions
Module 5 11
Comparison and Flow Control Instructions
meaning that the subroutine calls can be eight levels deep. The
controller will generate a subroutine stack overflow error if more
than eight subroutines are nested in a program. Conversely, the
controller will generate a subroutine stack underflow error if
the program contains more return instructions than jump to sub-
routine instructions. Note that you can only nest three levels of
subroutines if you are using the selectable timed interrupt and
high-speed counter files to store additional subroutines.
To use subroutines to implement the manual/automatic selector
switch program discussed earlier, you would use a rung con- Man Auto
L1 L2 I:0.0/0
taining two jump to subroutine instructions (see Figure 5-20). JSR
The first JSR instruction references subroutine 6, which stores I/0 JUMP TO SUBROUTINE
the manual control program. The second JSR instruction refer- OFF (Manual) SBR File Number 6
ences subroutine 7, which stores the automatic control program. ON (Auto) I:0.0/0 JSR
Thus, in this control program, when the selector switch is off, JUMP TO SUBROUTINE
the controller will jump to the manual subroutine and execute SBR File Number 7
it. When the selector switch is on, the controller will jump to the
automatic subroutine and execute it instead.
A jump to subroutine instruction can reduce the program scan Figure 5-20. Jump to subroutine instructions used to control the manual or automatic
operation of a machine.
time just as a jump instruction can, since it avoids the unneces-
sary evaluation of certain parts of the program. A jump to sub-
routine instruction can also simplify the main ladder program
by allowing complex routines to be performed outside the main
program. Moreover, subroutines can be used to program tasks
that occur many times in the main ladder program. A lookup
table routine is a good example of this kind of task. By using
jump to subroutine instructions to go to the subroutine for this
repetitive task, you can avoid having to program the task over
and over again in the main control program.
12 Module 5
Comparison and Flow Control Instructions
Module 5 13
Comparison and Flow Control Instructions
The circuit in Figure 5-22 works much the same way if the tim-
ers start timing and then the MCR fence turns off before either MCR
timer has timed out. In this situation, the timers will start timing TON
when the first MCR instruction turns on. However, when the TIMER ON-DELAY EN
Timer T4:0 DN
MCR turns off, the timers will turn off too, even though their Time Base 1.0
inputs may still be on. As a result, the accumulated value of the Preset 10
Accum 0 MCR
ON-delay timer will be reset to 0. The retentive timer, however,
Fence
will retain its accumulated value. To reset the retentive timers RTO
RETENTIVE TIMER ON EN
accumulated value, you would need to add a reset instruction
Timer T4:1 DN
outside of the MCR fence (see Figure 5-23). If this reset instruc- Time Base 1.0
tion was located inside the fence, it could only reset the reten- Preset 10
Accum 5
tive timer when the MCR zone was activated.
MCR
When using MCR instructions, you should never use a jump T4:1
instruction to jump inside an MCR zone. If you do, the logic you RES
jump to inside the MCR fence will be evaluated, regardless of
whether the MCR is on. This can cause a hazardous situation.
Figure 5-23. A ladder program with two fenced timers that uses a reset instruction
Also, you should be aware that although nesting is permitted to reset the RTO instruction.
with subroutines, it is not allowed with MCR zones.
14 Module 5
Comparison and Flow Control Instructions
Module 5 15
Comparison and Flow Control Instructions
16 Module 5
Comparison and Flow Control Instructions
Module 5 17
Comparison and Flow Control Instructions
Then it performs a mask to filter out all but the input Stored to
word I:0.0
bits specified.
Figure 5-32. The operation of an immediate input with mask instruction.
18 Module 5
Comparison and Flow Control Instructions
Module 5 19
Comparison and Flow Control Instructions
Figure 5-36. An immediate output with mask instruction used to update the status
of two pilot lights.
20 Module 5
Comparison and Flow Control Instructions
5-5 Review
An equal instruction compares two values to see if they are equal to each other.
Other basic comparison instructions (not equal, less than, less than or equal, greater than, and greater than or equal) also
compare two values, but they each test for a different comparison condition.
The masked comparison for equal instruction uses a mask value to compare part of the data in the source location to a
comparison value.
A limit test instruction checks to see if a test value falls within a certain range of values.
A jump instruction causes a controller to jump over the execution of a certain set of ladder rungs.
A jump to subroutine instruction causes the controller to stop executing the main control program and start executing a
subroutine program.
A master control reset instruction forms a conditional fence around a set of ladder rungs.
A temporary end instruction stops program execution before the end of the whole ladder program.
A suspend instruction halts program execution and turns off the outputs while maintaining the status file data.
An immediate input with mask instruction forces the PLC to halt program execution and immediately update the status of
the input devices.
An immediate output with mask instruction forces the PLC to halt program execution and immediately update the status
of the output devices.
Module 5 21