122
MODULE ONE 1 Key Points 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. This first module is broken up into four sections: 1. MicroLogix 1000 basic principles of operation 2. MicroLogix specifications 3. I/O structure and memory system 4. Addressing notation After finishing this module, you will: 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 MicroLogix’s intricate memory system—how 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 ARCHITECTURE AND OPERATION

AB MicroLogix Training Manual

Embed Size (px)

Citation preview

Page 1: AB MicroLogix Training Manual

M O D U L E O N E

1 Ke

y P

oin

ts

To understand the Allen-Bradley MicroLogix 1000, you need to startwith the basics. This first module explains the basic operation ofprogrammable controllers and details the specific features of theMicroLogix 1000 PLC.

This first module is broken up into four sections:

1. MicroLogix 1000 basic principles of operation

2. MicroLogix specifications

3. I/O structure and memory system

4. Addressing notation

After finishing this module, you will:

■ understand the basic operating principles of the MicroLogix—how it works, what the components are, and what thecomponents do

■ know the three basic specifications for the MicroLogix 1000—how the program is written, how data is represented in thesystem, and what configurations are available

■ grasp the MicroLogix’s intricate memory system—how theI/O is set up, what makes up the memory system, and how thememory system is organized

■ understand the unique MicroLogix addressing notation

ARCHITECTURE

AND

OPERATION

Page 2: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

2 Module 1

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 allPLCs follow. At the end of this section, you will know:

• what PLCs do

• why PLCs are invaluable to industrial facilities

• what makes up a PLC

• how a PLC operates

PLC FundamentalsA MicroLogix 1000 is a programmable logic controller—anindustrial computer that controls a machine or process. A PLCinterfaces with the field input and output devices that are part ofa control application. Then, through the control program storedin its memory, the PLC uses the data supplied by the inputdevices to manipulate or control the output devices. The overallPLC process, which is shown in Figure 1-1, is very simple. APLC 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 acontrol system. They eliminate the need to rewire the input andoutput devices if the control requirements change. If the controlrequirements for a PLC application change, all you need to do is

Figure 1-1. PLC operation.

Measures

Control

Inputs

Outputs

MicroLogix1000

Processor

Machine

Page 3: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 3

change the control program. Another benefit of PLCs is thatthey are more powerful and more accurate than electromechani-cal systems.

PLC ComponentsA PLC is made up of two basic components (see Figure 1-2):

• the input/output (I/O) system

• the central processing unit (CPU)

The input/output system is the part of the PLC that physicallyconnects to devices in the outside world. The central process-ing unit, on the other hand, is where the PLC stores all of itsdata and does all of its computer processing. Each of the com-ponents of a PLC has specific functions.

Input/Output System. The input/output system is made up oftwo 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 aPLC. These input devices provide data to the PLC. The role ofan input interface is to translate data from the inputs into a formthat the PLC’s central processing unit can understand.

An output interface is a bank of terminals that physically con-nects output devices, such as solenoids and motor starters, to aPLC. These output devices receive control data from a PLC. Therole of an output interface is to translate data from the PLC’sCPU into a form that the output devices can understand.

To put it simply, the I/O system communicates information fromthe input devices to the CPU. It also communicates data fromthe CPU to the output devices.

Figure 1-2. A PLC and its components: the central processing unit (CPU) and theinput/output (I/O) system.

Figure 1-3. (a) A PLC’s input interface interprets the data from the input devicesand then sends it to the CPU. (b) A PLC’s output interface interpretsthe data from the CPU and sends it to the output devices.

PLC

I/O System

CPU

Inputs

Outputs

Inputs

To PLC

Outputs

From PLCM

(a) (b)

Page 4: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

4 Module 1

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

• the memory system

• the processor

• the power supply

The memory system stores the PLC’s control program, as wellas the data received from and sent to the I/O system. It alsokeeps track of which I/O devices are connected to which I/Ointerfaces. The processor is the computerized part of the CPUthat performs the control program. It manipulates the data storedin the memory system and determines what control output shouldoccur based on the given input conditions. The power supplyprovides power to both the memory system and processor sothat they have power and so that they work properly.

PLC Operation

All PLCs, including the MicroLogix 1000, perform a three-stepoperation called a scan (see Figure 1-5). The scan consists of:

1. reading the input data that the PLC receives from theinput devices

2. executing the control program stored in memory

3. updating, or writing, the status of the output devices basedon 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 thecontrol program.

Processor

PowerSupply

MemorySystem

Program Execution

Write Read

Figure 1-4. A CPU with its three components—the processor, the memory system,and the power supply.

Figure 1-5. A PLC’s scan consists of reading the inputs, executing the control program,and updating the outputs.

Page 5: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 5

The scan can be broken up into two different parts, the I/O scanand the program scan (see Figure 1-6). During the I/O scan,the PLC reads inputs and updates the outputs. During the pro-gram scan, the PLC executes the control program.

The scan time is the specific amount of time required for a PLCto perform both the I/O scan and the program scan. Each PLC’sscan time is different. A MicroLogix 1000 can perform a scan inmilliseconds. However, when it is on-line with a programmingdevice, the MicroLogix experiences two delays during its scan(see Figure 1-7). These are:

• the service communications delay

• the overhead delay

The service communications delay is the time required forthe MicroLogix 1000 to send data to the programming or moni-toring device, which may be a personal computer or a handheldprogrammer. The overhead delay is the time required for house-keeping operations, like memory management and updatingtimer information. Although both of these delays add to theMicroLogix 1000’s scan time, it still performs its scan very quickly.

Figure 1-6. A PLC’s total scan consists of two different scans: the I/O scan and theprogram scan.

Figure 1-7. The MicroLogix experiences two scan delays, a service communicationsdelay and an overhead delay, when it is on-line with a programmingdevice.

Program Execution

Write Read

ServiceCommunications

DelayOverhead

Delay

Program Execution

Write Read

Program Scan

I/O Scan

Page 6: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

6 Module 1

1-2 MicroLogix Specifications

The MicroLogix 1000 PLC is a powerful micro–programmablecontroller 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 andspecifications. 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 representedin the MicroLogix 1000

• what number systems are used by the MicroLogix 1000to represent data

• 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 thetraditional hardwired method, the input and output devices arewired directly to each other. The sequence of operation, whichis the logic behind the system, is determined by the way thedevices are physically connected (see Figure 1-8).

In the PLC softwired method, the input and output devices arewired to the PLC’s input and output interface terminals—not toeach other (see Figure 1-9). The control program, which residesin the PLC’s memory, provides the connections between thedevices. So instead of being hardwired, the devices are “soft-wired” to each other. The MicroLogix 1000’s softwired controlprogram is represented through ladder diagram notation.

Figure 1-9. The circuit in Figure 1-8 implemented in a PLC via input/outputconnections.

Figure 1-8. A hardwired circuit where either a limit switch or a push button canturn on a pilot light.

LS

PB

L1 L2PL

ElectromechanicalDiagram

LS

PBPB

LS PL PL

Page 7: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 7

Ladder diagram notation has a particular format, as shown inFigure 1-10. The left side of a ladder circuit shows the inputdevices wired to the input terminals, which are represented byrectangles. The right side shows the output devices wired to theoutput terminals, which are represented by diamonds. The middlepart is the ladder diagram logic that connects the inputs and theoutputs together.

The logic performed within a ladder program works just like itsequivalent electromechanical circuit would. However, a ladderprogram represents its inputs by a contact rather than by a de-vice symbol. Likewise, it represents its outputs by a coil insteadof by a device symbol. The PLC uses an addressing scheme inthe 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 ahardwired, or traditional, system, the devices must be physicallyrewired if the control requirements change. This takes time andmoney. However, in a PLC system, no rewiring is necessary. Allchanges are made to the PLC’s ladder program instead. Thisprocess is much quicker and less costly than rewiring. The sec-ond benefit is reliability. The MicroLogix 1000 PLC is solid-stateand has no moving parts, which makes it very dependable.

Figure 1-10. An example of ladder diagram notation.

Inputs Outputs

LadderControlProgram

Page 8: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

8 Module 1

Number SystemsNumber systems are used to represent data in a PLC. The Micro-Logix 1000 PLC uses several different types of number systems torepresent program data, address data, and internal data. They are:

• binary

• decimal

• hexadecimal

• octal

• binary codes

Binary. The MicroLogix 1000 uses the binary number systemto represent program data. The binary number system uses onlytwo numbers, 0 and 1, to represent data. PLCs, including theMicroLogix 1000, use the binary system to represent I/O databecause PLCs are discrete devices capable of recognizing onlytwo states, ON and OFF.

Using the binary system, a PLC indicates that a device is ON, oractivated, by placing a value of 1 in the appropriate bit in memory(see Figure 1-11). Conversely, a PLC indicates that a device isOFF, or not activated, by placing a value of 0 in the appropriatebit in memory.

Decimal. The MicroLogix 1000 uses the decimal number sys-tem to represent the address data of inputs and outputs, as wellas contacts, coils, timers, counters, and other internal instruc-tions. The decimal number system uses ten numbers, 0 through9, to represent data.

The addresses represented by decimal numbers identify whichcontacts and coils refer to which input and output devices. Anaddress tells the PLC specifically which I/O device is wired to

Figure 1-11.(a) If a device is ON, a PLC will store a 1 in memory. (b) If a device isOFF, a PLC will store a 0 in memory.

(a)

(b) 0

PLC Memory

1PB

PLC Memory

PB

Page 9: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 9

which terminal. Figure 1-12 shows an example of address nota-tion. An address instructs a contact or coil to examine a terminalto see whether the device connected to it is ON or OFF.

Hexadecimal. The hexadecimal number system is differentfrom other number systems because it uses both numbers andletters to represent data. The MicroLogix 1000 uses this numbersystem to represent constants and other internal values. Thehexadecimal system uses 16 numbers. It represents the num-bers 0 through 9 by the digits 0–9. It represents the numbers 10through 15 by the letters A–F (see Figure 1-13).

Octal. The MicroLogix 1000 uses the octal number system asa shorthand way to express binary data. The octal number sys-tem uses eight numbers, 0 through 7, to represent data. It groupsbinary numbers into groups of three and then uses one of thenumbers 0 through 7 to represent the group of numbers (seeFigure 1-14).

Binary Code. A binary code is a code that lets a PLC commu-nicate with the outside world. Since PLCs are discrete devicesand the rest of the world is not, PLCs must have a way to inter-pret and communicate nonbinary information from devices likethumbwheel switches and seven-segment indicators. The Micro-Logix 1000 uses binary codes to do just that. A binary codetranslates nonbinary data, like letters, into a binary coded for-mat that the PLC can understand. It also communicates binaryinformation from the PLC to nonbinary outside devices. TheMicroLogix 1000 uses two binary codes, ASCII and BCD, to per-form these functions.

Figure 1-12.The numbers above the contacts, terminals, and coils are addressesexpressed by decimal numbers.

Figure 1-14.The octal number system groups binary numbers into groups of threeand then represents each group with a number.

PL

M

SOLPB1

PB2

LS1

LS2

11

2

3

4

3

2

4

1 2

3 9

8

7 7

8

9

Figure 1-13. In hexadecimal, the numbers 0 through 9 are represented by thedigits 0–9 and the numbers 10 through 15 by the letters A–F.

0 1 2 3 4 5 6 7 8 9

10 11 12 13 14 15

A B C D E F

0 1 0 0 0 0 1 1 0

2 0 6

Page 10: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

10 Module 1

ConfigurationsA MicroLogix 1000 PLC comes in many configurations. Theseconfigurations 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 comesin 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 (seeFigure 1-15). A 32 I/O model can connect with up to 20 inputdevices and 12 output devices (see Figure 1-16). The size of aMicroLogix 1000 should be chosen based on the amount of I/Orequired for its application.

Power Supply. The MicroLogix 1000 also has two types of powersupplies. These are 24 VDC (volts DC) and 120/240 VAC (voltsAC). The power supply should be chosen based on the powerrequirements and the power availability for the application.

I/O Interfaces. A MicroLogix 1000 PLC has many options availablefor both its input and output interfaces. A MicroLogix 1000 canhave one of two types of input interfaces, either 24 VDC or 120VAC. These input interfaces allow the MicroLogix 1000 to connectwith either 24 VDC or 120 VAC input devices, respectively.

Just as a MicroLogix 1000 has a choice of inputs, it has a choiceof outputs as well. The MicroLogix 1000 uses three types ofoutputs:

• relay

• transistor

• triac

Figure 1-16. A 32 I/O MicroLogix.

Figure 1-15. A 16 I/O MicroLogix.

Page 11: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 11

A relay output allows the MicroLogix to interface with outputdevices that must receive a signal ranging between either 5 and264 VAC or 5 and 125 VDC. A transistor output is specificallydesigned for outputs requiring a 24 VDC output signal. A triacspecifically supplies a 120/240 VAC signal to its output devices.Figure 1-17 shows the types of input and output interfaces avail-able in the MicroLogix 1000.

Figure 1-17. The inputs and outputs available in a MicroLogix 1000.

• 24 volts DC• 120 volts AC

• Relay• Transistor• Triac

MicroLogix 1000Inputs/Outputs

OutputsInputs

MicroLogix1000

Page 12: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

12 Module 1

1-3 I/O Structure and Memory System

This section covers the I/O structure and the memory system ofthe MicroLogix 1000. Both are very important aspects of thePLC. At the end of this section, you will know:

• how the I/O system is structured

• what makes up the MicroLogix 1000 memory system

• how the memory system is organized

I/O StructureA MicroLogix’s I/O structure is directly related to the way itsmemory system is organized. Each input is connected to a sepa-rate input terminal that has a unique address in the PLC. Also,each output is connected to a separate output terminal that hasa unique terminal and memory address. Figure 1-18 shows anexample of addressed inputs and outputs connected to the ter-minals of a MicroLogix PLC.

Memory SystemThe memory system of a MicroLogix 1000 consists of four units(see Figure 1-19):

• file sections

• files

• words

• bits

File sections are the largest unit of memory. They specify wheremajor categories of data are stored. The MicroLogix’s memorycontains two file sections, the program file section and the data

Figure 1-18.The limit switch is connected to the input terminal with address 2.Thus, its status is stored in input address 2 in memory. Likewise, thepilot light is connected to the output terminal with address 3 and hasthis same address in memory.

Figure 1-19. The four units used in a MicroLogix’s memory system.

LS1PL

09 08 07 0605 04 03 02 01 00 05 04 03 02 01 00Inputs Outputs

Input02

Output03

L1 L2L1L2

C

00

01

02

03

00

01

02

03

L1

1 1

Section

Bit

Word

File

File

Page 13: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 13

file section. Each file section is made up of a particular numberof files. Files are areas in the MicroLogix’s memory where aspecific type of data, like input data, is stored. Each file consistsof a certain number of words. Words are groups of memorylocations that store pieces of data. Each word can hold up to 16pieces of data, and each piece of data is called a bit. A bit is abinary digit that comprises the smallest unit of memory. A bitholds only one piece of information, either a 1 or a 0.

The MicroLogix’s memory system is organized into file sections,files, words, and bits in order to store all of the information thatthe PLC needs to operate. This information includes the controlprogram, input and output status data, internal data, and routinefunctioning data. The MicroLogix’s memory system has a lot ofinformation to keep track of, so it needs a well-structured orga-nization in order to do that.

As mentioned previously, the MicroLogix’s memory contains twofile sections—the program file section and the data file sec-tion (see Figure 1-20). Each of these file sections stores a differ-ent kind of information.

Program File Section. The program file section stores all thedata a MicroLogix needs to operate. This includes data aboutthe processor, the main control program, and any subroutines.Figure 1-21 shows a map of the MicroLogix’s program section.

The program section consists of 16 files numbered 0 through 15.They store information as follows:

• Files 0 and 1 contain the executive software of theMicroLogix 1000. This software is responsible for con-trolling all of the functions of the PLC and keepingtrack of what is happening while the PLC is operating.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.

Figure 1-20. The two file sections of a MicroLogix 1000’s memory system.

Data FileSection

ProgramFile

Section

10

23456789

101112131415

Executive

Main Ladder ProgramUser Error Fault Routine

High–Speed Counter InterruptSelectable Timed Interrupt

Subroutine LadderPrograms

Program File Section

Page 14: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

14 Module 1

• File 2 holds the main ladder program that is enteredinto the PLC’s memory. This ladder program controlsthe machine or process.

• File 3 stores an error fault routine that is executed whena recoverable, or fixable, fault occurs in the PLC’s con-trol program. When this routine is executed, theMicroLogix corrects the problem to get the system upand running again.

• File 4 stores the high-speed counter interrupt programthat is executed when a high-speed counter instruc-tion causes an interruption in the control program.

• File 5 contains the selectable timed interrupt program,which is used to interrupt the normal program scan sothat a subroutine can be executed immediately.

• Files 6–15 store the subroutine ladder programs thatare called by the main ladder control program. Thisarea can store up to ten subroutines. Files 4 and 5 canbe used to store additional subroutines, if necessary.

Data File Section. The data file section stores all of the pro-gram and I/O data used by the MicroLogix 1000. This section isdivided 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 statusof each output device connected to the MicroLogix’soutput terminals. Each of the PLC’s outputs is mappedto an address bit in this file. File 0 is also known as theoutput image table. The output file contains one word.

• File 1 is the input file. It stores data about the status ofeach input device. The input file is also known as theinput image table. As with the output file, each of

Figure 1-22. The data file section of the MicroLogix 1000.

1

0

2

3

4

5

6

7

Outputs

Inputs

Status

Binary

Timers

Counters

Control

Integer

Data File Section

Page 15: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 15

the MicroLogix’s inputs is mapped to a specific bit inthe input file. The input file is different from the out-put file because it contains two words to account forall of the possible input devices that can be connectedto a 32 I/O MicroLogix.

• File 2 is the status file. It stores information about howthe PLC is operating and how it is set up. This filecontains 33 words that hold three types of data: basicstatus data, dynamic configuration data, and static con-figuration data (see Figure 1-23).

• File 3 is the binary, or bit, file. It stores data about thestatus of internal coils and contacts. The binary filecontains 32 words. Because the binary file stores dataabout internal instructions, its bits do not map realfield devices, as the bits in the input and outputfiles do.

• File 4 is the timer file. It contains data about the timersused in the control program. It includes data abouteach timer’s status, preset value, and accumulated value.The MicroLogix can use up to 40 timers in its controlprogram, and it dedicates one word to each of thethree pieces of information it stores about each timer.So, in essence, the timer file has 120 words, three foreach of its 40 timers.

• File 5 is the counter file. It stores data about the 32counters available in the MicroLogix 1000. It storesthree pieces of data about each counter: the counter’sstatus, preset value, and accumulated value. Each pieceof counter data is stored in its own word. So, in es-sence, this file has 96 words, three words for each ofthe 32 counters.

Figure 1-23. The contents of a MicroLogix 1000’s status file.

1

0

2

3

4

5

6

7

Outputs

Inputs

Status • Status

operation

• Dynamic configuration

• Static configuration

off-line settings

Page 16: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

16 Module 1

• File 6 is the control file. It stores information used byspecialized PLC instructions, like shift and sequencerinstructions. 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 miscellaneousnumerical data, such as constant and variable data,binary codes, and mask patterns. The integer file uses105 words to store all of this information.

Job Aid 1-1 at the end of this module provides an overview ofthe program and data file sections of the MicroLogix 1000’smemory system.

Page 17: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 17

1-4 Addressing Notation

The concept of addressing is very important in a PLC. This ishow the PLC keeps track of all of its data. At the end of thissection, you will understand:

• the mnemonics of the MicroLogix 1000 addressingnotation

• the unique addressing of timers, counters, control files,and input files

• the addressing concepts used for specific situations

Addressing MnemonicsEvery bit in every file of the MicroLogix’s data section has aunique address. This address allows the MicroLogix to keeptrack of all its data. The MicroLogix’s addressing code has itsown language, or mnemonics, which is used to express an ad-dress. This addressing code gives the PLC all of the informationit needs to find any piece of data stored anywhere in the PLC’smemory. Each address has three parts:

• the file label

• the word label

• the bit label

The first part of a MicroLogix’s address is the file label. Thislabel tells the PLC which file the data is stored in. A letter or aletter/number combination is used to denote each file. Figure1-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 PLCknow which word in the file the data is located in. The last partof the address is the bit label. This label tells the PLC which bitof the word the data is in.

Figure 1-24. The letter codes used for each file in the data file section.

Outputs

Inputs

Status

Binary

Timers

Counters

Control

Integer

I

O

S2

B3

T4

C5

R6

N7

Page 18: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

18 Module 1

Additionally, the MicroLogix 1000 uses delimiters to separatethe different parts of an address. A colon (:) is used to separatethe file label and the word label. A slash (/) is used to separatethe word label and the bit label. Figure 1-25 shows an exampleof the MicroLogix 1000’s addressing notation.

Special Addressing SituationsThe timer, counter, and control files also use the addressingsystem just explained. However, they add two extra charactersto the word label—a period and a number.

The first number in this special word label identifies the timer,counter, or special instruction number. The period acts as a de-limiter. The last number in the word label refers to one of thethree words associated with the timer, counter, or special in-struction. Figure 1-26 shows an example of the addresses forthree timers.

Like the timer, counter, and control files, the input file also has aunique address code. It also adds two extra characters, a periodand a number, to the word label. This is done to account for theadditional 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 datafor the first 16 inputs. The second word is labeled I:0.1. It holdsthe data for the remaining 4 inputs.

