You are on page 1of 122

M O D U L E O N E

ARCHITECTURE To understand the Allen-Bradley MicroLogix 1000, you need to start


with the basics. This first module explains the basic operation of
programmable controllers and details the specific features of the
MicroLogix 1000 PLC.
AND This first module is broken up into four sections:
1. MicroLogix 1000 basic principles of operation

1
OPERATION 2. MicroLogix specifications
3. I/O structure and memory system
4. Addressing notation


After finishing this module, you will:

Ke y Po i n t s understand the basic operating principles of the MicroLogix


how it works, what the components are, and what the
components do
know the three basic specifications for the MicroLogix 1000
how the program is written, how data is represented in the
system, and what configurations are available
grasp the MicroLogixs intricate memory systemhow the
I/O is set up, what makes up the memory system, and how the
memory system is organized
understand the unique MicroLogix addressing notation
A rc h i t e c t u r e a n d O p e r a t i o n

1-1 MicroLogix 1000 Basic Principles of Operation


The MicroLogix 1000 programmable logic controller may ap-
pear to be like any other PLC, but it has special features, speci-
fications, and capabilities that make it a unique tool for imple-
menting process or machine control. The MicroLogix 1000 fol-
lows many of the same basic principles of operation that all
PLCs follow. At the end of this section, you will know:
what PLCs do
Measures
why PLCs are invaluable to industrial facilities
what makes up a PLC
how a PLC operates Inputs
Process
MicroLogix or
1000 Machine
PLC Fundamentals Outputs
A MicroLogix 1000 is a programmable logic controlleran
industrial computer that controls a machine or process. A PLC Control
interfaces with the field input and output devices that are part of
a control application. Then, through the control program stored Figure 1-1. PLC operation.
in its memory, the PLC uses the data supplied by the input
devices to manipulate or control the output devices. The overall
PLC process, which is shown in Figure 1-1, is very simple. A
PLC measures or senses signals coming from a machine or pro-
cess. Then, through its internal program, the PLC provides con-
trol back to the machine or process.
Programmable logic controllers provide many benefits over tra-
ditional electromechanical control systems. One of the best ben-
efits is that PLCs make it easier and less costly to change a
control system. They eliminate the need to rewire the input and
output devices if the control requirements change. If the control
requirements for a PLC application change, all you need to do is

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

change the control program. Another benefit of PLCs is that


PLC
they are more powerful and more accurate than electromechani-
cal systems.
I O
n
u PLC Components
t
p
CPU p
A PLC is made up of two basic components (see Figure 1-2):
u
u the input/output (I/O) system
t
t
s
s the central processing unit (CPU)
The input/output system is the part of the PLC that physically
connects to devices in the outside world. The central process-
I/O System
ing unit, on the other hand, is where the PLC stores all of its
data and does all of its computer processing. Each of the com-
Figure 1-2. A PLC and its components: the central processing unit (CPU) and the ponents of a PLC has specific functions.
input/output (I/O) system.
Input/Output System. The input/output system is made up of
two components, the input interface and the output interface
(see Figure 1-3).
An input interface is a bank of terminals that physically con-
nects input devices, like push buttons and limit switches, to a
PLC. These input devices provide data to the PLC. The role of
O an input interface is to translate data from the inputs into a form
I u
n t that the PLCs central processing unit can understand.
p p
u To PLC From PLC
u
M
An output interface is a bank of terminals that physically con-
t t
s s nects output devices, such as solenoids and motor starters, to a
PLC. These output devices receive control data from a PLC. The
(a) (b) role of an output interface is to translate data from the PLCs
CPU into a form that the output devices can understand.
Figure 1-3. (a) A PLCs input interface interprets the data from the input devices
and then sends it to the CPU. (b) A PLCs output interface interprets To put it simply, the I/O system communicates information from
the data from the CPU and sends it to the output devices. the input devices to the CPU. It also communicates data from
the CPU to the output devices.

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

CPU. The CPU is made up of three parts (see Figure 1-4):


the memory system
Processor
the processor
the power supply
The memory system stores the PLCs control program, as well
as the data received from and sent to the I/O system. It also
Memory Power
keeps track of which I/O devices are connected to which I/O System Supply
interfaces. The processor is the computerized part of the CPU
that performs the control program. It manipulates the data stored
in the memory system and determines what control output should Figure 1-4. A CPU with its three componentsthe processor, the memory system,
occur based on the given input conditions. The power supply and the power supply.
provides power to both the memory system and processor so
that they have power and so that they work properly.

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

1-2 MicroLogix Specifications


L1 PL L2
LS
The MicroLogix 1000 PLC is a powerful microprogrammable
controller capable of implementing all kinds of control func-
tions. Although the MicroLogix 1000 follows the basic PLC prin-
ciples of operation, it does have many unique functions and
PB
specifications. This section will discuss some of these specifica-
tions. At the end of this section, you will know:
what the control program is and how it is represented
in the MicroLogix 1000 Electromechanical
Diagram
what number systems are used by the MicroLogix 1000
to represent data Figure 1-8. A hardwired circuit where either a limit switch or a push button can
turn on a pilot light.
how the MicroLogix 1000 is configured

Control Program Notation


A control application can be implemented using either the tradi-
tional hardwired method or the PLC softwired method. In the
traditional hardwired method, the input and output devices are
wired directly to each other. The sequence of operation, which
LS LS PL PL
is the logic behind the system, is determined by the way the
devices are physically connected (see Figure 1-8).
In the PLC softwired method, the input and output devices are PB
wired to the PLCs input and output interface terminalsnot to PB
each other (see Figure 1-9). The control program, which resides
in the PLCs memory, provides the connections between the
devices. So instead of being hardwired, the devices are soft-
Figure 1-9. The circuit in Figure 1-8 implemented in a PLC via input/output
wired to each other. The MicroLogix 1000s softwired control
connections.
program is represented through ladder diagram notation.

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

Ladder diagram notation has a particular format, as shown in


Figure 1-10. The left side of a ladder circuit shows the input
devices wired to the input terminals, which are represented by
rectangles. The right side shows the output devices wired to the
output terminals, which are represented by diamonds. The middle
part is the ladder diagram logic that connects the inputs and the
outputs together.
The logic performed within a ladder program works just like its
Ladder equivalent electromechanical circuit would. However, a ladder
Control program represents its inputs by a contact rather than by a de-
Inputs Program Outputs
vice symbol. Likewise, it represents its outputs by a coil instead
of by a device symbol. The PLC uses an addressing scheme in
the ladder program to keep track of all its inputs and outputs,
including which contacts and coils reference them. The last sec-
tion of this module explains this addressing scheme.
The use of a MicroLogix PLC has many benefits over a tradi-
tional electromechanical application. The first is flexibility. In a
Figure 1-10. An example of ladder diagram notation. hardwired, or traditional, system, the devices must be physically
rewired if the control requirements change. This takes time and
money. However, in a PLC system, no rewiring is necessary. All
changes are made to the PLCs ladder program instead. This
process is much quicker and less costly than rewiring. The sec-
ond benefit is reliability. The MicroLogix 1000 PLC is solid-state
and has no moving parts, which makes it very dependable.

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.

Decimal. The MicroLogix 1000 uses the decimal number sys-


tem to represent the address data of inputs and outputs, as well
as contacts, coils, timers, counters, and other internal instruc-
tions. The decimal number system uses ten numbers, 0 through
9, to represent data.
The addresses represented by decimal numbers identify which
contacts and coils refer to which input and output devices. An
address tells the PLC specifically which I/O device is wired to

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

Figure 1-17. The inputs and outputs available in a MicroLogix 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

1-3 I/O Structure and Memory System L1 L2 L1 L2


C L1
This section covers the I/O structure and the memory system of Input Output
00 00
the MicroLogix 1000. Both are very important aspects of the 02 03
01 01
PLC. At the end of this section, you will know: LS1
02 02 PL
how the I/O system is structured 03 03

what makes up the MicroLogix 1000 memory system


how the memory system is organized
1 1
09 08 07 0605 04 03 02 01 00 05 04 03 02 01 00
I/O Structure Inputs Outputs
A MicroLogixs I/O structure is directly related to the way its
memory system is organized. Each input is connected to a sepa- Figure 1-18.The limit switch is connected to the input terminal with address 2.
rate input terminal that has a unique address in the PLC. Also, Thus, its status is stored in input address 2 in memory. Likewise, the
pilot light is connected to the output terminal with address 3 and has
each output is connected to a separate output terminal that has this same address in memory.
a unique terminal and memory address. Figure 1-18 shows an
example of addressed inputs and outputs connected to the ter-
minals of a MicroLogix PLC.

Memory System
The memory system of a MicroLogix 1000 consists of four units File
(see Figure 1-19): Section

file sections File


files
Word
words
bits
File sections are the largest unit of memory. They specify where Bit
major categories of data are stored. The MicroLogixs memory
contains two file sections, the program file section and the data Figure 1-19. The four units used in a MicroLogixs memory system.

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

file section. Each file section is made up of a particular number


Program of files. Files are areas in the MicroLogixs memory where a
File specific type of data, like input data, is stored. Each file consists
Section of a certain number of words. Words are groups of memory
locations that store pieces of data. Each word can hold up to 16
pieces of data, and each piece of data is called a bit. A bit is a
binary digit that comprises the smallest unit of memory. A bit
Data File
holds only one piece of information, either a 1 or a 0.
Section
The MicroLogixs memory system is organized into file sections,
files, words, and bits in order to store all of the information that
the PLC needs to operate. This information includes the control
Figure 1-20. The two file sections of a MicroLogix 1000s memory system.
program, input and output status data, internal data, and routine
functioning data. The MicroLogixs memory system has a lot of
information to keep track of, so it needs a well-structured orga-
nization in order to do that.
As mentioned previously, the MicroLogixs memory contains two
Program File Section file sectionsthe program file section and the data file sec-
0 Executive tion (see Figure 1-20). Each of these file sections stores a differ-
1 ent kind of information.
2 Main Ladder Program
3 User Error Fault Routine Program File Section. The program file section stores all the
4 HighSpeed Counter Interrupt data a MicroLogix needs to operate. This includes data about
5 Selectable Timed Interrupt the processor, the main control program, and any subroutines.
6 Figure 1-21 shows a map of the MicroLogixs program section.
7
8 The program section consists of 16 files numbered 0 through 15.
9
Subroutine Ladder They store information as follows:
10
Programs Files 0 and 1 contain the executive software of the
11
12 MicroLogix 1000. This software is responsible for con-
13 trolling all of the functions of the PLC and keeping
14 track of what is happening while the PLC is operating.
15
These files also contain data about the processor, in-
cluding type, configuration, and passwords access.
Figure 1-21. The program file section of the MicroLogix 1000.

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

File 2 holds the main ladder program that is entered


into the PLCs memory. This ladder program controls
the machine or process.
File 3 stores an error fault routine that is executed when
a recoverable, or fixable, fault occurs in the PLCs con-
trol program. When this routine is executed, the
MicroLogix corrects the problem to get the system up
and running again.
Data File Section
File 4 stores the high-speed counter interrupt program 0 Outputs
that is executed when a high-speed counter instruc-
1 Inputs
tion causes an interruption in the control program.
2 Status
File 5 contains the selectable timed interrupt program,
which is used to interrupt the normal program scan so 3 Binary
that a subroutine can be executed immediately. 4 Timers
Files 615 store the subroutine ladder programs that 5 Counters
are called by the main ladder control program. This
area can store up to ten subroutines. Files 4 and 5 can 6 Control
be used to store additional subroutines, if necessary. 7 Integer

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

the MicroLogixs inputs is mapped to a specific bit in


the input file. The input file is different from the out-
put file because it contains two words to account for
all of the possible input devices that can be connected
to a 32 I/O MicroLogix.
File 2 is the status file. It stores information about how
the PLC is operating and how it is set up. This file
contains 33 words that hold three types of data: basic
0 Outputs status data, dynamic configuration data, and static con-
Inputs
figuration data (see Figure 1-23).
1
2 Status Status File 3 is the binary, or bit, file. It stores data about the
operation status of internal coils and contacts. The binary file
3
contains 32 words. Because the binary file stores data
Dynamic configuration
4 about internal instructions, its bits do not map real
Static configuration field devices, as the bits in the input and output
5
off-line settings files do.
6
7 File 4 is the timer file. It contains data about the timers
used in the control program. It includes data about
each timers status, preset value, and accumulated value.
Figure 1-23. The contents of a MicroLogix 1000s status file.
The MicroLogix can use up to 40 timers in its control
program, and it dedicates one word to each of the
three pieces of information it stores about each timer.
So, in essence, the timer file has 120 words, three for
each of its 40 timers.
File 5 is the counter file. It stores data about the 32
counters available in the MicroLogix 1000. It stores
three pieces of data about each counter: the counters
status, preset value, and accumulated value. Each piece
of counter data is stored in its own word. So, in es-
sence, this file has 96 words, three words for each of
the 32 counters.

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

File 6 is the control file. It stores information used by


specialized PLC instructions, like shift and sequencer
instructions. This file can hold data for 16 instructions.
It uses three words for each instruction. Therefore,
this file can contain up to 48 words.
File 7 is the integer file. This file stores miscellaneous
numerical data, such as constant and variable data,
binary codes, and mask patterns. The integer file uses
105 words to store all of this information.
Job Aid 1-1 at the end of this module provides an overview of
the program and data file sections of the MicroLogix 1000s
memory system.

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

1-4 Addressing Notation


The concept of addressing is very important in a PLC. This is
how the PLC keeps track of all of its data. At the end of this
section, you will understand:
the mnemonics of the MicroLogix 1000 addressing
notation
the unique addressing of timers, counters, control files,
and input files
the addressing concepts used for specific situations
O Outputs
I Inputs Addressing Mnemonics
S2 Status Every bit in every file of the MicroLogixs data section has a
B3 Binary unique address. This address allows the MicroLogix to keep
T4 Timers track of all its data. The MicroLogixs addressing code has its
own language, or mnemonics, which is used to express an ad-
C5 Counters
dress. This addressing code gives the PLC all of the information
R6 Control it needs to find any piece of data stored anywhere in the PLCs
N7 Integer memory. Each address has three parts:
the file label
Figure 1-24. The letter codes used for each file in the data file section.
the word label
the bit label
The first part of a MicroLogixs address is the file label. This
label tells the PLC which file the data is stored in. A letter or a
letter/number combination is used to denote each file. Figure
1-24 lists the letter codes used for each file in the data section.
The word label is the next part of the address. It lets the PLC
know which word in the file the data is located in. The last part
of the address is the bit label. This label tells the PLC which bit
of the word the data is in.

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

Additionally, the MicroLogix 1000 uses delimiters to separate N7:6/14


the different parts of an address. A colon (:) is used to separate
the file label and the word label. A slash (/) is used to separate File
the word label and the bit label. Figure 1-25 shows an example Word
of the MicroLogix 1000s addressing notation. Bit

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

(O:0). Finally, the pilot light is connected to terminal 4, so it will