Addressing ExamplesFollowing are some examples of the addressing scheme used ina MicroLogix 1000 programmable controller:

Example 1—Output Device. Figure 1-28 shows a pilot lightconnected to output terminal 4 of a 16 I/O MicroLogix 1000.Since the pilot light is an output, its address will start with theletter O followed by a colon (O:). The output file has only oneword, so the pilot light’s status data will be stored in word 0

Figure 1-25.This address indicates that the data is stored in the integer file in word6, bit 14.

Figure 1-26.Three timers, each with three word addresses. Note that the period/word number extension is dropped from each timer’s first word address.

Figure 1-27. The MicroLogix 1000’s input file with the two words contained in it.

WordTimer File

012

012

012

T4:0T4:0.1T4:0.2

T4:1T4:1.1T4:1.2

T4:2T4:2.1T4:2.2

9101112131415 8 7 56 4 3 2 1 0

32 I/O MicroLogix—20 inputsInput File

I: 0.0I: 0.1

N 7 : 6 / 1 4

FileWord

Bit

Page 19: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 19

(O:0). Finally, the pilot light is connected to terminal 4, so it willbe mapped to bit 4 of output word 0 (O:0/4). Therefore, thepilot light will have the address O:0/4.

Example 2—Counter. Figure 1-29 shows the address used tocheck the data value stored in bit 8 of counter 7’s accumulatedvalue. The MicroLogix stores the accumulated value for a counterin the last word of the three words associated with the counter.The first part of the address (C5:) indicates that the data is storedin the counter file, since it is counter data. The second part ofthe address indicates that the accumulated value for counter 7 isstored in word 2 (C5:7.2). The data value specified is located inbit 8, so this data has the address C5:7.2/8.

Example 3—Input Device. Figure 1-30 shows the memory mapfor a push button connected to the last input terminal, input 19,of a 32 I/O MicroLogix. A push button is an input, so this device’saddress will start with an I and a colon (I:). The push button isconnected to the last input terminal, terminal 19. Since a wordhas only 16 bits, this input’s address must be located in thesecond word (I:0.1). Specifically, this input device’s status isstored in bit 3 of the second word of the 32 I/O MicroLogix;therefore, its address is I:0.1/3.

Entering Address DataWhen working with a MicroLogix 1000, address and other pro-gram data can be entered in one of two ways—with a handheldprogramming device or with a personal computer equipped withthe RSLogix software. Each of these addressing methods uses itsown addressing notation. The addressing notation shown in thevideo and in this book is the basic one used by the RSLogixsoftware. Job Aid 1-2 at the end of this module shows the differ-ences between the RSLogix and handheld programmer address-ing notations. Job Aid 1-3 shows some special addressing nota-tions you may encounter when using the RSLogix software.

Figure 1-29. Counter file address.

Figure 1-28. Output device address.

Figure 1-30. Input file address.

MicroLogix1000

O:0/4

Word 0

Word 1

Word 2

C5:7.2/8

Counter 79101112131415 8 7 56 4 3 2 1 0

Input 19(20th input)

Input File

Word 0.0

Word 0.1

First 16Inputs

Last 4inputs

I:0.1/3

9101112131415 8 7 56 4 3 2 1 0

Page 20: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

20 Module 1

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 programstored in memory, and updating the status of the output devices.

• The MicroLogix’s control program, which is represented by ladder diagrams, implements the softwired logic connectionsbetween the PLC’s input and output devices.

• The MicroLogix 1000 uses several different number systems—binary, decimal, hexadecimal, and octal, as well as binarycodes—to represent data.

• The MicroLogix comes in two sizes—16 I/O and 32 I/O—and has two types of power supplies—24 VDC and120/240 VAC.

• The MicroLogix is available with two types of input interfaces—24 VDC or 120 VAC—and three types of outputs—relay,transistor, and triac.

• The I/O structure of the MicroLogix is directly related to the way the memory system is organized.

• The MicroLogix’s 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 andoutput devices.

• A MicroLogix’s address has three parts: a file label, a word label, and a bit label.

• Most of the files in the MicroLogix’s memory system use the same addressing notation; however, some files use a specialword labeling mnemonic.

Page 21: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 21

margorPnoitceS

ELIF#

ELIFEMAN NOITCNUF

1 evitucexE .sdrowssapdna,noitarugifnoc,epyt:atadrossecorpsniatnocdnaCLPehtfonoitcnufehtslortnoC

2 margorPreddaLniaM .ssecorproenihcamehtslortnoC

3 enituoRtluaFrorrE .sruccororretluaf,elbaxifro,elbarevoceranehwdetucexE

4 retnuoCdeepS-hgiHeliFtpurretnI .margorplortnocehtninoitpurretninasesuacnoitcurtsniretnuocdeeps-hgihanehwdetucexE

5 demiTelbatceleSmargorPtpurretnI .detucexeebnacenituorbusaosxigoLorciMehtfonacsmargorplamronehttpurretniotdesU

6

51

reddaLenituorbuSsmargorP .senituorbusnetotpuerotsnaC.margorplortnocreddalniamehtybdellaC

ataDnoitceS

ELIF#

ELIFEMAN

ELIFLEBAL NOITCNUF

REBMUNDROWFO

ELBALIAVASESSERDDA

0 stuptuO O ehtotdetcennocecivedtuptuohcaefosutatsehttuobaatadsniatnoC.slanimrettuptuo 1 0:0

1 stupnI I tupniehtotdetcennocecivedtupnihcaefosutatsehttuobaatadsniatnoC.slanimret 2 0.0:I

1.0:I

2 sutatS 2S.putessitiwohdnagnitareposiCLPehtwohtuobanoitamrofniserotS

dnaatadnoitarugifnoccimanyd,atadsutatscisab:atadfosepyteerhtsdloH.atadsnoitarugifnoccitats

330:2S

23:2S

3 yraniB 3B .stcatnocdnaslioclanretnifosutatsehttuobaatadserotS 230:3B

13:3B

4 sremiT 4TatadspeeK.margorplortnocehtnidesusremitehttuobaatadsniatnoC

etarapes3nieulavdetalumuccadna,eulavteserp,sutatss’remithcaetuoba.sdrow

0404 02104

2.0:4T,1.0:4T,0:4T

2.93:4T,1.93:4T,93:4T

5 sretnuoC 5CatadspeeK.margorplortnocehtnidesusretnuocehttuobaatadsniatnoC

erotsnaC.eulavdetalumuccadna,eulavteserp,sutatss’retnuochcaetuoba.retnuochcaerofsdrow3sesudnasretnuoc23otpu

2323 6923

2.0:5C,1.0:5C,0:5C

2.13:5C,1.13:5C,13:5C

6 lortnoC 6R 61rofataddlohnaC.noitcurtsnidezilaicepsybdesunoitamrofniserotS.noitcurtsnihcaerofsdrow3gnisu,snoitcurtsni

6161 8461

2.0:6R,1.0:6R,0:6R

2.51:6R,1.51:6R,51:6R

7 regetnI 7N ybdesuatadelbairavdnatnatsnoc:atadlaciremunsuoenallecsimserotS.snrettapksamdna,sedocyranib,snoitcurtsnicitemhtira 501

0:7N

401:7N

➞➞

➞➞

➞➞

1-6 Job Aids

Job Aid 1-1: MicroLogix 1000 Memory Structure

Page 22: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

22 Module 1

Job Aid 1-2: Differences Between the RSLogix And Handheld Programmer Addressing NotationsThe 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:

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

Note that the handheld programmer drops the number from the word label (B3). It also expresses the addressed bit according towhich bit it is in the total file (50), rather than which bit it is in which word (3/2).

P001

B/50 0

B3:3/2

Page 23: AB MicroLogix Training Manual

A rc h i t e c t u r e a n d O p e r a t i o n

Module 1 23

Job Aid 1-3: Addressing Notations Used with the RSLogix SoftwareAn address, such as the address I:0.1/2 can be shown several different ways on an RSLogix programming screen, depending on theway the software’s properties are set up (View/Properties/Ladder):

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

Bit Address Format:m Single Line m Split Line

Binary Bit Display Mode:m /Bit m Word/Bit

I/O Bit Display Mode:m Slot/Bit m Slot.Word/Bit

Short Address:q Display q Entry

×

×

I:0.1/2

I:0/18

I0.1/2

I:0.1

2

I:0

18

I0.1

2

Page 24: AB MicroLogix Training Manual

M O D U L E T W O

2 Ke

y P

oin

ts

THE

INPUT/OUTPUT

SYSTEM

In the first module, you learned about the basic architecture andoperation of the Allen-Bradley Micrologix 1000, including a briefintroduction to its I/O system. This second module goes into moredetail about the I/O system of the Micrologix 1000 PLC. It includesfour sections:

1. Types of input/output devices

2. Input interfaces

3. Output interfaces

4. System and I/O power distribution wiring

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 theMicrologix 1000, their functional differences, and their differentwiring requirements

■ understand the various output interface configurations and thewiring requirements of each

■ have an overview of how to hook up a Micrologix 1000 and itsI/O devices to the incoming power source

Page 25: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

2 Module 2

2-1 Types of Input/Output Devices

A MicroLogix 1000 PLC uses its input and output interfaces toconnect with field input/output devices. To review, all inputdevices provide a signal to the PLC, and all output devices re-ceive a signal from the PLC. All I/O devices, however, do notsend 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 usethem. The two types of I/O devices are discrete devices andanalog devices.

At the end of this section, you will know:

• the difference between the two types of I/O devices

• which type works with the MicroLogix 1000

Discrete DevicesDiscrete devices are input or output devices that provide orreceive discrete digital signals. A discrete digital signal is onethat can report only two states, such as ON/OFF or open/closed.

A limit switch is an example of a discrete input device because,at any given time, it is either open or closed. It sends a discretedigital signal to a PLC. This signal can have one of only twovalues, 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 devicereceives a discrete digital signal from a PLC telling it to be ineither one state or the other. A discrete output can never be in astate in between ON and OFF.

Figure 2-1. A limit switch sends a discrete digital signal to a PLC.

Figure 2-2. A pilot light receives a discrete signal from a PLC.

Discrete

PL

OFF

ON1

0

Discrete

LS

OFF

ON1

0

Page 26: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 3

Analog DevicesIn contrast to discrete devices, analog devices are input or out-put devices that provide or receive analog signals. Analog sig-nals are continuous and can have any number of states—notjust two, as with discrete digital signals.

A temperature transducer is an example of an analog input de-vice. It sends a continuous stream of temperature data to a PLC(see Figure 2-3). This temperature data is expressed in varyingdegrees—not simply as hot or cold.

An analog control valve is an example of an analog output de-vice. It receives a continuous analog signal from a PLC telling ithow much to open or close (see Figure 2-4). If it was a discretedevice, it could only be either totally open or closed, but neverin 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 withdiscrete I/O devices.

Figure 2-3. A temperature transducer sends a continuous stream of data to a PLC.

Figure 2-4. An analog control valve receives a continuous signal from a PLC.

AnalogSignal

Output

AnalogControl

ValvePLC

TemperatureTransducer

AnalogSignal

Input

PLC

Page 27: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

4 Module 2

2-2 Input Interfaces

A MicroLogix 1000 uses input interfaces to connect with dis-crete input devices. These interfaces contain all of the circuitryneeded to allow the field input devices to communicate theirstatus to the PLC.

The previous module explained that there are two versions ofthe 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/Oversion has 20 input terminals.

All discrete input devices send an ON/OFF electrical signal to aprogrammable controller; however, not all discrete inputs sendthe same type of electrical signal. The two most common typesof discrete signals are 120-volt AC and 24-volt DC signals. Ac-cordingly, there are two input interface configurations availablein the MicroLogix 1000: 120-volts AC and 24-volts DC.

At the end of this section, you will understand:

• the 120 VAC and 24 VDC input interface configurations

• the functional differences between the two types ofinput interfaces

• the wiring requirements of each input interface

120-Volt AC Input InterfacesThree models of the MicroLogix 1000 come with a 120-volt ACinput interface, which converts the 120 VAC signal from theinput devices into a low-level DC signal that the PLC’s processorcan read (see Figure 2-5). To understand this conversion, youneed to be familiar with the interface’s components and wiring.

Figure 2-5. A 120 VAC input interface converts a 120 VAC signal into a low-levelDC signal.

ToProcessor

120 VACSignal

Low-LevelDC Signal120 VAC

Input

Interface

Page 28: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 5

Components. The 120 VAC input interface of a MicroLogix 1000has three components (see Figure 2-6):

• the power section

• the isolation section

• the logic section

Power Section. The power section receives the input signalfrom the field device and converts it into a low-level DC signalusing a bridge rectifier circuit. It then passes the signal througha filter to eliminate noise and bouncing. Finally, it uses a thresh-old detection circuit to check that the signal is valid.

Isolation Section. After the signal is converted by the powersection, it goes through the isolation section. This section usesan optical coupler to electrically isolate the power and logicsections. This prevents high-voltage spikes in the I/O signal fromreaching the PLC and damaging it.

Logic Section. After the isolation section, the signal enters thelogic section of the input interface. This section sends the newlyconverted and isolated input signal to the PLC’s processor.

The MicroLogix 1000’s 120 VAC input interface also includes apower LED indicator. This LED indicates whether the interfaceis receiving a valid signal from the input device. If both theinput device and the LED are ON, then everything is workingproperly. However, if the input device is ON but the LED is OFF,then a problem exists somewhere between the input device andthe MicroLogix’s input terminal.

Figure 2-6. The three components of a 120 VAC input interface.

ToProcessor

InputSignal

Power Isolation Logic

IsolatorBridge

Rectifier

Noiseand

DebounceFilter

LogicThreshold

LevelDetection

Page 29: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

6 Module 2

Wiring. To grasp the wiring requirements of the MicroLogix1000’s 120 VAC input interface, you must understand the threetypes of wiring associated with it. These are:

• the PLC wiring

• the device wiring

• the common (or return) wiring

PLC Wiring. The MicroLogix has built-in input interfaces in boththe 16 and 32 I/O models. Since the input interface is alreadywired to the PLC, input wiring is easy and quick.

Device Wiring. Input devices can be wired to a 120 VAC inputinterface in one of two ways:

• they can be wired directly to the interface

• they can be wired to a terminal block that is wired tothe interface

If an input device is wired directly to a MicroLogix 1000’s inputinterface (see Figure 2-7), then one side of the device should bewired to the L1 hot line of the incoming AC power source. Theother side should be wired to an input terminal on the PLC.

If an input device is wired to a terminal block instead of directlyto the PLC (see Figure 2-8), then the line going out of the inputdevice should be wired to the terminal block. The block, inturn, should be wired to the PLC. In MicroLogix 1000 applica-tions, the wiring of devices through a terminal block is morecommon than wiring them directly to the PLC.

Figure 2-8. An input device wired to a MicroLogix 1000 via a terminal block.

Figure 2-7. An input device wired directly to a MicroLogix 1000’s input interface.

120 VAC lineL1

MicroLogix1000

120 VAC lineL1 TB

MicroLogix1000

Page 30: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 7

Common Wiring. Each input device connected to a MicroLogix’s120 VAC input interface must also be connected to the AC returnline, called the L2 common line. The device must have this com-mon connection for its electrical circuit to be complete.

The input terminals on a 120 VAC interface are arranged in twogroups with each group sharing a connection to the commonline. In a 10-input MicroLogix, the first four input terminals shareone common connection, and the last six share another (seeFigure 2-9). In a 20-input model, the first four inputs again shareone common connection, while the last sixteen share another(see Figure 2-10).

24-Volt DC Input InterfacesA 24-volt DC input interface is used with field devices thatprovide a DC input signal to the PLC (see Figure 2-11). Thisinput signal can range from 0 VDC when the device is OFF tobetween 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-in 24 VDC power source. This power source can be used topower the DC inputs, but it should not be used to power thePLC’s DC outputs. The other four MicroLogix models do notprovide a built-in DC power source. These models require anexternal DC power supply to power the inputs.

Two types of DC input devices are used with PLCs:

• sourcing devices

• sinking devices

Sourcing devices provide current when they are ON, whilesinking 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.

Figure 2-9. In a 16 I/O MicroLogix, input terminals I/0–I/3 share a common, as doinput terminal I/4–I/9.

Figure 2-10. In a 32 I/O MicroLogix, input terminals I/0–I/3 share a common, as doinput terminal I/4–I/19.

MicroLogix1000

NOTUSED I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9NOT

USEDACCom

ACCom

ToProcessor

24 VDC

Input

Interface

DCSignal

0 VDC (OFF)15–30 VDC (ON)

MicroLogix1000

I/0NOTUSED

NOTUSED

I/1 I/2 I/3 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/19ACCOM

ACCOM

Page 31: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

8 Module 2

configuration. A MicroLogix 1000 with a DC interface can con-nect with either sinking or sourcing DC inputs, but the wiring isdifferent for each.

Sourcing DC Inputs. Sourcing input devices provide current whenthey are ON (see Figure 2-12). For a sourcing input, one side ofthe input device is wired to the positive DC voltage line, and theother side is wired to the PLC’s input interface. The interface isthen connected to the common line, which is the negative DCvoltage line. In a MicroLogix, the negative DC voltage line isgrounded; thus, the common line is grounded. This wiring con-figuration causes power to flow from the positive line, throughthe field device, through the PLC’s input interface, and return toground through the common line. Thus, as the input device sources(provides) current, the PLC sinks (receives) it.

The wiring connections for a MicroLogix 1000 with sourcing DCinputs depend on whether the PLC uses an external DC powersource or provides its own DC power source. If the PLC uses anexternal power source, the wiring diagram will look like the oneshown in Figure 2-13. One side of each device will be con-nected to the incoming positive DC voltage line, while the otherside of each device will be connected to the input terminal. Thecommon lines for each group of input terminals will be con-nected to the grounded negative line.

If the MicroLogix provides its own DC power source, the wiringdiagram will look like the one shown in Figure 2-14. One side ofeach device will be connected to the PLC’s positive DC voltageterminal instead of to a positive line coming from an externalDC power supply. The other side of each device will be con-nected to the input terminal. The common lines for each groupof inputs will then be connected to the PLC’s negative DC termi-nal, which is grounded.

Figure 2-13.Sourcing input device wiring for a MicroLogix that uses an externalDC power supply.

Figure 2-14.Sourcing input device wiring for a MicroLogix with a built-in DC powersupply.

Figure 2-12. A sourcing input device connected to a PLC’s input interface.

PLCInput

Interface

–VCom+V

Current

Sources Sinks

i

+V +VCom–V –V

Com

DCCOM

NOTUSED

NOTUSED

I /0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9

DevicesSourcing

PLC Sinking

DCCOM

I/0 DCCOMI/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

Devices Sourcing

+24–DC OUT

+VCom–V

PLC Sinking

DevicesSourcing

Page 32: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 9

The previous examples of sourcing input wiring connectionsare for two-wire devices. These are devices that have just twoelectrical connections—one that goes to the supply power lineand one that goes to the PLC input terminal. Some PLCs, how-ever, use three-wire devices (see Figure 2-15). These deviceshave three electrical connections—one to the supply power line,one to the PLC input terminal, and one to the common returnline. The connection to the common return line gives the devicethe power to perform its required function when it is not switch-ing power to the PLC.

Sinking Input Devices. Sinking input devices receive currentfrom the PLC when they are on. Sinking inputs operate just likesourcing inputs, but in reverse. Figure 2-16 shows a sinking de-vice connected to a PLC’s input interface. The supply side of theinput device is connected to the negative DC common line, andthe other side of the device is connected to the MicroLogix’sinput interface. The interface, in turn, is connected to the posi-tive DC voltage line. When the device closes, power from thepositive DC power line flows through the PLC’s input terminal,through the input device, and out to the common line, therebyclosing 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-Logix that uses an external DC power supply. The wiring con-nections here are similar to those for sourcing inputs, exceptthat the power line connections are reversed. In a sinking con-figuration, the input devices are connected to the negative volt-age line, and the MicroLogix’s DC common terminals are con-nected to the positive voltage line.

Figure 2-15. A MicroLogix with sourcing three-wire input devices.

Figure 2-16. A sinking input device connected to a PLC’s input interface.

Figure 2-17.Sinking input device wiring to a MicroLogix that uses an external DCpower supply.

DCCOM

NOTUSED

NOTUSED

I /0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9

–V+V +VCom

–VCom

DevicesSourcing

PLC Sinking

PLCInput

Interface

–VCom +V

Current

SourcesSinks

i

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

+V +V–V

Com–V

Com

DevicesSinking

PLC Sourcing

Page 33: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

10 Module 2

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 issimilar to that of sourcing devices connected to a MicroLogixwith a built-in power supply with one exception—the powerline connections are reversed.

Just as sourcing inputs can be either two-wire or three-wire de-vices, so can sinking input devices. The wiring for three-wiresinking inputs differs from the wiring for two-wire sinking in-puts. A three-wire sinking device has an extra connection to thepositive DC voltage line that allows the device to operate whenit is not switching power to the PLC (see Figure 2-19).

Job Aid 2-1, located at the end of this module, provides detaileddiagrams of two-wire and three-wire sinking/sourcing wiringconfigurations.

Figure 2-18.Sinking input device wiring to a MicroLogix with a built-in DC powersupply.

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

DCCOM I/0 DC

COMI/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

–VCom

24DC OUT+ –

+V

DevicesSinking

PLC Sourcing

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

+V +V–V

Com–V

Com

DevicesSinking

PLC Sourcing

Page 34: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 11

2-3 Output Interfaces

The MicroLogix 1000 has several different output interface con-figurations, and each of these configurations is geared toward aspecific 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-face configurations

Output Interface ComponentsFigure 2-20 illustrates the components of the MicroLogix’s out-put interface. They are:

• the logic section

• the isolation section

• 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 receivesthe control signal, which is either a 1 or 0, from the processor. A1 means that the interface should turn on the output device. A 0means that it should turn off the output device.

Isolation Section. After being received by the logic section, thecontrol signal is then passed through the isolation section. Justas it does for input interfaces, this section provides an electricalbarrier between the logic section and the power section.

Figure 2-20. The components of an output interface.

FromProcessor

To OutputDeviceIsolatorLogic Switch Filter

PowerIsolationLogic

Page 35: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

12 Module 2

Power Section. After the isolation section, the control signal en-ters the power section. In this section, the switching mechanismsends the PLC’s control signal to the output device. The controlsignal, however, passes through a filter before it actually reachesthe device. This filter eliminates the electrical noise in the powerlines and the electrical noise generated by the output load.

The MicroLogix’s output interface also has an LED in its powersection. When this light is ON, it indicates that the interface isreceiving a control signal from the PLC and switching power tothe output device.

Types of Output InterfacesA MicroLogix 1000 can have three different types of outputs:

• relay

• transistor

• triac

Each of these outputs is used to communicate with a differenttype of output device.

Relay Outputs. Relay outputs (see Figure 2-21) are used inapplications in which the PLC’s output devices require a controlsignal of either 5–265 VAC or 5–125 VDC. The maximum currentat each output is 2 A (amps) for both AC and DC devices.

Transistor Outputs. Transistor outputs (see Figure 2-22) areused only with output devices that require a 20.4–26.4 VDCcontrol signal from the PLC. A transistor output is most com-monly used with 24 VDC devices. A transistor’s maximum cur-rent at the output is 1 A. In a MicroLogix 1000, a transistor out-put is sometimes called a MOSFET, which is an acronym formetal-oxide semiconductor field effect transistor.

Figure 2-22. Transistor output.

Figure 2-21. Relay output.

5–265 VAC5–125 VDC

2 A (max current)

MOSFET

20.4–26.4 VDC24 VDC

1 A (max current)

Page 36: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 13

Triac Outputs. Triac outputs (see Figure 2-23) work with out-put devices that must receive a 85–264 VAC control signal. For atriac, the maximum output current to each device is 0.5 A.

Output Interface Configurations and WiringThe MicroLogix 1000 can have three types of outputs: relay,transistor, and triac. However, the MicroLogix does not have justone type of output or the other; rather, it can have a combina-tion of outputs. Specifically, a MicroLogix 1000 PLC is availablewith three output interface configurations:

• all-relay

• transistor/relay

• triac/relay

All-Relay Output Interfaces. Six models of the MicroLogix 1000have all-relay output interfaces. Three of the six are 16 I/Omodels, and three are 32 I/O models.

In the 16 I/O models (see Figure 2-24), two of the relay outputterminals, terminal 4 and 5, share a common power source. Theseterminals also share a connection to the common line. Each ofthe other four relay output terminals, terminals 0 through 3, hasits own separate power source and common connections. Thesefour terminals are called isolated output terminals, since theirpower and return lines are separated, or isolated, from eachother. Because this is an all-relay configuration, all of the powersources can be either AC or DC.

In 32 I/O all-relay MicroLogix models (see Figure 2-25), only thefirst two output terminals, 0 and 1, are isolated, meaning thatthey have their own power and common lines. The rest of theterminals, 2 through 11, share power source and common lineconnections in groups of two, four, and four.

Figure 2-23. Triac output.

Figure 2-25. A 32 I/O all-relay output interface.

Figure 2-24. A 16 I/O all-relay output interface.

Relays

O/0L2/N

ACIN

L1 O/1 O/2 O/3VACVDC

VACVDC

VACVDC

VACVDC

VACVDC O/4 O/5

L1 L2/NVACVDC

VACVDC VACO/0 O/1 O/2 O/3 O/4 O/5 O/6 O/7 O/8 O/9 O/10O/11

AC IN

Relays

VACVDC

VACVDC

85–264 VAC1/2 A (max current)

Page 37: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

14 Module 2

Transistor/Relay Output Interfaces. Two MicroLogix modelshave transistor/relay output interfaces. These include a 16I/O and a 32 I/O model.

In the 16 I/O transistor/relay model (see Figure 2-26), outputs 0and 1 are isolated relay outputs. Thus, they each have a separateAC/DC power supply connection and a separate common. Out-puts 2 through 5 are transistor output terminals that share acommon 24 VDC power source. They also share a commonconnection to the return line, which is connected to the nega-tive 24 VDC terminal. This terminal is grounded.

The 32 I/O transistor/relay model has two isolated relay outputterminals and a group of ten shared transistor outputs (see Fig-ure 2-27). This 32 I/O model also has a negative DC voltageterminal, which is where the return lines from the transistor out-put field devices are connected to the PLC. This negative termi-nal is grounded.

Triac/Relay Output Interfaces. Only one MicroLogix model hasa triac/relay output interface. This 32 I/O PLC has two iso-lated relay outputs at terminals 0 and 1 (see Figure 2-28). Theremaining ten outputs are triacs. These triacs are arranged ingroups of two, four, and four, with each group sharing an ACpower supply connection and a common return line.

Job Aid 2-2 lists the input and output interface specifications foreach model of the MicroLogix 1000, along with a chart explain-ing how to interpret the model numbers.

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

Figure 2-27. A 32 I/O transistor/relay output interface.

Figure 2-26. A 16 I/O transistor/relay output interface.

TransistorsRelays

0/0–24V 0/1 0/2 0/3DC

24V+DC

24V–VACVDC

VACVDC 0/4 0/5+

DC IN

Relays

VACVDC

VACVDCO/0 O/1 O/2 O/3 O/4 O/5 O/6 O/7

DC24–

DC24+ O/8 O/9 O/10 O/11–24V+

DC IN

Transistors

L1 L2/N

TriacsRelays

VACVDC

VACVDC VAC VACO/0 O/1 O/2 O/3 O/4 O/5 O/6 O/7 VAC O/8 O/9 O/10 O/11

AC IN

Page 38: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 15

2-4 System And I/O Power Distribution Wiring

This section provides an overview of how power is distributedto a MicroLogix 1000 and its I/O devices. At the end of thissection, you will understand:

• how power is distributed to a MicroLogix 1000

• how I/O devices connect to an incoming power source

System Power DistributionThe MicroLogix 1000 PLC can be directly mounted in a panel orenclosure. It also comes ready to be mounted on a DIN rail in anenclosure. These features make the wiring and the power distri-bution to the PLC very simple.

As explained in the previous module, some MicroLogix 1000srequire a 120/240 VAC power supply, while others require a 24VDC power supply. These two types of MicroLogix controllershave different wiring requirements.

AC Source Power Wiring. The AC power coming into a plantor factory is usually at a higher voltage than is needed by an ACMicroLogix 1000. Therefore, the power signal coming from thefield must be converted, or stepped down, to the right voltagelevel using a transformer.

For example, the source power coming into a plant may bethree-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 topower 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 convertsthe power from 480 VAC to 120/240 VAC.

Figure 2-29. AC source power wiring to a MicroLogix 1000.

480 VAC

MicroLogix1000 (AC)

L1L2L3

PowerfromField

3-Phase, 480 VAC

120/240VAC L1

L2

Transformer

Fuse

MicroLogix1000

Page 39: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

16 Module 2

3. Wire the hot L1 line from the transformer to thecontroller’s L1 terminal.

4. Wire the neutral L2 line from the transformer to thecontroller’s L2 terminal.

5. Connect the L2 line to ground to protect the system.

6. Wire the MicroLogix’s ground terminal to the systemground bus for added protection.

For further protection, connect the power lines to an accessibledisconnect switch inside the panel. This will allow for the quick,easy removal of power to the PLC, if necessary. Also, add a fuseto the hot L1 line to protect the system from overloads.

DC Source Power Wiring. With only a few detailed excep-tions, DC systems use the same wiring configurations as ACsystems. In a DC system, the power from the transformer isbrought through a fuse to a DC power supply instead of to thePLC (see Figure 2-30). From there, the DC power supply sendsout a 24 VDC signal through its positive and negative lines.These lines connect to the positive and negative terminals of theDC MicroLogix 1000, just as the L1 and L2 lines connect to theL1 and L2 terminals of the AC model. A DC MicroLogix’s powerwiring should also include a disconnect switch located betweenthe DC power supply and the PLC.

I/O Power DistributionLike system power distribution, I/O power distribution can bebroken down into two parts:

• AC I/O power distribution

• DC I/O power distribution

Figure 2-30. DC source power wiring to a MicroLogix 1000.

MicroLogix1000 (DC)

Transformer

Fuse

3-Phase, 480 VAC

Disconnect

L1L2L3

480 VAC

PowerfromField

+

+

DC PowerSupply 24 VDC

120/240VAC

MicroLogix1000

Page 40: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 17

AC I/O Power Distribution. If a MicroLogix uses AC inputsand outputs, then the same 120 VAC line that powers the PLCcan also power the I/O devices. Figure 2-31 shows an exampleof AC I/O power wiring. In this situation, the L1 line going to thePLC provides power to the inputs. The inputs’ common linesconnect to the L2 line to complete the circuit. The L1 and L2lines provide power and return to the output devices as well.

When using the same AC power source for the PLC and its I/Odevices, remember to install a master control relay (MCR) cir-cuit between the L1 line and the I/O devices. This MCR circuitwill allow the power to the I/O devices to be shut off in theevent of a PLC malfunction.

DC I/O Power Distribution. With DC devices, there are twowiring schemes to consider: one for MicroLogix models that pro-vide a built-in DC power supply and another for those modelsthat rely on an outside DC power supply.

If a MicroLogix has a built-in DC power supply, it can be used topower the DC input devices with up to 200 mA (milliamps) ofcurrent (see Figure 2-32). To do this, the input devices and theirreturn lines are connected to the appropriate DC power termi-nals. While the built-in DC power supply can provide power tothe DC inputs, it cannot provide power to the DC output de-vices. DC output devices must be connected to an external DCpower supply. This is necessary because the negative terminalof the built-in power supply is connected to chassis ground and,thus, cannot be connected to the common line of any other DCpower source.

Figure 2-31. AC I/O power distribution wiring.

Figure 2-32.DC I/O power distribution wiring for MicroLogix models that providea built-in DC power supply. Other supply output voltages are shownafter the MCR.

L1 L2

VAC 2

VAC 1COM

VDC 1 VDC 2 VDC 3

VDC +VDC +VDC Com

VAC 2COM

VDC 1COM

VDC 2COM

VDC 3COM

VDC Com

VACVDC

VACVDC

VACVDC

VACVDC

VACVDCO/0 O/1 O/2 O/3 O/4 O/5L1 L2/N

I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9DCCOM

DCCOM

+24–DC OUT

85-264 VAC

VAC 1MCR

MCRL2L1

VACVDC

VACVDC

VACVDC

VACVDC

VACVDCO/0 O/1 O/2 O/3 O/4 O/5L1 L2/N

85-264 VAC

NOTUSED

NOTUSED

I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9ACCOM

ACCOM

Page 41: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

18 Module 2

The I/O power wiring for DC MicroLogix models that use anexternal power supply is similar to the wiring for those withbuilt-in power supplies. The main difference is that both theinput and output devices are wired to an external power supply(see Figure 2-33).

An MCR circuit is required in DC I/O power wiring, just as it is inAC I/O power wiring. The MCR provides a safety mechanismthat allows the I/O devices to be turned off in emergencies.

Figure 2-33.DC I/O power distribution wiring for MicroLogix models that use anexternal DC power supply. Positive voltage supply to inputs and thesecondary AC supply to outputs are shown after the MCR.

VACVDC

VACVDC

VACVDC

VACVDC

VACVDCO/0 O/1 O/2 O/3 O/4 O/5L1 L2/N

I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9DCCOM

DCCOM

L1 L2

VAC 2VAC 1

MCR

VAC 1COM

VAC 2COM

–VCom

+V

NOTUSED

85-264 VAC

DC SupplyL1 L2

–V+VMCR

Page 42: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 19

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 states—ON and OFF—while an analog signal can have an infinite number ofpossible 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 1000’s output interface consists of three components: the logic section, the isolation section, and thepower 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 a24 VDC power source.

• AC and DC I/O devices require different power wiring schemes, which depend on whether the devices are beingpowered by an internal or external source.

• Both AC and DC devices require an MCR in their power wiring circuitry.

Page 43: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

20 Module 2

2-6 Job Aids

Job Aid 2-1: Two-Wire and Three-Wire Sinking and Sourcing Wiring DiagramsThe following examples provide detailed diagrams of both two-wire and three-wire sinking and sourcing input configurations.

Sourcing Inputs/Sinking MicroLogix—Internal DC Power

Two-Wire

Three-Wire

+V +VCom–V –V

Com

DCCOM

NOTUSED

NOTUSED

I /0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9

DevicesSourcing

PLC Sinking

DCCOM

NOTUSED

NOTUSED

I /0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9

–V+V +VCom

–VCom

DevicesSourcing

PLC Sinking

Sourcing Inputs/Sinking MicroLogix—External DC Power

Two-Wire

Three-Wire

DCCOM

I/0 DCCOMI/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

Devices Sourcing

+24–DC OUT

+VCom–V

PLC Sinking

DevicesSourcing

DCCOM

I/0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9+24 –DC OUT

+V

Devices SourcingCom–V

PLC Sinking

DevicesSourcing

Page 44: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

Module 2 21

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

+V +V–V

Com–V

Com

DevicesSinking

PLC Sourcing

Sinking Inputs/Sourcing MicroLogix—Internal DC Power

Two-Wire

Three-Wire

Sinking Inputs/Sourcing MicroLogix—External DC Power

Two-Wire

Three-Wire

DevicesSinking

PLC Sourcing

DCCOM I/0 DC

COMI/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

–VCom

24DC OUT+ –

+V

DevicesSinking

PLC Sourcing

DCCOM

I/0 DCCOM

I/1 I /2 I /3 I /4 I /5 I /6 I /7 I /8 I /9+24 –DC OUT

–V

+V

Com

DevicesSinking

PLC Sourcing

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

+V +V–V

Com–V

Com

Page 45: AB MicroLogix Training Manual

T h e I n p u t / O u t p u t S y s t e m

22 Module 2

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

Therefore, the example model number shown above (1761-L16BBB) refers to a 16 I/O MicroLogix 1000 with a 24 VDC inputinterface. This model has an output interface with both 24 VDC MOSFET (transistor) outputs and relay outputs. It also requires a24 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 inputs—120/240 VAC 6 outputs—4 isolated relays/2 shared relays 120 VAC

1761-L32AWA 20 inputs—120/240 VAC 12 outputs—2 isolated relays/2 shared relays/4 shared relays/4 shared relays 120 VAC

1761-L16BWA 10 inputs—24 VDC 6 outputs—4 isolated relays/2 shared relays 120 VAC

1761-L32BWA 20 inputs—24 VDC 12 outputs—2 isolated relays/2 shared relays/4 shared relays/4 shared relays 120 VAC

1761-L16BWB 10 inputs—24 VDC 6 outputs—4 isolated relays/2 shared relays 24 VDC

1761-L32BWB 20 inputs—24 VDC 12 outputs—2 isolated relays/2 shared relays/4 shared relays/4 shared relays 24 VDC

1761-L16BBB 10 inputs—24 VDC 6 outputs—2 isolated relays/4 shared transistors (MOSFET) 24 VDC

1761-L32BBB 20 inputs—24 VDC 12 outputs—2 isolated relays/10 shared transistors (MOSFET) 24 VDC

1761-L32AAA 20 inputs—120/240 VAC 12 outputs—2 isolated relays/2 shared triacs/4 shared triacs/4 shared triacs 120 VAC

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

1761 L 16

32

A = 120/240 VAC

B = 24 VDC

W = relays

B = 24 VDC MOSFET (transistor) and relays

A = 120/240 VAC triacs and relays

A = 120 VAC

B = 24 VDC

Page 46: AB MicroLogix Training Manual

M O D U L E T H R E E

3K

ey

Po

ints

BASIC

RELAY

INSTRUCTIONS

So far, you have learned about the components of the MicroLogix 1000PLC, including the CPU, the memory system, the power supply, and theinput/output system. This module teaches you about the control programthat links all of these components together.

There are five sections:

1. Ladder programming

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 ofrelay instructions available in the MicroLogix 1000

■ know the two types of contact instructions used to program aMicroLogix 1000, how they operate, and their referenceaddresses

■ know the four basic output instructions commonly used withthe MicroLogix 1000

■ understand key points concerning the ladder scan evaluation,the programming of normally closed input devices, and safetydevice programming

■ be able to apply techniques learned from specific programmingexamples

Page 47: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

2 Module 3

3-1 Ladder Programming

This section covers the fundamentals of ladder programming. AMicroLogix 1000 uses the control program stored in its CPU toanalyze input data and determine the corresponding output ac-tion. This control program is entered and stored in the CPU asladder diagrams. At the end of this section, you will know:

• the basics of ladder programming

• the two types of relay instructions available in the Micro-Logix 1000

Ladder Diagram BasicsLadder diagrams and electromechanical circuits function in muchthe same way. In an electromechanical circuit, one side of thecircuit is connected to the incoming L1 power line, while theother side is connected to the L2 return power line. The inputand output devices are wired between the two power lines. Inthe circuit shown in Figure 3-1a, when the limit switch inputdevice closes, it completes the electrical path between the in-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 showsthe devices connected between the L1 and L2 lines. However, ina ladder diagram, the L1 and L2 lines are represented by the leftand right rails, respectively. Also, in a ladder diagram, the inputsand outputs are represented by contacts and coils. Thus, whenthe limit switch in the ladder circuit shown in Figure 3-1b closes,the LS contact energizes, providing power to the PL coil andturning on the pilot light.

Figure 3-1. (a) An electromechanical circuit and (b) its equivalent ladder diagram.

PLLS

L1 L2

LS PLPLLS

L1 L2 L1 L2

(a)

(b)

Page 48: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 3

Contacts and Coils. In a ladder diagram, contact instructionsare used to reference input devices and coil instructions areused to reference output devices. A contact examines the stateof its corresponding input field device. It then either energizesor de-energizes, depending on whether the input device is ONor OFF, respectively.

Conversely, a coil energizes or de-energizes according to thestatus of the contacts in its ladder rung. When a coil energizes, itturns 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, thereare two other terms used when describing a ladder program:

• rung

• ladder rung matrix

Rung. A rung is a set of programmed instructions that forms acomplete electrical path between the left and right rails of aladder diagram (see Figure 3-2). A MicroLogix’s ladder rung canhave many contacts and coils in many branches. Since a rungcan 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 rightto left. Power must always flow from left to right through aladder 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 usedto program a ladder rung. In a MicroLogix 1000, a rung canhave a maximum of 75 branches. The ladder rung matrix alsodefines all of the possible locations for a contact or coil instruc-tion in a rung.

Figure 3-2. A ladder rung with arrows indicating the flow of power through therung.

Figure 3-3. A ladder rung matrix.

Contact Input Conditons OutputCoils

LeftRail

RightRail

Page 49: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

4 Module 3

Relay InstructionsRelay instructions form the category of programming instruc-tions that deals with the simple energizing and de-energizing ofinputs 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 inthe 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 comparisonfor 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

Page 50: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 5

3-2 Input/Contact Instructions

Contact instructions are used to reference input devices con-nected to the PLC. Thus, a contact represents an input conditionto a ladder rung. In some cases, a contact can also be used toreference an output coil.

At the end of this section, you will know the operation of thetwo basic contact instructions used with the MicroLogix 1000:

• examine-if-closed contacts

• examine-if-open contacts

Examine-If-Closed ContactsAn examine-if-closed contact instruction, also called a nor-mally open instruction, is represented by the symbol shown inFigure 3-4. It is abbreviated as XIC. An XIC contact checks thestatus of its input reference address for an ON, or closed, condi-tion. Then, if the reference address is ON, the contact closes,providing continuity through it.

Figure 3-5 illustrates how an XIC contact works. In this diagram,the push button is wired to terminal 0 of a MicroLogix 1000’sinput interface and, as a result, has the address I:0.0/1. The XICcontact in the ladder diagram shares this reference address. Whenthe push button closes (see Figure 3-5a), it supplies a voltage tothe PLC, causing a 1 to be stored in address I:0.0/1. When theXIC instruction detects the 1 in the address bit, it knows thebutton is closed. This causes the contact to close, providingcontinuity to the ladder rung. When the push button is OFF,however, its reference address bit will contain a 0 (see Figure 3-5b). This tells the XIC instruction that the button is open. As aresult, the XIC contact will open, breaking continuity in the rung.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 instructiondetects a 0 in its address bit, it opens, breaking continuity in the rung.

Figure 3-4. An examine-if-closed instruction.

Examine-If-Closed

(XIC)

PB

0

Input File

Word 0.0

L1 L2