be mapped to bit 4 of output word 0 (O:0/4). Therefore, the
Micro Logix pilot light will have the address O:0/4.
1000
Example 2Counter. Figure 1-29 shows the address used to
check the data value stored in bit 8 of counter 7s accumulated
value. The MicroLogix stores the accumulated value for a counter
in the last word of the three words associated with the counter.
The first part of the address (C5:) indicates that the data is stored
O:0/4 in the counter file, since it is counter data. The second part of
the address indicates that the accumulated value for counter 7 is
Figure 1-28. Output device address. stored in word 2 (C5:7.2). The data value specified is located in
bit 8, so this data has the address C5:7.2/8.
Example 3Input Device. Figure 1-30 shows the memory map
Counter 7 for a push button connected to the last input terminal, input 19,
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 of a 32 I/O MicroLogix. A push button is an input, so this devices
Word 0 address will start with an I and a colon (I:). The push button is
Word 1 connected to the last input terminal, terminal 19. Since a word
Word 2 has only 16 bits, this inputs address must be located in the
C5:7.2/8 second word (I:0.1). Specifically, this input devices status is
stored in bit 3 of the second word of the 32 I/O MicroLogix;
Figure 1-29. Counter file address. therefore, its address is I:0.1/3.

Entering Address Data


When working with a MicroLogix 1000, address and other pro-
Input File gram data can be entered in one of two wayswith a handheld
First 16
Inputs 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 programming device or with a personal computer equipped with
Word 0.0 the RSLogix software. Each of these addressing methods uses its
Word 0.1 own addressing notation. The addressing notation shown in the
I:0.1/3 video and in this book is the basic one used by the RSLogix
Last 4 software. Job Aid 1-2 at the end of this module shows the differ-
Input 19 inputs
ences between the RSLogix and handheld programmer address-
(20th input) ing notations. Job Aid 1-3 shows some special addressing nota-
Figure 1-30. Input file address. tions you may encounter when using the RSLogix software.

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

1-6 Job Aids

Job Aid 1-1: MicroLogix 1000 Memory Structure

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

FILE FILE FILE NUMBER AVAILABLE


# NAME LABEL FUNCTION OF WORD ADDRESSES
0 Outputs O Contains data about the status of each output device connected to the 1 0:0
output terminals.
1 Inputs I Contains data about the status of each input device connected to the input 2 I:0.0
terminals. I:0.1
Stores information about how the PLC is operating and how it is set up. S2:0
2 Status S2 33


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

This same address is shown as follows on a handheld programming screen:

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):

Bit Address Format: Bit Address Format:


m
Single Line m Split Line m Single Line m Split Line

Binary Bit Display Mode: Binary Bit Display Mode:


m
/Bit m Word/Bit I:0.1/2 m
/Bit m Word/Bit I:0.1

I/O Bit Display Mode: I/O Bit Display Mode:


m Slot/Bit m
Slot.Word/Bit m Slot/Bit m
Slot.Word/Bit 2
Short Address: Short Address:
q Display q Entry q Display q Entry

Bit Address Format: Bit Address Format:


m
Single Line m Split Line m Single Line m Split Line

Binary Bit Display Mode: Binary Bit Display Mode:


I:0/18 I:0
m
/Bit m Word/Bit m
/Bit m Word/Bit
I/O Bit Display Mode: I/O Bit Display Mode:
m m Slot.Word/Bit 18
Slot/Bit m Slot/Bit m Slot.Word/Bit
Short Address: Short Address:
q Display q Entry q Display q Entry

Bit Address Format: Bit Address Format:


m
Single Line m Split Line m Single Line m Split Line

Binary Bit Display Mode: Binary Bit Display Mode:


m /Bit m Word/Bit I0.1/2 m /Bit m Word/Bit I0.1

I/O Bit Display Mode: I/O Bit Display Mode:


m Slot/Bit m Slot.Word/Bit m Slot/Bit m Slot.Word/Bit 2

Short Address: Short Address:


Display q Entry
q Display q Entry
q

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

2-1 Types of Input/Output Devices


A MicroLogix 1000 PLC uses its input and output interfaces to ON
1
connect with field input/output devices. To review, all input
devices provide a signal to the PLC, and all output devices re-
ceive a signal from the PLC. All I/O devices, however, do not LS
send and receive the same type of signal. There are two differ-
ent types of I/O signals and two types of I/O devices that use
them. The two types of I/O devices are discrete devices and
analog devices. Discrete OFF
0
At the end of this section, you will know:
the difference between the two types of I/O devices Figure 2-1. A limit switch sends a discrete digital signal to a PLC.

which type works with the MicroLogix 1000

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

2-2 Input Interfaces


A MicroLogix 1000 uses input interfaces to connect with dis-
crete input devices. These interfaces contain all of the circuitry
needed to allow the field input devices to communicate their
status to the PLC.
The previous module explained that there are two versions of
the MicroLogix 1000 PLC: a 16 I/O version and a 32 I/O version.
The 16 I/O version has 10 input terminals, while the 32 I/O
version has 20 input terminals.
All discrete input devices send an ON/OFF electrical signal to a 120 VAC Low-Level
Signal 120 VAC DC Signal
programmable controller; however, not all discrete inputs send
the same type of electrical signal. The two most common types Input To
Processor
of discrete signals are 120-volt AC and 24-volt DC signals. Ac- Interface
cordingly, there are two input interface configurations available
in the MicroLogix 1000: 120-volts AC and 24-volts DC.
At the end of this section, you will understand:
Figure 2-5. A 120 VAC input interface converts a 120 VAC signal into a low-level
the 120 VAC and 24 VDC input interface configurations DC signal.

the functional differences between the two types of


input interfaces
the wiring requirements of each input interface

120-Volt AC Input Interfaces


Three models of the MicroLogix 1000 come with a 120-volt AC
input interface, which converts the 120 VAC signal from the
input devices into a low-level DC signal that the PLCs processor
can read (see Figure 2-5). To understand this conversion, you
need to be familiar with the interfaces components and wiring.

4 Module 2
The Input/Output System

Components. The 120 VAC input interface of a MicroLogix 1000


has three components (see Figure 2-6):
the power section
the isolation section
the logic section
Power Section. The power section receives the input signal
from the field device and converts it into a low-level DC signal
using a bridge rectifier circuit. It then passes the signal through
Power Isolation Logic a filter to eliminate noise and bouncing. Finally, it uses a thresh-
old detection circuit to check that the signal is valid.
Input To
Signal Processor Isolation Section. After the signal is converted by the power
section, it goes through the isolation section. This section uses
Noise
Bridge and
Threshold
Level Logic
an optical coupler to electrically isolate the power and logic
Rectifier Debounce Isolator
Filter
Detection sections. This prevents high-voltage spikes in the I/O signal from
reaching the PLC and damaging it.

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

Wiring. To grasp the wiring requirements of the MicroLogix


1000s 120 VAC input interface, you must understand the three
types of wiring associated with it. These are:
the PLC wiring 120 VAC line
L1
the device wiring
the common (or return) wiring
Micro Logix
PLC Wiring. The MicroLogix has built-in input interfaces in both 1000

the 16 and 32 I/O models. Since the input interface is already


wired to the PLC, input wiring is easy and quick.
Device Wiring. Input devices can be wired to a 120 VAC input Figure 2-7. An input device wired directly to a MicroLogix 1000s input interface.
interface in one of two ways:
they can be wired directly to the interface
they can be wired to a terminal block that is wired to
the interface
If an input device is wired directly to a MicroLogix 1000s input
interface (see Figure 2-7), then one side of the device should be
wired to the L1 hot line of the incoming AC power source. The
120 VAC line
other side should be wired to an input terminal on the PLC. L1 TB
If an input device is wired to a terminal block instead of directly
to the PLC (see Figure 2-8), then the line going out of the input
device should be wired to the terminal block. The block, in Micro Logix
turn, should be wired to the PLC. In MicroLogix 1000 applica- 1000

tions, the wiring of devices through a terminal block is more


common than wiring them directly to the PLC.
Figure 2-8. An input device wired to a MicroLogix 1000 via a terminal block.

6 Module 2
The Input/Output System

Common Wiring. Each input device connected to a MicroLogixs


NOT NOT AC
USED USED Com I/0 I/1 I/2 I/3 AC
Com I/4 I/5 I/6 I/7 I/8 I/9 120 VAC input interface must also be connected to the AC return
line, called the L2 common line. The device must have this com-
mon connection for its electrical circuit to be complete.
Micro Logix
The input terminals on a 120 VAC interface are arranged in two
1000 groups with each group sharing a connection to the common
line. In a 10-input MicroLogix, the first four input terminals share
Figure 2-9. In a 16 I/O MicroLogix, input terminals I/0I/3 share a common, as do one common connection, and the last six share another (see
input terminal I/4I/9. Figure 2-9). In a 20-input model, the first four inputs again share
one common connection, while the last sixteen share another
(see Figure 2-10).

24-Volt DC Input Interfaces


NOT NOT AC I/0 I/1 I/2 I/3 AC I/4 I/5 I/6 I/7 I/8 I/9 I/10 I/11 I/12 I/13 I/14 I/15 I/16 I/17 I/18 I/19
USED USED COM COM
A 24-volt DC input interface is used with field devices that
provide a DC input signal to the PLC (see Figure 2-11). This
Micro Logix input signal can range from 0 VDC when the device is OFF to
1000 between 15 and 30 VDC when the device is ON.
Six models of the MicroLogix 1000 have DC input interfaces.
Two of these come with an AC power supply, as well as a built-
Figure 2-10. In a 32 I/O MicroLogix, input terminals I/0I/3 share a common, as do
in 24 VDC power source. This power source can be used to
input terminal I/4I/19.
power the DC inputs, but it should not be used to power the
PLCs DC outputs. The other four MicroLogix models do not
provide a built-in DC power source. These models require an
external DC power supply to power the inputs.
Two types of DC input devices are used with PLCs:
DC
Signal 24 VDC
sourcing devices
Input To
Interface Processor sinking devices
0 VDC (OFF)
1530 VDC (ON) Sourcing devices provide current when they are ON, while
sinking devices receive current when they are ON. Some de-
vices, like DC sensors, can have either a sinking or a sourcing
Figure 2-11. A 24 VDC input interface.

Module 2 7
The Input/Output System

configuration. A MicroLogix 1000 with a DC interface can con- +V V


Com
nect with either sinking or sourcing DC inputs, but the wiring is PLC
different for each. Current Input
i Interface
Sourcing DC Inputs. Sourcing input devices provide current when
they are ON (see Figure 2-12). For a sourcing input, one side of
the input device is wired to the positive DC voltage line, and the Sources Sinks
other side is wired to the PLCs input interface. The interface is
then connected to the common line, which is the negative DC Figure 2-12. A sourcing input device connected to a PLCs input interface.
voltage line. In a MicroLogix, the negative DC voltage line is
grounded; thus, the common line is grounded. This wiring con-
figuration causes power to flow from the positive line, through
the field device, through the PLCs input interface, and return to V
Com
V
+V Com +V
ground through the common line. Thus, as the input device sources
(provides) current, the PLC sinks (receives) it. Devices
Sourcing
The wiring connections for a MicroLogix 1000 with sourcing DC
inputs depend on whether the PLC uses an external DC power
source or provides its own DC power source. If the PLC uses an 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
external power source, the wiring diagram will look like the one
PLC Sinking
shown in Figure 2-13. One side of each device will be con-
nected to the incoming positive DC voltage line, while the other Figure 2-13.Sourcing input device wiring for a MicroLogix that uses an external
DC power supply.
side of each device will be connected to the input terminal. The
common lines for each group of input terminals will be con-
nected to the grounded negative line.
Devices Sourcing
If the MicroLogix provides its own DC power source, the wiring V
Com Devices
Sourcing
diagram will look like the one shown in Figure 2-14. One side of +V

each device will be connected to the PLCs positive DC voltage


terminal instead of to a positive line coming from an external
DC power supply. The other side of each device will be con-
nected to the input terminal. The common lines for each group +24 DC I/0
DC OUT COM
I/1 I/2 I/3 DC I/4
COM
I/5 I/6 I/7 I/8 I/9

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

Figure 2-18 shows the wiring of sinking input devices to a Micro-


Logix 1000 with a built-in DC power supply. Again, the wiring is
similar to that of sourcing devices connected to a MicroLogix
Devices
with a built-in power supply with one exceptionthe power V
Com Sinking
line connections are reversed.
+V
Just as sourcing inputs can be either two-wire or three-wire de-
vices, so can sinking input devices. The wiring for three-wire
sinking inputs differs from the wiring for two-wire sinking in-
puts. A three-wire sinking device has an extra connection to the + 24 DC
positive DC voltage line that allows the device to operate when 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

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

Figure 2-19. A MicroLogix with sinking three-wire input devices.

10 Module 2
The Input/Output System

2-3 Output Interfaces


The MicroLogix 1000 has several different output interface con-
figurations, and each of these configurations is geared toward a
specific type of output device.
At the end of this section, you will know:
the components of an output interface
the types of outputs used with a MicroLogix 1000
the wiring requirements for the different output inter-
Logic Isolation Power face configurations

Output Interface Components


Figure 2-20 illustrates the components of the MicroLogixs out-
From To Output put interface. They are:
Processor Logic Isolator Switch Filter Device
the logic section
the isolation section
Figure 2-20. The components of an output interface.
the power section
These are the same components found in an input interface;
however, the logic and power sections are reversed.
Logic Section. The logic section of an output interface receives
the control signal, which is either a 1 or 0, from the processor. A
1 means that the interface should turn on the output device. A 0
means that it should turn off the output device.
Isolation Section. After being received by the logic section, the
control signal is then passed through the isolation section. Just
as it does for input interfaces, this section provides an electrical
barrier between the logic section and the power section.

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)

Types of Output Interfaces


A MicroLogix 1000 can have three different types of outputs: Figure 2-21. Relay output.

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.

Output Interface Configurations and Wiring


The MicroLogix 1000 can have three types of outputs: relay,
transistor, and triac. However, the MicroLogix does not have just
85264 VAC one type of output or the other; rather, it can have a combina-
1/2 A (max current) tion of outputs. Specifically, a MicroLogix 1000 PLC is available
with three output interface configurations:
all-relay
Figure 2-23. Triac output.
transistor/relay
triac/relay
All-Relay Output Interfaces. Six models of the MicroLogix 1000
Relays have all-relay output interfaces. Three of the six are 16 I/O
AC models, and three are 32 I/O models.
IN VAC VAC VAC VAC VAC
L1 L2/N VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5 In the 16 I/O models (see Figure 2-24), two of the relay output
terminals, terminal 4 and 5, share a common power source. These
terminals also share a connection to the common line. Each of
Figure 2-24. A 16 I/O all-relay output interface. the other four relay output terminals, terminals 0 through 3, has
its own separate power source and common connections. These
four terminals are called isolated output terminals, since their
power and return lines are separated, or isolated, from each
other. Because this is an all-relay configuration, all of the power
sources can be either AC or DC.
Relays
In 32 I/O all-relay MicroLogix models (see Figure 2-25), only the
AC IN
L1 L2/N
VAC VAC VAC VAC
VDC O/0 VDC O/1 VAC O/2 O/3 VDC O/4 O/5 O/6 O/7 VDCO/8 O/9 O/10O/11
first two output terminals, 0 and 1, are isolated, meaning that
they have their own power and common lines. The rest of the
terminals, 2 through 11, share power source and common line
connections in groups of two, four, and four.
Figure 2-25. A 32 I/O all-relay output interface.