I:0.0/0I/0

0

(b)

PB

0

(a)

1Input File

Word 0.0

L1 L2

I:0.0/0I/0

Page 51: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

6 Module 3

Examine-If-Open ContactsThe examine-if-open contact instruction, also called a nor-mally closed instruction, is represented by the symbol shown inFigure 3-6. It is abbreviated as XIO. An XIO instruction worksthe opposite of an XIC instruction. An XIO contact checks thestatus of its reference address for an OFF, or open, condition. Ifthe reference address is OFF, then the contact remains closed,providing continuity to the ladder rung.

Figure 3-7 illustrates how an XIO contact instruction works. Thelimit switch in this diagram is connected to terminal 1 of theMicroLogix’s input interface, which means that it has an addressof I:0.0/1. The XIO instruction in the ladder diagram referencesthis address. When the limit switch is open (see Figure 3-7a), bit1 of the input file will contain a 0. When the XIO contact detectsthe 0, the contact will stay in its normally closed condition, re-sulting in continuity to the rung. When the limit switch is closed,the opposite will occur (see Figure 3-7b). The XIO contact willdetect a 1 in the address bit, which will cause the contact toopen and break continuity to the rung.

The RSLogix software can be used to monitor the status of thecontacts in a ladder program. If the software shows a contact ashighlighted, then the contact is providing power continuity. If acontact is unhighlighted, then it is not providing continuity.

Figure 3-6. An examine-if open instruction.

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 instructiondetects a 1 in its address bit, it opens, breaking continuity in the rung.

Examine-If-Open

XIO

LS

Input FileWord 0.01

1

L1

(b)

(a)

L2

I:0.0/1I/1

LS

Input FileWord 0.0

L1 L2

I:0.0/1I/1

10

Page 52: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 7

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 ladderrung. At the end of this section, you will know the operation ofthe four basic coil instructions used with the MicroLogix 1000:

• standard output coils

• internal output coils

• latch/unlatch output coils

• one-shot rising instructions

Standard Output CoilsA standard output coil instruction, which is also called anoutput energize instruction, is represented by the symbol shownin Figure 3-8. If the coil’s ladder rung has continuity, then thecoil will energize, turning on the output device that shares itsreference address. This reference address is located in the out-put file of the data file section.

Figure 3-9 shows a push button driving an output coil that refer-ences a pilot light output. When the push button closes, its XICcontact will energize, providing continuity to the ladder rungand causing the output coil to turn ON. When the output coilturns ON, the MicroLogix will store a 1 in the coil’s referenceaddress (O:0/3) to indicate that the coil is ON. The PLC will thenturn on the output device that shares this address—in this case,the pilot light.

Figure 3-8. A standard output coil instruction.

Figure 3-9. When coil O:0/3 turns on, its associated output device will turn on.

PLPBI: 0.0/0

Output File

Word3

L1 L2 L1 L2

O: 0/3 O/3I/0

1

Output Coil

Page 53: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

8 Module 3

An output coil can be referenced by a contact instruction. There-fore, an output coil can drive a real field output device whilesimultaneously providing the input logic to another rung. Thecontacts used to reference an output coil can be either XIC orXIO instructions.

Internal Output CoilsAn internal output coil instruction looks like a regular out-put coil. It is even represented by the same symbol. The func-tional difference between the two is that a standard output coilreferences an actual field output device wired to the PLC, whilean internal output coil does not. Thus, instead of having a refer-ence address located in the output file, an internal output coilhas a reference address located in the binary file (file 3). Inter-nal coils are used with contacts to implement interlocking in aladder program. They are also used to store bit information thatdoes not directly impact the outside world.

Aside from being mapped to different files, an internal outputcoil and a regular coil work almost the same way (see Figure 3-10). If its rung has continuity, an internal output will turn onand store a 1 in its reference address bit. Since an internal out-put coil does not map a real output device, no field outputdevice will turn on. However, any contact that shares the inter-nal coil’s address will turn on or off with the coil.

Latch/Unlatch Output CoilsA latch/unlatch output coil instruction, which is actuallycomposed of two separate coil instructions, is represented bythe symbols shown in Figure 3-11. These coil instructions arealways used together in a ladder program and always share thesame address.

Figure 3-10. An internal output coil (B3:1/2) referenced by an XIC instruction.

Figure 3-11. The latch and unlatch output coil symbols.

Latch Unlatch

L U

Latch/Unlatch Output Coil

LS M1M

Binary File

Word 121

L1 L2 L1 L2

I: 0.0/0 B3:1/2

B3:1/2 O: 0/5

I/0 O/5

Page 54: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 9

The function of a latch coil is to turn on and stay on, even if itsinput condition turns off. The function of an unlatch coil is toturn off a latched output. A latch coil instruction is abbreviatedas OTL, and an unlatch coil is abbreviated as OTU.

Figure 3-12 illustrates a latch/unlatch ladder circuit. When pushbutton PB1 in the first rung is pressed, the latch output coil willturn on, causing pilot light PL to turn on. However, if the pushbutton is released, the latch output coil and pilot light will re-main on even though the first rung no longer has power conti-nuity. When LS1 closes, the unlatch output coil in the secondrung will be energized. This will change the status of address bitO:0/0 from a 1 to a 0. As a result, the latch output coil and pilotlight will turn off. An unlatch coil instruction is the only way toturn off a latched output coil. Note that the output cannot belatched again until the unlatch coil instruction turns off.

One-Shot Rising InstructionsA one-shot rising instruction is represented by the symbolshown in Figure 3-13. A one-shot rising instruction is not a coilinstruction, but rather, a contact instruction. It is covered in thissection, however, because it is used to control the behavior ofan output coil.

A one-shot rising instruction is used to energize an output coilfor only one scan. It is usually the last contact in a rung, locatedjust before the output coil. A one-shot instruction’s referenceaddress bit can be located in either the binary file (file 3) or theinteger file (file 7). Its address cannot be shared by anothercontact or coil, and it cannot correspond to a real input or out-put device. Also, the MicroLogix allows only one one-shot risinginstruction per rung.

Figure 3-13. A one-shot rising instruction.

Figure 3-12. A latch/unlatch ladder circuit.

One-Shot Rising Instruction

OSR

PLI: 0.0/0L

U

Output File

Word 0

PB1

LS1

L1 L2 L1 L2

I: 0.0/1 O: 0/0

O: 0/0 O/0I/0

I/1

0

Page 55: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

10 Module 3

When the logic before a one-shot rising instruction becomes en-ergized (see Figure 3-14), the one-shot rising instruction will beenergized. As a result, the output coil and output device will turnon. 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 outputcoil, and the associated field output device will turn off, even ifthe rest of the rung still has continuity. A one-shot rising instruc-tion is very useful for resetting output signals in one scan—forexample, for unlatching an output in one scan so that it will beready to latch again in the next scan.

Figure 3-14.(a) Ladder diagrams showing a one-shot rising instruction, which willbe energized for only one scan even if its input logic remains energized.(b) The timing diagram for a one-shot rising instruction.

LS I: 0.0/3 B3: 1/7

Scan 1

Scan 2

SOLOSR

O: 0/3I/3 O/3

L1 L2 L1 L2

LS I: 0.0/3 B3: 1/7 SOL

OSR

O: 0/3I/3 O/3

L1 L2 L1 L2

B3: 1/7

I: 0.0/3

O: 0/3

1 Scan

OSR

LS

(a)

(b)

Page 56: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 11

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 specialprogramming issues:

• ladder scan evaluation

• the programming of normally closed input devices

• safety device programming

Ladder Scan EvaluationThe way the controller evaluates the ladder program determinesthe order in which the programmed instructions will be executed.Thus, ladder scan evaluation can have a profound effect on theway the PLC and its associated machine or process operate.

A PLC’s scan consists of three activities (see Figure 3-15):

1. reading the inputs

2. executing the control program

3. updating the outputs

Once the PLC reads the status of the input devices, it begins toexecute the ladder control program. It starts its execution at thetop left corner of the ladder program and proceeds from left toright down the control program until it reaches the end of thelast ladder rung. The PLC evaluates the ladder program onceper scan. After the control program has been executed, the con-troller updates the status of the outputs according to the resultsof the control program.

Figure 3-15.The three parts of a PLC’s scan: reading the inputs, executing the controlprogram, and updating the outputs.

ExecuteControl Program

UpdateOutputs

ReadInputs

Page 57: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

12 Module 3

When developing a control program for a MicroLogix 1000, youmust pay close attention to the order in which the contacts andcoils are programmed. Arranging the same coils and contacts ina different order will produce different results. Figure 3-16 showstwo ladder programs containing the same elements but pro-grammed differently. The first program will require only onescan to turn on all of the outputs. The second program, how-ever, will require four scans before all the pilot lights will be on.

Programming Normally Closed DevicesWhen a normally open input device is connected to a PLC, it isprogrammed with an XIC contact instruction for the device toact like a normally open one in the ladder program. Conse-quently, the contact will energize if the input device closes andde-energize if the device opens.

Normally closed devices are programmed differently. Instead ofprogramming 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 thePLC program. Following are examples of a normally closed de-vice programmed with XIO and XIC contacts to explain why.

XIO Contact. If an XIO contact is used to program a normallyclosed input device, the ladder diagram will look like Figure3-17. Logically, this is the way you would expect a normallyclosed device to be programmed to function properly in a lad-der diagram. A closer inspection, however, reveals this to beincorrect. In the figure, the limit switch normally provides avoltage signal to the PLC in the same manner as it would in anelectromechanical circuit, meaning that the pilot light should beon. However, in the PLC program, the XIO contact looks for theinput device to be open, or OFF, in order to provide continuityto the output. Since the limit switch is closed, the XIO contact Figure 3-17.A normally closed input device programmed with an XIO contact,

along with its equivalent hardwired circuit.

Figure 3-16.Ladder programs in which (a) all of the outputs will turn on after onescan and (b) all of the outputs will be on after four scans.

I: 0.0/0 O: 0/0

O: 0/0 O: 0/1

O: 0/1 O: 0/2

O: 0/2 O: 0/3

PL1

PL2

PL3

PL4PB1

O/0

O/1

O/2

O/3I/0

L1 L2 L1 L2

I: 0.0/0 PL1

PL2

PL3

PL4

PB1O: 0/0

O: 0/0 O: 0/1

O: 0/1 O: 0/2

O: 0/2 O: 0/3

O/0

O/1

O/2

O/3

I/0

L1

(a)

(b)

L2 L1 L2

PLI: 0.0/0

PLLSL1 L2

LS O: 0/0

L1 L2 L1 L2

I/0 O/0

Page 58: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 13

will not be energized. Accordingly, the pilot light will be off.Under these conditions, the limit switch must open for the XIOcontact to be energized and the pilot light to turn on. This iscontrary to the way the circuit should work.

XIC Contact. Figure 3-18 shows the circuit from Figure 3-17programmed with an XIC contact. As in the previous laddercircuit, the normally closed limit switch provides a voltage tothe PLC. However, in this program, the XIC contact examinesthe limit switch for a closed condition in order to provide conti-nuity to the rung. Since the limit switch is closed, the contactwill be energized. In turn, the output coil and pilot light will beenergized. If the limit switch opens, the pilot light will turn off.Thus, the circuit works correctly.

Safety Device ProgrammingWhen connecting safety devices to PLCs, there is one cardinalrule to remember: never use a normally open device programmedwith an XIO contact instruction. The following explains why.

To implement the safety stop circuit shown in Figure 3-19, youmust use a normally closed input device programmed with anXIC instruction. In this configuration, when the start push but-ton is pressed, the motor will turn on because both of the XICcontacts will detect that their inputs are closed. When the startbutton is released, the motor will stay on because contact O:0/0seals the circuit. When the stop push button is pressed, the XICinstruction will detect that the stop button is open and turn off.This will turn off the motor circuit.

Moreover, if the motor in this circuit is sealed on and the con-nection from the stop push button breaks, the XIC instructionthat references the stop push button will detect an OFF, or open,condition. As a result, it will turn off the motor automatically.This creates a fail-safe circuit that is ideal for safety situations.

Figure 3-19.(a) A fail-safe safety stop circuit using a normally closed deviceprogrammed with an XIC instruction. (b) A safety stop circuit using anormally open device programmed with an XIO instruction. In thiscircuit, once the motor is on, the motor cannot be turned off if thesafety stop button malfunctions.

Figure 3-18.A normally closed input device programmed with an XIC contact,along with its equivalent hardwired circuit.

PLI: 0.0/0

PLLS

L1 L2

LS O: 0/0

L1 L2 L1 L2

I/0 O/0

I: 0.0/0 I: 0.0/1M

Start

Stop

O: 0/0

O: 0/0

O/0I/0

I/1

L1

(a)

(b)

L2 L1 L2

Motor

I: 0.0/0 I: 0.0/1M

Start

Stop

O: 0/0

O: 0/0

O/0I/0

I/1

L1 L2 L1 L2

Motor

Page 59: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

14 Module 3

3-5 Basic Relay Programming Examples

This section includes practical examples to help you apply whatyou have learned to two specific types of control circuits thatare often used in MicroLogix 1000 applications. At the end ofthis 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 CircuitFigure 3-20 shows the hardwired diagram for a simple start/stopmotor circuit. In this circuit, the motor turns on when the startpush button closes. The auxiliary contact in line 2 seals thecircuit so that the motor remains on when the start push buttonis released. When the stop push button is pressed, the motorturns off. The overload contacts can also turn the motor off inthe event of an overload situation.

PLC Requirements. To convert this circuit into a PLC 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-voltDC input interface. The motor starter, which has a 24-volt DCcoil, will be connected to one of the transistor outputs.

Figure 3-20. Hardwired diagram for a simple star t/stop motor circuit.

M

M

StartOLStop

L1

1

2

L2

2 3

Page 60: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 15

I/O Device and Power Wiring. The I/O devices to be wired tothe PLC are the stop push button, the start push button, and themotor starter. An internal instruction will be used to implementthe auxiliary contact in the PLC.

Figure 3-21 shows how the I/O devices and power will be wiredto the PLC. The stop button will be wired to the first inputterminal (I:0.0/0) and the start button to the next input terminal(I:0.0/1). These are both DC inputs. The motor starter’s coil willbe wired to the first transistor output terminal (O:0/2). The over-load contacts will remain wired in series with the motor starter’scoil, just as they were in the electromechanical circuit.

To apply power to the PLC, you should connect the MicroLogixto the DC power supply’s positive and negative voltages, notingthat the negative is connected to ground. The PLC itself shouldalso be grounded. Next, connect both the input devices and theoutput device to their respective DC power supply positive andnegative terminals.

Ladder Programming. Figure 3-22 shows the ladder controlprogram for the start/stop motor circuit. The ladder programuses the same logic that was used in the electromechanical cir-cuit; however, the PLC program uses XIC contacts to referencethe two inputs and an output coil to reference the motor. Inter-nal contact O:0/2, which references the output coil, seals thecircuit when the start push button is released.

The PLC program will work just like the hardwired circuit. Whenthe start button is pressed, the motor will turn on and stay on.When the stop button is pressed, the motor will turn off. If themotor is sealed on and the overload contact opens, the motorstarter will turn off. The reason for this is that the open overloadcontact will break the power continuity in the motor starter’scircuit. This situation is called low-voltage release.

Figure 3-22. Ladder program for the star t/stop motor circuit.

Figure 3-21.The I/O device and power wiring for the start/stop motor circuit. The+V supply connection shown occurs after the MCR power contact,which controls the power to the I/O devices.

M

Start

Stop I: 0.0/0 I: 0.0/1

L2L1L1 L2

O: 0/2

O: 0/2

OLO/2 MotorI/0

I/1

I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9 I/10 I/11I/12 I/13

OL

NOTUSED

NOTUSED

DCCOM

DCCOM

VACVDC

VACVDC

DC24+

DC24–O/0 O/1 O/2 O/3 O/4 O/5 O/6 O/7O/8 O/9O/10O/11

M

DC in+24v– NOT

USED

+V –VCom

–VCom +V

+V–V

Com

StartStop

Page 61: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

16 Module 3

Note that, since the motor’s PLC output coil is still on, the motorwill turn on again as soon as the overload contact recloses (i.e.,when the thermal overload heater cools off). Consequently, thiscircuit does not provide low-voltage protection. This can beundesirable and, in fact, dangerous in some applications. Forinstance, someone may be troubleshooting the motor to findout why it stopped. During this time, the overload contact maycool off and close again, causing the motor to start up againwithout warning.

Low-Voltage Protection. To provide low-voltage protection inthis circuit (see Figure 3-23), you must connect the auxiliarycontact from the motor starter as a real input to the PLC at inputterminal 2 (I:0.0/2). Then use an XIC contact to implement theauxiliary contact in the PLC. This replaces the internal contactused before. Now the motor is sealed after the start button ispushed because the auxiliary contact stays on as long as themotor starter’s coil is on. Therefore, this circuit still provideslow-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 starter’scoil turns off. This means that the motor will stay off even afterthe overload recloses. You must press the start button for themotor to turn on again.

Forward/Reverse Motor CircuitFigure 3-24 illustrates the hardwired electromechanical diagramfor a forward/reverse motor circuit (reversing motor starter). Thiscircuit has two normally open start push buttons—a forwardbutton and a reverse button. It also has two motor starter coils—one to start the motor going forward and another to start itgoing in reverse. The forward part of the circuit contains a con-tact labeled F1, which seals the forward push button. It alsocontains an R2 interlocking contact that prevents the forward

Figure 3-23.A star t/stop motor circuit with low-voltage release and low-voltageprotection.

Figure 3-24. Hardwired diagram for a forward/reverse motor circuit.

OLL2L1

F

R

Stop

R1

F1

R2

F2

REV

FWD

FWD

REV

M

M

Start

Stop I: 0.0/0 I: 0.0/1

L2L1L1 L2

O: 0/2 OLO/2 Motor

I: 0.0/2

I/2

I/0

I/1

Page 62: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 17

motor starter from turning on if the reverse starter is already on.Moreover, it has a forward pilot light that turns on when themotor is moving in a forward direction.

The reverse part of the circuit contains similar elements andworks identically to the forward part. Additionally, the circuithas a normally closed stop push button that can turn off eitherthe forward or the reverse motor starter. It also contains an over-load contact that will turn off either starter in the event of anoverload condition.

PLC Requirements. To begin the implementation, you mustchoose the appropriate MicroLogix model for the application.In this example, the PLC will have the following specifications:

• 32 I/O

• 120-volt AC power supply

• 120-volt AC input interface

• relay/triac output interface

I/O Device and Power Wiring. In this forward/reverse circuit,all of the devices except the R2 and F2 contacts and the over-load contact will be wired to the PLC. The motor starter contactsR1 and F1 will be wired to the PLC to provide low-voltage pro-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 overloadcontact, 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 theMicroLogix’s input and output interfaces. The input devices willbe connected to the first five input terminals, and the outputdevices will be connected to the first four output terminals. Thestarter coils will be connected to output terminals 0 and 1, thetwo relay terminals, and the pilot lights will be connected to the

Figure 3-25.The I/O device and power wiring for the forward/reverse motor circuit.

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

OL

NOTUSED

NOTUSED

ACCOM

ACCOM

VACVDC

VACVDCO/0L1 L2/N O/1

RF

32 I/O MicroLogix

O/2 O/3VAC

FwdPL

RevPL

Stop FwdMCR F1 Rev R1L1 L2

VAC

Page 63: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

18 Module 3

first two triac output terminals, which are terminals 2 and 3. ThePLC will be connected to the L1 and L2 power lines. The inputand output devices will also be connected to the L1 and L2power lines.

Ladder Programming. Figure 3-26 shows the ladder programthat will implement the forward/reverse motor circuit. The toptwo lines of the diagram control the forward motor starter andforward pilot light. The coils and contacts in the first line turnon the forward starter. This line starts out with an XIC contactthat references the stop push button. The next contact is an XICcontact that maps the forward start push button. The final con-tact is an XIO interlocking contact that references the reversestarter output. This contact provides interlocking so that the for-ward starter will not turn on while the reverse starter is ener-gized. When all of these inputs conditions are satisfied, the for-ward starter and the forward pilot light will turn on. When theyturn on, the F1 auxiliary contact mapped to input I:0.0/2 willseal the circuit so that the forward starter remains on even if theforward push button is released. Pushing the stop push buttonwill stop the forward motion of the motor.

The bottom two lines of the ladder diagram control the reversestarter and pilot light. They operate just like the first two linesdo. Line three contains contacts referencing the reverse startpush button and the forward motor starter. These are programmedin series with the stop push button contact located in line one.When all of these contacts are energized, the reverse motorstarter and pilot light will turn on. The XIC contact in line fourwill seal the circuit. Again, pushing the stop button will removepower to the motor.

Compelling Circuits. In the circuit shown in Figure 3-26, theforward and reverse starters are interlocked so that one cannotturn on while the other is operating. However, the way the

Figure 3-26. Ladder program that implements the forward/reverse circuit.

FOL

REV PL

Stop

REV

FWD

F1

R1

L1 L2L1L2

I: 0.0/0 I: 0.0/1

I: 0.0/2

I: 0.0/3

I: 0.0/4

O: 0/0

O: 0/0

O: 0/1

O: 0/2

O: 0/1

O: 0/3

I/2

O/0

O/3

I/1

I/3

I/4

R

O/1

FWD PLO/2

I/0

Page 64: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 19