Module 2 13
The Input/Output System

Transistor/Relay Output Interfaces. Two MicroLogix models


have transistor/relay output interfaces. These include a 16
I/O and a 32 I/O model. Relays Transistors
In the 16 I/O transistor/relay model (see Figure 2-26), outputs 0
and 1 are isolated relay outputs. Thus, they each have a separate DC IN VAC VAC DC DC
+ 24V VDC 0/0 VDC 0/1 24V+ 0/2 0/3 0/4 0/5 24V
AC/DC power supply connection and a separate common. Out-
puts 2 through 5 are transistor output terminals that share a
common 24 VDC power source. They also share a common
connection to the return line, which is connected to the nega- Figure 2-26. A 16 I/O transistor/relay output interface.
tive 24 VDC terminal. This terminal is grounded.
The 32 I/O transistor/relay model has two isolated relay output
terminals and a group of ten shared transistor outputs (see Fig-
ure 2-27). This 32 I/O model also has a negative DC voltage
terminal, which is where the return lines from the transistor out-
put field devices are connected to the PLC. This negative termi-
Relays Transistors
nal is grounded.
Triac/Relay Output Interfaces. Only one MicroLogix model has DC IN
+24V
VAC VAC DC DC
VDC O/0 VDC O/1 24+ O/2 O/3 O/4 O/5 O/6 O/7 O/8 O/9 O/10 O/11 24
a triac/relay output interface. This 32 I/O PLC has two iso-
lated relay outputs at terminals 0 and 1 (see Figure 2-28). The
remaining ten outputs are triacs. These triacs are arranged in Figure 2-27. A 32 I/O transistor/relay output interface.
groups of two, four, and four, with each group sharing an AC
power supply connection and a common return line.
Job Aid 2-2 lists the input and output interface specifications for
each model of the MicroLogix 1000, along with a chart explain-
ing how to interpret the model numbers.
Relays Triacs

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

Figure 2-28. A 32 I/O triac/relay output interface.

14 Module 2
The Input/Output System

2-4 System And I/O Power Distribution Wiring


This section provides an overview of how power is distributed
to a MicroLogix 1000 and its I/O devices. At the end of this
section, you will understand:
how power is distributed to a MicroLogix 1000
3-Phase, 480 VAC how I/O devices connect to an incoming power source
Power L1
from L2
Field L3 System Power Distribution
480
VAC The MicroLogix 1000 PLC can be directly mounted in a panel or
enclosure. It also comes ready to be mounted on a DIN rail in an
enclosure. These features make the wiring and the power distri-
bution to the PLC very simple.
Transformer
As explained in the previous module, some MicroLogix 1000s
MicroLogix require a 120/240 VAC power supply, while others require a 24
1000 (AC) VDC power supply. These two types of MicroLogix controllers
Fuse
120/240 have different wiring requirements.
VAC L1 Micro Logix
1000
L2 AC Source Power Wiring. The AC power coming into a plant
or factory is usually at a higher voltage than is needed by an AC
MicroLogix 1000. Therefore, the power signal coming from the
Figure 2-29. AC source power wiring to a MicroLogix 1000. field must be converted, or stepped down, to the right voltage
level using a transformer.
For example, the source power coming into a plant may be
three-phase 480 VAC (see Figure 2-29). However, an AC Micro-
Logix only needs a two-phase 120/240 VAC power signal. Thus,
the following steps are required to use the incoming power to
power the PLC:
1. Tap off the L1 and L2 lines of the source power supply.
2. Bring the L1 and L2 lines to a transformer that converts
the power from 480 VAC to 120/240 VAC.

Module 2 15
The Input/Output System

3. Wire the hot L1 line from the transformer to the


controllers L1 terminal.
4. Wire the neutral L2 line from the transformer to the
controllers L2 terminal.
5. Connect the L2 line to ground to protect the system.
6. Wire the MicroLogixs ground terminal to the system 3-Phase, 480 VAC
ground bus for added protection. Power L1
from L2
Field L3
For further protection, connect the power lines to an accessible 480
disconnect switch inside the panel. This will allow for the quick, VAC
easy removal of power to the PLC, if necessary. Also, add a fuse
to the hot L1 line to protect the system from overloads. Transformer
DC Source Power Wiring. With only a few detailed excep-
tions, DC systems use the same wiring configurations as AC Fuse
systems. In a DC system, the power from the transformer is Disconnect MicroLogix
120/240
brought through a fuse to a DC power supply instead of to the VAC 1000 (DC)
PLC (see Figure 2-30). From there, the DC power supply sends + +
out a 24 VDC signal through its positive and negative lines. DC Power Micro Logix
24 VDC
These lines connect to the positive and negative terminals of the Supply 1000


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.

I/O Power Distribution


Like system power distribution, I/O power distribution can be
broken down into two parts:
AC I/O power distribution
DC I/O power distribution

16 Module 2
The Input/Output System

L1 L2 AC I/O Power Distribution. If a MicroLogix uses AC inputs


MCR
and outputs, then the same 120 VAC line that powers the PLC
can also power the I/O devices. Figure 2-31 shows an example
of AC I/O power wiring. In this situation, the L1 line going to the
PLC provides power to the inputs. The inputs common lines
NOT NOT AC I/0 I/1 I/2 I/3 AC I/4 I/5 I/6 I/7 I/8 I/9
connect to the L2 line to complete the circuit. The L1 and L2
USEDUSED COM COM lines provide power and return to the output devices as well.
85-264VAC
VAC VAC VAC VAC VAC When using the same AC power source for the PLC and its I/O
L1 L2/N VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5
devices, remember to install a master control relay (MCR) cir-
cuit between the L1 line and the I/O devices. This MCR circuit
will allow the power to the I/O devices to be shut off in the
event of a PLC malfunction.
DC I/O Power Distribution. With DC devices, there are two
Figure 2-31. AC I/O power distribution wiring. wiring schemes to consider: one for MicroLogix models that pro-
vide a built-in DC power supply and another for those models
that rely on an outside DC power supply.
L1 L2 If a MicroLogix has a built-in DC power supply, it can be used to
VDC + VDC VDC + power the DC input devices with up to 200 mA (milliamps) of
Com
VDC
Com
current (see Figure 2-32). To do this, the input devices and their
return lines are connected to the appropriate DC power termi-
nals. While the built-in DC power supply can provide power to
+24
DC OUT
DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
COM COM
the DC inputs, it cannot provide power to the DC output de-
vices. DC output devices must be connected to an external DC
85-264VAC

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

The I/O power wiring for DC MicroLogix models that use an L1 L2


V +V
external power supply is similar to the wiring for those with Com
built-in power supplies. The main difference is that both the
input and output devices are wired to an external power supply
(see Figure 2-33).
NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
An MCR circuit is required in DC I/O power wiring, just as it is in USED COM COM

AC I/O power wiring. The MCR provides a safety mechanism 85-264VAC


VAC VAC VAC VAC VAC
that allows the I/O devices to be turned off in emergencies. L1 L2/N VDC O/0 VDC O/1VDC O/2 VDC O/3VDC O/4 O/5

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

2-6 Job Aids

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.

Sourcing Inputs/Sinking MicroLogixInternal DC Power Sourcing Inputs/Sinking MicroLogixExternal DC Power

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

PLC Sinking PLC Sinking

20 Module 2
The Input/Output System

Sinking Inputs/Sourcing MicroLogixInternal DC Power Sinking Inputs/Sourcing MicroLogixExternal DC Power

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

PLC Sourcing PLC Sourcing

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

PLC Sourcing PLC Sourcing

Module 2 21
The Input/Output System

Job Aid 2-2: MicroLogix Model Specifications


A MicroLogix is available in different models each with a unique identifying model number, such as 1761-L16BBB. To interpret the
model number, refer to the following chart:

Bulletin Number Base Unit I/O Count Input Type Output Type Power Supply

1761 L 16 A = 120 VAC W = relays A = 120/240 VAC


32 B = 24 VDC B = 24 VDC MOSFET (transistor) and relays B = 24 VDC
A = 120/240 VAC triacs and relays

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:

Model Number Number/Type of Inputs Number/Type of Outputs Power Supply

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-L16BWB 10 inputs24 VDC 6 outputs4 isolated relays/2 shared relays 24 VDC

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

INSTRUCTIONS 2. Input/contact instructions


3. Output/coil instructions
4. Special programming issues
5. Basic relay programming examples


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

3-1 Ladder Programming


This section covers the fundamentals of ladder programming. A
MicroLogix 1000 uses the control program stored in its CPU to
analyze input data and determine the corresponding output ac-
tion. This control program is entered and stored in the CPU as
ladder diagrams. At the end of this section, you will know:
the basics of ladder programming
L1 L2
the two types of relay instructions available in the Micro-
Logix 1000 LS PL
(a)
Ladder Diagram Basics
Ladder diagrams and electromechanical circuits function in much
the same way. In an electromechanical circuit, one side of the
L1 L2 L1 L2
circuit is connected to the incoming L1 power line, while the PL
LS LS PL
other side is connected to the L2 return power line. The input (b)
and output devices are wired between the two power lines. In
the circuit shown in Figure 3-1a, when the limit switch input
device closes, it completes the electrical path between the in-
Figure 3-1. (a) An electromechanical circuit and (b) its equivalent ladder diagram.
coming and return power lines. This turns on the pilot light.
When the limit switch opens, it breaks continuity in the circuit,
turning off the pilot light.
The ladder diagram equivalent of a hardwired circuit also shows
the devices connected between the L1 and L2 lines. However, in
a ladder diagram, the L1 and L2 lines are represented by the left
and right rails, respectively. Also, in a ladder diagram, the inputs
and outputs are represented by contacts and coils. Thus, when
the limit switch in the ladder circuit shown in Figure 3-1b closes,
the LS contact energizes, providing power to the PL coil and
turning on the pilot light.

2 Module 3
B a s i c R e l ay I n s t r u c t i o n s

Contacts and Coils. In a ladder diagram, contact instructions


are used to reference input devices and coil instructions are
Left Right used to reference output devices. A contact examines the state
Rail Rail
of its corresponding input field device. It then either energizes
or de-energizes, depending on whether the input device is ON
or OFF, respectively.
Conversely, a coil energizes or de-energizes according to the
status of the contacts in its ladder rung. When a coil energizes, it
turns its associated output device ON. When a coil de-ener-
gizes, it turns its associated output device OFF.
Ladder Rung Structure. In addition to contacts and coils, there
are two other terms used when describing a ladder program:
Figure 3-2. A ladder rung with arrows indicating the flow of power through the
rung. rung
ladder rung matrix
Rung. A rung is a set of programmed instructions that forms a
complete electrical path between the left and right rails of a
ladder diagram (see Figure 3-2). A MicroLogixs ladder rung can
Output have many contacts and coils in many branches. Since a rung
Contact Input Conditons
Coils can have many branches, it may provide several different com-
plete paths from the left to the right rail.
Note that a MicroLogix will not allow power to flow from right
to left. Power must always flow from left to right through a
ladder rung. Job Aid 3-1 explains how to program around re-
verse power flow in a MicroLogix 1000.
Ladder Rung Matrix. The ladder rung matrix (see Figure 3-3)
determines the maximum number of branches that can be used
to program a ladder rung. In a MicroLogix 1000, a rung can
Figure 3-3. A ladder rung matrix. have a maximum of 75 branches. The ladder rung matrix also
defines all of the possible locations for a contact or coil instruc-
tion in a rung.

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

3-2 Input/Contact Instructions


Examine-If-Closed Contact instructions are used to reference input devices con-
nected to the PLC. Thus, a contact represents an input condition
(XIC) to a ladder rung. In some cases, a contact can also be used to
reference an output coil.
Figure 3-4. An examine-if-closed instruction.
At the end of this section, you will know the operation of the
two basic contact instructions used with the MicroLogix 1000:
examine-if-closed contacts
examine-if-open contacts
L1 L2
Examine-If-Closed Contacts
PB
I/0 I:0.0/0 An examine-if-closed contact instruction, also called a nor-
mally open instruction, is represented by the symbol shown in
(a)
Figure 3-4. It is abbreviated as XIC. An XIC contact checks the
status of its input reference address for an ON, or closed, condi-
0 tion. Then, if the reference address is ON, the contact closes,
1 Word 0.0
providing continuity through it.
Input File
Figure 3-5 illustrates how an XIC contact works. In this diagram,
L1 L2 the push button is wired to terminal 0 of a MicroLogix 1000s
PB input interface and, as a result, has the address I:0.0/1. The XIC
I/0 I:0.0/0 contact in the ladder diagram shares this reference address. When
the push button closes (see Figure 3-5a), it supplies a voltage to
(b) the PLC, causing a 1 to be stored in address I:0.0/1. When the
XIC instruction detects the 1 in the address bit, it knows the
0 button is closed. This causes the contact to close, providing
0 Word 0.0 continuity to the ladder rung. When the push button is OFF,
Input File however, its reference address bit will contain a 0 (see Figure 3-
5b). This tells the XIC instruction that the button is open. As a
Figure 3-5. (a) When an XIC instruction detects a 1 in its address bit, it closes,
providing continuity to the ladder rung. (b) When an XIC instruction
result, the XIC contact will open, breaking continuity in the rung.
detects a 0 in its address bit, it opens, breaking continuity in the rung.

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

3-3 Output/Coil Instructions


A coil instruction is a ladder instruction that references an out-
put device. Thus, it represents the output action of a ladder
Output Coil rung. At the end of this section, you will know the operation of
the four basic coil instructions used with the MicroLogix 1000:
standard output coils
internal output coils
latch/unlatch output coils
Figure 3-8. A standard output coil instruction. one-shot rising instructions

Standard Output Coils


A standard output coil instruction, which is also called an
output energize instruction, is represented by the symbol shown
in Figure 3-8. If the coils ladder rung has continuity, then the
coil will energize, turning on the output device that shares its
reference address. This reference address is located in the out-
L1 L2 L1 L2
PB put file of the data file section.
I/0 I: 0.0/0 O: 0/3 O/3 PL
Figure 3-9 shows a push button driving an output coil that refer-
ences a pilot light output. When the push button closes, its XIC
contact will energize, providing continuity to the ladder rung
and causing the output coil to turn ON. When the output coil
3
1 Word
turns ON, the MicroLogix will store a 1 in the coils reference
address (O:0/3) to indicate that the coil is ON. The PLC will then
Output File turn on the output device that shares this addressin this case,
the pilot light.
Figure 3-9. When coil O:0/3 turns on, its associated output device will turn on.

Module 3 7
B a s i c R e l ay I n s t r u c t i o n s

An output coil can be referenced by a contact instruction. There-