Figure 3-27.The forward/reverse motor circuit programmed as a noncompellingcircuit.

circuit is programmed, you must press the stop push button tostop one motor starter before the other one can turn on. Thisconfiguration is called a compelling circuit. This circuit can beconverted into a noncompelling circuit, which will automati-cally change the direction of the motor rotation when you presseither the forward or reverse start push button.

Noncompelling Circuit. To make a noncompelling circuit, youmust add XIO forward and reverse push button interlocks to theladder program (see Figure 3-27). These contacts make the for-ward starter turn off when the reverse start push button is pressedand vice versa. If the forward starter is sealed on and the reversepush 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 thisconfiguration, you do not have to press the stop push buttonbefore turning on the reverse motor starter. This is a noncom-pelling circuit. To stop the motor, you must simply press thestop push button.

FOL

REV PL

Stop

REV

FWD

F1

R1

L1 L2L1L2

I: 0.0/0 I: 0.0/1

I: 0.0/2

I: 0.0/3

I: 0.0/4

O: 0/0

O: 0/0

O: 0/1 I:0.0/3

I: 0.0/1

O: 0/2

O: 0/1

O: 0/3

I/2

O/0

O/3

I/1

I/3

I/4

R

O/1

FWD PLO/2

I/0

Page 65: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

20 Module 3

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) andexamine-if-open (XIO).

• An examine-if-closed contact provides power to the ladder rung when the contact’s reference device is closed, or ON.

• An examine-if-open contact provides power to the ladder rung when the contact’s reference device is open, or OFF.

• Four basic output instructions are used with the MicroLogix 1000: the standard output coil, the internal output coil, thelatch/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 toright and from top to bottom.

• When programming a normally closed input device, you must use an examine-if-closed instruction for the device tobehave 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 beconnected to, (4) determine how the I/O devices and PLC will be powered, and (5) develop a ladder program thatimplements the required control.

Page 66: AB MicroLogix Training Manual

B a s i c R e l a y I n s t r u c t i o n s

Module 3 21

3-7 Job Aids

Job Aid 3-1: Programming Around Reverse Power FlowThe following ladder diagram allows power to flow from right to left through contact D. This type of reverse power flow is notpermitted in a MicroLogix ladder program.

If the reverse condition is not a required part of the output’s logic, then the ladder rung can be reprogrammed as follows to avoidthe reverse power flow condition:

If the reverse condition is a required part of the output’s logic, then the ladder rung can be reprogrammed as follows to avoid thereverse power flow condition:

Y

D

F

E

A B C

Y

D

F E

E

A B C

Y

D

F E

B C

A B C

A D E

Page 67: AB MicroLogix Training Manual

M O D U L E F O U R

4 Ke

y P

oin

ts

TIMING,COUNTING, AND

DATA-HANDLING

INSTRUCTIONS

This module is a fur ther exploration of the MicroLogix 1000’sprogramming instructions. Module 3 covered basic relay instructions,which perform simple ON/OFF operations. All of those instructionsuse a basic ladder format. The three sections of this module discussprogramming instructions that are represented in block format. Thesesections are:

1. Timing instructions

2. Counting instructions

3. Data-handling instructions

After finishing this module, you will:

■ understand the three timing instructions used in a MicroLogix1000—timer ON-delay, timer OFF-delay, and retentive timer—as well as the values and special programming issues associatedwith each

■ understand the count up and count down counting instructionsand the reset instruction, including the values and specialprogramming issues associated with each

■ know how to use data-handling instructions to move and convertdata in a MicroLogix 1000 PLC

Page 68: AB MicroLogix Training Manual

2 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

4-1 Timing Instructions

Timing instructions are programming instructions that replace theneed for electromechanical timers in a control system. Timinginstructions 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

• the operation of a timer OFF-delay instruction

• how a retentive timer instruction works

• how to use and implement the trapping of instanta-neous timer contacts in a PLC

General Timer InformationTimer Values. A timer instruction has three important valuesassociated 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 totime an event. A MicroLogix 1000’s timers can have a time baseof either 0.01 seconds or 1 second. A timer instruction times anevent by counting the number of times the time base has oc-curred since the instruction was energized. For example, if aMicroLogix 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 basehas occurred 2 times before the timer times out (see Figure 4-1).

Figure 4-1. Time base illustration.

TimeBase

TimedValued

Number of Times

Time BaseIs Counted

1 sec

0.01 sec

2 sec = 2 times

2 sec = 200 times

Page 69: AB MicroLogix Training Manual

Module 4 3

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Conversely, if the PLC’s time base setting is 0.01 seconds, it willwait until the time base has occurred 200 times before timingout. The selection of the time base depends on what is mostappropriate for the application.

Preset Value. The preset value of a timer works in conjunctionwith the time base by specifying the number of times that thetimer must count the time base. This preset value, which is alsoreferred to as the number of ticks, is predetermined and prepro-grammed by the user. Thus, in the previous example of a timerwith a 0.01 time base and a target value of 2 seconds, the presetvalue would be 200. This value indicates that the timer mustwait 200 time bases before timing out.

Accumulated Value. The final value associated with a timer isthe accumulated value. This value keeps track of how manytimes the time base has occurred since the timer instruction wasenergized. When the accumulated value equals the preset value,the timer will time out because it has reached its target timingvalue. So if a timer has a time base of 0.01 and a preset value of200, the accumulated value will increase by one every 0.01 sec-onds until the accumulated value equals 200. At that point, thetimer instruction will time out.

Addressing. A MicroLogix 1000 stores data about timers in file4 of its data file section. This file can store the data of up to 40timers, numbered 0 through 39. Each of these timers has threewords 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 (seeFigure 4-3).

Figure 4-3. MicroLogix 1000 timer addressing.

Figure 4-2. The timer file showing the three words associated with each timer.

40 timers T4:0.00.10.2

T4:39.139.0

39.2

Timers Timer FileFile 44

Timer 0

Timer 1

Timer 39

Control

Timer 1

Timer FileFile 4

Preset

Accumulated

0

Word

1

2

Page 70: AB MicroLogix Training Manual

4 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Each of the three words associated with a timer holds a specifickind of data (see Figure 4-4):

• Word 0 holds control data about the status of the timer’senable output, whether the timer is actively timing,and the status of the timer’s done output. The controlword stores this information in bits 15, 14, and 13,respectively.

• Word 1 stores the timer’s preset value. This is the tar-get timing value specified in memory.

• Word 2 holds the accumulated value. This value indi-cates how much time has actually elapsed since thetimer was energized.

In the RSLogix software, the labels PRE and ACC are used todenote timer words 1 and 2, respectively. Thus, timer wordsT4:0.0, T4:0.1, and T4:0.2 are represented as T4:0, T4:0.PRE, andT4:0.ACC in the RSLogix software.

Timer ON-Delay InstructionThe timer ON-delay instruction is a block-format instructionthat is represented by the symbol shown in Figure 4-5. Thisblock has two outputs:

• an enable output coil

• a done output coil

Inside the block is information about the timer’s address, timebase, preset value, and accumulated value. A timer ON-delayinstruction energizes its done output after the timer block’s in-put turns on and a specified delay has occurred. Consequently,this instruction is sometimes called a timer ON-delay energizeinstruction.

Figure 4-5. A timer ON-delay instruction.

EN

DN

TIMER ON-DELAYTimer Timer Base Preset Accum

TON

T4:181.0

40

ON EnergizesDelay

Figure 4-4. The data stored in each word of a timer’s address.

Control

Preset

Accumulated

131415

T4:0.0

T4:0.1

T4:0.2

DoneTimer TimingEnable

T4:0/15 (or T4:0/EN) → set when timer’s input turns ONT4:0/14 (or T4:0/TT) → set when timer is timingT4:0/15 (or T4:0/DN) → set when timer has timed out

Page 71: AB MicroLogix Training Manual

Module 4 5

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Figure 4-6 illustrates how a timer ON-delay instruction works.When the timer block’s input has logic continuity, the block’senable output will turn on. As a result, a 1 will be stored in bit15 of the timer’s control word. Once the timer is enabled, it willstart to time. Thus, a 1 will be stored in bit 14, which is the timertiming bit. As the timer times, the accumulated value increasesuntil it equals the preset value. At that point, the timer timing bitwill become a 0, and the done bit will become a 1, meaning thatthe done output will turn on. This done output is the timer’sdelay action contact.

The timer-ON delay instruction’s enable output will remain onas long as the input logic to the block remains energized. How-ever, the timer will stop timing as soon as the accumulated valueequals the preset value. The timer’s input logic must turn offand then on again before the timer will start timing again. Thetimer’s done output can be referenced throughout the programby XIC and XIO contacts to implement the time delay.

In the ladder program shown in Figure 4-6, the pilot light outputwill turn on four seconds after the push button input is pressed.In the ladder diagram, the input logic to the pilot light is acontact that references the done output coil of the timer block.The timer’s address is T4:18, its preset value is 4, and its timebase 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 andoutputs turn on and off. The ladder diagram operates like this:

• When the timer’s input turns on, it will cause the timer’senable output to turn on. When this happens, the timerwill start timing, but the done output coil will remainoff. The time between the timer being energized andthe done output being energized is the four-seconddelay implemented by the timer.

Figure 4-6. The operation of a timer ON-delay block in a control program.

Figure 4-7. A timer ON-delay block and its associated timing diagram.

EN

DN

I:0.0/0 T4:18/EN

T4:18/DN

L2 L2L1L1

T4:18/DN O:0/0

O/0I/0PB PL

TIMER ON-DELAYTON

T4:181.0

44

Timer Timer Base Preset Accum

131415

101

EN TT DN

Word T4:18.0

EN

DN

O:0/0

I:0.0/0

T4:18/DN

Timer Input

T4:18/EN

T4:18/TT

T4:18/DN

10101010

TIMER ON-DELAY

Timer Timer Base Preset Accum

TON

T4:181.0

40

Delay

Page 72: AB MicroLogix Training Manual

6 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

• The timer will stop timing as soon as the accumulatedvalue equals the preset value.

• When the accumulated and preset values are equal,the done output will turn on, causing the output coilthat drives the pilot light to turn on.

• The done output—and hence, the pilot light—will stayon until the timer block’s input turns off. At that time,everything in the ladder rung will turn off, and thetimer’s accumulated value will be reset to 0.

Timer OFF-Delay InstructionFigure 4-8 illustrates a timer OFF-delay instruction. This in-struction looks much like a timer ON-delay instruction in that ithas two outputs—done and enable—and includes informationabout the timer’s preset and accumulated values. Although atimer OFF-delay instruction may look like an ON-delay instruc-tion, it works a little differently. A timer OFF-delay instructionde-energizes its done output after the timer block’s input turnsoff and a specified delay has occurred. Thus, the timer OFF-delay instruction is also called a timer OFF-delay de-energizeinstruction.

The ladder program in Figure 4-9 uses a timer OFF-delay in-struction. This circuit works as follows:

• The done output will be off when the program is firststarted and the timer’s input is off.

• When the input logic turns on, both the block’s en-able output and done output will turn on. However,the timer will not start timing because it is waiting foran OFF signal instead of an ON signal.

Figure 4-8. A timer OFF-delay instruction.

EN

DN

TIMER OFF-DELAY

Timer Timer Base Preset Accum

TOF

T4:180.01315

0

OFF De-EnergizesDelay

Figure 4-9. A timer OFF-delay block and its associated timing diagram.

EN

DN

O:0/0

I:0.0/0

T4:18/DN

Timer Input

T4:18/EN

T4:18/TT

T4:18/DN

10101010

TIMER OFF-DELAY

Timer Timer Base Preset Accum

TOF

T4:180.01315315

Delay

Page 73: AB MicroLogix Training Manual

Module 4 7

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

• When the block’s input turns off, the enable outputwill turn off and the timer will start timing. The doneoutput will stay on because it is waiting for the timerto time out before it will turn off.

• Once the accumulated value equals the preset value,the timer will stop timing and the done output will turnoff, implementing the OFF-delay de-energize function.

• Therefore, the done bit’s action follows the action ofthe timer’s input signal, except that the done bit re-mains on for the specified delay period after the inputturns off. All of the timer’s outputs will now remain offuntil the input logic turns on again. At this point, theaccumulated value is reset to 0.

Retentive Timer InstructionA retentive timer instruction, pictured in Figure 4-10, oper-ates much like a timer ON-delay instruction. A retentive timer,however, can stop timing and then start timing again without itsaccumulated value resetting to 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 willturn on, and the timer will start timing.

• If the input logic turns off, the enable output will turnoff, and the timer will stop timing. The accumulatedvalue, however, will not reset to 0.

• When the timer starts timing again, it will pick up whereit left off.

• When the accumulated value finally reaches the pre-set value, the done output will turn on.

Figure 4-10. A retentive timer instruction.

Figure 4-11. A retentive timer circuit and its associated timing diagram.

EN

DN

RETENTIVE TIMER ON

RTO

T4:71.0100

Timer Timer Base Preset Accum

EN

DN

I:0.0/0

O:0/0

Reset

T4:7/DN

Timer Input

T4:7/EN

T4:7/TT

T4:7/DN

10

10

10

10

RETENTIVE TIMER ON

Timer Timer Base Preset Accum

RTO

T4:71.0100

Delay 1 Delay 2

Delay 1 + Delay 2 = Total Timer Delay

Page 74: AB MicroLogix Training Manual

8 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Once a retentive timer has timed out, its done output will re-main on even if its input logic and enable output turn off. Areset instruction must be used to turn the done output off andreset the timer’s accumulated value. The operation of a resetinstruction is explained in the counter section of this module.

TrappingTrapping is a special timer programming issue. The electrome-chanical timers used in hardwired circuits have two kinds ofcontacts:

• time-delayed

• instantaneous

The time-delayed contact is used to turn on the output afterthe timer has timed out. The instantaneous contact is used toseal the timer’s input so that, once the timer has started timing,it will continue to time even if its input logic turns off. Thisprovides interlocking in the circuit.

Figure 4-12 illustrates how the two types of timer contacts arerepresented in an electromechanical diagram. An instantaneouscontact is represented by a contact symbol, and a time-delayedcontact is represented by a timer switch symbol. The symbol foran ON-delay timer’s time-delayed contact has an arrow that pointsup. This indicates that the contact energizes, or closes, after thedelay following the input’s 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 followingthe input’s ON-to-OFF transition.

In contrast to electromechanical timers, PLC timers have onlyone type of contact—a time-delayed contact. This contact mustnot be confused with an instantaneous contact when replacingrelay logic. Consequently, you must use trapping to implement

Figure 4-12. Instantaneous and time-delayed timer contacts as represented in bothan electromechanical system and a MicroLogix system. The XX in theMicroLogix timer labels symbolizes the timer address.

TON/TOF

N/A

TMR

Electromechanical MicroLogix

TMR

TMR

TMR

T4:XX/DN

T4:XX/DN

Timer Coil

InstantaneousContacts

ON-Delay(Energize) Contacts

OFF-Delay(De-Energize) Contacts

Page 75: AB MicroLogix Training Manual

Module 4 9

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

an instantaneous contact in a PLC timer circuit, if the applicationrequires it. When you trap a circuit, you use an internal contactand coil to seal the timer on. You can also use the enable outputof the timer to trap the circuit.

Trapping Circuit—Internal Output. Figure 4-13 shows an elec-tromechanical timer circuit that will be implemented in a PLC.In this circuit, the timer will start timing as soon as float switchFS1 and pressure switch PS1 close. The timer will continue totime even if the float switch turns off. This is because instanta-neous contact TMR1-1 will seal the timer’s input logic. After a10-second delay, the timer will energize time-delayed contactTMR1-2, causing the solenoid to turn on.

The first step in making this a PLC circuit is to determine whichdevices will be connected to the PLC’s I/O interfaces. In thiscase, only the float switch, pressure switch, and solenoid will beconnected to the PLC. The rest of the circuit will be implementedthrough PLC instructions. The float switch will be connected tothe MicroLogix’s first input terminal, and the pressure switch tothe second terminal. The solenoid will be connected to the firstoutput terminal.

Figure 4-14 illustrates the ladder program that will implementthe timer circuit in the PLC. This ladder program contains threerungs:

• The first rung traps the timer on.

• The second rung implements the timing function.

• The third rung implements the time-delayed outputaction.

Rung 1. The first rung in the ladder program consists of contactsthat reference the float switch and pressure switch, along withan internal coil. It also contains an internal contact that refer-ences the internal coil, which implements the trap. When the

Figure 4-13. An electromechanical timer circuit to be implemented in a PLC.

L1 L2

FS1 PS1 TMR1

10 sec

SOL

TMR1-1

TMR1-2

Figure 4-14.The timer circuit implemented in a ladder program using an internaloutput to trap the timer.

I:0.0/0 I:0.0/1

I/1

I/0

B3:0/0

T4:0/DN

L1 L1L2 L2O:0/0

FS1

PS1

B3:0/0

B3:0/0 O/0

EN

DN

O:0/0

Timer Timer Base Preset Accum

TON

T4:01.0100

Page 76: AB MicroLogix Training Manual

10 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

float switch and pressure switch turn on, the internal coil willturn on. Because contact B3:0/0 seals the input, the internal coilwill stay on even if the float switch turns off. Thus, contactB3:0/0 performs the function of an instantaneous contact.

Rung 2. Rung two actually implements the timer. When the in-ternal output coil in the first rung energizes, the timer will startto time because its input logic will be satisfied. Once the accu-mulated value equals the preset value, the timer’s done outputwill turn on because the 10-second delay will be satisfied.

Rung 3. Rung three controls the solenoid output. When thedone output in rung two turns on, the solenoid output will turnon because its input logic references the done output coil. There-fore, this PLC circuit implements both the instantaneous andtime-delayed contacts of the hardwired circuit through the useof internal contacts.

Trapping Circuit—Enable Output. Another way to trap aninstantaneous timer contact is to use a contact that referencesthe timer’s enable output. In this method, the enable contact isused to seal the timer’s input, instead of an internal coil andcontact. Figure 4-15 shows an example of this type of trapping.When the float switch and pressure switch turn on, the enableoutput and its corresponding contact will turn on. However, ifthe float switch opens, the timer will remain on because theenable contact will trap it.

Figure 4-16 shows a multispeed motor. In low speed, this motoroperates in a delta configuration. In high speed, it operates in awye configuration. In this motor, if the low push button is pressed,the motor will run at low speed. If the high push button is pressedafter being in low speed, the motor will run at high speed. Thetimer in this circuit ensures that a 10.8-second delay occurs be-fore the motor will run in high speed. Thus, if the high pushbutton is pressed, the motor will first start out at low speed and

Figure 4-15.The timer circuit from Figure 4-13 implemented in a ladder programusing the enable output to trap the timer.

T4:0/DN

I:0.0/0 I:0.0/1

T4:0/EN

EN

DN

O:0/0

Timer Timer Base Preset Accum

TONT4:0

1.0100

I/1

I/0L1 L1L2 L2

O:0/0FS1

PS1

O/0

Figure 4-16. A multispeed motor circuit.

LowLow

High

Stop

CR

L

L

L1 L2

OLH

TMR

CR

TMR

TMR

TMR

CR

CR

High

Wye (High)

High Speed Powerto T4, T5, and T6(T1, T2, and T3 together)

SpeedLowHigh

Open Together

T1, T2, T3All others

L1T1T6

Low Speed Powerto T1, T2, and T3(T4, T5, and T6 open)

T1

T2

T3

T4

T5 T6

T1

T2T3 T5

T4 T6

Delta (Low)

T1

T2

T3

T4

T5 T6

L2T2T4

L3T3T5

L1

LO

OLLO

T1

L2

LO

T2

L3

LO

T3

HI

T6

HI

T4

HI

T5

HI HI

OLHI

Page 77: AB MicroLogix Training Manual

Module 4 11

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

rev up to high speed after 10.8 seconds. Notice that the circuituses interlocking motor starter contacts so that the high-speedstarter 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 realinputs. The low (L) and high (H) motor starter contacts will alsobe brought in as inputs to provide low-voltage protection. Thelow- and high-speed starter coils will be connected as outputs.The rest of the circuit, including the timer, will be implementedusing programming instructions.

The completed PLC program will look like Figure 4-17. Thetimer trap is implemented using the timer’s enable output. Inter-nal contact B3:0/0 is used to implement the control relay for thehigh-speed starter, which is driven by the high push button. Thetwo rungs of this program perform the following functions:

• Rung one controls the low-speed motor starter.

• Rung two controls the high-speed motor starter andimplements the 10.8-second delay through the use ofa timer ON-delay instruction.

Rung 1. The first rung of the ladder program controls the low-speed starter coil and provides interlocking with the high-speedstarter coil. When the low push button is pressed, the motor willstart at low speed. At the same time, the timer will start timingand 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 whenthe high push button is pressed. It does this using an internalcoil (B3:0/0) that bypasses the activation of the low push buttoncontact I:0:0/1 in the first rung. Once the high push button hasbeen pushed and the low-speed coil is on, the top three lines ofthe second rung enable the timer, which begins the 10.8-second

Figure 4-17.Multispeed motor ladder program using the timer’s enable output totrap the timer.

EN

DN

I:0.0/0 I:0.0/1 T4:0/DN I:0.0/4

I:0.0/0 I:0.0/1

I:0.0/2

B3:0/0 B3:0/0

B3:0/0

B3:0/0 T4:0/DN