fore, an output coil can drive a real field output device while
simultaneously providing the input logic to another rung. The
contacts used to reference an output coil can be either XIC or L1 L2 L1 L2
XIO instructions. LS I/0 I: 0.0/0 B3:1/2 O/5 M1
M
Internal Output Coils B3:1/2 O: 0/5
An internal output coil instruction looks like a regular out-
put coil. It is even represented by the same symbol. The func-
2
tional difference between the two is that a standard output coil Word 1
1
references an actual field output device wired to the PLC, while
Binary File
an internal output coil does not. Thus, instead of having a refer-
ence address located in the output file, an internal output coil Figure 3-10. An internal output coil (B3:1/2) referenced by an XIC instruction.
has a reference address located in the binary file (file 3). Inter-
nal coils are used with contacts to implement interlocking in a
ladder program. They are also used to store bit information that
does not directly impact the outside world.
Aside from being mapped to different files, an internal output
coil and a regular coil work almost the same way (see Figure 3-
10). If its rung has continuity, an internal output will turn on
and store a 1 in its reference address bit. Since an internal out-
put coil does not map a real output device, no field output Latch/Unlatch Output Coil
device will turn on. However, any contact that shares the inter-
nal coils address will turn on or off with the coil. Latch Unlatch

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.

One-Shot Rising Instructions


A one-shot rising instruction is represented by the symbol
shown in Figure 3-13. A one-shot rising instruction is not a coil
instruction, but rather, a contact instruction. It is covered in this
section, however, because it is used to control the behavior of
One-Shot Rising Instruction an output coil.
A one-shot rising instruction is used to energize an output coil
OSR for only one scan. It is usually the last contact in a rung, located
just before the output coil. A one-shot instructions reference
address bit can be located in either the binary file (file 3) or the
Figure 3-13. A one-shot rising instruction.
integer file (file 7). Its address cannot be shared by another
contact or coil, and it cannot correspond to a real input or out-
put device. Also, the MicroLogix allows only one one-shot rising
instruction per rung.

Module 3 9
B a s i c R e l ay I n s t r u c t i o n s

When the logic before a one-shot rising instruction becomes en- L1 L2 L1 L2


ergized (see Figure 3-14), the one-shot rising instruction will be LS I/3 I:0.0/3 B3:1/7 O:0/3 O/3 SOL
energized. As a result, the output coil and output device will turn OSR
on. A one-shot rising instruction, however, will only stay ener-
gized for one scan, even if its driving logic remains energized.
Thus, after one scan, the one-shot rising instruction, the output Scan 1
(a)
coil, and the associated field output device will turn off, even if
the rest of the rung still has continuity. A one-shot rising instruc- L1 L2 L1 L2
tion is very useful for resetting output signals in one scanfor LS I/3 I:0.0/3 B3:1/7 O: 0/3 O/3 SOL
example, for unlatching an output in one scan so that it will be OSR
ready to latch again in the next scan.
Scan 2

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

3-4 Special Programming Issues


This section covers special issues you may encounter while pro-
gramming a MicroLogix 1000 controller. At the end of this sec-
tion you will know the techniques associated with three special
programming issues:
ladder scan evaluation
Update Read
Outputs Inputs the programming of normally closed input devices
safety device programming

Ladder Scan Evaluation


The way the controller evaluates the ladder program determines
the order in which the programmed instructions will be executed.
Thus, ladder scan evaluation can have a profound effect on the
way the PLC and its associated machine or process operate.
A PLCs scan consists of three activities (see Figure 3-15):
1. reading the inputs
Execute
Control Program 2. executing the control program

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

When developing a control program for a MicroLogix 1000, you L1 PB1 L2 L1 L2


I: 0.0/0 O: 0/0 O/0 PL1
must pay close attention to the order in which the contacts and I/0
coils are programmed. Arranging the same coils and contacts in O: 0/0 O: 0/1 O/1 PL2
a different order will produce different results. Figure 3-16 shows (a) O/2 PL3
two ladder programs containing the same elements but pro- O: 0/1 O: 0/2

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

L1 L2 will not be energized. Accordingly, the pilot light will be off.


LS PL Under these conditions, the limit switch must open for the XIO
contact to be energized and the pilot light to turn on. This is
contrary to the way the circuit should work.
XIC Contact. Figure 3-18 shows the circuit from Figure 3-17
L1 L2 L1 L2 programmed with an XIC contact. As in the previous ladder
I: 0.0/0 O: 0/0 O/0 PL
LS I/0 circuit, the normally closed limit switch provides a voltage to
the PLC. However, in this program, the XIC contact examines
the limit switch for a closed condition in order to provide conti-
nuity to the rung. Since the limit switch is closed, the contact
Figure 3-18. A normally closed input device programmed with an XIC contact, will be energized. In turn, the output coil and pilot light will be
along with its equivalent hardwired circuit. energized. If the limit switch opens, the pilot light will turn off.
Thus, the circuit works correctly.

Safety Device Programming


L1 L2 L1 L2 When connecting safety devices to PLCs, there is one cardinal
Start
I: 0.0/0 I: 0.0/1 O: 0/0 O/0 Motor rule to remember: never use a normally open device programmed
I/0 with an XIO contact instruction. The following explains why.
M
(a) Stop O: 0/0 To implement the safety stop circuit shown in Figure 3-19, you
I/1
must use a normally closed input device programmed with an
XIC instruction. In this configuration, when the start push but-
ton is pressed, the motor will turn on because both of the XIC
L1 L2 L1 L2 contacts will detect that their inputs are closed. When the start
Start
I/0 I: 0.0/0 I: 0.0/1 O: 0/0 O/0 Motor button is released, the motor will stay on because contact O:0/0
M seals the circuit. When the stop push button is pressed, the XIC
(b) Stop instruction will detect that the stop button is open and turn off.
I/1 O: 0/0
This will turn off the motor circuit.
Moreover, if the motor in this circuit is sealed on and the con-
Figure 3-19. (a) A fail-safe safety stop circuit using a normally closed device nection from the stop push button breaks, the XIC instruction
programmed with an XIC instruction. (b) A safety stop circuit using a that references the stop push button will detect an OFF, or open,
normally open device programmed with an XIO instruction. In this condition. As a result, it will turn off the motor automatically.
circuit, once the motor is on, the motor cannot be turned off if the This creates a fail-safe circuit that is ideal for safety situations.
safety stop button malfunctions.

Module 3 13
B a s i c R e l ay I n s t r u c t i o n s

3-5 Basic Relay Programming Examples


This section includes practical examples to help you apply what
you have learned to two specific types of control circuits that
are often used in MicroLogix 1000 applications. At the end of
this section, you will know about the I/O device wiring, ad-
dressing, power wiring, and ladder programming of:
simple motor control circuits
forward/reverse motor circuits

Simple Motor Control Circuit


Figure 3-20 shows the hardwired diagram for a simple start/stop L1 L2
Start
motor circuit. In this circuit, the motor turns on when the start Stop OL
push button closes. The auxiliary contact in line 2 seals the 1 M
circuit so that the motor remains on when the start push button
is released. When the stop push button is pressed, the motor M
2
turns off. The overload contacts can also turn the motor off in 2 3
the event of an overload situation.
PLC Requirements. To convert this circuit into a PLC circuit, Figure 3-20. Hardwired diagram for a simple star t/stop motor circuit.
you could use a PLC with the following specifications:
32 I/O
24-volt DC power supply
24-volt DC input interface
relay/transistor output interface
The start and stop input devices will be connected to the 24-volt
DC input interface. The motor starter, which has a 24-volt DC
coil, will be connected to one of the transistor outputs.

14 Module 3
B a s i c R e l ay I n s t r u c t i o n s

V I/O Device and Power Wiring. The I/O devices to be wired to


Com +V
the PLC are the stop push button, the start push button, and the
motor starter. An internal instruction will be used to implement
the auxiliary contact in the PLC.
Stop Start
Figure 3-21 shows how the I/O devices and power will be wired
to the PLC. The stop button will be wired to the first input
NOT NOT DC I/0
USEDUSED COM
I/1 I/2 I/3 DC I/4
COM
I/5 I/6 I/7 I/8 I/9 I/10 I/11I/12 I/13 terminal (I:0.0/0) and the start button to the next input terminal
(I:0.0/1). These are both DC inputs. The motor starters coil will
DC in
VAC VAC DC DC NOT
be wired to the first transistor output terminal (O:0/2). The over-
+24v VDC O/0 VDC O/1 24+ O/2 O/3 O/4 O/5 O/6 O/7O/8 O/9O/10O/11 24 USED
load contacts will remain wired in series with the motor starters
coil, just as they were in the electromechanical circuit.
M
To apply power to the PLC, you should connect the MicroLogix
OL to the DC power supplys positive and negative voltages, noting
+V
+V V V that the negative is connected to ground. The PLC itself should
Com Com also be grounded. Next, connect both the input devices and the
output device to their respective DC power supply positive and
Figure 3-21. The I/O device and power wiring for the start/stop motor circuit. The
negative terminals.
+V supply connection shown occurs after the MCR power contact,
which controls the power to the I/O devices. Ladder Programming. Figure 3-22 shows the ladder control
program for the start/stop motor circuit. The ladder program
uses the same logic that was used in the electromechanical cir-
cuit; however, the PLC program uses XIC contacts to reference
the two inputs and an output coil to reference the motor. Inter-
nal contact O:0/2, which references the output coil, seals the
circuit when the start push button is released.
L1 L2 L1 L2
Stop
I/0 I: 0.0/0 I: 0.0/1 O: 0/2 O/2 Motor OL The PLC program will work just like the hardwired circuit. When
M the start button is pressed, the motor will turn on and stay on.
Start
When the stop button is pressed, the motor will turn off. If the
I/1 O: 0/2 motor is sealed on and the overload contact opens, the motor
starter will turn off. The reason for this is that the open overload
contact will break the power continuity in the motor starters
circuit. This situation is called low-voltage release.
Figure 3-22. Ladder program for the star t/stop motor circuit.

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

Forward/Reverse Motor Circuit REV


F2
Figure 3-24 illustrates the hardwired electromechanical diagram R
for a forward/reverse motor circuit (reversing motor starter). This
REV
circuit has two normally open start push buttonsa forward R1
button and a reverse button. It also has two motor starter coils
one to start the motor going forward and another to start it
going in reverse. The forward part of the circuit contains a con- Figure 3-24. Hardwired diagram for a forward/reverse motor circuit.
tact labeled F1, which seals the forward push button. It also
contains an R2 interlocking contact that prevents the forward

16 Module 3
B a s i c R e l ay I n s t r u c t i o n s

motor starter from turning on if the reverse starter is already on.


Moreover, it has a forward pilot light that turns on when the
motor is moving in a forward direction.
The reverse part of the circuit contains similar elements and
works identically to the forward part. Additionally, the circuit
has a normally closed stop push button that can turn off either
the forward or the reverse motor starter. It also contains an over-
load contact that will turn off either starter in the event of an
32 I/O MicroLogix
L1 L2 overload condition.
MCR Stop Fwd F1 Rev R1
PLC Requirements. To begin the implementation, you must
choose the appropriate MicroLogix model for the application.
In this example, the PLC will have the following specifications:

NOT NOT AC I/0 I/1 I/2 I/3 AC I/4 I/5


32 I/O
USED USED COM COM
120-volt AC power supply
VAC VAC
L1 L2/N VDC O/0 VDC O/1 VAC O/2 O/3 VAC 120-volt AC input interface
relay/triac output interface
F R Fwd Rev I/O Device and Power Wiring. In this forward/reverse circuit,
PL PL all of the devices except the R2 and F2 contacts and the over-
OL
load contact will be wired to the PLC. The motor starter contacts
R1 and F1 will be wired to the PLC to provide low-voltage pro-
Figure 3-25.The I/O device and power wiring for the forward/reverse motor circuit. tection in the program. The R2 and F2 interlocking contacts,
however, will be implemented in the PLC through internal con-
tacts that reference the forward and reverse coils. The overload
contact, which protects the motor, will be wired after the for-
ward and reverse starters.
Figure 3-25 shows how the I/O devices will be wired to the
MicroLogixs input and output interfaces. The input devices will
be connected to the first five input terminals, and the output
devices will be connected to the first four output terminals. The
starter coils will be connected to output terminals 0 and 1, the
two relay terminals, and the pilot lights will be connected to the

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

tact is an XIO interlocking contact that references the reverse FWD


I:0.0/2 O:0/2 O/2 FWD PL
starter output. This contact provides interlocking so that the for- I/1

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

L1 L2 L1 L2 circuit is programmed, you must press the stop push button to


Stop I/0 I:0.0/0 I:0.0/1 O:0/1 I:0.0/3 O:0/0 O/0 OL stop one motor starter before the other one can turn on. This
F configuration is called a compelling circuit. This circuit can be
FWD FWD PL
converted into a noncompelling circuit, which will automati-
I:0.0/2 O:0/2 O/2
I/1 cally change the direction of the motor rotation when you press
either the forward or reverse start push button.
F1 I:0.0/3 O:0/0 I:0.0/1 O:0/1 O/1
I/2 Noncompelling Circuit. To make a noncompelling circuit, you
R
must add XIO forward and reverse push button interlocks to the
REV
I:0.0/4 O:0/3 O/3 REV PL ladder program (see Figure 3-27). These contacts make the for-
I/3
ward starter turn off when the reverse start push button is pressed
R1
and vice versa. If the forward starter is sealed on and the reverse
I/4
push button is pressed, XIO contact I:0.0/3 in line one will open.
This will turn off the forward starter. At the same time, the re-
verse start push button will turn on the reverse starter. So in this
Figure 3-27. The forward/reverse motor circuit programmed as a noncompelling configuration, you do not have to press the stop push button
circuit. before turning on the reverse motor starter. This is a noncom-
pelling circuit. To stop the motor, you must simply press the
stop push button.

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

3-7 Job Aids

Job Aid 3-1: Programming Around Reverse Power Flow


The following ladder diagram allows power to flow from right to left through contact D. This type of reverse power flow is not
permitted in a MicroLogix ladder program.

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

TIMING, programming instructions. Module 3 covered basic relay instructions,


which perform simple ON/OFF operations. All of those instructions
use a basic ladder format. The three sections of this module discuss
programming instructions that are represented in block format. These
COUNTING, AND sections are:
1. Timing instructions

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

4-1 Timing Instructions


Timing instructions are programming instructions that replace the
need for electromechanical timers in a control system. Timing
instructions perform the same function as electromechanical tim-
ers, but they are more accurate, do not cost extra, and save space.
At the end of this section, you will know:
timer basics, including timer values and addresses
the operation of a timer ON-delay instruction
Number of
the operation of a timer OFF-delay instruction Times
Time Timed Time Base
Base Valued Is Counted
how a retentive timer instruction works
how to use and implement the trapping of instanta- 1 sec 2 sec = 2 times
neous timer contacts in a PLC 0.01 sec 2 sec = 200 times

General Timer Information


Figure 4-1. Time base illustration.
Timer Values. A timer instruction has three important values
associated with it:
the time base
the preset value
the accumulated value
Time Base. The time base is the unit of time used by a timer to
time an event. A MicroLogix 1000s timers can have a time base
of either 0.01 seconds or 1 second. A timer instruction times an
event by counting the number of times the time base has oc-
curred since the instruction was energized. For example, if a
MicroLogix has a time base of 1 second and it is timing some-
thing that is 2 seconds long, the PLC will wait until the time base
has occurred 2 times before the timer times out (see Figure 4-1).

2 Module 4
Timing, Counting, and Data-Handling Instructions

Conversely, if the PLCs time base setting is 0.01 seconds, it will


Timer 1 Word wait until the time base has occurred 200 times before timing
Timer File Control 0 out. The selection of the time base depends on what is most
File 4 appropriate for the application.
Preset 1
Timer 0 Accumulated
Preset Value. The preset value of a timer works in conjunction
2 with the time base by specifying the number of times that the
Timer 1 timer must count the time base. This preset value, which is also
referred to as the number of ticks, is predetermined and prepro-
grammed by the user. Thus, in the previous example of a timer
with a 0.01 time base and a target value of 2 seconds, the preset
value would be 200. This value indicates that the timer must
Timer 39 wait 200 time bases before timing out.
Accumulated Value. The final value associated with a timer is
Figure 4-2. The timer file showing the three words associated with each timer. the accumulated value. This value keeps track of how many
times the time base has occurred since the timer instruction was
energized. When the accumulated value equals the preset value,
the timer will time out because it has reached its target timing
value. So if a timer has a time base of 0.01 and a preset value of
200, the accumulated value will increase by one every 0.01 sec-
Timer File onds until the accumulated value equals 200. At that point, the
4 Timers File 4 timer instruction will time out.
Addressing. A MicroLogix 1000 stores data about timers in file
40 timers T4:0.0 4 of its data file section. This file can store the data of up to 40
0.1 timers, numbered 0 through 39. Each of these timers has three
0.2 words associated with it (see Figure 4-2). Therefore, the avail-
able addresses in the timer file range from T4:0.0 to T4:39.2 (see
T4:39.0 Figure 4-3).
39.1
39.2

Figure 4-3. MicroLogix 1000 timer addressing.

Module 4 3
Timing, Counting, and Data-Handling Instructions

Each of the three words associated with a timer holds a specific


kind of data (see Figure 4-4): Enable
Timer Timing
Word 0 holds control data about the status of the timers Done
enable output, whether the timer is actively timing,
and the status of the timers done output. The control 15 14 13
word stores this information in bits 15, 14, and 13, T4:0.0 Control
respectively.
T4:0.1 Preset
Word 1 stores the timers preset value. This is the tar-
get timing value specified in memory. T4:0.2 Accumulated

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.

Timer ON-Delay Instruction


The timer ON-delay instruction is a block-format instruction
that is represented by the symbol shown in Figure 4-5. This TON
TIMER ON-DELAY EN
block has two outputs:
Timer T4:18
an enable output coil Timer Base 1.0
Preset 4 DN
Accum 0
a done output coil
Inside the block is information about the timers address, time ON Energizes
base, preset value, and accumulated value. A timer ON-delay Delay
instruction energizes its done output after the timer blocks in-
Figure 4-5. A timer ON-delay instruction.
put turns on and a specified delay has occurred. Consequently,
this instruction is sometimes called a timer ON-delay energize
instruction.

4 Module 4
Timing, Counting, and Data-Handling Instructions

L1 L2 TON L1 L2 Figure 4-6 illustrates how a timer ON-delay instruction works.


PB O/0 PL
I/0 I:0.0/0 TIMER ON-DELAY T4:18/EN
EN
When the timer blocks input has logic continuity, the blocks
Timer T4:18 enable output will turn on. As a result, a 1 will be stored in bit
Timer Base 1.0
Preset 4 T4:18/DN
15 of the timers control word. Once the timer is enabled, it will
Accum 4 DN start to time. Thus, a 1 will be stored in bit 14, which is the timer
timing bit. As the timer times, the accumulated value increases
T4:18/DN O:0/0 until it equals the preset value. At that point, the timer timing bit
will become a 0, and the done bit will become a 1, meaning that
the done output will turn on. This done output is the timers
EN TT DN delay action contact.
15 14 13
The timer-ON delay instructions enable output will remain on
1 0 1 Word T4:18.0 as long as the input logic to the block remains energized. How-
ever, the timer will stop timing as soon as the accumulated value
Figure 4-6. The operation of a timer ON-delay block in a control program. equals the preset value. The timers input logic must turn off
and then on again before the timer will start timing again. The
timers done output can be referenced throughout the program
by XIC and XIO contacts to implement the time delay.
I:0.0/0 TON
In the ladder program shown in Figure 4-6, the pilot light output
TIMER ON-DELAY EN
will turn on four seconds after the push button input is pressed.
Timer T4:18 In the ladder diagram, the input logic to the pilot light is a
Timer Base 1.0
Preset 4 contact that references the done output coil of the timer block.
DN
Accum 0 The timers address is T4:18, its preset value is 4, and its time
T4:18/DN O:0/0 base is 1 second.
Figure 4-7 shows the operation of the same ladder diagram,
using a timing diagram to keep track of when the input and
Timer Input 1
0 outputs turn on and off. The ladder diagram operates like this:
1
T4:18/EN
0 When the timers input turns on, it will cause the timers
1 enable output to turn on. When this happens, the timer
T4:18/TT 0
1 will start timing, but the done output coil will remain
T4:18/DN 0
off. The time between the timer being energized and
Delay the done output being energized is the four-second
Figure 4-7. A timer ON-delay block and its associated timing diagram.
delay implemented by the timer.

Module 4 5
Timing, Counting, and Data-Handling Instructions

The timer will stop timing as soon as the accumulated


value equals the preset value. TOF
TIMER OFF-DELAY EN
When the accumulated and preset values are equal,
the done output will turn on, causing the output coil Timer T4:18
Timer Base 0.01
that drives the pilot light to turn on. Preset 315 DN
Accum 0
The done outputand hence, the pilot lightwill stay
on until the timer blocks input turns off. At that time,
OFF De-Energizes
everything in the ladder rung will turn off, and the Delay
timers accumulated value will be reset to 0.
Figure 4-8. A timer OFF-delay instruction.
Timer OFF-Delay Instruction
Figure 4-8 illustrates a timer OFF-delay instruction. This in-
struction looks much like a timer ON-delay instruction in that it
has two outputsdone and enableand includes information
about the timers preset and accumulated values. Although a
I:0.0/0 TOF
timer OFF-delay instruction may look like an ON-delay instruc-
TIMER OFF-DELAY EN
tion, it works a little differently. A timer OFF-delay instruction
de-energizes its done output after the timer blocks input turns Timer T4:18
Timer Base 0.01
off and a specified delay has occurred. Thus, the timer OFF- Preset 315 DN
delay instruction is also called a timer OFF-delay de-energize Accum 315
instruction. T4:18/DN O:0/0

The ladder program in Figure 4-9 uses a timer OFF-delay in-


struction. This circuit works as follows:
Timer Input 1
The done output will be off when the program is first 0
1
started and the timers input is off. T4:18/EN
0
1
When the input logic turns on, both the blocks en- T4:18/TT 0
able output and done output will turn on. However, T4:18/DN 0
1
the timer will not start timing because it is waiting for
Delay
an OFF signal instead of an ON signal.
Figure 4-9. A timer OFF-delay block and its associated timing diagram.

6 Module 4
Timing, Counting, and Data-Handling Instructions

When the blocks input turns off, the enable output


will turn off and the timer will start timing. The done
RTO
output will stay on because it is waiting for the timer
RETENTIVE TIMER ON EN
to time out before it will turn off.
Timer T4:7
Timer Base 1.0 Once the accumulated value equals the preset value,
Preset 10 DN the timer will stop timing and the done output will turn
Accum 0 off, implementing the OFF-delay de-energize function.
Therefore, the done bits action follows the action of
Figure 4-10. A retentive timer instruction. the timers input signal, except that the done bit re-
mains on for the specified delay period after the input
turns off. All of the timers outputs will now remain off
until the input logic turns on again. At this point, the
accumulated value is reset to 0.

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

L1 L2 an instantaneous contact in a PLC timer circuit, if the application


requires it. When you trap a circuit, you use an internal contact
FS1 PS1 TMR1 and coil to seal the timer on. You can also use the enable output
of the timer to trap the circuit.
10 sec Trapping CircuitInternal Output. Figure 4-13 shows an elec-
tromechanical timer circuit that will be implemented in a PLC.
TMR1-1 In this circuit, the timer will start timing as soon as float switch
FS1 and pressure switch PS1 close. The timer will continue to
time even if the float switch turns off. This is because instanta-
SOL neous contact TMR1-1 will seal the timers input logic. After a
TMR1-2
10-second delay, the timer will energize time-delayed contact
TMR1-2, causing the solenoid to turn on.
The first step in making this a PLC circuit is to determine which
Figure 4-13. An electromechanical timer circuit to be implemented in a PLC.
devices will be connected to the PLCs I/O interfaces. In this
case, only the float switch, pressure switch, and solenoid will be
connected to the PLC. The rest of the circuit will be implemented
through PLC instructions. The float switch will be connected to
the MicroLogixs first input terminal, and the pressure switch to
the second terminal. The solenoid will be connected to the first
output terminal.
L1 L2 L1 L2 Figure 4-14 illustrates the ladder program that will implement
I/0 I:0.0/0 I:0.0/1 B3:0/0 O/0 O:0/0
FS1 the timer circuit in the PLC. This ladder program contains three
rungs:
B3:0/0
The first rung traps the timer on.
PS1 I/1 B3:0/0 TON
Timer T4:0 EN The second rung implements the timing function.
Timer Base 1.0
Preset 10
Accum 0 DN The third rung implements the time-delayed output
action.
T4:0/DN O:0/0
Rung 1. The first rung in the ladder program consists of contacts
that reference the float switch and pressure switch, along with
Figure 4-14. The timer circuit implemented in a ladder program using an internal an internal coil. It also contains an internal contact that refer-
output to trap the timer. ences the internal coil, which implements the trap. When the

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

Trapping CircuitEnable Output. Another way to trap an T3 T1


LO LO LO HI HI HI
instantaneous timer contact is to use a contact that references
the timers enable output. In this method, the enable contact is T5 T2 T6 OL
LO
OL
HI
used to seal the timers input, instead of an internal coil and Speed L1 L2 L3 Open Together HI HI
Low T1 T2 T3 All others
contact. Figure 4-15 shows an example of this type of trapping. High T6 T4 T5 T1, T2, T3
T1 T2 T3 T6 T4 T5
When the float switch and pressure switch turn on, the enable
output and its corresponding contact will turn on. However, if L1 L2 T4 High Speed Power
to T4, T5, and T6
the float switch opens, the timer will remain on because the Low (T1, T2, and T3 together)
Stop TMR H Low OL T3 T1
enable contact will trap it.
CR CR T5 T6
Figure 4-16 shows a multispeed motor. In low speed, this motor T2
Wye (High)
L
operates in a delta configuration. In high speed, it operates in a TMR TMR
T1 Low Speed Power
wye configuration. In this motor, if the low push button is pressed, High to T1, T2, and T3
CR T6 (T4, T5, and T6 open)
the motor will run at low speed. If the high push button is pressed T4

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

Counter 1 Word 4-2 Counting Instructions


Control 0
Counter File
File 5 Preset 1 Just as timing instructions replace the need for electromechani-
Accumulated 2 cal timers in a PLC, counting instructions replace the need for
Counter 0
electromechanical counters. This section discusses the different
Counter 1
types of counting instructions available in a MicroLogix 1000.
(a)
At the end of this section, you will know:

Counter 31 (b) 5 Counters basic counter information

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

Word 0 is the control word, which stores data about


the counter blocks operation and status. This word
holds information about the status of the count up
and count down outputs and data about the counters
done, overflow, and underflow status. This informa-
tion is stored in bits 11 through 15 of the control word.
Word 1 stores the counters preset value, which is the
target count value.
Word 2 stores the counters accumulated value, which
is the actual count value. A counters preset and accu-
mulated words, words 1 and 2, are addressed with the CTU
labels PRE and ACC in the RSLogix software. COUNT UP CU
Counting instructions allow the implementation of several types Counter C5:2
Preset 3
of counter functions in a programmable controller. The three Accum 0 DN
counting instructions found in a MicroLogix 1000 are:
the count up instruction
Energizes
the count down instruction OFF-to-ON Increases
Transition by 1
the reset instruction
Figure 4-20. A count up instruction.
Count Up Instruction
A count up instruction is represented by the symbol shown in
Figure 4-20. The function of a count up instruction is to increase
its accumulated value by one every time the blocks input makes
an OFF-to-ON transition. After a certain number of OFF-to-ON
transitions have occurred, the count up instruction will energize
its output. A count up block has two output coils:
a count up output coil (CU), which indicates that the
counter block is energized
a done output coil (DN), which indicates that the count
is complete

14 Module 4
Timing, Counting, and Data-Handling Instructions

Figure 4-21 shows a count up circuit in which a limit switch and


a solenoid are connected to a MicroLogix 1000 controller. The
solenoid should turn on after the limit switch has turned on
L1 L2 L1 L2
I:0.0/0 CTU C5:2/CU O/0 SOL three times. The circuit operates as follows:
LS1 I/0
COUNT UP CU
When the limit switch turns on for the first time, the
Counter C5: 2
Preset 3 C5:2/DN count up output will be energized, and the accumu-
Accum 0 DN
lated value will increase to 1.
C5:2/DN O:0/0
When the limit switch turns off then on again, the
accumulated value will increase to 2.

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

Like a count up instruction, a count down instruction also has


two outputs: I:0.0/0 CTD

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.

When the blocks input turns from OFF to ON, the


accumulated value will decrease to 3.
When the blocks input makes this OFF-to-ON transi-
tion again, the accumulated value will decrease to 2. I:0.0/0 CTU
When the input makes one more OFF-to-ON transi- COUNT UP CU
tion, the accumulated value will drop to less than the Counter C5:0
preset value and the done output will turn off, de- Preset 100
Increase Accum 0 DN
energizing the done output and output O:0/0.
In practice, a count down instruction is most often used with a
count up instruction to form an up/down counter. In the up/ I:0.0/1 CTD
down counter shown in Figure 4-24, both counters share the COUNT DOWN CD
same address and the same preset and accumulated values. As a
Counter C5:0
result, the up counter increases the accumulated value every Preset 100
time a certain event occurs, while the down counter decreases Decrease Accum 0 DN
the same accumulated value if another event occurs.

Figure 4-24. Up/down counter configuration.

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.

Special Programming Issues


When using counter instructions in a MicroLogix PLC, you must
consider some special programming issues:
using a reset instruction to implement a self-resetting
counter
counting past the maximum count
reading fast input signals

Module 4 17
Timing, Counting, and Data-Handling Instructions

Self-Resetting Counter. A self-resetting counter is a counter I:0.0/0 CTU