O:0/0

L2 L2L1L1O/0

O:0/1I:0.0/3

I/0Stop L

HO/1

TON

T4:0

I/1

L

I/2

I/3

High

H I/4

Low

I:0.0/3

T4:0/EN

B3:0/0

T4:0/EN

I:0.0/3

OLs

Page 78: AB MicroLogix Training Manual

12 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

time delay. The timer is trapped using the T4:0/EN contact, whichreferences the enable coil. When the timer times out, its doneoutput will turn on. This will turn off the low-speed coil bybreaking continuity to it. At the same time, the high-speed startercoil 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/0when the high push button is pushed. Thus, if the high-speedpush button is pressed, the motor will start at low speed andthen change to high speed after a 10.8-second delay.

Page 79: AB MicroLogix Training Manual

Module 4 13

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

4-2 Counting Instructions

Just as timing instructions replace the need for electromechani-cal timers in a PLC, counting instructions replace the need forelectromechanical counters. This section discusses the differenttypes of counting instructions available in a MicroLogix 1000.

At the end of this section, you will know:

• basic counter information

• the structure and operation of a MicroLogix’s countinginstructions

• special counter programming issues

General Counter InformationCounter Values. A counter instruction has two values associ-ated with it:

• the preset value

• the accumulated value

These values perform the same function as they do in timerinstructions. The preset value specifies the target number ofcounts, while the accumulated value indicates the actual num-ber of counts that have already occurred. In a counter, the pre-set and accumulated values always increase or decrease in in-crements of one.

Addressing. Data about a MicroLogix 1000’s counters is storedin file 5 of the data file section. The counter file can store thedata of up to 32 counters, numbered 0 through 31 (see Figure 4-18). As with timers, each counter is allotted three words, whichare numbered 0, 1, and 2. Each of these three words storesparticular data about the counter instruction (see Figure 4-19):

Figure 4-19. The data stored in each word of a counter’s address.

Control

Preset

Accumulated

131415 1112

C5:0.0

C5:0.1

C5:0.2

UnderflowOverflowDoneCount DownCount Up

32 counters C5:0.0

C5:31.0

0.10.2

31.131.2

Counters5(b)

(a)

Counter 0Counter 1

Counter 31

Control

Counter 1

Counter FileFile 5 Preset

Accumulated

0

Word

1

2

Figure 4-18. (a) The counter file and (b) its addressing scheme.

Page 80: AB MicroLogix Training Manual

14 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

• Word 0 is the control word, which stores data aboutthe counter block’s operation and status. This wordholds information about the status of the count upand count down outputs and data about the counter’sdone, overflow, and underflow status. This informa-tion is stored in bits 11 through 15 of the control word.

• Word 1 stores the counter’s preset value, which is thetarget count value.

• Word 2 stores the counter’s accumulated value, whichis the actual count value. A counter’s preset and accu-mulated words, words 1 and 2, are addressed with thelabels PRE and ACC in the RSLogix software.

Counting instructions allow the implementation of several typesof counter functions in a programmable controller. The threecounting instructions found in a MicroLogix 1000 are:

• the count up instruction

• the count down instruction

• the reset instruction

Count Up InstructionA count up instruction is represented by the symbol shown inFigure 4-20. The function of a count up instruction is to increaseits accumulated value by one every time the block’s input makesan OFF-to-ON transition. After a certain number of OFF-to-ONtransitions have occurred, the count up instruction will energizeits output. A count up block has two output coils:

• a count up output coil (CU), which indicates that thecounter block is energized

• a done output coil (DN), which indicates that the countis complete

Figure 4-20. A count up instruction.

DN

CUCOUNT UP

Counter Preset Accum

CTU

C5:230

OFF-to-ONTransition

Increasesby 1

Energizes

Page 81: AB MicroLogix Training Manual

Module 4 15

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Figure 4-21 shows a count up circuit in which a limit switch anda solenoid are connected to a MicroLogix 1000 controller. Thesolenoid should turn on after the limit switch has turned onthree times. The circuit operates as follows:

• When the limit switch turns on for the first time, thecount up output will be energized, and the accumu-lated value will increase to 1.

• When the limit switch turns off then on again, theaccumulated value will increase to 2.

• When the switch makes its third OFF-to-ON transition,the accumulated value will increase to 3 and the doneoutput will turn on because the accumulated value isequal to the preset value.

• When the done output turns on, the solenoid outputin the second rung will be energized.

In a counter circuit, the counter will continue to count evenafter the accumulated value has reached the preset value. Thedone output will remain on as long as the accumulated count isgreater than or equal to the preset count. The only way to resetthe accumulated value and turn off the done output is to use areset instruction, which will be discussed later in this section.

Count Down InstructionA count down instruction (see Figure 4-22) decreases its ac-cumulated value by one every time the block’s input makes anOFF-to-ON transition. When the accumulated value becomesless than the preset value, the count down instruction de-ener-gizes its output. When the counter’s accumulated value is greaterthan or equal to its preset value, the counter’s output will be on.

Figure 4-21.A count up circuit in which a limit switch and a solenoid are connectedto a MicroLogix 1000.

LS1

DN

CU

O:0/0

I:0.0/0

C5:2/DN

C5:2/DN

C5:2/CU O/0 SOLLS1 I/0

COUNT UP

Counter Preset Accum

CTU

C5: 230

L1 L2 L1 L2

Figure 4-22. A count down instruction.

DN

CDCOUNT DOWNCTD

C5:224

Counter Preset Accum

OFF-to-ONTransition Decreases

by 1

De-Energizes

Page 82: AB MicroLogix Training Manual

16 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Like a count up instruction, a count down instruction also hastwo outputs:

• a count down output, which indicates that the counteris energized

• a done output, which signals that the target count valuehas been reached

Figure 4-23 shows a count down circuit, which works as fol-lows:

• In this circuit, the count down block’s done outputwill already be on because the accumulated value isgreater than the preset value.

• When the block’s input turns from OFF to ON, theaccumulated value will decrease to 3.

• When the block’s input makes this OFF-to-ON transi-tion again, the accumulated value will decrease to 2.

• When the input makes one more OFF-to-ON transi-tion, the accumulated value will drop to less than thepreset value and the done output will turn off, de-energizing the done output and output O:0/0.

In practice, a count down instruction is most often used with acount up instruction to form an up/down counter. In the up/down counter shown in Figure 4-24, both counters share thesame address and the same preset and accumulated values. As aresult, the up counter increases the accumulated value everytime a certain event occurs, while the down counter decreasesthe same accumulated value if another event occurs.

Figure 4-23. A ladder program containing a count down circuit.

Figure 4-24. Up/down counter configuration.

DN

CU

I:0.0/0

COUNT UP

Counter Preset Accum

CTU

C5:0100

0

DN

CD

I:0.0/1

COUNT DOWN

Counter Preset Accum

CTD

C5:0100

0

Increase

Decrease

DN

O:0/0

CD

I:0.0/0

C5:2/DN

COUNT DOWN

Counter Preset Accum

CTD

C5:224

Page 83: AB MicroLogix Training Manual

Module 4 17

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Reset InstructionA reset instruction is a coil instruction that can reset either atiming or counting instruction. When a reset instruction is ener-gized, it sets the accumulated value of its corresponding timeror counter to 0. It also resets all of the control bits in word 0 ofthe timer or counter’s memory location.

The ladder program shown in Figure 4-25 illustrates a reset in-struction being used to reset a count up instruction. The resetcoil shares the count up instruction’s address—C5:10. The countup instruction has already counted up to 10, which is severalcounts past its preset value. Consequently, the counter’s doneoutput is on. When the reset coil’s input is energized, the resetinstruction will set the up counter’s accumulated value to 0. Atthe same time, it will reset all of the bits in the counter’s controlword. This will turn the done output off.

A reset instruction can be used with all types of timing andcounting instructions except a timer OFF-delay instruction. Itcannot be used with a timer OFF-delay instruction because areset instruction resets the done, timer timing, and enable bits ofthe timer’s control word. If the status of these bits is alteredwhile a timer OFF-delay instruction is timing, a machine mal-function could occur.

Special Programming IssuesWhen using counter instructions in a MicroLogix PLC, you mustconsider some special programming issues:

• using a reset instruction to implement a self-resettingcounter

• counting past the maximum count

• reading fast input signals

Figure 4-25. A reset instruction being used to reset a count up instruction.

DN

CU

I:0.0/0

C5:10/DN O:0/0

I:0.1/1 C5:10

RES

131415 12 11CU CD DN OV UN

10 0 0 C5:10.00

COUNT UP

Counter Preset Accum

CTU

C5:107

10

Page 84: AB MicroLogix Training Manual

18 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Self-Resetting Counter. A self-resetting counter is a counterthat resets itself in the same scan after the accumulated valuereaches the preset value. Often a reset instruction is used in acounter circuit to implement a self-resetting action. However,this should be avoided in a MicroLogix 1000 unless certain pre-cautions are taken, because the result will be an incorrect countvalue. Following is an explanation of why.

Figure 4-26 shows a reset instruction used to implement a self-resetting counter. When the counter’s input turns on, the accu-mulated count value will increase to 1. At the same time, thecounter’s count up bit, bit 15, will turn on because its actionfollows that of the counter’s input. Since the count up bit re-flects the status of the input signal, the PLC uses it to determineif the input signal has made an OFF-to-ON transition. It doesthis by comparing the current status of the input signal to thevalue stored in the count up bit address.

Figure 4-27 shows the self-resetting counter circuit after severalsubsequent scans. If the input remains on in the scan followingthe 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.Since the count up value is already a 1, the PLC detects that theinput has not made an OFF-to-ON transition. The controller willcontinue to make this same comparison every scan (points Band C). Therefore, when the input signal makes an off-to-ontransition (point D), the MicroLogix will know it because thePLC will detect that the current status of the input is 1 and thatthe previous status of the count up bit was 0. Since the PLCsenses an OFF-to-ON transition, it will increase its accumulatedcount value by one. In this circuit, the done bit will turn onsince the accumulated value now equals the preset value.

Figure 4-26. A reset instruction used to implement a self-resetting counter.

Figure 4-27. The self-resetting counter circuit after several subsequent scans.

DN

CU

I:0.0/0

C5:2

RES

C5:2/DN

Input

CU (Bit 15)

DN

Reset

10101010

COUNT UP

Counter Preset Accum

CTU

C5:221

DN

CU

I:0.0/0

Scan

C5:2

RES

C5:2/DN

Input

CU (Bit 15)

DN

Reset

10

A B C D

101010

1 2 3 4 5 6

COUNT UP

Counter Preset Accum

CTU

C5:222

Page 85: AB MicroLogix Training Manual

Module 4 19

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Figure 4-28 shows what will happen after the counter’s done bitturns on. When the done output turns on, the reset bit will alsoturn on since the done bit provides the input logic to the resetcoil. The reset instruction will reset the accumulated value, aswell 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 theinput signal has not turned off (point B). This means that in thenext scan the PLC will sense an OFF-to-ON transition as it com-pares the input signal to the count up value (point C), eventhough no transition has occurred. As a result, the PLC will in-crease the counter’s accumulated value, despite the fact that noactual input transition has occurred.

Thus, using a reset instruction to implement a self-resettingcounter will result in an inaccurate accumulated count value. Toavoid this situation, you can use one of the following program-ming methods to create a self-resetting counter:

• Use a clear instruction instead of a reset instruction toset the counter’s accumulated value to 0.

• Use a move instruction to move a value of 0 into theaccumulated word at the end of the scan.

• Use a reset instruction, but with a one-shot rising in-struction programmed at the input to the counter. Thisone-shot instruction will ensure that the input mustturn 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-resettingcounter programming methods.

Counting Past The Maximum Count Value. A counterinstruction’s accumulated value has a range from –32,768 to+32,767. Once a counter reaches a count of +32,767, it cannot

Figure 4-28.An illustration of what will happen after the count up instruction’saccumulated value is reset.

DN

CU

I:0.0/0

C5:2

RES

C5:2/DN

Input

CU (Bit 15)

DN

Reset

10101010

1

0

COUNT UP

Counter Preset Accum

CTU

C5:221

Scan 1 2 3 4 6 75

A

B

C

Page 86: AB MicroLogix Training Manual

20 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

go any higher. Therefore, it wraps the accumulated count backaround to –32,768 and starts counting up again. To count pastthe +32,767 count value, you must cascade two counters, mak-ing sure that they self-reset in each scan.

When two counters are cascaded, they are programmed so thatone counter provides the input to the other counter (see Figure4-29). This way, the second counter counts how many times thefirst one has reached its preset value. Figure 4-30 shows twocascaded counters that implement a count to 100,000. Thesecascaded counters have addresses C5:10 and C5:11, and theirprogramming 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 thatreferences the first counter’s done bit.

• The first counter will increase its count every time theinput event occurs. The second counter will increaseits count every time the first counter’s done outputturns on—that is, every time the first counter’s accu-mulated value equals its preset value.

• If the first counter’s preset value is set to 1000 and thesecond counter’s preset value is set to 100, they willimplement a count to 100,000.

• Internal output B3:0/0 indicates when the count hasreached 100,000 because this internal turns on whenthe second counter’s done output turns on.

• The clear instruction resets the contents of the firstcounter’s accumulated word to 0 every time its donebit is enabled, so that the first counter will reset to 0every time it reaches a count of 1000.

Figure 4-29.Cascaded counter, where counter 1 provides the input to counter 2.

Counter1

Counter2

Input

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

DN

CU

CU

I:0.0/0

COUNT UPCounter Preset Accum

CTU

C5:101000

0

DN

C5:10/DN

C5:11/DN

C5:10/DN

B3:0/0

COUNT UPCounter Preset Accum

CTU

C5:11100

0

CLRCLEARDest C5:10.2

Page 87: AB MicroLogix Training Manual

Module 4 21

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Job Aid 2-2 provides more information about cascading countersto count past the maximum count.

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

Figure 4-31. If the input events to be counted are happening at a rate faster thanthe scan, some of the inputs will not be counted.

Inputs

Detected NotDetected

Detected NotDetected

Detected

SCAN SCAN

Page 88: AB MicroLogix Training Manual

22 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

4-3 Data Handling Instructions

This section discusses data-handling instructions. Data-handlinginstructions 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.

At the end of this section, you will know:

• BCD data-handling information

• how to use a convert-from-BCD instruction

• how to use a convert-to-BCD instruction

• how a move instruction operates

• how a masked move instruction operates

• how to apply ladder logic filtering to a BCD application

BCD Data-Handling InformationBefore you can understand how BCD data-handling instructionswork, you must first understand two fundamental BCD topics:

• how BCD input data is sent from an input field deviceto a PLC

• how BCD output data is sent from a PLC to an outputfield device

Reading BCD Input Data. A BCD input device communicatesa decimal value to a PLC in binary coded decimal form. Tocommunicate this data, the device uses a 4-bit code containing1s and 0s (see Figure 4-32). To send this code to the controller,the device requires 4 input connections to the PLC’s input inter-

Figure 4-32.(a) Two BCD thumbwheel switches communicating decimal values toa PLC in binary coded decimal form and (b) a decimal-to-BCDconversion table.

Decimal BCD

0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001

(a)

(b)

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

0 1 0 1 0 0 1 1

5 3+

+

Page 89: AB MicroLogix Training Manual

Module 4 23

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

face—one connection for each BCD code bit. If more than oneinput device is used, then each device requires its own fourseparate input connections.

Figure 4-33 shows a thumbwheel switch connected to the firstfour input terminals of a MicroLogix PLC. This thumbwheel switchwill transmit the BCD-equivalent value of the number 5 to thecontroller by providing a voltage to terminals 1 and 3, but not toterminals 0 and 2. Note that the PLC will interpret this numberas 1010 instead of 0101, which is the actual BCD equivalent ofthe decimal number 5. This occurs because of the way the switchis wired. The BCD data will be stored in the input file in reverseorder, with the most significant bit of the BCD value in the leastsignificant input bit position and vice versa.

After the PLC has received the thumbwheel switch’s BCD data,the data must be stored in the integer file in the correct order ofsignificance. The ladder program shown in Figure 4-34 performsthis task. Each rung of this program contains an examine-if-closed instruction that references one of the inputs. Each rungalso contains an internal coil that references a bit in the integerfile, which is where the input data will be transferred. This pro-gram operates as follows:

• The thumbwheel’s inputs are programmed to transfertheir data to the appropriate bit of the integer word tomaintain the proper bit significance (i.e., input 3 to bit0, input 2 to bit 1, input 1 to bit 2, and input 0 to bit 3).

• When the MicroLogix receives the BCD code equiva-lent to the number 5, the contacts referencing inputs 1and 3 will energize. As a result, the internal outputscorresponding to integer word bits 0 and 2 will be on.

• At the same time, inputs 0 and 2, corresponding tointernal outputs 1 and 3, will be off.

Figure 4-33.A thumbwheel switch connected to the first four input terminals of aMicroLogix PLC.

Figure 4-34.Ladder program used to store the BCD data in the integer file in thecorrect order of significance.

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5

0 1 0 1

LSBMSB

LSBMSB

5+

– 1 0231 001 I:0.0

I:0.0/3

I:0.0/2

I:0.0/1

I:0.0/0

N7:0/0

N7:0/1

N7:0/2

N7:0/3

LSBMSB

1 0231 001

N7:0

1 0230 110

I:0.0

Page 90: AB MicroLogix Training Manual

24 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

• Consequently, bits 0 through 3 of the integer file willstore the value 0101, which is the BCD equivalent ofthe number 5.

Writing BCD Output Data. A BCD output device works theopposite of a BCD input. Figure 4-35 shows a seven-segmentindicator 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.The indicator is wired so that its least significant bit is wired toterminal 5 and its most significant bit is wired to terminal 2.

Figure 4-36 shows the ladder program used to transfer the BCDdata from the integer file to the output device in the correctorder. This program uses internal contacts to reference the BCDdata stored in the integer file word. The rungs in this programenergize based on the status of their reference bits. This trans-fers the BCD data to the output file via the output coils. Theladder program reverses the data from the integer file so that itis in the appropriate order and place in the output file.

BCD I/O Utilization. Using BCD input and output devices cantie up a MicroLogix 1000’s 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 usedfor just the BCD devices alone. This leaves no room for otherinputs or outputs.

As an alternative to BCD I/O devices, you can use a MicroViewoperator interface instead. This MicroView interface inputs BCDdata directly to the controller, replacing the need for thumb-wheel switches, seven-segment indicators, and other similar BCDdevices. This interface connects directly to the MicroLogix’s RS-232 communication channel, meaning that it does not utilizeany of the I/O terminals. The MicroView interface comes inboth a handheld and a panel-mounted model.

Figure 4-35. A seven-segment indicator connected to a MicroLogix’s output interface.

Figure 4-36.Ladder program used to transfer the BCD data from the integer file tothe output device in the correct order.

1 0230 110

N7:0/0

N7:0/1

N7:0/2

N7:0/3

O:0/5

O:0/4

O:0/3

O:0/2

N7:0

1 0230 110 O:0

5 4 23O:0

0 1 0 1

VACVDC

VACVDC

VACVDC

VACVDCO/0 O/1 O/2 O/3 O/4 O/5 O/6 O/7

DC IN+24–

Page 91: AB MicroLogix Training Manual

Module 4 25

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Convert-From-BCD InstructionA convert-from-BCD instruction is a block instruction thatconverts the BCD data stored in a MicroLogix’s data file into itsequivalent decimal value (see Figure 4-37). This instruction block,which is abbreviated by the letters FRD, contains two pieces ofinformation:

• a source location

• a destination location

The source location indicates where the BCD data to be con-verted is located. The destination location indicates where thedecimal-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.This data is represented as two sets of 4-bit codes, with oneset—bits 4 through 7— being the BCD equivalent of the num-ber 1 (0001) and the other set—bits 0 through 3—being theBCD equivalent of the number 5 (0101).

Although the data in word 0 is supposed to represent the deci-mal number 15, the MicroLogix does not interpret it that way.Because a PLC is a straight binary machine, it interprets the datain word 0 as the binary number 00010101, which is actually thedecimal number 21. As a result, you must use a convert-from-BCD instruction to convert the BCD value 15 (00010101) intothe binary equivalent of the value 15 (00001111) and store thisconverted value in a new word location (N7:1).

Convert-To-BCD InstructionA convert-to-BCD instruction looks like a convert-from-BCDinstruction, but it is abbreviated TOD (see Figure 4-39). A convert-to-BCD instruction converts data stored in decimal form into its

Figure 4-37. A convert-from-BCD instruction.

Figure 4-38.A convert-from-BCD instruction used to convert the BCD number15 into the binary equivalent of the decimal number 15.

FROM BCD

Source

Dest

FRD

N7: 0

N7: 1

BCD

DecimalEquivalent

Figure 4-39. A convert-to-BCD instruction.

TO BCD

Source

Dest

TOD

N7: 7

N7: 9

Decimal

BCD Equivalent

N7:0BCD 15

N7:1Binary 15

FRD

1 0235 467

1 0235 467

0 10 0 0 10 1

0 00 0 1 11 1

Page 92: AB MicroLogix Training Manual

26 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

equivalent BCD value. This instruction’s source word contains thedecimal value to be converted, while its destination word indicateswhere the converted BCD-equivalent value should be stored.