that resets itself in the same scan after the accumulated value COUNT UP CU
reaches the preset value. Often a reset instruction is used in a Counter C5:2
counter circuit to implement a self-resetting action. However, Preset 2
this should be avoided in a MicroLogix 1000 unless certain pre- Accum 1 DN
cautions are taken, because the result will be an incorrect count C5:2/DN C5:2
value. Following is an explanation of why. RES
Figure 4-26 shows a reset instruction used to implement a self-
resetting counter. When the counters input turns on, the accu- Input 1
0
mulated count value will increase to 1. At the same time, the
CU (Bit 15) 1
counters count up bit, bit 15, will turn on because its action 0
follows that of the counters input. Since the count up bit re- DN 1
0
flects the status of the input signal, the PLC uses it to determine Reset 1
0
if the input signal has made an OFF-to-ON transition. It does
this by comparing the current status of the input signal to the Figure 4-26. A reset instruction used to implement a self-resetting counter.
value stored in the count up bit address.
Figure 4-27 shows the self-resetting counter circuit after several I:0.0/0 CTU
subsequent scans. If the input remains on in the scan following CU
COUNT UP
the first OFF-to-ON transition (point A), the MicroLogix will com-
pare this 1 value to the value stored in count up bit 15 in scan 1. Counter C5:2
Preset 2
Since the count up value is already a 1, the PLC detects that the Accum 2 DN
input has not made an OFF-to-ON transition. The controller will
C5:2/DN C5:2
continue to make this same comparison every scan (points B
and C). Therefore, when the input signal makes an off-to-on RES
transition (point D), the MicroLogix will know it because the A B C D
PLC will detect that the current status of the input is 1 and that Input 1
the previous status of the count up bit was 0. Since the PLC 0
senses an OFF-to-ON transition, it will increase its accumulated CU (Bit 15) 1
0
count value by one. In this circuit, the done bit will turn on DN 1
0
since the accumulated value now equals the preset value. Reset 1
0
Scan 1 2 3 4 5 6

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

go any higher. Therefore, it wraps the accumulated count back


around to 32,768 and starts counting up again. To count past
the +32,767 count value, you must cascade two counters, mak-
Input
ing sure that they self-reset in each scan. Counter Counter
1 2
When two counters are cascaded, they are programmed so that
one counter provides the input to the other counter (see Figure
4-29). This way, the second counter counts how many times the
first one has reached its preset value. Figure 4-30 shows two
Figure 4-29. Cascaded counter, where counter 1 provides the input to counter 2.
cascaded counters that implement a count to 100,000. These
cascaded counters have addresses C5:10 and C5:11, and their
programming works as follows:
The input to the first counter is the event to be counted,
while the input to the second counter is a contact that
references the first counters done bit. I:0.0/0 CTU
The first counter will increase its count every time the COUNT UP CU
input event occurs. The second counter will increase Counter C5:10
Preset 1000
its count every time the first counters done output DN
Accum 0
turns onthat is, every time the first counters accu-
mulated value equals its preset value.
C5:10/DN CTU
If the first counters preset value is set to 1000 and the COUNT UP CU
second counters preset value is set to 100, they will Counter C5:11
implement a count to 100,000. Preset 100
DN
Accum 0
Internal output B3:0/0 indicates when the count has
C5:11/DN B3:0/0
reached 100,000 because this internal turns on when
the second counters done output turns on.
The clear instruction resets the contents of the first C5:10/DN CLR
counters accumulated word to 0 every time its done CLEAR
bit is enabled, so that the first counter will reset to 0 Dest C5:10.2
every time it reaches a count of 1000.

Figure 4-30. Two cascaded counters that implement a count to 100,000.

20 Module 4
Timing, Counting, and Data-Handling Instructions

Job Aid 2-2 provides more information about cascading counters


Detected Not Detected Not Detected to count past the maximum count.
Detected Detected
Reading Fast Input Signals. If the input events to be counted
are happening at a rate faster than the scan, some of the inputs
will not be counted (see Figure 4-31). This is because a PLC
Inputs only detects inputs that are valid at the beginning of each scan.
It will not detect inputs that occur during the scan. If an applica-
SCAN SCAN tion requires the counting of fast inputs, you must use a high-
speed counter instruction to count them. This instruction is de-
Figure 4-31. If the input events to be counted are happening at a rate faster than signed to count fast input signal pulses at a frequency of up to
the scan, some of the inputs will not be counted. 6.6 kilohertz.

Module 4 21
Timing, Counting, and Data-Handling Instructions

4-3 Data Handling Instructions


This section discusses data-handling instructions. Data-handling
instructions are used to convert and move data within a Micro-
Logix PLC. Data-handling instructions are often used to inter-
face with field devices that supply or require data in BCD (bi-
nary coded decimal) form.
5 3
+ +
At the end of this section, you will know: (a) 0 1 0 1 0 0 1 1

BCD data-handling information


how to use a convert-from-BCD instruction
how to use a convert-to-BCD instruction
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9
how a move instruction operates USED USED COM COM

how a masked move instruction operates


how to apply ladder logic filtering to a BCD application
Decimal BCD

BCD Data-Handling Information 0 0000


1 0001
Before you can understand how BCD data-handling instructions 2 0010
work, you must first understand two fundamental BCD topics: 3 0011
(b)
4 0100
how BCD input data is sent from an input field device
5 0101
to a PLC
6 0110
how BCD output data is sent from a PLC to an output 7 0111
field device 8 1000
9 1001
Reading BCD Input Data. A BCD input device communicates
a decimal value to a PLC in binary coded decimal form. To
communicate this data, the device uses a 4-bit code containing Figure 4-32. (a) Two BCD thumbwheel switches communicating decimal values to
1s and 0s (see Figure 4-32). To send this code to the controller, a PLC in binary coded decimal form and (b) a decimal-to-BCD
conversion table.
the device requires 4 input connections to the PLCs input inter-

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.

5 Figure 4-33 shows a thumbwheel switch connected to the first


four input terminals of a MicroLogix PLC. This thumbwheel switch
will transmit the BCD-equivalent value of the number 5 to the
+
0 1 0 1
controller by providing a voltage to terminals 1 and 3, but not to
MSB LSB terminals 0 and 2. Note that the PLC will interpret this number
as 1010 instead of 0101, which is the actual BCD equivalent of
the decimal number 5. This occurs because of the way the switch
is wired. The BCD data will be stored in the input file in reverse
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 order, with the most significant bit of the BCD value in the least
USEDUSEDCOM COM
significant input bit position and vice versa.

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

Consequently, bits 0 through 3 of the integer file will 5 4 3 2


store the value 0101, which is the BCD equivalent of O:0
the number 5.
Writing BCD Output Data. A BCD output device works the DC IN VAC VAC VAC VAC
VDC O/0 VDC O/1VDC O/2 O/3VDC O/4 O/5 O/6 O/7
opposite of a BCD input. Figure 4-35 shows a seven-segment +24

indicator connected to the output interface of a MicroLogix 1000.


Like an input, a BCD output device requires four output con-
nections to receive a binary coded decimal value from a PLC. 0 1 0 1
The indicator is wired so that its least significant bit is wired to
terminal 5 and its most significant bit is wired to terminal 2.
Figure 4-36 shows the ladder program used to transfer the BCD
data from the integer file to the output device in the correct
order. This program uses internal contacts to reference the BCD Figure 4-35. A seven-segment indicator connected to a MicroLogixs output interface.
data stored in the integer file word. The rungs in this program
energize based on the status of their reference bits. This trans-
fers the BCD data to the output file via the output coils. The
ladder program reverses the data from the integer file so that it
is in the appropriate order and place in the output file.
BCD I/O Utilization. Using BCD input and output devices can N7:0/0 O:0/5
tie up a MicroLogix 1000s I/O interfaces. If an application re-
quires five thumbwheel switches and three seven-segment indi-
cators, 20 input terminals and 12 output terminals must be used N7:0/1 O:0/4
3 2 1 0
for just the BCD devices alone. This leaves no room for other 0 1 0 1 N7:0
inputs or outputs.
N7:0/2 O:0/3 3 2 1 0
As an alternative to BCD I/O devices, you can use a MicroView 0 1 0 1 O:0
operator interface instead. This MicroView interface inputs BCD
data directly to the controller, replacing the need for thumb- N7:0/3 O:0/2
wheel switches, seven-segment indicators, and other similar BCD
devices. This interface connects directly to the MicroLogixs RS-
232 communication channel, meaning that it does not utilize
any of the I/O terminals. The MicroView interface comes in Figure 4-36.Ladder program used to transfer the BCD data from the integer file to
both a handheld and a panel-mounted model. the output device in the correct order.

24 Module 4
Timing, Counting, and Data-Handling Instructions

FRD Convert-From-BCD Instruction


FROM BCD
A convert-from-BCD instruction is a block instruction that
Source N7: 0 BCD converts the BCD data stored in a MicroLogixs data file into its
Dest N7: 1 Decimal equivalent decimal value (see Figure 4-37). This instruction block,
Equivalent which is abbreviated by the letters FRD, contains two pieces of
information:
Figure 4-37. A convert-from-BCD instruction.
a source location
a destination location

7 6 5 4 3 2 1 0 The source location indicates where the BCD data to be con-


N7:0 verted is located. The destination location indicates where the
0 0 0 1 0 1 0 1 BCD 15 decimal-equivalent value should be stored.
Figure 4-38 shows the first eight bits of integer file word 0,
which contains the BCD-equivalent of the decimal number 15.
FRD This data is represented as two sets of 4-bit codes, with one
setbits 4 through 7 being the BCD equivalent of the num-
7 6 5 4 3 2 1 0 ber 1 (0001) and the other setbits 0 through 3being the
N7:1 BCD equivalent of the number 5 (0101).
0 0 0 0 1 1 1 1 Binary 15
Although the data in word 0 is supposed to represent the deci-
Figure 4-38. A convert-from-BCD instruction used to convert the BCD number mal number 15, the MicroLogix does not interpret it that way.
15 into the binary equivalent of the decimal number 15. Because a PLC is a straight binary machine, it interprets the data
in word 0 as the binary number 00010101, which is actually the
decimal number 21. As a result, you must use a convert-from-
BCD instruction to convert the BCD value 15 (00010101) into
the binary equivalent of the value 15 (00001111) and store this
TOD
converted value in a new word location (N7:1).
TO BCD
Source N7: 7 Decimal
Convert-To-BCD Instruction
Dest N7: 9 BCD
Equivalent A convert-to-BCD instruction looks like a convert-from-BCD
instruction, but it is abbreviated TOD (see Figure 4-39). A convert-
to-BCD instruction converts data stored in decimal form into its
Figure 4-39. A convert-to-BCD instruction.

Module 4 25
Timing, Counting, and Data-Handling Instructions

equivalent BCD value. This instructions source word contains the 7 6 5 4 3 2 1 0


decimal value to be converted, while its destination word indicates N7:7
0 0 0 0 1 1 1 1
Binary 15
where the converted BCD-equivalent value should be stored.
A convert-to-BCD instruction performs the opposite function of
TOD
a convert-from-BCD instruction. Figure 4-40 shows a convert-
to-BCD instruction that takes the binary-equivalent decimal value
15 (00001111) and converts it into the BCD-equivalent form of 7 6 5 4 3 2 1 0
N7:9
the number 15 (00010101). It then stores this BCD number in a 0 0 0 1 0 1 0 1
BCD 15
new word. Thus, the convert-to-BCD instruction converts the
decimal data into its BCD-equivalent value, which can then be Figure 4-40. A convert-to-BCD instruction used to convert the binary-equivalent
sent to a BCD output device. decimal value 15 (00001111) into the BCD equivalent form of the
number 15 (00010101).
Move Instruction
Like BCD instructions, a move instruction also comes in a block
format with both a source and a destination parameter (see Fig-
ure 4-41). A move instruction, however, simply moves data from MOV
the source word and puts it into the destination word. It does not MOVE
Variable Source N7:3
convert or manipulate the data in any way. The data in a move
Constant
blocks source parameter can be either a variable value stored in Dest N7:11
a word, which changes during program execution, or a fixed
constant value, which is entered during programming.
Figure 4-41. A move instruction.

Masked Move Instruction


A masked move instruction is used to manipulate data as it is
moved (see Figure 4-42). A masked move instruction operates
like a regular move instruction, except that a masked move lets
you filter out data that you do not want to move. The mask MVM
parameter specified in the instruction block is what performs MASKED MOVE
this filtering process. This mask parameter can be either a word Source N7:0
Word Address
address location or a hexadecimal constant. Mask F00F
Dest N7:10 Hex Constant

Figure 4-42. A masked move instruction.

26 Module 4
Timing, Counting, and Data-Handling Instructions

The mask parameter of a masked move instruction specifies


which bits in the source word are to be moved to the destina-
tion word and which bits in the source word are to be masked
that is, not moved (see Figure 4-43). If a bit in the mask word
contains a 1, then the corresponding bit in the source word will
Source be moved to the destination word. Conversely, if a bit in the
mask contains a 0, then the corresponding bit in the source
Moved 1 MASK 0 Not
moved word will not be moved to the destination word.
MASKED
As an example, Figure 4-44 shows a masked move instruction
Destination that moves only the first four and last four bits of data in the
source word to the destination word. The instruction operates
Figure 4-43. Mask parameter of a masked move instruction. like this:
The first four and last four bits of the mask word are
set to 1, while the other bits are left as 0.
When the masked move instruction is energized, only
the first four and last four bits of data will be moved to
the destination word.
The middle bits in the destination word will not be
replaced. They will remain in their previous state, which
Source 1 0 1 1 1 1 0 0 1 1 0 0 0 1 0 1 in this case was all zeros.
The bits in the mask register are set to either 1 or 0 in groups of
Mask 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
four using the hexadecimal equivalent of each groups binary
pattern. Thus, you would use the letter F to indicate that a group
Destination 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 of four bits is set to one. You would use a 0 to indicate that a
group of four bits is set to zero. This notation is what you see as
Figure 4-44. A masked move instructions source, mask, and destination values. the mask value in the masked move instruction. Job Aid 4-3
provides more information on using mask codes to filter data
and input BCD information.

Module 4 27
Timing, Counting, and Data-Handling Instructions

Ladder Logic Filtering

Ladder logic filtering prevents BCD conversion errors due to


the difference in the BCD device and PLC processing speeds.
Figure 4-45 shows a thumbwheel switch that is sending the BCD
7
number 7 to a MicroLogix 1000. The PLC sees this number 7 as +
the BCD value 0111. Note that the thumbwheel switch is wired 0 1 1 1
so that its least significant bit corresponds to the least significant MSB LSB MSB LSB
3 2 1 0
input word bit and its most significant bit corresponds to the 0 1 1 1 I:0.0
most significant input word bit. LSB MSB

If the thumbwheel switchs value changes from 7 to the number


NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5
8, which has the BCD binary pattern of 1000, the device will USED USED COM COM

send the new number to the PLC. Because of its mechanical


nature, however, a BCD device operates slowly as compared to Figure 4-45. A thumbwheel switch sending the number 7 to a MicroLogix.
a MicroLogix 1000. Thus, the BCD device may not be able to
send all of its new data to the PLC within the period of one scan.
In fact, it may take the device several scans to provide the BCD
pattern for the selected number. During this time, the output of
the BCD device may specify an invalid BCD bit pattern.