A convert-to-BCD instruction performs the opposite function ofa convert-from-BCD instruction. Figure 4-40 shows a convert-to-BCD instruction that takes the binary-equivalent decimal value15 (00001111) and converts it into the BCD-equivalent form ofthe number 15 (00010101). It then stores this BCD number in anew word. Thus, the convert-to-BCD instruction converts thedecimal data into its BCD-equivalent value, which can then besent to a BCD output device.

Move InstructionLike BCD instructions, a move instruction also comes in a blockformat with both a source and a destination parameter (see Fig-ure 4-41). A move instruction, however, simply moves data fromthe source word and puts it into the destination word. It does notconvert or manipulate the data in any way. The data in a moveblock’s source parameter can be either a variable value stored ina word, which changes during program execution, or a fixedconstant value, which is entered during programming.

Masked Move InstructionA masked move instruction is used to manipulate data as it ismoved (see Figure 4-42). A masked move instruction operateslike a regular move instruction, except that a masked move letsyou filter out data that you do not want to move. The maskparameter specified in the instruction block is what performsthis filtering process. This mask parameter can be either a wordaddress location or a hexadecimal constant.

Figure 4-40.A convert-to-BCD instruction used to convert the binary-equivalentdecimal value 15 (00001111) into the BCD equivalent form of thenumber 15 (00010101).

Figure 4-42. A masked move instruction.

ConstantVariable

MOVE

Source

Dest

MOV

N7:3

N7:11

Figure 4-41. A move instruction.

1 0235 467

1 0235 467

N7:7

N7:9

0 00 0 1 11 1 Binary 15

BCD 150 10 0 0 10 1

TOD

Hex Constant

Word Address

MASKED MOVESourceMaskDest

MVM

N7:0F00F

N7:10

Page 93: AB MicroLogix Training Manual

Module 4 27

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

The mask parameter of a masked move instruction specifieswhich 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 wordcontains a 1, then the corresponding bit in the source word willbe moved to the destination word. Conversely, if a bit in themask contains a 0, then the corresponding bit in the sourceword will not be moved to the destination word.

As an example, Figure 4-44 shows a masked move instructionthat moves only the first four and last four bits of data in thesource word to the destination word. The instruction operateslike this:

• The first four and last four bits of the mask word areset to 1, while the other bits are left as 0.

• When the masked move instruction is energized, onlythe first four and last four bits of data will be moved tothe destination word.

• The middle bits in the destination word will not bereplaced. They will remain in their previous state, whichin this case was all zeros.

The bits in the mask register are set to either 1 or 0 in groups offour using the hexadecimal equivalent of each group’s binarypattern. Thus, you would use the letter F to indicate that a groupof four bits is set to one. You would use a 0 to indicate that agroup of four bits is set to zero. This notation is what you see asthe mask value in the masked move instruction. Job Aid 4-3provides more information on using mask codes to filter dataand input BCD information.

Figure 4-43. Mask parameter of a masked move instruction.

Figure 4-44. A masked move instruction’s source, mask, and destination values.

Source

Destination

MASK Not movedMoved

MASKED1 0

Source

Mask

Destination

1 0 1 1 1 1 0 0 1 1 0 0 0 1 0 1

1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1

1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1

Page 94: AB MicroLogix Training Manual

28 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Ladder Logic FilteringLadder logic filtering prevents BCD conversion errors due tothe difference in the BCD device and PLC processing speeds.Figure 4-45 shows a thumbwheel switch that is sending the BCDnumber 7 to a MicroLogix 1000. The PLC sees this number 7 asthe BCD value 0111. Note that the thumbwheel switch is wiredso that its least significant bit corresponds to the least significantinput word bit and its most significant bit corresponds to themost significant input word bit.

If the thumbwheel switch’s value changes from 7 to the number8, which has the BCD binary pattern of 1000, the device willsend the new number to the PLC. Because of its mechanicalnature, however, a BCD device operates slowly as compared toa MicroLogix 1000. Thus, the BCD device may not be able tosend 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 BCDpattern for the selected number. During this time, the output ofthe 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), andthen the PLC performs a scan, the controller will read the BCDnumber 1111. This is not a valid BCD value. Thus, if theMicroLogix tries to perform a BCD conversion on this data onceit has been input to the controller, an overflow will occur in bit1 of status file word 0 (the math overflow bit). This overflowwill cause an error fault at the end of the scan, halting the PLC’soperation. As a result of this invalid BCD number, the PLC willstore a +32,767 in the destination word of the convert-from-BCD instruction.

Figure 4-45. A thumbwheel switch sending the number 7 to a MicroLogix.

Figure 4-46. The thumbwheel switch’s value changing from 7 to the number 8.

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5

1 1 1 1 1 023LSBMSB

I:0.01 111

8+

Fast

Slow

Overflow S2:0/1

Error Fault

+32,767

FRD

DCCOM

NOTUSED

NOTUSED

I/0 DCCOMI/1 I/2 I/3 I/4 I/5

0 1 1 1

1 023LSBMSB

I:0.01 110

7+

LSB MSB

MSB LSB

Page 95: AB MicroLogix Training Manual

Module 4 29

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

To avoid this situation, you must apply ladder logic filtering tothe circuit. Ladder logic filtering ensures that the data receivedfrom the BCD device is a valid BCD code. This way, the PLCwill wait until it has received all of the updated BCD input databefore it performs a BCD-to-binary conversion.

Figure 4-47 shows a circuit with ladder logic filtering. It containsthree rungs, which perform the following functions:

• The first rung contains a convert-from-BCD block thatconverts the BCD data in word N7:0 to its decimalbinary equivalent and stores it in word N7:1.

• The second rung contains an examine-if-closed con-tact that references the MicroLogix’s status overflowbit. If this contact is on, the convert-from-BCD instruc-tion in rung one has read an invalid BCD code in itssource register. This contact drives an unlatch coil thatresets the overflow condition so that the MicroLogixwill not fault at the end of the scan. This will allow thePLC to keep reading the input data.

• 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 BCDcode, then the overflow bit will not be on. Accord-ingly, this rung will energize, moving the convertedBCD 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, wordN7:10) will hold the converted valid BCD value. This destina-tion word should be used when referencing the converted BCDnumber in the ladder program.

Figure 4-47. A circuit with ladder logic filtering.

Overflow TrapS2:5/0

Overflow FlagS2:0/1

U

S2:0/1

FROM BCDSource

Dest

FRD

N7:0

N7:1

MOVESource

Dest

MOV

N7:1

N7:10

Page 96: AB MicroLogix Training Manual

30 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

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 evenif the timer’s 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 circuitbecause 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 inbinary equivalent form.

• A convert-to-BCD instruction takes the binary data stored in the source word and stores it in the destination word inBCD-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 anoverflow fault resulting from an invalid BCD value.

Page 97: AB MicroLogix Training Manual

Module 4 31

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

4-5 Job Aids

Job Aid 4-1: Self-Resetting Counter Programming MethodsBecause a reset instruction cannot be used alone to implement a self-resetting counter circuit, you must use another programmingmethod to implement this type of circuit. Following are three methods that can be used to create a self-resetting counter.

Method 2: Use a move instruction tomove a source value of 0 into thecounter’s accumulated word at theend of the scan.

Method 1: Use a clear instruction toset the counter’s accumulated countvalue to 0.

Method 3: Use a reset instruction inconjunction with a one-shot rising in-struction programmed at the input tothe counter.

TON

1600

TIMER T4:0Time BasePresetAccum

DN

I:0.0/0

CU

C5:I0/DN

CTU

C5:10500

0

COUNT UPCounterPresetAccum

(Clears accumulated value)

CLRCLEARDest C5:10.ACC

TON

1600

TIMER T4:0Time BasePresetAccum

DN

I:0.0/0

CU

C5:I0/DN

CTU

C5:10500

0

COUNT UPCounterPresetAccum

(Moves a constant of 0 to theaccumulated value)

MOVMOVESourceDest

0C5:10.ACC

TONTIMER T4:0Time BasePresetAccum

DN

I:0.0/0 B3:0/0

OSR CU

C5:I0/DN C5:10

RES

CTU

C5:10500

0

COUNT UPCounterPresetAccum

(Resets accumulatedvalue to 0)

Page 98: AB MicroLogix Training Manual

32 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Job Aid 4-2: Counting Past the Maximum CountWhen a counter instruction reaches the end of its range of count values (–32,768 to +32,767), it wraps the accumulated count valueback around and starts counting from the other side. The following graphic illustrates what occurs when a counter reaches itsmaximum count of +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 settingits preset value to the opposite end of the range because the done bit will not behave properly. For example, you could try tocount to +32,770 by setting a counter’s preset value to –32,766, since this value is three counts past the maximum limit once thecounter 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 counter’s done output will turn on, even though its accumulated value is less thanits 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,767–32,768 Counter

Page 99: AB MicroLogix Training Manual

Module 4 33

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

Job Aid 4-3: Using Mask Codes to Filter BCD DataYou 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/OMicroLogix 1000:

To filter and move this BCD data, you could use a masked move instruction to mask out all but the thumbwheel switch’s input dataand move it to an integer word location. You could then use a bit shift right instruction to shift the BCD data into the integer word’sfirst 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 amasked move (MVM) instruction in rung 0 to read the thumbwheel switch’s input data (inputs I/2 through I/5). The MVMinstruction uses a hexadecimal mask value of 003C to move only the desired bits into word N7:0. The bits in this word must thenbe shifted two positions to the right for the word to contain the correct BCD number in the correct position. The shifting of the twobits is accomplished in rungs 1 through 5. Rung 6 implements a BCD-to-decimal conversion.

DCCOM

NOTUSED

NOTUSED

I/0 DCCOM

I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9

5+

0 1 0 1

Page 100: AB MicroLogix Training Manual

34 Module 4

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

TON

Read DataInput Signal

I:0.0/9

Read DataInput Signal

I:0.0/9

Read DataInput Signal

I:0.0/9

ProcessorArithmeticUnderflow/

OverflowFlagS2:0/1

ProcessorArithmeticUnderflow/

Overflow FlagS2:0/1

NotShifted 2 Times

Q2:99Shifted 2 Times

C5:0/DN

Shifted 2 TimesC5:0/DN

Shifted 2 TimesC5:0/DN

NotShifted 2 Times

Q2:99

OverflowTrap

S2:5/0

Finished 2 Shifts Reset Counter

C5:0

Reset Shift to 0B3:0/0

Reset Shift to 0B3:0/0

Shift CommandB3:0/2

Shift CommandB3:0/2

Shift CommandB3:0/2

LBL

END

Shifted 2 TimesC5:0/DN

DN

EN

DN

JMP

CUU

CTU

C5:020

COUNT UPCounterPresetAccum

TONFRD

N7:0N7:1

FROM BCDSourceDest

TONMOV

N7:1N7:10

MOVESourceDest

TONBSR

N7:0R6:0

N7:0/156

BIT SHIFT RIGHTFileControlBit AddressLength

TONMVM

I:0.0003CN7:0

MASKED MOVESourceMaskDest

1

0

2

3 6

7

4

5

Page 101: AB MicroLogix Training Manual

Module 4 35