If the switch sends its terminal 3 data to the input terminals first,
before it sends any of its other new data (see Figure 4-46), and
then the PLC performs a scan, the controller will read the BCD
Slow 8
number 1111. This is not a valid BCD value. Thus, if the MSB LSB
+
MicroLogix tries to perform a BCD conversion on this data once 1 1 1 1 3 2 1 0
it has been input to the controller, an overflow will occur in bit 1 1 1 1 I:0.0
1 of status file word 0 (the math overflow bit). This overflow Fast
will cause an error fault at the end of the scan, halting the PLCs FRD Overflow S2:0/1
operation. As a result of this invalid BCD number, the PLC will
store a +32,767 in the destination word of the convert-from- Error Fault
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5
BCD instruction. USED USED COM COM
+32,767

Figure 4-46. The thumbwheel switchs value changing from 7 to the number 8.

28 Module 4
Timing, Counting, and Data-Handling Instructions

To avoid this situation, you must apply ladder logic filtering to


the circuit. Ladder logic filtering ensures that the data received
from the BCD device is a valid BCD code. This way, the PLC
will wait until it has received all of the updated BCD input data
before it performs a BCD-to-binary conversion.
Figure 4-47 shows a circuit with ladder logic filtering. It contains
three rungs, which perform the following functions:
FRD The first rung contains a convert-from-BCD block that
FROM BCD converts the BCD data in word N7:0 to its decimal
Source N7:0 binary equivalent and stores it in word N7:1.
Dest N7:1
The second rung contains an examine-if-closed con-
Overflow Flag Overflow Trap tact that references the MicroLogixs status overflow
S2:0/1 S2:5/0
bit. If this contact is on, the convert-from-BCD instruc-
U
tion in rung one has read an invalid BCD code in its
S2:0/1 MOV
source register. This contact drives an unlatch coil that
MOVE
Source N7:1 resets the overflow condition so that the MicroLogix
will not fault at the end of the scan. This will allow the
Dest N7:10
PLC to keep reading the input data.

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

4-5 Job Aids

Job Aid 4-1: Self-Resetting Counter Programming Methods


Because a reset instruction cannot be used alone to implement a self-resetting counter circuit, you must use another programming
method to implement this type of circuit. Following are three methods that can be used to create a self-resetting counter.

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.

I:0.0/0 I:0.0/0 B3:0/0


I:0.0/0 TON
CTU TON
CTU
TON
CTU COUNTT4:0
TIMER UP CU OSR COUNTT4:0
TIMER UP CU
TIMER T4:0
COUNT UP CU Time Base
Counter C5:101 Time Base
Counter C5:10
Time Base
Counter C5:101 Preset 500
60 DN Preset 500 DN
Preset 500
60 DN Accum 0 Accum 0
Accum 0

C5:I0/DN MOV C5:I0/DN C5:10


C5:I0/DN CLR MOVE
CLEAR Source 0 RES
Dest C5:10.ACC Dest C5:10.ACC (Resets accumulated
value to 0)
(Clears accumulated value)
(Moves a constant of 0 to the
accumulated value)

Module 4 31
Timing, Counting, and Data-Handling Instructions

Job Aid 4-2: Counting Past the Maximum Count


When a counter instruction reaches the end of its range of count values (32,768 to +32,767), it wraps the accumulated count value
back around and starts counting from the other side. The following graphic illustrates what occurs when a counter reaches its
maximum count of +32,767:

32,768 Counter +32,767

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

Job Aid 4-3: Using Mask Codes to Filter BCD Data


You can use a masked move instruction to input data to a PLC from BCD devices connected to odd input terminal bit locations.
For example, the following diagram shows a thumbwheel switch that is connected to input terminals 2, 3, 4, and 5 of a 16 I/O
MicroLogix 1000:

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

Not Read Data


Shifted 2 Times Input Signal Shift Command Shifted 2 Times Reset Shift to 0
Q2:99 I:0.0/9 B3:0/2 C5:0/DN B3:0/0
1 LBL

Shifted 2 Times Reset Shift to 0 Shift Command


C5:0/DN B3:0/0 B3:0/2
2

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

Following is a detailed explanation of the function of each of the ladder rungs:


Rung 0: The XIC contact I:0.0/9 in this rung references an input event that will trigger the MVM instruction, which reads
and transfers the thumbwheel switchs BCD input data to word N7:0. If the input data is to be read continuously, rather
than conditionally, this XIC contact should be omitted. If this is the case, the I:0.0/9 contacts in rungs 1 and 4 should be
omitted as well.
Rungs 1, 2, 4, and 5: Rungs 1 and 2 implement an oscillating OFF-to-ON/ON-to-OFF input command for the bit shift right
(BSR) instruction in rung 3 by referencing the output of the count up instruction, also located in rung 3. The counter
keeps track of how many times the BSR instruction has been executed. These rungs work as follows:
If the BSR instruction has been executed less than two times, rung 4 will jump the program to rung 1, which resets rung
2 (if rung 2 is already energized). Subsequently, rung 2 will energize, meaning that the BSR instruction will be executed.
If the BSR instruction has already been executed two times, then rung 4 will not be energized, meaning that program
execution will move to rung 5. Rung 5 resets the counters accumulated value.
Rung 3: The BSR instruction shifts the BCD data bits in the integer word. When the BSR blocks input turns from OFF to
ON, the block will shift the contents of word N7:0 one bit to the right. The block uses the following parameters to
complete this operation:
The file parameter (N7:0) indicates where the data to be shifted is stored.
The control parameter (R6:0) stores control data about the BSR instruction (e.g., EN output, DN output, length, etc.).
The length parameter (6) specifies the file word bit into which data will be shiftedi.e., word N7:0, bit 5 (the sixth bit).
The bit address parameter (N7:0/15) specifies the location of the data to be shifted into the specified file word bit. This
bit address will always contain a 0, so each time the BSR instruction is executed, the bits in word N7:0 will be shifted
one bit to the right and a 0 will be stored in bit N7:0/5.
The counter in this rung simply counts the number of times the BSR instruction has been executed. The counters done
output will be energized when the BSR instruction has been executed two times.
Rung 6: This rung implements the BCD-to-decimal conversion of the data stored in word N7:0. Once the data has been
shifted into the proper position, the convert-from-BCD block will convert the BCD number into its equivalent decimal
value. This rung also contains ladder logic filtering to prevent an overflow fault due to an invalid BCD number. Thus,
once the PLC determines that a valid BCD number has been converted, the move instruction will transfer the newly
converted data to word N7:10, where it will be stored for use by the rest of the control program.
Note that this program could be programmed as a subroutine rather than as part of the main control program if you did not want
to include it in the main program.

Module 4 35
M O D U L E F I V E

This final module covers two more categories of programming

COMPARISON AND instructions: comparison instructions and flow control instructions.


Comparison instructions are used in a MicroLogix 1000 to compare
the values stored in two memory locations. Flow control instructions
are used to change the order of execution of instructions in a ladder
FLOW CONTROL

5
program. This module contains four sections:
1. Comparison instructions

INSTRUCTIONS 2. Flow control instructionsalter sequence


3. Flow control instructionshalt execution
4. Flow control instructionsalter I/O scan


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

5-1 Comparison Instructions


Comparison instructions compare the values stored in two mem-
ory locations. These two values can be the data stored in two
different word locations, or one can be the data stored in a
word and the other can be a constant value. EQU
At the end of this section, you will know: EQUAL
Source A N7:0
the equal instruction Source B N7:1
other basic comparison instructions that work like the
equal instruction Figure 5-1. An equal instruction.
the masked comparison for equal instruction
the limit test instruction

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

An equal instruction is always the first instruction programmed in


a rung (see Figure 5-3). This instruction looks at the data stored in
the source A word, which may hold a value such as the input
value from a set of thumbwheel switches. The equal instruction
EQU I: 0.0/0 O:0/0 then compares this source A data to the value indicated by source
EQUAL B. If these two data values are equal, the equal block energizes,
Source A N7:1 providing continuity to the rest of the rung. If the other input
conditions in the rung are satisfied, the output will turn on. If the
Source B 587
source A and B values are not equal, then the equal block will not
A=B be energized (see Figure 5-4). As a result, the output will not be
energized, even if the other input conditions are satisfied.
Figure 5-3. An equal instruction programmed in a ladder rung.
Other Basic Comparison Instructions
The five other comparison instructions used in a MicroLogix
1000 work much like the equal instruction. All of these other
comparison instructions are block instructions that specify source
A and source B values. As in an equal block, source A must be
a word location, while source B can be either a word location or
a constant. The other comparison instructions are as follows:
not equal instructionenergizes its output if the
EQU I: 0.0/0 O:0/0
source A and B values are not equal to each other
EQUAL
Source A N7:1 less than instructionenergizes its output if the val-
ue in source A is less than the value stored in source B
Source B 587
less than or equal instructionenergizes its output
AB
if the source A value is either less than or equal to the
source B value
Figure 5-4. If the source A and B values are not equal, then the equal block will not
be energized. greater than instructionenergizes its output if the
value stored in source A is greater than the value stored
in source B

Module 5 3
Comparison and Flow Control Instructions

greater than or equal instructionenergizes its


output if the source A value is greater than or equal to
the source B value

Masked Comparison For Equal Instruction


MEQ
A masked comparison for equal instruction, which is shown
MASKED EQUAL
in Figure 5-5, is abbreviated as MEQ in a MicroLogixs ladder Source N7:0
program. This instruction compares part of the word specified
Mask N7:1
by the source location with the value specified by the compare
Compare N7:2
location. It uses a mask value to filter out those parts of the
source value that will not be compared. An MEQ instructions
source, compare, and mask parameters work as follows: Figure 5-5. A masked comparison for equal instruction.

The source parameter specifies the word location of


the data to be compared. This is equivalent to the source
A parameter in an equal instruction.
The mask parameter specifies either the word location
of the mask value or the mask value itself. If the mask
value is entered directly into the MEQ block, then it
will be expressed in hexadecimal form. If the mask
MEQ
parameter specifies a word location, then the decimal
MASKED EQUAL
value in the word will be displayed in the block in
hexadecimal form. Source N7:0
N7:10
The compare parameter specifies either a word loca- Mask 000F0 0000 0000 1111 0000
tion or a constant value. The compare parameter is 0 0 F 0
much like an equal instructions source B parameter. Compare N7:2

When an MEQ instruction is enabled, it takes the value stored in


the source word and then masks out the bits denoted by zeroes
Figure 5-6. When an MEQ instruction is enabled, it masks out the source word bits
in the mask (see Figure 5-6). This leaves only the bits that are denoted by zeroes in the mask.
specified by ones in the mask. The block then compares this
masked value to the compare value. If the two bit patterns de-
fined by the mask are equal, the blocks output turns on.

4 Module 5
Comparison and Flow Control Instructions

Pressure Volume An MEQ instruction is useful for applications such as decoding


TWS #1 TWS #2
data from multiple thumbwheel switches. Figure 5-7 shows an
example of this type of application in which two thumbwheel
3 5 switches are connected to terminals 0 through 7 of a MicroLogix
1000. The first thumbwheel switch sends pressure data to the
+ +
PLC, while the second thumbwheel switch sends volume data.
The MicroLogix stores this data in the first eight bits of file N7:0.
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 Figure 5-8 shows a ladder program in which output O:0/0 turns
USED USED COM COM
on when the pressure level is 3. The program works like this:
5 3
TWS #2 TWS #1 The source value for the masked comparison for equal
instruction is integer file 0 (N7:0).
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 N7:0
The mask value is 000F, which will mask out all but
the first thumbwheel switchs bits.
Figure 5-7. An MEQ instruction used to decode data from multiple thumbwheel
switches. The compare value is the decimal value 3, which is
equivalent to the binary value 11.
When the masked comparison block is energized, it
compares the masked pressure value (0011) with the
MEQ
O:0/0 compare value (0011). Because they are equal, the
Source N7:0
instruction block will energize the rung.
Mask 000F
Compare 3 Note that the masked comparison for equal instruction only com-
5 3
pares the bits that are specified by ones in the mask. If the
TWS #2 TWS #1 source word had contained any number other than 3, the com-
parison would have been false.
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 N7:0
If you wanted to compare the volume data instead, you would
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 Mask 000F
have to specify a hex mask with the value 00F0 (Figure 5-9).
This mask value will only pass and compare the data from the
0 0 1 1
second thumbwheel switch. You would also have to enter an 80
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Compare 3 10 as the compare value rather than 5. This is because the decimal
value 80 translates into the binary value to be compared (i.e.,
Figure 5-8. A ladder program in which output O:0/0 turns on when the pressure the value 0101 located in bits 4 through 7). Because the com-
level is 3.

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

Figure 5-12 illustrates is an example of how a limit test instruc-


LIM To rest tion can be used in a process application to ensure that an oper-
LIMIT TEST of
logic ator enters a valid parameter into the PLC. In this application, the
Low Lim 0 limit test instructions test value is the word location of the data
Test N7:8
High Lim 10000
entered by the operator (word N7:8). The low and high limit
values are the minimum and maximum possible valid entries.
Thus, if the test value falls within the valid entry range, the limit
test instruction will provide continuity to the rest of the rung.
Figure 5-12. A limit test instruction used to ensure that an operator enters a valid
parameter into the PLC.

Module 5 7
Comparison and Flow Control Instructions

5-2 Flow Control InstructionsAlter Sequence


A MicroLogix 1000 uses three types of flow control instructions
those that alter the sequence of the control programs execu-
tion, those that halt its execution, and those that alter the I/O
JMP LBL
scan reading. This section covers the first type, those that alter
the sequence of evaluation of the rungs in a ladder program. At
the end of this section, you will know:
the jump instruction Figure 5-13. A jump instruction and a label instruction
the jump to subroutine instruction
the master control reset instruction

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

Figure 5-15 illustrates how a jump instruction can be used to


control the manual or automatic operation of a machine. In this
example, if the selector switch connected to input 0 is off, the
machine will be in manual mode. If the switch is on, the ma-
chine will be in automatic mode. By using jump instructions,
you can program two sets of instructionsone set for when the
machine is in manual mode and another set for when the ma-
chine is in automatic mode. This avoids having to interlock the
Man Auto
L1 L2 Auto manual and automatic programming in all of the ladder instruc-
I:0.0/0 99
tions. Following is a description of how this program works:
I/0 JMP
OFF (Manual) Manual If the selector switch is on (automatic mode), the jump
Man Operation
ON (Auto) I:0.0/0 999 99 coil in rung one will be energized.
JMP
Auto
When the jump 99 coil is energized, the PLC will jump
99
LBL the program execution to the rung with label 99.
Auto When the controller jumps to label 99, it will start ex-
999 Operation B3:0/0 ecuting the automatic control program, thereby skip-
LBL
ping the manual control program.
Conversely, if the selector switch is off (manual mode),
Figure 5-15. A jump instruction used to implement manual/automatic machine
the controller will execute the manual control program
operation.
because it will not jump over it.
When the PLC finishes the manual program, the con-
troller will encounter a jump 999 instruction that will
cause it to jump over the automatic control program.
When the controller jumps over the automatic pro-
gram, it will jump to the rung with label 999. This rung
contains a dummy coil that does not control any-
thing. The purpose of this rung is to give the control-
ler some place to jump to when it skips the automatic
operation at the end of the program.

Module 5 9
Comparison and Flow Control Instructions

Jump instructions affect program execution in a variety of ways.


A jump instruction that jumps forward reduces the program scan
time, since it omits the execution of part of the ladder program.
Jumping backwards has the opposite effect. It increases the scan
JSR
time, since it causes the PLC to repeat part of the control pro-
JUMP TO SUBROUTINE
gram. Both jumping forward and backward are valid uses for
jump instructions. In fact, you can even jump forward or back- SBR File Number 6
ward several times to the same label using multiple jump in-
structions. Nevertheless, you should be careful not to jump back- Figure 5-16. A jump to subroutine instruction.
wards an excessive number of times. If you do, the processors
watchdog timer may time out and cause the controller to fault.

Jump To Subroutine Instruction


A jump to subroutine instruction (see Figure 5-16) is used to
call a subroutine from the main ladder program. When a jump
to subroutine instruction in the main ladder program is enabled, JSR
it causes the program to jump to the specified subroutine locat- JUMP TO SUBROUTINE
ed in the subroutine storage area. The controller then executes
this subroutine until it finds a return or end instruction. At that SBR File Number 6
point, it jumps back to the main program and resumes program
execution with the instruction immediately following the jump
to subroutine instruction. SBR
SUBROUTINE
Three instructions are associated with a jump to subroutine in-
struction (see Figure 5-17). These are:
the subroutine instruction RET
RETURN
the return instruction
the end instruction
END
Subroutine Instruction. A subroutine instruction should be
programmed at the beginning of the subroutine being called. Figure 5-17. A jump to subroutine instruction and its three associated instructions
Although this instruction is not technically necessary, it is a good the subroutine instruction, the return instruction, and the end
practice to use it for programming clarity. instruction.

10 Module 5
Comparison and Flow Control Instructions

Return Instruction. A return instruction is used to tell the


PLC to stop executing the subroutine and return to the main
File 2 (Main Program)
JSR
program. This instruction terminates a subroutine, either condi-
I:0.0/0
JUMP TO SUBROUTINE tionally or unconditionally, before the whole subroutine pro-
SBR File Number 6 gram has been executed. If a subroutine does not contain a
I:0.0/3 I:0.1/1 O:0/4
File 6 (SBR) return instruction, the controller will execute the subroutine until
SBR it reaches the end instruction in the subroutines file.
I:0.1/2 SUBROUTINE
Subroutine End Instruction. An end instruction is always present as the
Program
RET
last instruction in a subroutine file, just as it is in the main ladder
RETURN program and other program files. This instruction lets the PLC
Subroutine know that it has finished the subroutine.
Program(cont'd)

END Jump to Subroutine Operation. When a jump to subroutine


instruction is enabled, the controller will jump to the subroutine
specified and start executing it (see Figure 5-18). If the PLC
Figure 5-18. A jump to subroutine instruction that jumps to subroutine 6. encounters an energized return instruction in the subroutine, it
will jump back to the main program and pick up where it left
off. If it does not find an energized return instruction, the con-
troller will wait until it gets to the end of the subroutine before
jumping back to the main ladder program. When a subroutine is
executed, its outputs remain in their last state, either on or off,
Main until the subroutine is executed again.
Program Level 1
SBR 6 Level 2 As explained in Module 1, a MicroLogix 1000 stores the main
SBR 7 Level 3
Level 8
JSR SBR
SBR 8
SBR 13 ladder program in file 2 of the program file section. It stores the
SBR subroutines in files 6 through 15 of this same section. Each of
SBR
JSR7 SBR
JSR8
the subroutine files can store one subroutine, for a total of 10
JSR9 subroutines. Although these subroutines do not need to be pro-
JSR
RET grammed in the order in which they are called, you should do
RET
RET
RET so anyway.
In a MicroLogix 1000, you can nest subroutines (see Figure 5-19).
Nesting involves using one subroutine to call another subrou-
Figure 5-19. Nested subroutines in a MicroLogix 1000 program.
tine. You can do this up to eight times in a MicroLogix program,

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

Master Control Reset Instruction


A master control reset instruction, which is also called an
MCR MCR instruction (see Figure 5-21), creates a fence around a group
of ladder rungs. If the MCR instruction is energized, then the
MCR energized fenced
instructions executed controller will execute the fenced instructions. If not energized,
MCR not energized fenced the controller will not execute the fenced instructions.
instructions not executed
Master control reset instructions are always used in pairs to form
a conditional fence around a group of rungs. If the input logic
Figure 5-21. A master control reset instruction. to the first MCR is energized, the programmed logic within the
fence will be executed. If the input logic to the first MCR is not
satisfied, then the controller will skip the fenced logic and re-
sume program execution after the second MCR instruction. This
second MCR instruction must be unconditional, meaning that it
is always active because it has no driving input logic.
When an MCR fence is deactivated, all of the nonretentive out-
puts within the MCR fence will turn off, regardless of the status
MCR of their input conditions. Only the retentive outputs will retain
TON their last status, either ON or OFF.
TIMER ON-DELAY EN
Timer T4:0 DN Figure 5-22 shows a ladder program with two fenced timers to
Time Base 1.0
Preset 10 demonstrate how MCRs work. One of these timers is an ON-
Accum 0 delay timer; the other is a retentive timer. Both timers are locat-
MCR
RTO Fence ed within the MCR fence. This means that neither timer will start
RETENTIVE TIMER ON EN timing, even if its input is on, unless the first MCR instruction is
Timer T4:1 DN on. When the first MCR instruction turns on, both timers will be
Time Base 1.0
Preset 10 enabled if their inputs are on. Thus, the timers will start timing,
Accum 0 and if the MCR zone stays on long enough, both timers will time
MCR out. When the first MCR eventually turns off, the ON-delay tim-
ers output will turn off, since all nonretentive outputs in an
MCR fence are reset when the fence turns off. The retentive
timers output will remain on.
Figure 5-22. A ladder program with two fenced timers.

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

5-3 Flow Control InstructionsHalt Execution


TND
This section discusses flow control instructions that interrupt the
execution of the control program. Two flow control instructions
Figure 5-24. A temporary end instruction. perform this type of function. They are:
the temporary end instruction
the suspend instruction

Temporary End Instruction


A temporary end instruction (see Figure 5-24) is a coil in-
struction that stops the execution of the control program at the
Outputs Inputs
point where the temporary end coil is located. It works as fol-
lows (see Figure 5-25):
TND
If the temporary end coil is on, the PLC will stop exe-
cuting the control program at the temporary end in-
struction and perform an update of the outputs.
END
Program
The PLC will then begin its next scan by reading the
inputs and executing the control program again, start-
Figure 5-25. The operation of a temporary end instruction. ing from the top.
If the temporary end coil is not on as the PLC per-
forms this next scan, the controller will continue with
its scan until it reaches either the end of the program
or another energized temporary end instruction.
Operator Entry
Temporary end instructions are often used to test or trouble-
TND shoot certain parts of a control program. They allow you to test
Conveyor Belt part of the control program with the inputs and outputs on-line,
without having to run through the rest of the program. For ex-
END
ample, Figure 5-26 shows a control program with two sections
one section that evaluates an operators entry values and anoth-
Figure 5-26. A control program with two sectionsone section that evaluates an
er section that runs a conveyor belt. If you want to test the
operators entry values and another section that runs a conveyor belt.

Module 5 15
Comparison and Flow Control Instructions

operator entry section without turning on the conveyor, then SUS


you would program an unconditional temporary end after the SUSPEND
first section. This allows you to run just the top section over and Suspend ID 112
over again until you know that it is working properly. After that,
you can take out the temporary end instruction and run the Figure 5-27. A suspend instruction.
whole program.
You can use a temporary end instruction in the main program
and any of its subroutines stored in files 6 through 15. However,
you cannot use a temporary end instruction in the user-error SUS
fault routine (file 3), the high-speed counter interrupt routine
SUSPEND
(file 4), or the selectable timed interrupt routine (file 5). If you
Suspend ID 112
do, the PLC will generate a fault.
Status
Suspend Instruction (File 2)
1 1 2 Word 7
Like a temporary end instruction, a suspend instruction (see
Figure 5-27) is used for testing or troubleshooting a control pro-
Figure 5-28. When a suspend instruction is activated, its ID number is stored in
gram. A suspend instruction causes the controller to stop exe- word 7 of the status file.
cuting the control program and enter an idle mode. When it
does this, the controller de-energizes all outputs. However, it
does not clear the bits in the status file. This allows you check
the status bits to retrieve information about the controllers op-
eration and why it stopped.
A suspend instruction has an ID number that can range be-
tween 32,768 and +32,767. When a suspend instruction is acti-
vated, its ID number is stored in word 7 of the status file (see
Figure 5-28). This indicates where the controller was in the con-
trol program when its operation was suspended.
A suspend instruction is useful, for example, for halting the con- S2:0/1 SUS
trol program when an overflow occurs to allow troubleshoot- SUSPEND
Suspend ID 112
ing. To do this, you would program a suspend instruction, such
as the one in Figure 5-29, which operates as follows: Figure 5-29. A suspend instruction used to halt the control program when an
overflow occurs to allow troubleshooting.

16 Module 5
Comparison and Flow Control Instructions

The suspend instructions input logic is a contact ref-


erencing a math overflow bit (S:0/1).
If this overflow bit is energized, the suspend instruc-
tion will be energized. Hence, the controller will halt
JSR the program execution.
JUMP TO SUBROUTINE
SBR #7 At this point, you can review the logic programmed
SBR File Number 7
before the suspend instruction to see why the over-
SUS flow occurred.
SUSPEND
Check The ID number, which is 112 in this case, indicates
Suspend ID 223
that the suspend was triggered by a math overflow.
Other suspend instructions may have different IDs to
indicate other reasons for the program halt.
You can also use a suspend instruction after a subroutine to
Figure 5-30. A suspend instruction used after a subroutine to allow a check of the
allow you to check the subroutines data before resuming the
subroutines data before resuming main program execution.
main program (see Figure 5-30). In some critical applications,
you may also use one or more inputs to drive one or more
suspend instructions. This kind of programming turns off the
outputs if certain critical error conditions occur.

Module 5 17
Comparison and Flow Control Instructions

5-4 Flow Control InstructionsAlter I/O Scan


This section discusses two flow control instructions that alter IIM
the I/O scan evaluation of the controller. These are: IMMEDIATE INPUT w/MASK
Slot I:0.0
the immediate input with mask instruction
Mask 000F
the immediate output with mask instruction
Figure 5-31. An immediate input with mask instruction.
Immediate Input With Mask Instruction
An immediate input with mask instruction , which is abbre-
viated as IIM, interrupts program execution to update the spec-
ified input data (see Figure 5-31). When energized, an immedi-
ate input with mask instruction masks the data in the specified
input word to obtain just the data to be updated. Then it inter-
rupts normal program execution to store this data to the input
file. Thus, an immediate input instruction updates input data
without having to wait until the beginning of the next scan.
IIM
In an immediate input instruction, the slot parameter indicates
IMMEDIATE INPUT w/MASK
the input word to be updated. This will be either I:0.0 or I:0.1. Slot I:0.0
The mask specifies which bits will be masked. This mask, which Mask 000F
is expressed in hexadecimal, works like the mask value used by
the masked move instruction.
An immediate input with mask instruction works as follows (see
Figure 5-32):
1111 0110 1101 1100 Input Status
When energized, an immediate input with mask in-
0000 0000 0000 1111 Mask
struction checks the inputs mapped to the specified
word for their current status. 1100

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

L1 L2 It then stores this data to the input word denoted by


LS
I/2 the slot parameter. The input bits that are not masked
are not updated; thus, these bits are left in their previ-
IIM ous state.
IMMEDIATE INPUT W/MASK
Slot I:0.0 The PLC uses the updated input data to evaluate all the
Mask 0004 rungs located after the immediate input instruction.
Figure 5-33 shows an example of an IIM application in which a
limit switch is connected to input terminal 2 of a MicroLogix
1000. To update the data about this input during the ladder
15141312 1110 9 8 7 6 5 4 3 2 1 0
0000 0000 0110 0100 Input Status program, the program contains an IIM instruction whose slot
0000 0000 0000 0100 Mask parameter is I:0.0, since this is the input word that maps the
limit switch. The IIM instructions mask value is 0004 to mask
0000 0000 0000 0100
out all but the data for bit 2. Thus, if the limit switch was off
To I:0.0/2 when the PLC started its scan but has since turned on, the im-
mediate input instruction will interrupt the scan to read the cur-
Figure 5-33. An immediate input with mask block used to update the status of a
rent status of the limit switch. It will then update the new data
limit switch connected to input terminal 2 of a MicroLogix 1000.
about the limit switchs logic status in address I:0.0/2. The rest
of the program will now use this updated input data.
The mask address specified in an IIM instruction determines how
many inputs will be updated by the instruction. To update all of
IIM
IMMEDIATE INPUT w/MASK
the inputs for a 16 I/O MicroLogix, you must specify a slot param-
eter of I:0.0 and a mask value of 03FF. This will update all 10
Slot I:0.0
input bits of the MicroLogixs input file. To update all the input
Mask FFFF
bits of a 32 I/O MicroLogix, you must program two consecutive
IIM immediate input instructions (see Figure 5-34). The first instruc-
IMMEDIATE INPUT w/MASK tion must have a slot parameter of I:0.0 and a mask of FFFF to
Slot I:0.1 update all the bits of this word. The second instruction must have
Mask 000F a slot parameter of I:0.1 and a mask of 000F, since a 32 I/O
MicroLogix only uses the first four bits of word I:0.1 for inputs.
Figure 5-34. Two consecutive immediate input with mask instructions used to update
all the input bits of a 32 I/O MicroLogix.

Module 5 19
Comparison and Flow Control Instructions

Immediate Output With Mask Instruction


IOM
An immediate output with mask instruction, which is ab-
IMMEDIATE OUTPUT w/MASK
breviated as IOM, interrupts program execution to update the Slot O:0
specified output data, which is located in output word O:0 (see Mask 003F
Figure 5-35). When energized, an immediate output instruction
updates the outputs specified by the mask. It interrupts the nor- Figure 5-35. An immediate output with mask instruction.
mal program execution to store this data to the output file. Like
an immediate input instruction, an immediate output instruction
specifies slot and mask parameters. The slot parameter indicates
the output word to be updated. The mask indicates which out-
puts will be updated.
L1 L2
To illustrate how an IOM instruction works, Figure 5-36 shows O/0 PL1
two pilot lights that are connected to output terminals 0 and 1 of
a MicroLogix 1000. At the end of the last scan, both lights were
on, but now, according to the current logic, they should both be IOM O/1 PL2
off. To update these outputs during the scan, you can program IMMEDIATE OUTPUT w/MASK
Slot O:0
an immediate output with mask instruction with a slot parame- Mask 0003
ter of O:0 and a mask of 0003. When energized, the IOM in-
struction will update the status of the output file and mask out
all but the data for bits 0 and 1. It will then send this data to PL1 15141312 1110 9 8 7 6 5 4 3 2 1 0
and PL2, turning them off immediately instead of waiting until 0000 0000 0001 1000 Output Status
the update output section of the scan. 0000 0000 0000 0011 Mask

0000 0000 0000 0000


To PL1
To PL2

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

You might also like