T i m i n g , C o u n t i n g , a n d D a t a - H a n d l i n g I n s t r u c t i o n s

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 readsand transfers the thumbwheel switch’s BCD input data to word N7:0. If the input data is to be read continuously, ratherthan conditionally, this XIC contact should be omitted. If this is the case, the I:0.0/9 contacts in rungs 1 and 4 should beomitted 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 counterkeeps 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 rung2 (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 programexecution will move to rung 5. Rung 5 resets the counter’s accumulated value.

• Rung 3: The BSR instruction shifts the BCD data bits in the integer word. When the BSR block’s input turns from OFF toON, the block will shift the contents of word N7:0 one bit to the right. The block uses the following parameters tocomplete 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 shifted—i.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. Thisbit address will always contain a 0, so each time the BSR instruction is executed, the bits in word N7:0 will be shiftedone 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 counter’s doneoutput 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 beenshifted into the proper position, the convert-from-BCD block will convert the BCD number into its equivalent decimalvalue. 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 newlyconverted 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 wantto include it in the main program.

Page 102: AB MicroLogix Training Manual

M O D U L E F I V E

5K

ey

Po

ints

COMPARISON AND

FLOW CONTROL

INSTRUCTIONS

This final module covers two more categories of programminginstructions: comparison instructions and flow control instructions.Comparison instructions are used in a MicroLogix 1000 to comparethe values stored in two memory locations. Flow control instructionsare used to change the order of execution of instructions in a ladderprogram. This module contains four sections:

1. Comparison instructions

2. Flow control instructions—alter sequence

3. Flow control instructions—halt execution

4. Flow control instructions—alter I/O scan

After finishing this module, you will:

■ understand the different comparison instructions available inthe MicroLogix 1000—including equal, masked comparison forequal, and the limit test instructions

■ know the flow control instructions that alter the sequence ofprogram execution—including the jump, jump to subroutine, andmaster 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 immediateoutput with mask instruction

Page 103: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

2 Module 5

5-1 Comparison Instructions

Comparison instructions compare the values stored in two mem-ory locations. These two values can be the data stored in twodifferent word locations, or one can be the data stored in aword and the other can be a constant value.

At the end of this section, you will know:

• the equal instruction

• other basic comparison instructions that work like theequal instruction

• the masked comparison for equal instruction

• the limit test instruction

Equal InstructionThe equal instruction is a block instruction that looks like theone shown in Figure 5-1. This instruction compares the datavalues specified by the source A and source B parameters. Ifthese data values are equal, then the equal block’s output willenergize, providing continuity to the rest of the rung.

The value specified by source A must be a word location inmemory (see Figure 5-2). This word location may specify theaccumulated value for a timer or counter, the contents of aninteger file word, or any other data stored in memory. The valuespecified by source B may be either a word location or a con-stant. If source B contains a word location, then it specifies thelocation of particular data in memory, just as the source A pa-rameter does. If source B is a constant, then this parameter con-tains a fixed decimal value to which the instruction comparesthe source A data.

Figure 5-2. In an equal instruction, the value specified by source A must be a wordlocation. The value specified by source B may be either a word locationor a constant.

Figure 5-1. An equal instruction.

EQUALSource A

Source B

EQU

N7:0

N7:1

EQUALSource A

Source B

EQU

Word

Wordor

Constant

Page 104: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 3

An equal instruction is always the first instruction programmed ina rung (see Figure 5-3). This instruction looks at the data stored inthe source A word, which may hold a value such as the inputvalue from a set of thumbwheel switches. The equal instructionthen compares this source A data to the value indicated by sourceB. If these two data values are equal, the equal block energizes,providing continuity to the rest of the rung. If the other inputconditions in the rung are satisfied, the output will turn on. If thesource A and B values are not equal, then the equal block will notbe energized (see Figure 5-4). As a result, the output will not beenergized, even if the other input conditions are satisfied.

Other Basic Comparison InstructionsThe five other comparison instructions used in a MicroLogix1000 work much like the equal instruction. All of these othercomparison instructions are block instructions that specify sourceA and source B values. As in an equal block, source A must bea word location, while source B can be either a word location ora constant. The other comparison instructions are as follows:

• not equal instruction—energizes its output if thesource A and B values are not equal to each other

• less than instruction—energizes its output if the val-ue in source A is less than the value stored in source B

• less than or equal instruction—energizes its outputif the source A value is either less than or equal to thesource B value

• greater than instruction—energizes its output if thevalue stored in source A is greater than the value storedin source B

Figure 5-3. An equal instruction programmed in a ladder rung.

Figure 5-4. If the source A and B values are not equal, then the equal block will notbe energized.

Source A

Source B

EQUAL

EQU O:0/0I: 0.0/0

A ≠ B

N7:1

587

Source A

Source B

EQUAL

EQU O:0/0I: 0.0/0

A = B

N7:1

587

Page 105: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

4 Module 5

• greater than or equal instruction—energizes itsoutput if the source A value is greater than or equal tothe source B value

Masked Comparison For Equal InstructionA masked comparison for equal instruction, which is shownin Figure 5-5, is abbreviated as MEQ in a MicroLogix’s ladderprogram. This instruction compares part of the word specifiedby the source location with the value specified by the comparelocation. It uses a mask value to filter out those parts of thesource value that will not be compared. An MEQ instruction’ssource, compare, and mask parameters work as follows:

• The source parameter specifies the word location ofthe data to be compared. This is equivalent to the sourceA parameter in an equal instruction.

• The mask parameter specifies either the word locationof the mask value or the mask value itself. If the maskvalue is entered directly into the MEQ block, then itwill be expressed in hexadecimal form. If the maskparameter specifies a word location, then the decimalvalue in the word will be displayed in the block inhexadecimal form.

• The compare parameter specifies either a word loca-tion or a constant value. The compare parameter ismuch like an equal instruction’s source B parameter.

When an MEQ instruction is enabled, it takes the value stored inthe source word and then masks out the bits denoted by zeroesin the mask (see Figure 5-6). This leaves only the bits that arespecified by ones in the mask. The block then compares thismasked value to the compare value. If the two bit patterns de-fined by the mask are equal, the block’s output turns on.

Figure 5-5. A masked comparison for equal instruction.

Figure 5-6. When an MEQ instruction is enabled, it masks out the source word bitsdenoted by zeroes in the mask.

MASKED EQUALSource

Mask

Compare

MEQ

N7:0

N7:1

N7:2

0 0 0 0 0 0 0 0 1 1 1 1 0 00 0

MEQ

N7:0

000F0

N7:2

Source

Mask

Compare

MASKED EQUAL

0 0 0F

N7:10

Page 106: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 5

An MEQ instruction is useful for applications such as decodingdata from multiple thumbwheel switches. Figure 5-7 shows anexample of this type of application in which two thumbwheelswitches are connected to terminals 0 through 7 of a MicroLogix1000. The first thumbwheel switch sends pressure data to thePLC, while the second thumbwheel switch sends volume data.The MicroLogix stores this data in the first eight bits of file N7:0.

Figure 5-8 shows a ladder program in which output O:0/0 turnson when the pressure level is 3. The program works like this:

• The source value for the masked comparison for equalinstruction is integer file 0 (N7:0).

• The mask value is 000F, which will mask out all butthe first thumbwheel switch’s bits.

• The compare value is the decimal value 3, which isequivalent to the binary value 11.

• When the masked comparison block is energized, itcompares the masked pressure value (0011) with thecompare value (0011). Because they are equal, theinstruction block will energize the rung.

Note that the masked comparison for equal instruction only com-pares the bits that are specified by ones in the mask. If thesource word had contained any number other than 3, the com-parison would have been false.

If you wanted to compare the volume data instead, you wouldhave to specify a hex mask with the value 00F0 (Figure 5-9).This mask value will only pass and compare the data from thesecond thumbwheel switch. You would also have to enter an 80as the compare value rather than 5. This is because the decimalvalue 80 translates into the binary value to be compared (i.e.,the value 0101 located in bits 4 through 7). Because the com-Figure 5-8. A ladder program in which output O:0/0 turns on when the pressure

level is 3.

Figure 5-7. An MEQ instruction used to decode data from multiple thumbwheelswitches.

Source

Mask

Compare

N7:0

000F

3

MEQ

0 0 0 0 0 0 0 0 0 0 0 0

0 0 1 1

1 10 0

0 0 0 0 0 0 0 0 0 1 0 1 1 10 0

0 0 0 0 0 0 0 0 0 0 0 0 1 11 1

O:0/0

N7:0

Mask 000F

Compare 310

5TWS #2

3TWS #1

0 0 0 0 0 0 0 0 0 1 0 1 1 10 0 N7:0

5TWS #2

3TWS #1

I/0 I/1 I/2 I/3 I/4 I/5 I/6 I/7 I/8 I/9DCCOM

DCCOM

NOTUSED

NOTUSED

VolumeTWS #2

PressureTWS #1

3+

5+

Page 107: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

6 Module 5

parison is true, the output will turn on. If you used the decimalvalue 5, it would generate the wrong binary comparison value(0101 located in bits 0 through 3). Thus, the MEQ instructionwould not work correctly because the masked source value wouldnot be identical to the compare value.

Limit Test InstructionA limit test instruction, which is abbreviated as LIM, checks avalue to see whether it is within a certain range (see Figure5-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 orequal to them, the block’s output energizes or de-energizes ac-cording to how the high and low parameters are defined.

In a limit test instruction, the test value can be either a constantor a word (see Figure 5-11). If the test value is a constant, thelow and high limit values must be words. If the test value is aword, then the low and high limits can be either words or con-stants. The function of a limit test instruction depends on whichis greater, the high limit value or the low limit value:

• If the high limit is greater than the low limit, the block’soutput will be on if the test value is between the twolimits. The block’s output will be off if the test value islower than the low limit or greater than the high limit.

• If the low limit is greater than the high limit, the block’soutput will be off if the test value is between the twolimits. The block’s output will be on if the test value isgreater than the low limit or lower than the high limit.

This high and low limit information is important to remember,especially when using word addresses for the high and lowlimit values. In this situation, the output continuity of the limittest block may reverse if the contents of the high and low limitwords change.

Figure 5-10. A limit test instruction.

LIMIT TESTLow LimTestHigh Lim

0N7:1100

LIM

Figure 5-11. In a limit test instruction, the test value can be either a constant or a word.

LIMIT TESTLow LimTestHigh Lim

WordConstant

Word

LIMLIMIT TESTLow LimTestHigh Lim

Word or Constant

WordWord or Constant

LIM

Figure 5-9. A ladder program in which output O:0/0 turns on when the pressurevolume level is 5.

Source

Mask

Compare

N7:0

00F0

80

MEQ

0 0 0 0 0 0 0 0 0 1 0 1

0 1 0 1

0 00 0

0 0 0 0 0 0 0 0 0 1 0 1 1 10 0

0 0 0 0 0 0 0 0 1 1 1 1 0 00 0

O:0/0

N7:0

Mask 00F0

Compare 8010

5TWS #2

3TWS #1

Page 108: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 7

Figure 5-12 illustrates is an example of how a limit test instruc-tion can be used in a process application to ensure that an oper-ator enters a valid parameter into the PLC. In this application, thelimit test instruction’s test value is the word location of the dataentered by the operator (word N7:8). The low and high limitvalues are the minimum and maximum possible valid entries.Thus, if the test value falls within the valid entry range, the limittest 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 validparameter into the PLC.

LIMIT TESTLow Lim TestHigh Lim

0N7:8

10000

LIM To restof

logic

Page 109: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

8 Module 5

5-2 Flow Control Instructions—Alter Sequence

A MicroLogix 1000 uses three types of flow control instructions—those that alter the sequence of the control program’s execu-tion, those that halt its execution, and those that alter the I/Oscan reading. This section covers the first type, those that alterthe sequence of evaluation of the rungs in a ladder program. Atthe end of this section, you will know:

• the jump instruction

• the jump to subroutine instruction

• the master control reset instruction

Jump InstructionA jump instruction (see Figure 5-13) is a coil instruction thatjumps the PLC’s program execution to a specified rung, therebyskipping those rungs programmed between the jump instruc-tion and the destination rung. Because it does not reference aparticular memory location, a jump instruction can have anynumerical address between 0 and 999. A jump coil instructionworks in conjunction with a label contact instruction, whichspecifies which rung to jump to.

Figure 5-14 illustrates how a jump instruction works. In thisprogram, the output of the first rung is a jump coil with address10. The fourth rung begins with a label contact that shares thejump coil’s address. If input I:0.0/0 is true, jump coil 10 will beenergized. This will cause the MicroLogix to jump to the rungcontaining the label instruction with address 10 and resume pro-gram execution from there. Thus, the jump instruction causesthe PLC to skip the execution of rungs two and three. If thejump instruction is not energized, then the PLC will evaluate allthe rungs of the ladder program as it would normally.

Figure 5-13. A jump instruction and a label instruction

Figure 5-14. A ladder program containing a jump instruction.

LBL

JMP

10

I:0.0/0

I:0.0/1 O:0/0

I:0.0/2 O:0/1

I:0.1/0 I:0.1/1 O:0/5

10

LBLJMP

Page 110: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 9

Figure 5-15 illustrates how a jump instruction can be used tocontrol the manual or automatic operation of a machine. In thisexample, if the selector switch connected to input 0 is off, themachine 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 instructions—one set for when themachine is in manual mode and another set for when the ma-chine is in automatic mode. This avoids having to interlock themanual and automatic programming in all of the ladder instruc-tions. Following is a description of how this program works:

• If the selector switch is on (automatic mode), the jump99 coil in rung one will be energized.

• When the jump 99 coil is energized, the PLC will jumpthe program execution to the rung with label 99.

• When the controller jumps to label 99, it will start ex-ecuting the automatic control program, thereby skip-ping the manual control program.

• Conversely, if the selector switch is off (manual mode),the controller will execute the manual control programbecause it will not jump over it.

• When the PLC finishes the manual program, the con-troller will encounter a jump 999 instruction that willcause 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 rungcontains 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 automaticoperation at the end of the program.

LBL

LBL

JMP

JMP

AutoI:0.0/0 99

ManI:0.0/0 999

99

L2L1Man Auto

Auto

OFF (Manual)ON (Auto)

999 B3:0/0

ManualOperation

AutoOperation

I/0

Figure 5-15.A jump instruction used to implement manual/automatic machineoperation.

Page 111: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

10 Module 5

Jump instructions affect program execution in a variety of ways.A jump instruction that jumps forward reduces the program scantime, since it omits the execution of part of the ladder program.Jumping backwards has the opposite effect. It increases the scantime, since it causes the PLC to repeat part of the control pro-gram. Both jumping forward and backward are valid uses forjump instructions. In fact, you can even jump forward or back-ward several times to the same label using multiple jump in-structions. Nevertheless, you should be careful not to jump back-wards an excessive number of times. If you do, the processor’swatchdog timer may time out and cause the controller to fault.

Jump To Subroutine InstructionA jump to subroutine instruction (see Figure 5-16) is used tocall a subroutine from the main ladder program. When a jumpto subroutine instruction in the main ladder program is enabled,it causes the program to jump to the specified subroutine locat-ed in the subroutine storage area. The controller then executesthis subroutine until it finds a return or end instruction. At thatpoint, it jumps back to the main program and resumes programexecution with the instruction immediately following the jumpto subroutine instruction.

Three instructions are associated with a jump to subroutine in-struction (see Figure 5-17). These are:

• the subroutine instruction

• the return instruction

• the end instruction

Subroutine Instruction. A subroutine instruction should beprogrammed at the beginning of the subroutine being called.Although this instruction is not technically necessary, it is a goodpractice to use it for programming clarity.

Figure 5-17.A jump to subroutine instruction and its three associated instructions—the subroutine instruction, the return instruction, and the endinstruction.

JUMP TO SUBROUTINE

SBR File Number

JSR

6

JSR

SBR

RET

JUMP TO SUBROUTINE

SBR File Number

SUBROUTINE

RETURN

END

6

Figure 5-16. A jump to subroutine instruction.

Page 112: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 11

Return Instruction. A return instruction is used to tell thePLC to stop executing the subroutine and return to the mainprogram. This instruction terminates a subroutine, either condi-tionally or unconditionally, before the whole subroutine pro-gram has been executed. If a subroutine does not contain areturn instruction, the controller will execute the subroutine untilit reaches the end instruction in the subroutine’s file.

End Instruction. An end instruction is always present as thelast instruction in a subroutine file, just as it is in the main ladderprogram and other program files. This instruction lets the PLCknow that it has finished the subroutine.

Jump to Subroutine Operation. When a jump to subroutineinstruction is enabled, the controller will jump to the subroutinespecified and start executing it (see Figure 5-18). If the PLCencounters an energized return instruction in the subroutine, itwill jump back to the main program and pick up where it leftoff. If it does not find an energized return instruction, the con-troller will wait until it gets to the end of the subroutine beforejumping back to the main ladder program. When a subroutine isexecuted, its outputs remain in their last state, either on or off,until the subroutine is executed again.

As explained in Module 1, a MicroLogix 1000 stores the mainladder program in file 2 of the program file section. It stores thesubroutines in files 6 through 15 of this same section. Each ofthe subroutine files can store one subroutine, for a total of 10subroutines. Although these subroutines do not need to be pro-grammed in the order in which they are called, you should doso anyway.

In a MicroLogix 1000, you can nest subroutines (see Figure 5-19).Nesting involves using one subroutine to call another subrou-tine. You can do this up to eight times in a MicroLogix program,

Figure 5-18. A jump to subroutine instruction that jumps to subroutine 6.

Figure 5-19. Nested subroutines in a MicroLogix 1000 program.

SubroutineProgram

SUBROUTINE

SubroutineProgram(cont'd)

END

JUMP TO SUBROUTINESBR File Number 6

I:0.0/0

I:0.0/3 I:0.1/1

I:0.1/2

O:0/4

File 2 (Main Program)

File 6 (SBR)

RETURNRET

JSR

SBR

MainProgram Level 1

SBR 6 Level 2SBR 7 Level 3

SBR 8 Level 8SBR 13SBR

RET

SBR

RET

SBR

RET

SBR

RET

JSR

JSR7JSR8

JSR9JSR

Page 113: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

12 Module 5

meaning that the subroutine calls can be eight levels deep. Thecontroller will generate a subroutine stack overflow error if morethan eight subroutines are nested in a program. Conversely, thecontroller will generate a subroutine stack underflow error ifthe program contains more return instructions than jump to sub-routine instructions. Note that you can only nest three levels ofsubroutines if you are using the selectable timed interrupt andhigh-speed counter files to store additional subroutines.

To use subroutines to implement the manual/automatic selectorswitch program discussed earlier, you would use a rung con-taining two jump to subroutine instructions (see Figure 5-20).The first JSR instruction references subroutine 6, which storesthe manual control program. The second JSR instruction refer-ences subroutine 7, which stores the automatic control program.Thus, in this control program, when the selector switch is off,the controller will jump to the manual subroutine and executeit. When the selector switch is on, the controller will jump to theautomatic subroutine and execute it instead.

A jump to subroutine instruction can reduce the program scantime 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 programby allowing complex routines to be performed outside the mainprogram. Moreover, subroutines can be used to program tasksthat occur many times in the main ladder program. A lookuptable routine is a good example of this kind of task. By usingjump to subroutine instructions to go to the subroutine for thisrepetitive task, you can avoid having to program the task overand over again in the main control program.

Figure 5-20. Jump to subroutine instructions used to control the manual or automaticoperation of a machine.

L2L1

I:0.0/0

I:0.0/0

JUMP TO SUBROUTINESBR File Number 7

JSR

JUMP TO SUBROUTINESBR File Number 6

JSR

Man Auto

OFF (Manual)ON (Auto)

I/0

Page 114: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 13

Master Control Reset InstructionA master control reset instruction, which is also called anMCR instruction (see Figure 5-21), creates a fence around a groupof ladder rungs. If the MCR instruction is energized, then thecontroller will execute the fenced instructions. If not energized,the controller will not execute the fenced instructions.

Master control reset instructions are always used in pairs to forma conditional fence around a group of rungs. If the input logicto the first MCR is energized, the programmed logic within thefence will be executed. If the input logic to the first MCR is notsatisfied, then the controller will skip the fenced logic and re-sume program execution after the second MCR instruction. Thissecond MCR instruction must be unconditional, meaning that itis 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 statusof their input conditions. Only the retentive outputs will retaintheir last status, either ON or OFF.

Figure 5-22 shows a ladder program with two fenced timers todemonstrate how MCRs work. One of these timers is an ON-delay timer; the other is a retentive timer. Both timers are locat-ed within the MCR fence. This means that neither timer will starttiming, even if its input is on, unless the first MCR instruction ison. When the first MCR instruction turns on, both timers will beenabled if their inputs are on. Thus, the timers will start timing,and if the MCR zone stays on long enough, both timers will timeout. When the first MCR eventually turns off, the ON-delay tim-er’s output will turn off, since all nonretentive outputs in anMCR fence are reset when the fence turns off. The retentivetimer’s output will remain on.

Figure 5-21. A master control reset instruction.

Figure 5-22. A ladder program with two fenced timers.

• MCR energized fencedinstructions executed

• MCR not energized fenced instructions not executed

MCR

MCR

MCRTON

T4:01.0100

EN

ENDN

DN

MCRFence

TIMER ON-DELAYTimerTime BasePresetAccum

RTO

T4:11.0100

RETENTIVE TIMER ONTimerTime BasePresetAccum

Page 115: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

14 Module 5

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 eithertimer has timed out. In this situation, the timers will start timingwhen the first MCR instruction turns on. However, when theMCR turns off, the timers will turn off too, even though theirinputs may still be on. As a result, the accumulated value of theON-delay timer will be reset to 0. The retentive timer, however,will retain its accumulated value. To reset the retentive timer’saccumulated value, you would need to add a reset instructionoutside of the MCR fence (see Figure 5-23). If this reset instruc-tion was located inside the fence, it could only reset the reten-tive timer when the MCR zone was activated.

When using MCR instructions, you should never use a jumpinstruction to jump inside an MCR zone. If you do, the logic youjump to inside the MCR fence will be evaluated, regardless ofwhether the MCR is on. This can cause a hazardous situation.Also, you should be aware that although nesting is permittedwith subroutines, it is not allowed with MCR zones.

Figure 5-23.A ladder program with two fenced timers that uses a reset instructionto reset the RTO instruction.

MCR

MCRTON

T4:01.0100

EN

ENDN

DN

MCRFence

TIMER ON-DELAYTimerTime BasePresetAccum

RTO

T4:11.0105

RETENTIVE TIMER ONTimerTime BasePresetAccum

REST4:1

Page 116: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 15

5-3 Flow Control Instructions—Halt Execution

This section discusses flow control instructions that interrupt theexecution of the control program. Two flow control instructionsperform this type of function. They are:

• the temporary end instruction

• the suspend instruction

Temporary End InstructionA temporary end instruction (see Figure 5-24) is a coil in-struction that stops the execution of the control program at thepoint where the temporary end coil is located. It works as fol-lows (see Figure 5-25):

• 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.

• The PLC will then begin its next scan by reading theinputs and executing the control program again, start-ing from the top.

• If the temporary end coil is not on as the PLC per-forms this next scan, the controller will continue withits scan until it reaches either the end of the programor another energized temporary end instruction.

Temporary end instructions are often used to test or trouble-shoot certain parts of a control program. They allow you to testpart of the control program with the inputs and outputs on-line,without having to run through the rest of the program. For ex-ample, Figure 5-26 shows a control program with two sections—one section that evaluates an operator’s entry values and anoth-er section that runs a conveyor belt. If you want to test theFigure 5-26.A control program with two sections—one section that evaluates an

operator’s entry values and another section that runs a conveyor belt.

Figure 5-24. A temporary end instruction.

Figure 5-25. The operation of a temporary end instruction.

END

TND

Outputs Inputs

Program

TND

END

TND

Conveyor Belt

Operator Entry

Page 117: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

16 Module 5

operator entry section without turning on the conveyor, thenyou would program an unconditional temporary end after thefirst section. This allows you to run just the top section over andover again until you know that it is working properly. After that,you can take out the temporary end instruction and run thewhole program.

You can use a temporary end instruction in the main programand any of its subroutines stored in files 6 through 15. However,you cannot use a temporary end instruction in the user-errorfault routine (file 3), the high-speed counter interrupt routine(file 4), or the selectable timed interrupt routine (file 5). If youdo, the PLC will generate a fault.

Suspend InstructionLike a temporary end instruction, a suspend instruction (seeFigure 5-27) is used for testing or troubleshooting a control pro-gram. A suspend instruction causes the controller to stop exe-cuting the control program and enter an idle mode. When itdoes this, the controller de-energizes all outputs. However, itdoes not clear the bits in the status file. This allows you checkthe status bits to retrieve information about the controller’s 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 (seeFigure 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-trol program when an overflow occurs to allow troubleshoot-ing. To do this, you would program a suspend instruction, suchas the one in Figure 5-29, which operates as follows:

Figure 5-27. A suspend instruction.

Figure 5-28.When a suspend instruction is activated, its ID number is stored inword 7 of the status file.

Figure 5-29.A suspend instruction used to halt the control program when anoverflow occurs to allow troubleshooting.

SUSPENDSuspend ID 112

SUS

SUSPENDSuspend ID 112

SUSS2:0/1

Status(File 2)

Word 7

SUSPENDSuspend ID 112

SUS

211

Page 118: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 17

• The suspend instruction’s 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 haltthe program execution.

• At this point, you can review the logic programmedbefore the suspend instruction to see why the over-flow occurred.

• The ID number, which is 112 in this case, indicatesthat the suspend was triggered by a math overflow.Other suspend instructions may have different IDs toindicate other reasons for the program halt.

You can also use a suspend instruction after a subroutine toallow you to check the subroutine’s data before resuming themain program (see Figure 5-30). In some critical applications,you may also use one or more inputs to drive one or moresuspend instructions. This kind of programming turns off theoutputs if certain critical error conditions occur.

Figure 5-30.A suspend instruction used after a subroutine to allow a check of thesubroutine’s data before resuming main program execution.

JUMP TO SUBROUTINE

SBR File Number

JSR

SBR #7

SUSPEND

Suspend ID 223

SUS

Check

7

Page 119: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

18 Module 5

5-4 Flow Control Instructions—Alter I/O Scan

This section discusses two flow control instructions that alterthe I/O scan evaluation of the controller. These are:

• the immediate input with mask instruction

• the immediate output with mask instruction

Immediate Input With Mask InstructionAn 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 specifiedinput word to obtain just the data to be updated. Then it inter-rupts normal program execution to store this data to the inputfile. Thus, an immediate input instruction updates input datawithout having to wait until the beginning of the next scan.

In an immediate input instruction, the slot parameter indicatesthe input word to be updated. This will be either I:0.0 or I:0.1.The mask specifies which bits will be masked. This mask, whichis expressed in hexadecimal, works like the mask value used bythe masked move instruction.

An immediate input with mask instruction works as follows (seeFigure 5-32):

• When energized, an immediate input with mask in-struction checks the inputs mapped to the specifiedword for their current status.

• Then it performs a mask to filter out all but the inputbits specified.

Figure 5-31. An immediate input with mask instruction.

Figure 5-32. The operation of an immediate input with mask instruction.

IMMEDIATE INPUT w/MASK

Slot

Mask

I:0.0

000F

IIM

IMMEDIATE INPUT w/MASKSlotMask

I:0.0000F

IIM

1 1 1 1 0 1 1 0 1 1 0 1 0 01 10 0 0 0 0 0 0 0 0 0 0 0 1 11 1

0 01 1

Input StatusMask

Stored to word I:0.0

Page 120: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 19

• It then stores this data to the input word denoted bythe slot parameter. The input bits that are not maskedare not updated; thus, these bits are left in their previ-ous state.

• The PLC uses the updated input data to evaluate all therungs located after the immediate input instruction.

Figure 5-33 shows an example of an IIM application in which alimit switch is connected to input terminal 2 of a MicroLogix1000. To update the data about this input during the ladderprogram, the program contains an IIM instruction whose slotparameter is I:0.0, since this is the input word that maps thelimit switch. The IIM instruction’s mask value is 0004 to maskout all but the data for bit 2. Thus, if the limit switch was offwhen the PLC started its scan but has since turned on, the im-mediate input instruction will interrupt the scan to read the cur-rent status of the limit switch. It will then update the new dataabout the limit switch’s logic status in address I:0.0/2. The restof the program will now use this updated input data.

The mask address specified in an IIM instruction determines howmany inputs will be updated by the instruction. To update all ofthe 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 10input bits of the MicroLogix’s input file. To update all the inputbits of a 32 I/O MicroLogix, you must program two consecutiveimmediate input instructions (see Figure 5-34). The first instruc-tion must have a slot parameter of I:0.0 and a mask of FFFF toupdate all the bits of this word. The second instruction must havea slot parameter of I:0.1 and a mask of 000F, since a 32 I/OMicroLogix only uses the first four bits of word I:0.1 for inputs.

Figure 5-33.An immediate input with mask block used to update the status of alimit switch connected to input terminal 2 of a MicroLogix 1000.

Figure 5-34.Two consecutive immediate input with mask instructions used to updateall the input bits of a 32 I/O MicroLogix.

L2L1LS

I/2

IMMEDIATE INPUT W/MASKSlotMask

IIM

I:0.00004

0 0 0 0 0 0 0 0 0 1 1 0 0 00 115141312 1110 9 8 7 6 5 4 1 03 2

0 0 0 0 0 0 0 0 0 0 0 0 0 00 1

1

Input StatusMask

To I:0.0/2

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

IMMEDIATE INPUT w/MASK

Slot

Mask

I:0.0

FFFF

IIM

IMMEDIATE INPUT w/MASK

Slot

Mask

I:0.1

000F

IIM

Page 121: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

20 Module 5

Immediate Output With Mask InstructionAn immediate output with mask instruction, which is ab-breviated as IOM, interrupts program execution to update thespecified output data, which is located in output word O:0 (seeFigure 5-35). When energized, an immediate output instructionupdates the outputs specified by the mask. It interrupts the nor-mal program execution to store this data to the output file. Likean immediate input instruction, an immediate output instructionspecifies slot and mask parameters. The slot parameter indicatesthe output word to be updated. The mask indicates which out-puts will be updated.

To illustrate how an IOM instruction works, Figure 5-36 showstwo pilot lights that are connected to output terminals 0 and 1 ofa MicroLogix 1000. At the end of the last scan, both lights wereon, but now, according to the current logic, they should both beoff. To update these outputs during the scan, you can programan immediate output with mask instruction with a slot parame-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 outall but the data for bits 0 and 1. It will then send this data to PL1and PL2, turning them off immediately instead of waiting untilthe update output section of the scan.

Figure 5-35. An immediate output with mask instruction.

Figure 5-36.An immediate output with mask instruction used to update the statusof two pilot lights.

IMMEDIATE OUTPUT w/MASKSlotMask

O:0003F

IOM

L2L1

IMMEDIATE OUTPUT w/MASKSlotMask

O:00003

IOM

PL1

PL2

O/0

O/1

0 0 0 0 0 0 0 0 0 0 0 1 0 01 015141312 1110 9 8 7 6 5 4 1 03 2

0 0 0 0 0 0 0 0 0 0 0 0 1 10 0

0

Output StatusMask

To PL2To PL1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Page 122: AB MicroLogix Training Manual

C o m p a r i s o n a n d F l o w C o n t r o l I n s t r u c t i o n s

Module 5 21

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) alsocompare 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 acomparison 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 asubroutine 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 ofthe input devices.

• An immediate output with mask instruction forces the PLC to halt program execution and immediately update the statusof the output devices.