Professional Documents
Culture Documents
O N E
ARCHITECTURE
AND
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
1
OPERATION
Ke y Po i n t s
s understand the basic operating principles of the MicroLogix how it works, what the components are, and what the components do s 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 s grasp the MicroLogixs intricate memory systemhow the I/O is set up, what makes up the memory system, and how the memory system is organized s understand the unique MicroLogix addressing notation
A rc h i t e c t u r e a n d O p e r a t i o n
why PLCs are invaluable to industrial facilities what makes up a PLC how a PLC operates
Inputs MicroLogix 1000 Outputs Control Figure 1-1. PLC operation. Process or Machine
PLC Fundamentals
A MicroLogix 1000 is a programmable logic controlleran industrial computer that controls a machine or process. A PLC interfaces with the field input and output devices that are part of a control application. Then, through the control program stored in its memory, the PLC uses the data supplied by the input devices to manipulate or control the output devices. The overall PLC process, which is shown in Figure 1-1, is very simple. A PLC measures or senses signals coming from a machine or process. Then, through its internal program, the PLC provides control back to the machine or process. Programmable logic controllers provide many benefits over traditional electromechanical control systems. One of the best benefits is that PLCs make it easier and less costly to change a control system. They eliminate the need to rewire the input and output devices if the control requirements change. If the control requirements for a PLC application change, all you need to do is
2
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
PLC I n p u t s O u t p u t s
change the control program. Another benefit of PLCs is that they are more powerful and more accurate than electromechanical systems.
PLC Components
A 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 physically connects to devices in the outside world. The central processing unit, on the other hand, is where the PLC stores all of its data and does all of its computer processing. Each of the components of a PLC has specific functions. Input/Output System. The input/output system is made up of two components, the input interface and the output interface (see Figure 1-3). An input interface is a bank of terminals that physically connects input devices, like push buttons and limit switches, to a PLC. These input devices provide data to the PLC. The role of an input interface is to translate data from the inputs into a form that the PLCs central processing unit can understand.
M
CPU
I/O System Figure 1-2. A PLC and its components: the central processing unit (CPU) and the input/output (I/O) system.
I n p u t s (a)
To PLC
From PLC
O u t p u t s (b)
Figure 1-3. (a) A PLCs input interface interprets the data from the input devices and then sends it to the CPU. (b) A PLCs output interface interprets the data from the CPU and sends it to the output devices.
An output interface is a bank of terminals that physically connects output devices, such as solenoids and motor starters, to a PLC. These output devices receive control data from a PLC. The role of an output interface is to translate data from the PLCs CPU into a form that the output devices can understand. To put it simply, the I/O system communicates information from the input devices to the CPU. It also communicates data from the CPU to the output devices.
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
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 PLCs control program, as well as the data received from and sent to the I/O system. It also keeps track of which I/O devices are connected to which I/O interfaces. The processor is the computerized part of the CPU that performs the control program. It manipulates the data stored in the memory system and determines what control output should occur based on the given input conditions. The power supply provides power to both the memory system and processor so that they have power and so that they work properly.
Processor
Memory System
Power Supply
Figure 1-4. A CPU with its three componentsthe processor, the memory system, and the power supply.
PLC Operation
All PLCs, including the MicroLogix 1000, perform a three-step operation called a scan (see Figure 1-5). The scan consists of: 1. reading the input data that the PLC receives from the input devices 2. executing the control program stored in memory 3. updating, or writing, the status of the output devices based on the outcome of the control program execution A PLC performs the scan over and over again, constantly updating the outputs based on how new input conditions affect the control program.
Program Execution Figure 1-5. A PLCs scan consists of reading the inputs, executing the control program, and updating the outputs. Write Read
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Read
The scan can be broken up into two different parts, the I/O scan and the program scan (see Figure 1-6). During the I/O scan, the PLC reads inputs and updates the outputs. During the program scan, the PLC executes the control program. The scan time is the specific amount of time required for a PLC to perform both the I/O scan and the program scan. Each PLCs scan time is different. A MicroLogix 1000 can perform a scan in milliseconds. However, when it is on-line with a programming device, the MicroLogix experiences two delays during its scan (see Figure 1-7). These are: the service communications delay the overhead delay The service communications delay is the time required for the MicroLogix 1000 to send data to the programming or monitoring device, which may be a personal computer or a handheld programmer. The overhead delay is the time required for housekeeping operations, like memory management and updating timer information. Although both of these delays add to the MicroLogix 1000s scan time, it still performs its scan very quickly.
Program Scan
Program Execution Figure 1-6. A PLCs total scan consists of two different scans: the I/O scan and the program scan.
Program Execution Figure 1-7. The MicroLogix experiences two scan delays, a service communications delay and an overhead delay, when it is on-line with a programming device.
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
The MicroLogix 1000 PLC is a powerful microprogrammable controller capable of implementing all kinds of control functions. Although the MicroLogix 1000 follows the basic PLC principles of operation, it does have many unique functions and specifications. This section will discuss some of these specifications. At the end of this section, you will know: what the control program is and how it is represented in the MicroLogix 1000 what number systems are used by the MicroLogix 1000 to represent data how the MicroLogix 1000 is configured
LS
PL
L2
PB
Electromechanical Diagram Figure 1-8. A hardwired circuit where either a limit switch or a push button can turn on a pilot light.
LS
LS
PL
PL
PB PB
Figure 1-9. The circuit in Figure 1-8 implemented in a PLC via input/output connections.
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Ladder diagram notation has a particular format, as shown in Figure 1-10. The left side of a ladder circuit shows the input devices wired to the input terminals, which are represented by rectangles. The right side shows the output devices wired to the output terminals, which are represented by diamonds. The middle part is the ladder diagram logic that connects the inputs and the outputs together.
Ladder Control Program
Inputs
Outputs
The logic performed within a ladder program works just like its equivalent electromechanical circuit would. However, a ladder program represents its inputs by a contact rather than by a device symbol. Likewise, it represents its outputs by a coil instead of by a device symbol. The PLC uses an addressing scheme in the ladder program to keep track of all its inputs and outputs, including which contacts and coils reference them. The last section of this module explains this addressing scheme. The use of a MicroLogix PLC has many benefits over a traditional electromechanical application. The first is flexibility. In a hardwired, or traditional, system, the devices must be physically rewired if the control requirements change. This takes time and money. However, in a PLC system, no rewiring is necessary. All changes are made to the PLCs ladder program instead. This process is much quicker and less costly than rewiring. The second benefit is reliability. The MicroLogix 1000 PLC is solid-state and has no moving parts, which makes it very dependable.
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Number Systems
Number systems are used to represent data in a PLC. The MicroLogix 1000 PLC uses several different types of number systems to represent program data, address data, and internal data. They are: binary decimal hexadecimal octal binary codes Binary. The MicroLogix 1000 uses the binary number system to represent program data. The binary number system uses only two numbers, 0 and 1, to represent data. PLCs, including the MicroLogix 1000, use the binary system to represent I/O data because PLCs are discrete devices capable of recognizing only two states, ON and OFF. Using the binary system, a PLC indicates that a device is ON, or activated, by placing a value of 1 in the appropriate bit in memory (see Figure 1-11). Conversely, a PLC indicates that a device is OFF, or not activated, by placing a value of 0 in the appropriate bit in memory. Decimal. The MicroLogix 1000 uses the decimal number system to represent the address data of inputs and outputs, as well as contacts, coils, timers, counters, and other internal instructions. The decimal number system uses ten numbers, 0 through 9, to represent data. The addresses represented by decimal numbers identify which contacts and coils refer to which input and output devices. An address tells the PLC specifically which I/O device is wired to
(a) PB PLC Memory
Figure 1-11. (a) If a device is ON, a PLC will store a 1 in memory. (b) If a device is OFF, a PLC will store a 0 in memory.
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
PB1 1 PB2 2 2 1
SOL
PL
which terminal. Figure 1-12 shows an example of address notation. An address instructs a contact or coil to examine a terminal to see whether the device connected to it is ON or OFF. Hexadecimal. The hexadecimal number system is different from other number systems because it uses both numbers and letters to represent data. The MicroLogix 1000 uses this number system to represent constants and other internal values. The hexadecimal system uses 16 numbers. It represents the numbers 0 through 9 by the digits 09. It represents the numbers 10 through 15 by the letters AF (see Figure 1-13). Octal. The MicroLogix 1000 uses the octal number system as a shorthand way to express binary data. The octal number system uses eight numbers, 0 through 7, to represent data. It groups binary numbers into groups of three and then uses one of the numbers 0 through 7 to represent the group of numbers (see Figure 1-14). Binary Code. A binary code is a code that lets a PLC communicate with the outside world. Since PLCs are discrete devices and the rest of the world is not, PLCs must have a way to interpret and communicate nonbinary information from devices like thumbwheel switches and seven-segment indicators. The MicroLogix 1000 uses binary codes to do just that. A binary code translates nonbinary data, like letters, into a binary coded format that the PLC can understand. It also communicates binary information from the PLC to nonbinary outside devices. The MicroLogix 1000 uses two binary codes, ASCII and BCD, to perform these functions.
LS1
4 1 2
LS2
Figure 1-12. The numbers above the contacts, terminals, and coils are addresses expressed by decimal numbers.
1 10 A
2 11 B
4 12 C
5 13 D
6 14 E
8 15 F
Figure 1-13. In hexadecimal, the numbers 0 through 9 are represented by the digits 09 and the numbers 10 through 15 by the letters AF.
010 2
000 0
110 6
Figure 1-14. The octal number system groups binary numbers into groups of three and then represents each group with a number. Module 1 9
A rc h i t e c t u r e a n d O p e r a t i o n
Configurations
A MicroLogix 1000 PLC comes in many configurations. These configurations differ by: the number of inputs and outputs the type of power supply the type of I/O interfaces Inputs and Outputs. The number of inputs and outputs determines the size of a MicroLogix PLC. The MicroLogix 1000 comes in two sizes: 16 I/O and 32 I/O. A 16 I/O MicroLogix can connect with up to 10 input devices and 6 output devices (see Figure 1-15). A 32 I/O model can connect with up to 20 input devices and 12 output devices (see Figure 1-16). The size of a MicroLogix 1000 should be chosen based on the amount of I/O required for its application. Power Supply. The MicroLogix 1000 also has two types of power supplies. These are 24 VDC (volts DC) and 120/240 VAC (volts AC). The power supply should be chosen based on the power requirements and the power availability for the application. I/O Interfaces. A MicroLogix 1000 PLC has many options available for both its input and output interfaces. A MicroLogix 1000 can have one of two types of input interfaces, either 24 VDC or 120 VAC. These input interfaces allow the MicroLogix 1000 to connect with either 24 VDC or 120 VAC input devices, respectively. Just as a MicroLogix 1000 has a choice of inputs, it has a choice of outputs as well. The MicroLogix 1000 uses three types of outputs: relay transistor triac
10 Module 1 Figure 1-16. A 32 I/O MicroLogix.
A rc h i t e c t u r e a n d O p e r a t i o n
A relay output allows the MicroLogix to interface with output devices that must receive a signal ranging between either 5 and 264 VAC or 5 and 125 VDC. A transistor output is specifically designed for outputs requiring a 24 VDC output signal. A triac specifically supplies a 120/240 VAC signal to its output devices. Figure 1-17 shows the types of input and output interfaces available in the MicroLogix 1000.
Module 1
11
A rc h i t e c t u r e a n d O p e r a t i o n
L1
C 00
L2 Input Output 02 03
L1
L1 00 01 02 03
L2
LS1
01 02 03
PL
I/O Structure
A MicroLogixs I/O structure is directly related to the way its memory system is organized. Each input is connected to a separate input terminal that has a unique address in the PLC. Also, each output is connected to a separate output terminal that has a unique terminal and memory address. Figure 1-18 shows an example of addressed inputs and outputs connected to the terminals of a MicroLogix PLC.
1 09 08 07 0605 04 03 02 01 00 Inputs
1 05 04 03 02 01 00 Outputs
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, the pilot light is connected to the output terminal with address 3 and has this same address in memory.
Memory System
The 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 where major categories of data are stored. The MicroLogixs memory contains two file sections, the program file section and the data
Bit Figure 1-19. The four units used in a MicroLogixs memory system. Word File Section File
12
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
file section. Each file section is made up of a particular number of files. Files are areas in the MicroLogixs memory where a specific type of data, like input data, is stored. Each file consists of a certain number of words. Words are groups of memory locations that store pieces of data. Each word can hold up to 16 pieces of data, and each piece of data is called a bit. A bit is a binary digit that comprises the smallest unit of memory. A bit holds only one piece of information, either a 1 or a 0. The MicroLogixs memory system is organized into file sections, files, words, and bits in order to store all of the information that the PLC needs to operate. This information includes the control program, input and output status data, internal data, and routine functioning data. The MicroLogixs memory system has a lot of information to keep track of, so it needs a well-structured organization in order to do that. As mentioned previously, the MicroLogixs memory contains two file sectionsthe program file section and the data file section (see Figure 1-20). Each of these file sections stores a different kind of information. Program File Section. The program file section stores all the data a MicroLogix needs to operate. This includes data about the processor, the main control program, and any subroutines. Figure 1-21 shows a map of the MicroLogixs 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 the MicroLogix 1000. This software is responsible for controlling all of the functions of the PLC and keeping track of what is happening while the PLC is operating. These files also contain data about the processor, including type, configuration, and passwords access.
13
Figure 1-20. The two file sections of a MicroLogix 1000s memory system.
Program File Section 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Executive Main Ladder Program User Error Fault Routine HighSpeed Counter Interrupt Selectable Timed Interrupt
Figure 1-21. The program file section of the MicroLogix 1000. Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
File 2 holds the main ladder program that is entered into the PLCs memory. This ladder program controls the machine or process. File 3 stores an error fault routine that is executed when a recoverable, or fixable, fault occurs in the PLCs control program. When this routine is executed, the MicroLogix corrects the problem to get the system up and running again. File 4 stores the high-speed counter interrupt program that is executed when a high-speed counter instruction causes an interruption in the control program. File 5 contains the selectable timed interrupt program, which is used to interrupt the normal program scan so that a subroutine can be executed immediately. Files 615 store the subroutine ladder programs that are called by the main ladder control program. This area can store up to ten subroutines. Files 4 and 5 can be used to store additional subroutines, if necessary. Data File Section. The data file section stores all of the program and I/O data used by the MicroLogix 1000. This section is divided into eight files numbered 0 through 7, as shown in Figure 1-22. Each file stores a different type of information. Following is an outline of the data files: File 0 is the output file. It stores data about the status of each output device connected to the MicroLogixs output terminals. Each of the PLCs outputs is mapped to an address bit in this file. File 0 is also known as the output image table. The output file contains one word. File 1 is the input file. It stores data about the status of each input device. The input file is also known as the input image table. As with the output file, each of
14 Module 1 0 1 2 3 4 5 6 7
Data File Section Outputs Inputs Status Binary Timers Counters Control Integer
A rc h i t e c t u r e a n d O p e r a t i o n
the MicroLogixs inputs is mapped to a specific bit in the input file. The input file is different from the output file because it contains two words to account for all of the possible input devices that can be connected to a 32 I/O MicroLogix. File 2 is the status file. It stores information about how the PLC is operating and how it is set up. This file contains 33 words that hold three types of data: basic status data, dynamic configuration data, and static configuration data (see Figure 1-23).
Status operation Dynamic configuration Static configuration off-line settings
0 1 2 3 4 5 6 7
File 3 is the binary, or bit, file. It stores data about the status of internal coils and contacts. The binary file contains 32 words. Because the binary file stores data about internal instructions, its bits do not map real field devices, as the bits in the input and output files do. File 4 is the timer file. It contains data about the timers used in the control program. It includes data about each timers status, preset value, and accumulated value. The MicroLogix can use up to 40 timers in its control program, and it dedicates one word to each of the three pieces of information it stores about each timer. So, in essence, the timer file has 120 words, three for each of its 40 timers. File 5 is the counter file. It stores data about the 32 counters available in the MicroLogix 1000. It stores three pieces of data about each counter: the counters status, preset value, and accumulated value. Each piece of counter data is stored in its own word. So, in essence, this file has 96 words, three words for each of the 32 counters.
Module 1
15
A rc h i t e c t u r e a n d O p e r a t i o n
File 6 is the control file. It stores information used by specialized PLC instructions, like shift and sequencer instructions. This file can hold data for 16 instructions. It uses three words for each instruction. Therefore, this file can contain up to 48 words. File 7 is the integer file. This file stores miscellaneous numerical data, such as constant and variable data, binary codes, and mask patterns. The integer file uses 105 words to store all of this information. Job Aid 1-1 at the end of this module provides an overview of the program and data file sections of the MicroLogix 1000s memory system.
16
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Addressing Mnemonics
Every bit in every file of the MicroLogixs data section has a unique address. This address allows the MicroLogix to keep track of all its data. The MicroLogixs addressing code has its own language, or mnemonics, which is used to express an address. This addressing code gives the PLC all of the information it needs to find any piece of data stored anywhere in the PLCs memory. Each address has three parts: the file label
Figure 1-24. The letter codes used for each file in the data file section.
the word label the bit label The first part of a MicroLogixs address is the file label. This label tells the PLC which file the data is stored in. A letter or a letter/number combination is used to denote each file. Figure 1-24 lists the letter codes used for each file in the data section. The word label is the next part of the address. It lets the PLC know which word in the file the data is located in. The last part of the address is the bit label. This label tells the PLC which bit of the word the data is in.
Module 1
17
A rc h i t e c t u r e a n d O p e r a t i o n
Additionally, the MicroLogix 1000 uses delimiters to separate the different parts of an address. A colon (:) is used to separate the file label and the word label. A slash (/) is used to separate the word label and the bit label. Figure 1-25 shows an example of the MicroLogix 1000s addressing notation.
N7:6/14 File Word Bit Figure 1-25. This address indicates that the data is stored in the integer file in word 6, bit 14.
Timer File
Word 0 1 2 0 1 2 0 1 2 T4:0 T4:0.1 T4:0.2 T4:1 T4:1.1 T4:1.2 T4:2 T4:2.1 T4:2.2
Figure 1-26. Three timers, each with three word addresses. Note that the period/ word number extension is dropped from each timers first word address.
Addressing Examples
Following are some examples of the addressing scheme used in a MicroLogix 1000 programmable controller: Example 1Output Device. Figure 1-28 shows a pilot light connected to output terminal 4 of a 16 I/O MicroLogix 1000. Since the pilot light is an output, its address will start with the letter O followed by a colon (O:). The output file has only one word, so the pilot lights status data will be stored in word 0
18 32 I/O MicroLogix20 inputs Input File 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 I: 0.0 I: 0.1
Figure 1-27. The MicroLogix 1000s input file with the two words contained in it. Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
(O:0). Finally, the pilot light is connected to terminal 4, so it will be mapped to bit 4 of output word 0 (O:0/4). Therefore, the pilot light will have the address O:0/4. Example 2Counter. Figure 1-29 shows the address used to check the data value stored in bit 8 of counter 7s accumulated value. The MicroLogix stores the accumulated value for a counter in the last word of the three words associated with the counter. The first part of the address (C5:) indicates that the data is stored in the counter file, since it is counter data. The second part of the address indicates that the accumulated value for counter 7 is stored in word 2 (C5:7.2). The data value specified is located in bit 8, so this data has the address C5:7.2/8. Example 3Input Device. Figure 1-30 shows the memory map for 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 devices address will start with an I and a colon (I:). The push button is connected to the last input terminal, terminal 19. Since a word has only 16 bits, this inputs address must be located in the second word (I:0.1). Specifically, this input devices status is stored in bit 3 of the second word of the 32 I/O MicroLogix; therefore, its address is I:0.1/3.
Counter 7 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Word 0 Word 1 Word 2 C5:7.2/8 Figure 1-29. Counter file address.
Last 4 inputs
When working with a MicroLogix 1000, address and other program data can be entered in one of two wayswith a handheld programming device or with a personal computer equipped with the RSLogix software. Each of these addressing methods uses its own addressing notation. The addressing notation shown in the video and in this book is the basic one used by the RSLogix software. Job Aid 1-2 at the end of this module shows the differences between the RSLogix and handheld programmer addressing notations. Job Aid 1-3 shows some special addressing notations you may encounter when using the RSLogix software.
19
A rc h i t e c t u r e a n d O p e r a t i o n
1-5 Review
PLCs make it cheaper and easier to make changes to a control system. The MicroLogix 1000, like other PLCs, is an industrial computer that controls a machine or process. PLCs consist of two basic parts: the CPU and the I/O system. All PLCs perform a three-step operation called a scan, which involves reading the inputs, executing the control program stored in memory, and updating the status of the output devices. The MicroLogixs control program, which is represented by ladder diagrams, implements the softwired logic connections between the PLCs input and output devices. The MicroLogix 1000 uses several different number systemsbinary, decimal, hexadecimal, and octal, as well as binary codesto represent data. The MicroLogix comes in two sizes16 I/O and 32 I/Oand has two types of power supplies24 VDC and 120/240 VAC. The MicroLogix is available with two types of input interfaces24 VDC or 120 VACand three types of outputsrelay, transistor, and triac. The I/O structure of the MicroLogix is directly related to the way the memory system is organized. The MicroLogixs memory system, which stores all of the information the PLC needs to operate, is divided into four units: file sections, files, words, and bits. The MicroLogix 1000 has two file sections: the program file section and the data file section. The program file section contains 16 files, while the data file section contains 8 files. PLCs use addresses to keep track of their data and to specify which contacts and coils reference which input and output devices. A MicroLogixs address has three parts: a file label, a word label, and a bit label. Most of the files in the MicroLogixs memory system use the same addressing notation; however, some files use a special word labeling mnemonic.
20
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
1-6 Job Aids Job Aid 1-1: MicroLogix 1000 Memory Structure
FILE #
1
FILE NAME
Executive
FUNCTION
Controls the function of the PLC and contains processor data: type, configuration, and passwords.
Program Section
2 3 4 5 6 15
Main Ladder Program Controls the machine or process. Error Fault Routine Executed when a recoverable, or fixable, fault error occurs. High-Speed Counter Executed when a high-speed counter instruction causes an interruption in the control program. Interrupt File Selectable Timed Interrupt Program Used to interrupt the normal program scan of the MicroLogix so a subroutine can be executed. Subroutine Ladder Programs Called by the main ladder control program. Can store up to ten subroutines.
FILE #
0 1 2
FILE NAME
Outputs Inputs Status
FILE LABEL
O I S2
FUNCTION
Contains data about the status of each output device connected to the output terminals. Contains data about the status of each input device connected to the input terminals. Stores information about how the PLC is operating and how it is set up. Holds three types of data: basic status data, dynamic configuration data and static configurations data. Stores data about the status of internal coils and contacts. Contains data about the timers used in the control program. Keeps data 40 about each timer s status, preset value, and accumulated value in 3 separate 40 words. 40 Contains data about the counters used in the control program. Keeps data 32 about each counter s status, preset value, and accumulated value. Can store 32 up to 32 counters and uses 3 words for each counter. 32 16 Stores information used by specialized instruction. Can hold data for 16 16 instructions, using 3 words for each instruction. 16 Stores miscellaneous numerical data: constant and variable data used by arithmetic instructions, binary codes, and mask patterns.
NUMBER OF WORD
1 2 33
AVAILABLE ADDRESSES
0:0 I:0.0 I:0.1 S2:0 S2:32 B3:0
Data Section
Binary
B3
32
B3:31 T4:0, T4:0.1, T4:0.2 120 T4:39, T4:39.1, T4:39.2 C5:0, C5:0.1, C5:0.2 96 C5:31, C5:31.1, C5:31.2 R6:0, R6:0.1, R6:0.2 48 R6:15, R6:15.1, R6:15.2 N7:0 105 N7:104
Timers
T4
Counters
C5
Control
R6
Integer
N7
Module 1
21
A rc h i t e c t u r e a n d O p e r a t i o n
Job Aid 1-2: Differences Between the RSLogix And Handheld Programmer Addressing Notations
The RSLogix software program and a handheld programmer use slightly different notations for displaying an address. The following example illustrates two of these differences. The address B3:3/2 is shown as follows on an RSLogix screen, depending on the properties settings:
B3:3/2
P001 B/50 0
Note that the handheld programmer drops the number from the word label (B3). It also expresses the addressed bit according to which bit it is in the total file (50), rather than which bit it is in which word (3/2).
22
Module 1
A rc h i t e c t u r e a n d O p e r a t i o n
Job Aid 1-3: Addressing Notations Used with the RSLogix Software
An address, such as the address I:0.1/2 can be shown several different ways on an RSLogix programming screen, depending on the way the softwares properties are set up (View/Properties/Ladder):
Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot.Word/Bit Slot/Bit Short Address: Display Entry Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot/Bit Slot.Word/Bit Short Address: Display Entry Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot/Bit Slot.Word/Bit Short Address: Display Entry I0.1/2 I:0/18 I:0.1/2
Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot.Word/Bit Slot/Bit Short Address: Display Entry Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot/Bit Slot.Word/Bit Short Address: Display Entry Bit Address Format: Single Line Split Line Binary Bit Display Mode: /Bit Word/Bit I/O Bit Display Mode: Slot/Bit Slot.Word/Bit Short Address: Display Entry I0.1 2 I:0 18 I:0.1 2
Module 1
23
M O D U L E
T W O
In the first module, you learned about the basic architecture and operation of the Allen-Bradley Micrologix 1000, including a brief introduction to its I/O system. This second module goes into more detail about the I/O system of the Micrologix 1000 PLC. It includes four sections: 1. Types of input/output devices 2. Input interfaces 3. Output interfaces 4. System and I/O power distribution wiring
Ke y Po i n t s
After finishing this module, you will: s know the difference between the two types of I/O devices, including which type works with the Micrologix 1000 s understand the input interface configurations available in the Micrologix 1000, their functional differences, and their different wiring requirements s understand the various output interface configurations and the wiring requirements of each s have an overview of how to hook up a Micrologix 1000 and its I/O devices to the incoming power source
LS
Discrete
OFF
Discrete Devices
Discrete devices are input or output devices that provide or receive discrete digital signals. A discrete digital signal is one that can report only two states, such as ON/OFF or open/closed. 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 discrete digital signal to a PLC. This signal can have one of only two values, 0 or 1, indicating that the device is either OFF or ON, respectively (see Figure 2-1). A pilot light is an example of a discrete output device (see Figure 2-2). It can only be ON or OFF. A discrete output device receives a discrete digital signal from a PLC telling it to be in either one state or the other. A discrete output can never be in a state in between ON and OFF.
1 ON PL
OFF
Discrete
Module 2
Analog Devices
In contrast to discrete devices, analog devices are input or output devices that provide or receive analog signals. Analog signals are continuous and can have any number of statesnot just two, as with discrete digital signals.
PLC
Input Temperature Transducer Analog Signal Figure 2-3. A temperature transducer sends a continuous stream of data to a PLC.
A temperature transducer is an example of an analog input device. It sends a continuous stream of temperature data to a PLC (see Figure 2-3). This temperature data is expressed in varying degreesnot simply as hot or cold. An analog control valve is an example of an analog output device. It receives a continuous analog signal from a PLC telling it how much to open or close (see Figure 2-4). If it was a discrete device, it could only be either totally open or closed, but never in between. PLCs can interface with both discrete and analog devices. However, discrete devices are much more prevalent in PLC applications. The MicroLogix 1000 is designed to interface only with discrete I/O devices.
Output PLC Analog Control Valve Analog Signal Figure 2-4. An analog control valve receives a continuous signal from a PLC.
Module 2
Figure 2-5. A 120 VAC input interface converts a 120 VAC signal into a low-level DC signal.
Module 2
Components. The 120 VAC input interface of a MicroLogix 1000 has three components (see Figure 2-6): the power section the isolation section the logic section Power Section. The power section receives the input signal from the field device and converts it into a low-level DC signal using a bridge rectifier circuit. It then passes the signal through a filter to eliminate noise and bouncing. Finally, it uses a threshold detection circuit to check that the signal is valid. Isolation Section. After the signal is converted by the power section, it goes through the isolation section. This section uses an optical coupler to electrically isolate the power and logic sections. This prevents high-voltage spikes in the I/O signal from reaching the PLC and damaging it. Logic Section. After the isolation section, the signal enters the logic section of the input interface. This section sends the newly converted and isolated input signal to the PLCs processor. The MicroLogix 1000s 120 VAC input interface also includes a power LED indicator. This LED indicates whether the interface is receiving a valid signal from the input device. If both the input device and the LED are ON, then everything is working properly. However, if the input device is ON but the LED is OFF, then a problem exists somewhere between the input device and the MicroLogixs input terminal.
Power
Isolation
Logic
Input Signal
Bridge Rectifier Noise and Debounce Filter Threshold Level Detection Isolator
To Processor
Logic
Module 2
Wiring. To grasp the wiring requirements of the MicroLogix 1000s 120 VAC input interface, you must understand the three types of wiring associated with it. These are: the PLC wiring the device wiring the common (or return) wiring PLC Wiring. The MicroLogix has built-in input interfaces in both the 16 and 32 I/O models. Since the input interface is already wired to the PLC, input wiring is easy and quick. Device Wiring. Input devices can be wired to a 120 VAC input interface in one of two ways: they can be wired directly to the interface they can be wired to a terminal block that is wired to the interface If an input device is wired directly to a MicroLogix 1000s input interface (see Figure 2-7), then one side of the device should be wired to the L1 hot line of the incoming AC power source. The other side should be wired to an input terminal on the PLC. If an input device is wired to a terminal block instead of directly to the PLC (see Figure 2-8), then the line going out of the input device should be wired to the terminal block. The block, in turn, should be wired to the PLC. In MicroLogix 1000 applications, the wiring of devices through a terminal block is more common than wiring them directly to the PLC.
Micro Logix 1000
Figure 2-7. An input device wired directly to a MicroLogix 1000s input interface.
TB
Figure 2-8. An input device wired to a MicroLogix 1000 via a terminal block.
Module 2
AC Com
Common Wiring. Each input device connected to a MicroLogixs 120 VAC input interface must also be connected to the AC return line, called the L2 common line. The device must have this common connection for its electrical circuit to be complete. The input terminals on a 120 VAC interface are arranged in two groups with each group sharing a connection to the common line. In a 10-input MicroLogix, the first four input terminals share one common connection, and the last six share another (see Figure 2-9). In a 20-input model, the first four inputs again share one common connection, while the last sixteen share another (see Figure 2-10).
AC COM
I/4 I/5 I/6 I/7 I/8 I/9 I/10 I/11 I/12 I/13 I/14 I/15 I/16 I/17 I/18 I/19
Micro Logix
1000
Figure 2-10. In a 32 I/O MicroLogix, input terminals I/0I/3 share a common, as do input terminal I/4I/19.
A 24-volt DC input interface is used with field devices that provide a DC input signal to the PLC (see Figure 2-11). This input signal can range from 0 VDC when the device is OFF to between 15 and 30 VDC when the device is ON. Six models of the MicroLogix 1000 have DC input interfaces. Two of these come with an AC power supply, as well as a builtin 24 VDC power source. This power source can be used to power the DC inputs, but it should not be used to power the PLCs DC outputs. The other four MicroLogix models do not provide a built-in DC power source. These models require an external DC power supply to power the inputs. Two types of DC input devices are used with PLCs:
DC Signal
sourcing devices sinking devices Sourcing devices provide current when they are ON, while sinking devices receive current when they are ON. Some devices, like DC sensors, can have either a sinking or a sourcing
7
configuration. A MicroLogix 1000 with a DC interface can connect with either sinking or sourcing DC inputs, but the wiring is different for each. Sourcing DC Inputs. Sourcing input devices provide current when they are ON (see Figure 2-12). For a sourcing input, one side of the input device is wired to the positive DC voltage line, and the other side is wired to the PLCs input interface. The interface is then connected to the common line, which is the negative DC voltage line. In a MicroLogix, the negative DC voltage line is grounded; thus, the common line is grounded. This wiring configuration causes power to flow from the positive line, through the field device, through the PLCs input interface, and return to ground through the common line. Thus, as the input device sources (provides) current, the PLC sinks (receives) it.
V Com
Sources
Sinks
V Com
V +V Com
+V
The wiring connections for a MicroLogix 1000 with sourcing DC inputs depend on whether the PLC uses an external DC power source or provides its own DC power source. If the PLC uses an NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 COM USED USED COM external power source, the wiring diagram will look like the one PLC Sinking shown in Figure 2-13. One side of each device will be connected to the incoming positive DC voltage line, while the other Figure 2-13.Sourcing input device wiring for a MicroLogix that uses an external DC power supply. side of each device will be connected to the input terminal. The common lines for each group of input terminals will be connected to the grounded negative line. If the MicroLogix provides its own DC power source, the wiring diagram will look like the one shown in Figure 2-14. One side of each device will be connected to the PLCs positive DC voltage terminal instead of to a positive line coming from an external DC power supply. The other side of each device will be connected to the input terminal. The common lines for each group of inputs will then be connected to the PLCs negative DC terminal, which is grounded.
V Com +V
Devices Sourcing
DC I/4 COM
PLC Sinking
Figure 2-14.Sourcing input device wiring for a MicroLogix with a built-in DC power supply. 8 Module 2
V Com
V +V Com
+V
Devices Sourcing
PLC Sinking
The previous examples of sourcing input wiring connections are for two-wire devices. These are devices that have just two electrical connectionsone that goes to the supply power line and one that goes to the PLC input terminal. Some PLCs, however, use three-wire devices (see Figure 2-15). These devices have three electrical connectionsone to the supply power line, one to the PLC input terminal, and one to the common return line. The connection to the common return line gives the device the power to perform its required function when it is not switching power to the PLC. Sinking Input Devices. Sinking input devices receive current from the PLC when they are on. Sinking inputs operate just like sourcing inputs, but in reverse. Figure 2-16 shows a sinking device connected to a PLCs input interface. The supply side of the input device is connected to the negative DC common line, and the other side of the device is connected to the MicroLogixs input interface. The interface, in turn, is connected to the positive DC voltage line. When the device closes, power from the positive DC power line flows through the PLCs input terminal, through the input device, and out to the common line, thereby closing the circuit. Thus, as the PLC sources (provides) current, the input device sinks (receives) it. Figure 2-17 shows the wiring of sinking input devices to a MicroLogix that uses an external DC power supply. The wiring connections here are similar to those for sourcing inputs, except that the power line connections are reversed. In a sinking configuration, the input devices are connected to the negative voltage line, and the MicroLogixs DC common terminals are connected to the positive voltage line.
+V
Sinks
Sources
+V
V Com +V
V Com
Devices Sinking
PLC Sourcing
Figure 2-17. Sinking input device wiring to a MicroLogix that uses an external DC power supply. Module 2 9
Figure 2-18 shows the wiring of sinking input devices to a MicroLogix 1000 with a built-in DC power supply. Again, the wiring is similar to that of sourcing devices connected to a MicroLogix with a built-in power supply with one exceptionthe power line connections are reversed. Just as sourcing inputs can be either two-wire or three-wire devices, so can sinking input devices. The wiring for three-wire sinking inputs differs from the wiring for two-wire sinking inputs. A three-wire sinking device has an extra connection to the positive DC voltage line that allows the device to operate when it is not switching power to the PLC (see Figure 2-19). Job Aid 2-1, located at the end of this module, provides detailed diagrams of two-wire and three-wire sinking/sourcing wiring configurations.
+V
V Com
Devices Sinking
+ 24 DC DC OUT COM
I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 COM
PLC Sourcing
Figure 2-18.Sinking input device wiring to a MicroLogix with a built-in DC power supply.
+V
V Com +V
V Com
Devices Sinking
DC COM
PLC Sourcing
10
Module 2
Figure 2-20 illustrates the components of the MicroLogixs output 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 receives the control signal, which is either a 1 or 0, from the processor. A 1 means that the interface should turn on the output device. A 0 means that it should turn off the output device. Isolation Section. After being received by the logic section, the control signal is then passed through the isolation section. Just as it does for input interfaces, this section provides an electrical barrier between the logic section and the power section.
Module 2
11
Power Section. After the isolation section, the control signal enters the power section. In this section, the switching mechanism sends the PLCs control signal to the output device. The control signal, however, passes through a filter before it actually reaches the device. This filter eliminates the electrical noise in the power lines and the electrical noise generated by the output load. The MicroLogixs output interface also has an LED in its power section. When this light is ON, it indicates that the interface is receiving a control signal from the PLC and switching power to the output device.
12
Module 2
Triac Outputs. Triac outputs (see Figure 2-23) work with output devices that must receive a 85264 VAC control signal. For a triac, the maximum output current to each device is 0.5 A.
All-Relay Output Interfaces. Six models of the MicroLogix 1000 have all-relay output interfaces. Three of the six are 16 I/O models, and three are 32 I/O models. In the 16 I/O models (see Figure 2-24), two of the relay output terminals, terminal 4 and 5, share a common power source. These terminals also share a connection to the common line. Each of the other four relay output terminals, terminals 0 through 3, has its own separate power source and common connections. These four terminals are called isolated output terminals, since their power and return lines are separated, or isolated, from each other. Because this is an all-relay configuration, all of the power sources can be either AC or DC. In 32 I/O all-relay MicroLogix models (see Figure 2-25), only the first two output terminals, 0 and 1, are isolated, meaning that they have their own power and common lines. The rest of the terminals, 2 through 11, share power source and common line connections in groups of two, four, and four.
13
L1 L2/N
VAC VAC VAC VAC VAC VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5
Relays
AC IN
L1 L2/N
VAC VAC VAC VAC VDC O/0 VDC O/1 VAC O/2 O/3 VDC O/4 O/5 O/6 O/7 VDCO/8 O/9 O/10O/11
Transistor/Relay Output Interfaces. Two MicroLogix models have transistor/relay output interfaces. These include a 16 I/O and a 32 I/O model. In the 16 I/O transistor/relay model (see Figure 2-26), outputs 0 and 1 are isolated relay outputs. Thus, they each have a separate AC/DC power supply connection and a separate common. Outputs 2 through 5 are transistor output terminals that share a common 24 VDC power source. They also share a common connection to the return line, which is connected to the negative 24 VDC terminal. This terminal is grounded. The 32 I/O transistor/relay model has two isolated relay output terminals and a group of ten shared transistor outputs (see Figure 2-27). This 32 I/O model also has a negative DC voltage terminal, which is where the return lines from the transistor output field devices are connected to the PLC. This negative terminal is grounded. Triac/Relay Output Interfaces. Only one MicroLogix model has a triac/relay output interface. This 32 I/O PLC has two isolated relay outputs at terminals 0 and 1 (see Figure 2-28). The remaining ten outputs are triacs. These triacs are arranged in groups of two, four, and four, with each group sharing an AC power supply connection and a common return line. Job Aid 2-2 lists the input and output interface specifications for each model of the MicroLogix 1000, along with a chart explaining how to interpret the model numbers.
DC IN +24V
Relays DC IN + 24V
Transistors
VAC VAC DC DC VDC 0/0 VDC 0/1 24V+ 0/2 0/3 0/4 0/5 24V
Relays
Transistors
DC DC VAC VAC VDC O/0 VDC O/1 24+ O/2 O/3 O/4 O/5 O/6 O/7 O/8 O/9 O/10 O/11 24
Relays
AC IN
Triacs
L1 L2/N
VAC VAC VDC O/0 VDC O/1 VAC O/2 O/3 VAC O/4 O/5 O/6 O/7 VAC O/8 O/9 O/10 O/11
14
Module 2
The MicroLogix 1000 PLC can be directly mounted in a panel or enclosure. It also comes ready to be mounted on a DIN rail in an enclosure. These features make the wiring and the power distribution to the PLC very simple. As explained in the previous module, some MicroLogix 1000s require a 120/240 VAC power supply, while others require a 24 VDC power supply. These two types of MicroLogix controllers have different wiring requirements. AC Source Power Wiring. The AC power coming into a plant or factory is usually at a higher voltage than is needed by an AC MicroLogix 1000. Therefore, the power signal coming from the field must be converted, or stepped down, to the right voltage level using a transformer. For example, the source power coming into a plant may be three-phase 480 VAC (see Figure 2-29). However, an AC MicroLogix only needs a two-phase 120/240 VAC power signal. Thus, the following steps are required to use the incoming power to power the PLC: 1. Tap off the L1 and L2 lines of the source power supply. 2. Bring the L1 and L2 lines to a transformer that converts the power from 480 VAC to 120/240 VAC.
120/240 VAC
Fuse
Module 2
15
3. Wire the hot L1 line from the transformer to the controllers L1 terminal. 4. Wire the neutral L2 line from the transformer to the controllers L2 terminal. 5. Connect the L2 line to ground to protect the system. 6. Wire the MicroLogixs ground terminal to the system ground bus for added protection. For further protection, connect the power lines to an accessible disconnect switch inside the panel. This will allow for the quick, easy removal of power to the PLC, if necessary. Also, add a fuse to the hot L1 line to protect the system from overloads. DC Source Power Wiring. With only a few detailed exceptions, DC systems use the same wiring configurations as AC systems. In a DC system, the power from the transformer is brought through a fuse to a DC power supply instead of to the PLC (see Figure 2-30). From there, the DC power supply sends out a 24 VDC signal through its positive and negative lines. These lines connect to the positive and negative terminals of the DC MicroLogix 1000, just as the L1 and L2 lines connect to the L1 and L2 terminals of the AC model. A DC MicroLogixs power wiring should also include a disconnect switch located between the DC power supply and the PLC.
Power L1 from L2 Field L3 3-Phase, 480 VAC 480 VAC Transformer Fuse Disconnect 120/240 VAC + + DC Power 24 VDC Supply
16
Module 2
L1 MCR
L2
NOT NOT AC I/0 I/1 I/2 I/3 AC I/4 I/5 I/6 I/7 I/8 I/9 USEDUSED COM COM
85-264VAC
AC I/O Power Distribution. If a MicroLogix uses AC inputs and outputs, then the same 120 VAC line that powers the PLC can also power the I/O devices. Figure 2-31 shows an example of AC I/O power wiring. In this situation, the L1 line going to the PLC provides power to the inputs. The inputs common lines connect to the L2 line to complete the circuit. The L1 and L2 lines provide power and return to the output devices as well. When using the same AC power source for the PLC and its I/O devices, remember to install a master control relay (MCR) circuit between the L1 line and the I/O devices. This MCR circuit will allow the power to the I/O devices to be shut off in the event of a PLC malfunction. DC I/O Power Distribution. With DC devices, there are two wiring schemes to consider: one for MicroLogix models that provide a built-in DC power supply and another for those models that rely on an outside DC power supply. If a MicroLogix has a built-in DC power supply, it can be used to power the DC input devices with up to 200 mA (milliamps) of current (see Figure 2-32). To do this, the input devices and their return lines are connected to the appropriate DC power terminals. While the built-in DC power supply can provide power to the DC inputs, it cannot provide power to the DC output devices. DC output devices must be connected to an external DC power supply. This is necessary because the negative terminal of the built-in power supply is connected to chassis ground and, thus, cannot be connected to the common line of any other DC power source.
L1 L2/N
VAC VAC VAC VAC VAC VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5
L2
+24 DC OUT
DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 COM COM VAC VAC VAC VAC VAC VDC O/0 VDC O/1 VDC O/2 VDC O/3 VDC O/4 O/5
85-264VAC
L1 L2/N
VAC 1 MCR
VAC 2 VDC 1 VDC 2 VDC 3 VAC 2 VDC 1 VDC 2 COM COM COM VDC 3 COM
VAC 1 COM
Figure 2-32. DC I/O power distribution wiring for MicroLogix models that provide a built-in DC power supply. Other supply output voltages are shown after the MCR. Module 2 17
The I/O power wiring for DC MicroLogix models that use an external power supply is similar to the wiring for those with built-in power supplies. The main difference is that both the input and output devices are wired to an external power supply (see Figure 2-33). An MCR circuit is required in DC I/O power wiring, just as it is in AC I/O power wiring. The MCR provides a safety mechanism that allows the I/O devices to be turned off in emergencies.
L1 V Com +V
L2
NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 COM USED COM
85-264VAC
L1 L2/N
VAC VAC VAC VAC VAC VDC O/0 VDC O/1VDC O/2 VDC O/3VDC O/4 O/5
DC Supply
Figure 2-33. DC I/O power distribution wiring for MicroLogix models that use an external DC power supply. Positive voltage supply to inputs and the secondary AC supply to outputs are shown after the MCR.
18
Module 2
2-5 Review
There are two types of I/O devices: discrete devices and analog devices. The MicroLogix 1000 is designed to work with discrete devices only. A discrete signal has only two possible statesON and OFFwhile an analog signal can have an infinite number of possible states. There are two types of input interfaces available with the MicroLogix 1000: 120 VAC and 24 VDC. A 120 VAC input interface has three components: the power section, the isolation section, and the logic section. Devices can be wired to a 120 VAC input interface either directly or via a terminal block. A 24 VDC interface can connect with input devices in either a sourcing or sinking configuration. Sourcing devices provide current when they are on; sinking devices receive current when they are on. Sourcing and sinking input devices can be either two-wire or three-wire devices. The MicroLogix 1000s output interface consists of three components: the logic section, the isolation section, and the power section. The MicroLogix 1000 can interface with three types of outputs: relay, transistor, and triac. A MicroLogix 1000 comes with three possible output interface configurations: all-relay, transistor/relay, and triac/relay. The power wiring for a MicroLogix 1000 depends on whether the controller requires a 120/240 VAC power source or a 24 VDC power source. AC and DC I/O devices require different power wiring schemes, which depend on whether the devices are being powered by an internal or external source. Both AC and DC devices require an MCR in their power wiring circuitry.
Module 2
19
2-6 Job Aids Job Aid 2-1:Two-Wire and Three-Wire Sinking and Sourcing Wiring Diagrams
The following examples provide detailed diagrams of both two-wire and three-wire sinking and sourcing input configurations.
V Com
V +V Com
+V
Devices Sourcing
DC I/4 COM
PLC Sinking
PLC Sinking
Three-Wire
V Com +V Devices Sourcing Devices
Three-Wire
V Com V +V Com +V
PLC Sinking
PLC Sinking
20
Module 2
Devices Sinking
+V
V Com +V
V Com
Devices Sinking
+ 24 DC DC OUT COM
I/0 I/1 I/2 I/3 DC I/4 I/5 I/6 I/7 I/8 I/9 COM
PLC Sourcing
PLC Sourcing
Three-Wire
V Com +V
Three-Wire
Devices Sinking
+V V Com +V V Com
Devices Sinking
DC COM
PLC Sourcing
PLC Sourcing
Module 2
21
Bulletin Number
1761
Base Unit
L
I/O Count
16 32
Input Type
A = 120 VAC B = 24 VDC
Output Type
W = relays B = 24 VDC MOSFET (transistor) and relays A = 120/240 VAC triacs and relays
Power Supply
A = 120/240 VAC B = 24 VDC
Therefore, the example model number shown above (1761-L16BBB) refers to a 16 I/O MicroLogix 1000 with a 24 VDC input interface. This model has an output interface with both 24 VDC MOSFET (transistor) outputs and relay outputs. It also requires a 24 VDC power source. Following is a list of the nine different MicroLogix models, along with their specifications:
Model Number
1761-L16AWA 1761-L32AWA 1761-L16BWA 1761-L32BWA 1761-L16BWB 1761-L32BWB 1761-L16BBB 1761-L32BBB 1761-L32AAA
Number/Type of Inputs
10 inputs120/240 VAC 20 inputs120/240 VAC 10 inputs24 VDC 20 inputs24 VDC 10 inputs24 VDC 20 inputs24 VDC 10 inputs24 VDC 20 inputs24 VDC 20 inputs120/240 VAC
Number/Type of Outputs
6 outputs4 isolated relays/2 shared relays 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 6 outputs4 isolated relays/2 shared relays 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 6 outputs4 isolated relays/2 shared relays 12 outputs2 isolated relays/2 shared relays/4 shared relays/4 shared relays 6 outputs2 isolated relays/4 shared transistors (MOSFET) 12 outputs2 isolated relays/10 shared transistors (MOSFET) 12 outputs2 isolated relays/2 shared triacs/4 shared triacs/4 shared triacs
Power Supply
120 VAC 120 VAC 120 VAC 120 VAC 24 VDC 24 VDC 24 VDC 24 VDC 120 VAC
22
Module 2
M O D U L E
T H R E E
So far, you have learned about the components of the MicroLogix 1000 PLC, including the CPU, the memory system, the power supply, and the input/output system.This module teaches you about the control program that links all of these components together. 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: s understand the basics of ladder programming and the types of relay instructions available in the MicroLogix 1000
Ke y Po i n t s
s know the two types of contact instructions used to program a MicroLogix 1000, how they operate, and their reference addresses s know the four basic output instructions commonly used with the MicroLogix 1000 s understand key points concerning the ladder scan evaluation, the programming of normally closed input devices, and safety device programming s be able to apply techniques learned from specific programming examples
B a s i c R e l ay I n s t r u c t i o n s
Figure 3-1. (a) An electromechanical circuit and (b) its equivalent ladder diagram.
Module 3
B a s i c R e l ay I n s t r u c t i o n s
Left Rail
Right Rail
Contacts and Coils. In a ladder diagram, contact instructions are used to reference input devices and coil instructions are used to reference output devices. A contact examines the state of its corresponding input field device. It then either energizes or de-energizes, depending on whether the input device is ON or OFF, respectively. Conversely, a coil energizes or de-energizes according to the status of the contacts in its ladder rung. When a coil energizes, it turns its associated output device ON. When a coil de-energizes, it turns its associated output device OFF. Ladder Rung Structure. In addition to contacts and coils, there are two other terms used when describing a ladder program:
Figure 3-2. A ladder rung with arrows indicating the flow of power through the rung.
rung ladder rung matrix Rung. A rung is a set of programmed instructions that forms a complete electrical path between the left and right rails of a ladder diagram (see Figure 3-2). A MicroLogixs ladder rung can have many contacts and coils in many branches. Since a rung can have many branches, it may provide several different complete paths from the left to the right rail. Note that a MicroLogix will not allow power to flow from right to left. Power must always flow from left to right through a ladder rung. Job Aid 3-1 explains how to program around reverse power flow in a MicroLogix 1000. Ladder Rung Matrix. The ladder rung matrix (see Figure 3-3) determines the maximum number of branches that can be used to program a ladder rung. In a MicroLogix 1000, a rung can have a maximum of 75 branches. The ladder rung matrix also defines all of the possible locations for a contact or coil instruction in a rung.
3
Output Coils
Module 3
B a s i c R e l ay I n s t r u c t i o n s
Relay Instructions
Relay instructions form the category of programming instructions that deals with the simple energizing and de-energizing of inputs and outputs. Contacts and coils fall into this category. There are two kinds of relay contact input instructions: examine-if-closed examine-if-open There are four kinds of relay coil output instructions: simple output internal output latch/unlatch output one-shot rising instructions Other instructions, in addition to simple relay, are available in the MicroLogix 1000. These instructions, which include the following, 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, convert-to-BCD, move, and masked move comparison instructions: equal, masked comparison for equal, and limit test flow control instructions: jump, jump to subroutine, master control reset, temporary end, suspend, immediate input with mask, and immediate output with mask
Module 3
B a s i c R e l ay I n s t r u c t i o n s
Contact instructions are used to reference input devices connected to the PLC. Thus, a contact represents an input condition to a ladder rung. In some cases, a contact can also be used to reference an output coil. At the end of this section, you will know the operation of the two basic contact instructions used with the MicroLogix 1000: examine-if-closed contacts examine-if-open contacts
L1 PB (a) I/0
L2 I:0.0/0
Examine-If-Closed Contacts
An examine-if-closed contact instruction, also called a normally open instruction, is represented by the symbol shown in Figure 3-4. It is abbreviated as XIC. An XIC contact checks the status of its input reference address for an ON, or closed, condition. 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 1000s input interface and, as a result, has the address I:0.0/1. The XIC contact in the ladder diagram shares this reference address. When the push button closes (see Figure 3-5a), it supplies a voltage to the PLC, causing a 1 to be stored in address I:0.0/1. When the XIC instruction detects the 1 in the address bit, it knows the button is closed. This causes the contact to close, providing continuity to the ladder rung. When the push button is OFF, however, its reference address bit will contain a 0 (see Figure 35b). This tells the XIC instruction that the button is open. As a result, the XIC contact will open, breaking continuity in the rung.
0 1 Word 0.0 Input File L1 PB I/0 (b) 0 0 Word 0.0 Input File
Figure 3-5. (a) When an XIC instruction detects a 1 in its address bit, it closes, providing continuity to the ladder rung. (b) When an XIC instruction detects a 0 in its address bit, it opens, breaking continuity in the rung. Module 3
L2 I:0.0/0
B a s i c R e l ay I n s t r u c t i o n s
Examine-If-Open Contacts
The examine-if-open contact instruction, also called a normally closed instruction, is represented by the symbol shown in Figure 3-6. It is abbreviated as XIO. An XIO instruction works the opposite of an XIC instruction. An XIO contact checks the status of its reference address for an OFF, or open, condition. If the reference address is OFF, then the contact remains closed, providing continuity to the ladder rung. Figure 3-7 illustrates how an XIO contact instruction works. The limit switch in this diagram is connected to terminal 1 of the MicroLogixs input interface, which means that it has an address of I:0.0/1. The XIO instruction in the ladder diagram references this address. When the limit switch is open (see Figure 3-7a), bit 1 of the input file will contain a 0. When the XIO contact detects the 0, the contact will stay in its normally closed condition, resulting in continuity to the rung. When the limit switch is closed, the opposite will occur (see Figure 3-7b). The XIO contact will detect a 1 in the address bit, which will cause the contact to open and break continuity to the rung. The RSLogix software can be used to monitor the status of the contacts in a ladder program. If the software shows a contact as highlighted, then the contact is providing power continuity. If a contact is unhighlighted, then it is not providing continuity.
(b)
Examine-If-Open
XIO
L1 LS (a) I/1
L2 I:0.0/1
Word 0.0
I:0.0/1
1 1 Input File
Word 0.0
Figure 3-7. (a) When an XIO instruction detects a 0 in its address bit, it closes, resulting in continuity to the ladder rung. (b) When an XIO instruction detects a 1 in its address bit, it opens, breaking continuity in the rung. 6 Module 3
B a s i c R e l ay I n s t r u c t i o n s
Output Coil
L1 PB I/0
L2 I: 0.0/0 O: 0/3
L1 O/3 PL
L2
3 1 Output File
Word
Figure 3-9. When coil O:0/3 turns on, its associated output device will turn on.
Module 3
B a s i c R e l ay I n s t r u c t i o n s
An output coil can be referenced by a contact instruction. Therefore, an output coil can drive a real field output device while simultaneously providing the input logic to another rung. The contacts used to reference an output coil can be either XIC or XIO instructions.
L1 LS I/0
L1 O/5 M1 M
L2
2 1 Binary File
Word 1
Module 3
B a s i c R e l ay I n s t r u c t i o n s
L1
L1 O/0 PL
L2
The function of a latch coil is to turn on and stay on, even if its input condition turns off. The function of an unlatch coil is to turn off a latched output. A latch coil instruction is abbreviated as OTL, and an unlatch coil is abbreviated as OTU. Figure 3-12 illustrates a latch/unlatch ladder circuit. When push button PB1 in the first rung is pressed, the latch output coil will turn on, causing pilot light PL to turn on. However, if the push button is released, the latch output coil and pilot light will remain on even though the first rung no longer has power continuity. When LS1 closes, the unlatch output coil in the second rung will be energized. This will change the status of address bit O:0/0 from a 1 to a 0. As a result, the latch output coil and pilot light will turn off. An unlatch coil instruction is the only way to turn off a latched output coil. Note that the output cannot be latched again until the unlatch coil instruction turns off.
Module 3
B a s i c R e l ay I n s t r u c t i o n s
When the logic before a one-shot rising instruction becomes energized (see Figure 3-14), the one-shot rising instruction will be energized. As a result, the output coil and output device will turn on. A one-shot rising instruction, however, will only stay energized for one scan, even if its driving logic remains energized. Thus, after one scan, the one-shot rising instruction, the output coil, and the associated field output device will turn off, even if the rest of the rung still has continuity. A one-shot rising instruction is very useful for resetting output signals in one scanfor example, for unlatching an output in one scan so that it will be ready to latch again in the next scan.
L1 LS I/3
L1 O/3 SOL
L2
LS I:0.0/3
(b)
Figure 3-14. (a) Ladder diagrams showing a one-shot rising instruction, which will be energized for only one scan even if its input logic remains energized. (b) The timing diagram for a one-shot rising instruction.
10
Module 3
B a s i c R e l ay I n s t r u c t i o n s
ladder scan evaluation the programming of normally closed input devices safety device programming
2. executing the control program 3. updating the outputs Once the PLC reads the status of the input devices, it begins to execute the ladder control program. It starts its execution at the top left corner of the ladder program and proceeds from left to right down the control program until it reaches the end of the last ladder rung. The PLC evaluates the ladder program once per scan. After the control program has been executed, the controller updates the status of the outputs according to the results of the control program.
Module 3
11
B a s i c R e l ay I n s t r u c t i o n s
When developing a control program for a MicroLogix 1000, you must pay close attention to the order in which the contacts and coils are programmed. Arranging the same coils and contacts in a different order will produce different results. Figure 3-16 shows two ladder programs containing the same elements but programmed differently. The first program will require only one scan to turn on all of the outputs. The second program, however, will require four scans before all the pilot lights will be on.
L1 PB1 I/0
L2
(a)
O: 0/1 O: 0/2 O: 0/2 O: 0/3 L1 PB1 I/0 L2 O: 0/2 O: 0/3 O: 0/1 O: 0/2 L1
Figure 3-16. Ladder programs in which (a) all of the outputs will turn on after one scan and (b) all of the outputs will be on after four scans.
L1 LS PL
L2
L1 LS I/0
L2 I: 0.0/0 O: 0/0
L1 O/0 PL
L2
Figure 3-17. A normally closed input device programmed with an XIO contact, along with its equivalent hardwired circuit. Module 3
B a s i c R e l ay I n s t r u c t i o n s
L1 LS PL
L2
will not be energized. Accordingly, the pilot light will be off. Under these conditions, the limit switch must open for the XIO contact to be energized and the pilot light to turn on. This is contrary to the way the circuit should work.
L1 L2 O/0 PL
L1 LS I/0
L2 I: 0.0/0 O: 0/0
Figure 3-18. A normally closed input device programmed with an XIC contact, along with its equivalent hardwired circuit.
XIC Contact. Figure 3-18 shows the circuit from Figure 3-17 programmed with an XIC contact. As in the previous ladder circuit, the normally closed limit switch provides a voltage to the PLC. However, in this program, the XIC contact examines the limit switch for a closed condition in order to provide continuity to the rung. Since the limit switch is closed, the contact will be energized. In turn, the output coil and pilot light will be energized. If the limit switch opens, the pilot light will turn off. Thus, the circuit works correctly.
When connecting safety devices to PLCs, there is one cardinal rule to remember: never use a normally open device programmed with an XIO contact instruction. The following explains why. To implement the safety stop circuit shown in Figure 3-19, you must use a normally closed input device programmed with an XIC instruction. In this configuration, when the start push button is pressed, the motor will turn on because both of the XIC contacts will detect that their inputs are closed. When the start button is released, the motor will stay on because contact O:0/0 seals the circuit. When the stop push button is pressed, the XIC instruction 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 connection from the stop push button breaks, the XIC instruction that 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.
13
L1
Start I/0
L1
L2 O/0 Motor M
(b)
Stop
I/1
Figure 3-19. (a) A fail-safe safety stop circuit using a normally closed device programmed with an XIC instruction. (b) A safety stop circuit using a normally open device programmed with an XIO instruction. In this circuit, once the motor is on, the motor cannot be turned off if the safety stop button malfunctions. Module 3
B a s i c R e l ay I n s t r u c t i o n s
Figure 3-20. Hardwired diagram for a simple star t/stop motor circuit.
14
Module 3
B a s i c R e l ay I n s t r u c t i o n s
V Com
+V
Stop
Start
I/O Device and Power Wiring. The I/O devices to be wired to the PLC are the stop push button, the start push button, and the motor starter. An internal instruction will be used to implement the auxiliary contact in the PLC. Figure 3-21 shows how the I/O devices and power will be wired to the PLC. The stop button will be wired to the first input terminal (I:0.0/0) and the start button to the next input terminal (I:0.0/1). These are both DC inputs. The motor starters coil will be wired to the first transistor output terminal (O:0/2). The overload contacts will remain wired in series with the motor starters coil, just as they were in the electromechanical circuit. To apply power to the PLC, you should connect the MicroLogix to the DC power supplys positive and negative voltages, noting that the negative is connected to ground. The PLC itself should also be grounded. Next, connect both the input devices and the output device to their respective DC power supply positive and negative terminals. Ladder Programming. Figure 3-22 shows the ladder control program for the start/stop motor circuit. The ladder program uses the same logic that was used in the electromechanical circuit; however, the PLC program uses XIC contacts to reference the two inputs and an output coil to reference the motor. Internal contact O:0/2, which references the output coil, seals the circuit when the start push button is released. The PLC program will work just like the hardwired circuit. When the start button is pressed, the motor will turn on and stay on. When the stop button is pressed, the motor will turn off. If the motor is sealed on and the overload contact opens, the motor starter will turn off. The reason for this is that the open overload contact will break the power continuity in the motor starters circuit. This situation is called low-voltage release.
DC I/4 COM
DC in +24v
VAC VDC
O/0
VAC VDC
DC DC NOT O/1 24+ O/2 O/3 O/4 O/5 O/6 O/7O/8 O/9O/10O/11 24 USED
M +V OL V Com
+V V Com
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.
L1 Stop I/0
L1
L2 O/2 Motor OL M
Figure 3-22. Ladder program for the star t/stop motor circuit. Module 3
15
B a s i c R e l ay I n s t r u c t i o n s
Note that, since the motors PLC output coil is still on, the motor will turn on again as soon as the overload contact recloses (i.e., when the thermal overload heater cools off). Consequently, this circuit does not provide low-voltage protection. This can be undesirable and, in fact, dangerous in some applications. For instance, someone may be troubleshooting the motor to find out why it stopped. During this time, the overload contact may cool off and close again, causing the motor to start up again without warning. Low-Voltage Protection. To provide low-voltage protection in this circuit (see Figure 3-23), you must connect the auxiliary contact from the motor starter as a real input to the PLC at input terminal 2 (I:0.0/2). Then use an XIC contact to implement the auxiliary contact in the PLC. This replaces the internal contact used before. Now the motor is sealed after the start button is pushed because the auxiliary contact stays on as long as the motor starters coil is on. Therefore, this circuit still provides low-voltage release, since the motor will turn off when the overload opens. However, it also provides low-voltage protection, since the auxiliary contact will turn off when the motor starters coil turns off. This means that the motor will stay off even after the overload recloses. You must press the start button for the motor to turn on again.
L1 O/2 Motor OL M
L2
I: 0.0/2
I/2
Figure 3-23.A star t/stop motor circuit with low-voltage release and low-voltage protection.
L1
Stop
L2
Module 3
B a s i c R e l ay I n s t r u c t i o n s
motor starter from turning on if the reverse starter is already on. Moreover, it has a forward pilot light that turns on when the motor is moving in a forward direction. The reverse part of the circuit contains similar elements and works identically to the forward part. Additionally, the circuit has a normally closed stop push button that can turn off either the forward or the reverse motor starter. It also contains an overload contact that will turn off either starter in the event of an overload condition. PLC Requirements. To begin the implementation, you must choose the appropriate MicroLogix model for the application. In this example, the PLC will have the following specifications:
I/5
L1 MCR
L2
I/1
I/2
I/3
AC I/4 COM
32 I/O 120-volt AC power supply 120-volt AC input interface relay/triac output interface
L1 L2/N
VAC VAC VDC O/0 VDC O/1 VAC O/2 O/3 VAC
F OL
R Fwd PL
Rev PL
Figure 3-25.The I/O device and power wiring for the forward/reverse motor circuit.
I/O Device and Power Wiring. In this forward/reverse circuit, all of the devices except the R2 and F2 contacts and the overload contact will be wired to the PLC. The motor starter contacts R1 and F1 will be wired to the PLC to provide low-voltage protection in the program. The R2 and F2 interlocking contacts, however, will be implemented in the PLC through internal contacts that reference the forward and reverse coils. The overload contact, which protects the motor, will be wired after the forward and reverse starters. Figure 3-25 shows how the I/O devices will be wired to the MicroLogixs input and output interfaces. The input devices will be connected to the first five input terminals, and the output devices will be connected to the first four output terminals. The starter coils will be connected to output terminals 0 and 1, the two relay terminals, and the pilot lights will be connected to the
Module 3
17
B a s i c R e l ay I n s t r u c t i o n s
first two triac output terminals, which are terminals 2 and 3. The PLC will be connected to the L1 and L2 power lines. The input and output devices will also be connected to the L1 and L2 power lines. Ladder Programming. Figure 3-26 shows the ladder program that will implement the forward/reverse motor circuit. The top two lines of the diagram control the forward motor starter and forward pilot light. The coils and contacts in the first line turn on the forward starter. This line starts out with an XIC contact that references the stop push button. The next contact is an XIC contact that maps the forward start push button. The final contact is an XIO interlocking contact that references the reverse starter output. This contact provides interlocking so that the forward starter will not turn on while the reverse starter is energized. When all of these inputs conditions are satisfied, the forward starter and the forward pilot light will turn on. When they turn on, the F1 auxiliary contact mapped to input I:0.0/2 will seal the circuit so that the forward starter remains on even if the forward push button is released. Pushing the stop push button will stop the forward motion of the motor. The bottom two lines of the ladder diagram control the reverse starter and pilot light. They operate just like the first two lines do. Line three contains contacts referencing the reverse start push button and the forward motor starter. These are programmed in series with the stop push button contact located in line one. When all of these contacts are energized, the reverse motor starter and pilot light will turn on. The XIC contact in line four will seal the circuit. Again, pushing the stop button will remove power to the motor. Compelling Circuits. In the circuit shown in Figure 3-26, the forward and reverse starters are interlocked so that one cannot turn on while the other is operating. However, the way the
18 Module 3
L2 OL
F1 REV
I/2
O/1 R
I/3
I:0.0/4
O:0/3
O/3 REV PL
R1
I/4
B a s i c R e l ay I n s t r u c t i o n s
L2
circuit is programmed, you must press the stop push button to stop one motor starter before the other one can turn on. This configuration is called a compelling circuit. This circuit can be converted into a noncompelling circuit, which will automatically change the direction of the motor rotation when you press either the forward or reverse start push button. Noncompelling Circuit. To make a noncompelling circuit, you must add XIO forward and reverse push button interlocks to the ladder program (see Figure 3-27). These contacts make the forward starter turn off when the reverse start push button is pressed and vice versa. If the forward starter is sealed on and the reverse push button is pressed, XIO contact I:0.0/3 in line one will open. This will turn off the forward starter. At the same time, the reverse start push button will turn on the reverse starter. So in this configuration, you do not have to press the stop push button before turning on the reverse motor starter. This is a noncompelling circuit. To stop the motor, you must simply press the stop push button.
F1
I/2
O/1 R
O/3 REV PL
R1
I/4
Module 3
19
B a s i c R e l ay I n s t r u c t i o n s
3-6 Review
A ladder diagram consists of many rungs formed by contacts and coils. The ladder rung matrix determines how many branches, contacts, and coils can be used to program a ladder rung. Power must flow through a ladder rung in a left-to-right direction. There are two types of contact instructions used to program inputs in a MicroLogix 1000: examine-if-closed (XIC) and examine-if-open (XIO). An examine-if-closed contact provides power to the ladder rung when the contacts reference device is closed, or ON. An examine-if-open contact provides power to the ladder rung when the contacts reference device is open, or OFF. Four basic output instructions are used with the MicroLogix 1000: the standard output coil, the internal output coil, the latch/unlatch coil, and the one-shot rising instruction. A standard output coil is used to energize a real field output device connected to the PLC. An internal output coil is used to implement interlocking in a ladder program. Latch/unlatch coils are used to turn an output on and keep it on, even if its input logic turns off. A one-shot rising instruction is used to turn an output on for one scan. In ladder scan evaluation, a PLC only evaluates the ladder program once during each scan, and it does so from left to right and from top to bottom. When programming a normally closed input device, you must use an examine-if-closed instruction for the device to behave like a normally closed one in the PLC program. When programming a safety stop device in a PLC, never use a normally open device programmed with an examine-ifopen contact. You should approach the programming of all PLC applications the same way: (1) identify the control requirements, (2) determine which I/O devices will be connected to the PLC, (3) determine which terminals the I/O devices will be connected to, (4) determine how the I/O devices and PLC will be powered, and (5) develop a ladder program that implements the required control.
20
Module 3
B a s i c R e l ay I n s t r u c t i o n s
3-7 Job Aids Job Aid 3-1: Programming Around Reverse Power Flow
The following ladder diagram allows power to flow from right to left through contact D. This type of reverse power flow is not permitted in a MicroLogix ladder program.
A B D C E Y
If the reverse condition is not a required part of the outputs logic, then the ladder rung can be reprogrammed as follows to avoid the reverse power flow condition:
A B D C E Y
If the reverse condition is a required part of the outputs logic, then the ladder rung can be reprogrammed as follows to avoid the reverse power flow condition:
A A F B D E D B C C E Y
Module 3
21
M O D U L E
F O U R
This module is a fur ther exploration of the MicroLogix 1000s programming instructions. Module 3 covered basic relay instructions, which perform simple ON/OFF operations. All of those instructions use a basic ladder format. The three sections of this module discuss programming instructions that are represented in block format. These sections are: 1. Timing instructions 2. Counting instructions 3. Data-handling instructions
After finishing this module, you will: s understand the three timing instructions used in a MicroLogix 1000timer ON-delay, timer OFF-delay, and retentive timer as well as the values and special programming issues associated with each s understand the count up and count down counting instructions and the reset instruction, including the values and special programming issues associated with each s know how to use data-handling instructions to move and convert data in a MicroLogix 1000 PLC
Module 4
Word 0 1 2
Conversely, if the PLCs time base setting is 0.01 seconds, it will wait until the time base has occurred 200 times before timing out. The selection of the time base depends on what is most appropriate for the application. Preset Value. The preset value of a timer works in conjunction with the time base by specifying the number of times that the timer must count the time base. This preset value, which is also referred to as the number of ticks, is predetermined and preprogrammed by the user. Thus, in the previous example of a timer with a 0.01 time base and a target value of 2 seconds, the preset value would be 200. This value indicates that the timer must wait 200 time bases before timing out. Accumulated Value. The final value associated with a timer is the accumulated value. This value keeps track of how many times the time base has occurred since the timer instruction was energized. When the accumulated value equals the preset value, the timer will time out because it has reached its target timing value. So if a timer has a time base of 0.01 and a preset value of 200, the accumulated value will increase by one every 0.01 seconds until the accumulated value equals 200. At that point, the timer instruction will time out. Addressing. A MicroLogix 1000 stores data about timers in file 4 of its data file section. This file can store the data of up to 40 timers, numbered 0 through 39. Each of these timers has three words associated with it (see Figure 4-2). Therefore, the available addresses in the timer file range from T4:0.0 to T4:39.2 (see Figure 4-3).
Timer 39 Figure 4-2. The timer file showing the three words associated with each timer.
Timers
40 timers
Module 4
Each of the three words associated with a timer holds a specific kind of data (see Figure 4-4): Word 0 holds control data about the status of the timers enable output, whether the timer is actively timing, and the status of the timers done output. The control word stores this information in bits 15, 14, and 13, respectively. Word 1 stores the timers preset value. This is the target timing value specified in memory. Word 2 holds the accumulated value. This value indicates how much time has actually elapsed since the timer was energized. In the RSLogix software, the labels PRE and ACC are used to denote timer words 1 and 2, respectively. Thus, timer words T4:0.0, T4:0.1, and T4:0.2 are represented as T4:0, T4:0.PRE, and T4:0.ACC in the RSLogix software.
Enable Timer Timing Done 15 14 13 T4:0.0 T4:0.1 T4:0.2 Control Preset Accumulated
T4:0/15 (or T4:0/EN) set when timers input turns ON T4:0/14 (or T4:0/TT) set when timer is timing T4:0/15 (or T4:0/DN) set when timer has timed out Figure 4-4. The data stored in each word of a timers address.
DN
Delay
Energizes
Module 4
L1
PB
L2 I/0
TON
I:0.0/0 TIMER ON-DELAY T4:18/EN EN
L1 O/0 PL
L2
T4:18/DN
EN TT DN 15 14 13 1 0 1 Word T4:18.0
Figure 4-6 illustrates how a timer ON-delay instruction works. When the timer blocks input has logic continuity, the blocks enable output will turn on. As a result, a 1 will be stored in bit 15 of the timers control word. Once the timer is enabled, it will start to time. Thus, a 1 will be stored in bit 14, which is the timer timing bit. As the timer times, the accumulated value increases until it equals the preset value. At that point, the timer timing bit will become a 0, and the done bit will become a 1, meaning that the done output will turn on. This done output is the timers delay action contact. The timer-ON delay instructions enable output will remain on as long as the input logic to the block remains energized. However, the timer will stop timing as soon as the accumulated value equals the preset value. The timers input logic must turn off and then on again before the timer will start timing again. The timers done output can be referenced throughout the program by XIC and XIO contacts to implement the time delay. In the ladder program shown in Figure 4-6, the pilot light output will turn on four seconds after the push button input is pressed. In the ladder diagram, the input logic to the pilot light is a contact that references the done output coil of the timer block. The timers address is T4:18, its preset value is 4, and its time base is 1 second. Figure 4-7 shows the operation of the same ladder diagram, using a timing diagram to keep track of when the input and outputs turn on and off. The ladder diagram operates like this: When the timers input turns on, it will cause the timers enable output to turn on. When this happens, the timer will start timing, but the done output coil will remain off. The time between the timer being energized and the done output being energized is the four-second delay implemented by the timer.
5
I:0.0/0
TON TIMER ON-DELAY Timer Timer Base Preset Accum T4:18 1.0 4 0 EN
DN O:0/0
T4:18/DN
Timer Input 1 0 1 T4:18/EN 0 1 T4:18/TT 0 1 T4:18/DN 0 Delay Figure 4-7. A timer ON-delay block and its associated timing diagram. Module 4
The timer will stop timing as soon as the accumulated value equals the preset value. When the accumulated and preset values are equal, the done output will turn on, causing the output coil that drives the pilot light to turn on. The done outputand hence, the pilot lightwill stay on until the timer blocks input turns off. At that time, everything in the ladder rung will turn off, and the timers accumulated value will be reset to 0.
TOF TIMER OFF-DELAY Timer Timer Base Preset Accum OFF Delay Figure 4-8. A timer OFF-delay instruction. T4:18 0.01 315 0 EN
DN
De-Energizes
I:0.0/0
TOF TIMER OFF-DELAY Timer Timer Base Preset Accum T4:18 0.01 315 315 EN
DN O:0/0
T4:18/DN
Timer Input 1 0 1 T4:18/EN 0 1 T4:18/TT 0 1 T4:18/DN 0 Delay Figure 4-9. A timer OFF-delay block and its associated timing diagram.
Module 4
RTO RETENTIVE TIMER ON Timer Timer Base Preset Accum T4:7 1.0 10 0 EN
When the blocks input turns off, the enable output will turn off and the timer will start timing. The done output will stay on because it is waiting for the timer to 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 turn off, implementing the OFF-delay de-energize function. Therefore, the done bits action follows the action of the timers input signal, except that the done bit remains on for the specified delay period after the input turns off. All of the timers outputs will now remain off until the input logic turns on again. At this point, the accumulated value is reset to 0.
DN
I:0.0/0
RTO
RETENTIVE TIMER ON
DN O:0/0
A retentive timer instruction, pictured in Figure 4-10, operates much like a timer ON-delay instruction. A retentive timer, however, can stop timing and then start timing again without its accumulated value resetting to 0. Figure 4-11 shows a retentive timer circuit and its timing diagram, which work as follows: When the input logic turns on, the enable output will turn on, and the timer will start timing. If the input logic turns off, the enable output will turn off, and the timer will stop timing. The accumulated value, however, will not reset to 0.
Delay 1
Delay 2
Reset
When the timer starts timing again, it will pick up where it left off. When the accumulated value finally reaches the preset value, the done output will turn on.
7
Once a retentive timer has timed out, its done output will remain on even if its input logic and enable output turn off. A reset instruction must be used to turn the done output off and reset the timers accumulated value. The operation of a reset instruction is explained in the counter section of this module.
Trapping
Trapping is a special timer programming issue. The electromechanical timers used in hardwired circuits have two kinds of contacts: time-delayed instantaneous The time-delayed contact is used to turn on the output after the timer has timed out. The instantaneous contact is used to seal the timers input so that, once the timer has started timing, it will continue to time even if its input logic turns off. This provides interlocking in the circuit. Figure 4-12 illustrates how the two types of timer contacts are represented in an electromechanical diagram. An instantaneous contact is represented by a contact symbol, and a time-delayed contact is represented by a timer switch symbol. The symbol for an ON-delay timers time-delayed contact has an arrow that points up. This indicates that the contact energizes, or closes, after the delay following the inputs OFF-to-ON transition. In contrast, the time-delayed contact for an OFF-delay timer points down, indicating that it turns off, or opens, after the delay following the inputs ON-to-OFF transition. In contrast to electromechanical timers, PLC timers have only one type of contacta time-delayed contact. This contact must not be confused with an instantaneous contact when replacing relay logic. Consequently, you must use trapping to implement
8 Module 4 Electromechanical MicroLogix
TMR
Timer Coil Instantaneous Contacts ON-Delay (Energize) Contacts OFF-Delay (De-Energize) Contacts
TMR
TON/TOF
N/A T4:XX/DN
TMR
TMR
T4:XX/DN
Figure 4-12. Instantaneous and time-delayed timer contacts as represented in both an electromechanical system and a MicroLogix system. The XX in the MicroLogix timer labels symbolizes the timer address.
L2
an instantaneous contact in a PLC timer circuit, if the application requires it. When you trap a circuit, you use an internal contact and coil to seal the timer on. You can also use the enable output of the timer to trap the circuit. Trapping CircuitInternal Output. Figure 4-13 shows an electromechanical timer circuit that will be implemented in a PLC. In this circuit, the timer will start timing as soon as float switch FS1 and pressure switch PS1 close. The timer will continue to time even if the float switch turns off. This is because instantaneous contact TMR1-1 will seal the timers input logic. After a 10-second delay, the timer will energize time-delayed contact TMR1-2, causing the solenoid to turn on. The first step in making this a PLC circuit is to determine which devices will be connected to the PLCs I/O interfaces. In this case, only the float switch, pressure switch, and solenoid will be connected to the PLC. The rest of the circuit will be implemented through PLC instructions. The float switch will be connected to the MicroLogixs first input terminal, and the pressure switch to the second terminal. The solenoid will be connected to the first output terminal. Figure 4-14 illustrates the ladder program that will implement the timer circuit in the PLC. This ladder program contains three rungs: The first rung traps the timer on.
10 sec TMR1-1
TMR1-2
SOL
L1
FS1 I/0
L2
I:0.0/0 B3:0/0 PS1 I/1 B3:0/0 I:0.0/1 B3:0/0
L1
O/0 O:0/0
L2
TON
EN DN
The second rung implements the timing function. The third rung implements the time-delayed output action. Rung 1. The first rung in the ladder program consists of contacts that reference the float switch and pressure switch, along with an internal coil. It also contains an internal contact that references the internal coil, which implements the trap. When the
9
T4:0/DN
O:0/0
Figure 4-14. The timer circuit implemented in a ladder program using an internal output to trap the timer. Module 4
float switch and pressure switch turn on, the internal coil will turn on. Because contact B3:0/0 seals the input, the internal coil will stay on even if the float switch turns off. Thus, contact B3:0/0 performs the function of an instantaneous contact. Rung 2. Rung two actually implements the timer. When the internal output coil in the first rung energizes, the timer will start to time because its input logic will be satisfied. Once the accumulated value equals the preset value, the timers done output will turn on because the 10-second delay will be satisfied. Rung 3. Rung three controls the solenoid output. When the done output in rung two turns on, the solenoid output will turn on because its input logic references the done output coil. Therefore, this PLC circuit implements both the instantaneous and time-delayed contacts of the hardwired circuit through the use of internal contacts. Trapping CircuitEnable Output. Another way to trap an instantaneous timer contact is to use a contact that references the timers enable output. In this method, the enable contact is used to seal the timers input, instead of an internal coil and contact. Figure 4-15 shows an example of this type of trapping. When the float switch and pressure switch turn on, the enable output and its corresponding contact will turn on. However, if the float switch opens, the timer will remain on because the enable contact will trap it. Figure 4-16 shows a multispeed motor. In low speed, this motor operates in a delta configuration. In high speed, it operates in a wye configuration. In this motor, if the low push button is pressed, the motor will run at low speed. If the high push button is pressed after being in low speed, the motor will run at high speed. The timer in this circuit ensures that a 10.8-second delay occurs before the motor will run in high speed. Thus, if the high push button is pressed, the motor will first start out at low speed and
10
L1
FS1 I/0
L2
I:0.0/0 T4:0/EN I:0.0/1
L1
EN DN O:0/0
L2
O/0 O:0/0
PS1
I/1
T4:0/DN
Figure 4-15. The timer circuit from Figure 4-13 implemented in a ladder program using the enable output to trap the timer.
T4
L1
L2
L3
T3
T1
LO
LO
LO OL HI
HI
HI
HI
HI T1 T2 T4
HI T3 T6 T4 T5
L1
Stop Low TMR CR TMR High CR TMR CR L TMR CR L High
L2
H Low OL
T3 T5
T1
High Speed Power to T4, T5, and T6 (T1, T2, and T3 together)
T6 T2 Wye (High) T1 Low Speed Power to T1, T2, and T3 T6 (T4, T5, and T6 open)
T4
T3
T2 T5 Delta (Low)
rev up to high speed after 10.8 seconds. Notice that the circuit uses interlocking motor starter contacts so that the high-speed starter coil will not turn on until the time delay has occurred. When this circuit is implemented in a MicroLogix, the stop, low, and high push buttons will be connected to the PLC as real inputs. The low (L) and high (H) motor starter contacts will also be brought in as inputs to provide low-voltage protection. The low- and high-speed starter coils will be connected as outputs. The rest of the circuit, including the timer, will be implemented using programming instructions. The completed PLC program will look like Figure 4-17. The timer trap is implemented using the timers enable output. Internal contact B3:0/0 is used to implement the control relay for the high-speed starter, which is driven by the high push button. The two rungs of this program perform the following functions: Rung one controls the low-speed motor starter. Rung two controls the high-speed motor starter and implements the 10.8-second delay through the use of a timer ON-delay instruction. Rung 1. The first rung of the ladder program controls the lowspeed starter coil and provides interlocking with the high-speed starter coil. When the low push button is pressed, the motor will start at low speed. At the same time, the timer will start timing and its done output will turn on after 10.8 seconds. Rung 2. The second rung controls the high-speed starter coil. The fourth line of this rung turns the low-speed coil on when the high push button is pressed. It does this using an internal coil (B3:0/0) that bypasses the activation of the low push button contact I:0:0/1 in the first rung. Once the high push button has been pushed and the low-speed coil is on, the top three lines of the second rung enable the timer, which begins the 10.8-second
Module 4 11
L1
Stop Low I/1 High I/2 L H I/3 I/4 I/0
L2
I:0.0/0 I:0.0/1 B3:0/0 T4:0/EN I:0.0/3 I:0.0/1 B3:0/0 T4:0/EN I:0.0/2 B3:0/0 B3:0/0 T4:0/DN I:0.0/3 O:0/1 T4:0/DN I:0.0/4 O:0/0 B3:0/0
L1
O/0 O/1 L H
L2
OLs
I:0.0/0
I:0.0/3
TON EN DN
T4:0
Figure 4-17.Multispeed motor ladder program using the timers enable output to trap the timer.
time delay. The timer is trapped using the T4:0/EN contact, which references the enable coil. When the timer times out, its done output will turn on. This will turn off the low-speed coil by breaking continuity to it. At the same time, the high-speed starter coil in line five of rung two will turn on because the done output will be on and the low-speed coil will be off. The highspeed push button in this rung is trapped on by contact B3:0/0 when the high push button is pushed. Thus, if the high-speed push button is pressed, the motor will start at low speed and then change to high speed after a 10.8-second delay.
12
Module 4
Counter 1
Counter 31
(b)
basic counter information the structure and operation of a MicroLogixs counting instructions special counter programming issues
32 counters
Figure 4-18. (a) The counter file and (b) its addressing scheme.
Count Up Count Down Done Overflow Underflow 15 14 13 12 11 C5:0.0 C5:0.1 C5:0.2 Control Preset Accumulated
These values perform the same function as they do in timer instructions. The preset value specifies the target number of counts, while the accumulated value indicates the actual number of counts that have already occurred. In a counter, the preset and accumulated values always increase or decrease in increments of one. Addressing. Data about a MicroLogix 1000s counters is stored in file 5 of the data file section. The counter file can store the data of up to 32 counters, numbered 0 through 31 (see Figure 418). As with timers, each counter is allotted three words, which are numbered 0, 1, and 2. Each of these three words stores particular data about the counter instruction (see Figure 4-19):
13
Module 4
Word 0 is the control word, which stores data about the counter blocks operation and status. This word holds information about the status of the count up and count down outputs and data about the counters done, overflow, and underflow status. This information is stored in bits 11 through 15 of the control word. Word 1 stores the counters preset value, which is the target count value. Word 2 stores the counters accumulated value, which is the actual count value. A counters preset and accumulated words, words 1 and 2, are addressed with the labels PRE and ACC in the RSLogix software. Counting instructions allow the implementation of several types of counter functions in a programmable controller. The three counting instructions found in a MicroLogix 1000 are: the count up instruction the count down instruction the reset instruction
Figure 4-20. A count up instruction. OFF-to-ON Transition Increases by 1 Energizes
DN
Count Up Instruction
A count up instruction is represented by the symbol shown in Figure 4-20. The function of a count up instruction is to increase its accumulated value by one every time the blocks input makes an OFF-to-ON transition. After a certain number of OFF-to-ON transitions have occurred, the count up instruction will energize its output. A count up block has two output coils: a count up output coil (CU), which indicates that the counter block is energized a done output coil (DN), which indicates that the count is complete
14 Module 4
L1 LS1 I/0
L2 I:0.0/0 CTU COUNT UP Counter C5: 2 3 Preset 0 Accum C5:2/CU CU C5:2/DN DN O:0/0
L1 O/0
L2 SOL
Figure 4-21 shows a count up circuit in which a limit switch and a solenoid are connected to a MicroLogix 1000 controller. The solenoid should turn on after the limit switch has turned on three times. The circuit operates as follows: When the limit switch turns on for the first time, the count up output will be energized, and the accumulated value will increase to 1. When the limit switch turns off then on again, the accumulated value will increase to 2. When the switch makes its third OFF-to-ON transition, the accumulated value will increase to 3 and the done output will turn on because the accumulated value is equal to the preset value. When the done output turns on, the solenoid output in the second rung will be energized. In a counter circuit, the counter will continue to count even after the accumulated value has reached the preset value. The done output will remain on as long as the accumulated count is greater than or equal to the preset count. The only way to reset the accumulated value and turn off the done output is to use a reset instruction, which will be discussed later in this section.
C5:2/DN
Figure 4-21. A count up circuit in which a limit switch and a solenoid are connected to a MicroLogix 1000.
CD
DN
A count down instruction (see Figure 4-22) decreases its accumulated value by one every time the blocks input makes an OFF-to-ON transition. When the accumulated value becomes less than the preset value, the count down instruction de-energizes its output. When the counters accumulated value is greater than or equal to its preset value, the counters output will be on.
Module 4
15
Like a count up instruction, a count down instruction also has two outputs: a count down output, which indicates that the counter is energized a done output, which signals that the target count value has been reached Figure 4-23 shows a count down circuit, which works as follows: In this circuit, the count down blocks done output will already be on because the accumulated value is greater than the preset value. When the blocks input turns from OFF to ON, the accumulated value will decrease to 3. When the blocks input makes this OFF-to-ON transition again, the accumulated value will decrease to 2. When the input makes one more OFF-to-ON transition, the accumulated value will drop to less than the preset value and the done output will turn off, deenergizing the done output and output O:0/0. In practice, a count down instruction is most often used with a count up instruction to form an up/down counter. In the up/ down counter shown in Figure 4-24, both counters share the same address and the same preset and accumulated values. As a result, the up counter increases the accumulated value every time a certain event occurs, while the down counter decreases the same accumulated value if another event occurs.
I:0.0/0
DN
C5:2/DN
O:0/0
I:0.0/0
Increase
DN
I:0.0/1
Decrease
DN
16
Module 4
Reset Instruction
A reset instruction is a coil instruction that can reset either a timing or counting instruction. When a reset instruction is energized, it sets the accumulated value of its corresponding timer or counter to 0. It also resets all of the control bits in word 0 of the timer or counters memory location.
I:0.0/0 CTU COUNT UP Counter Preset Accum C5:10/DN C5:10 7 10 CU
DN O:0/0
The ladder program shown in Figure 4-25 illustrates a reset instruction being used to reset a count up instruction. The reset coil shares the count up instructions addressC5:10. The count up instruction has already counted up to 10, which is several counts past its preset value. Consequently, the counters done output is on. When the reset coils input is energized, the reset instruction will set the up counters accumulated value to 0. At the same time, it will reset all of the bits in the counters control word. This will turn the done output off. A reset instruction can be used with all types of timing and counting instructions except a timer OFF-delay instruction. It cannot be used with a timer OFF-delay instruction because a reset instruction resets the done, timer timing, and enable bits of the timers control word. If the status of these bits is altered while a timer OFF-delay instruction is timing, a machine malfunction could occur.
I:0.1/1
C5:10 RES
CU CD DN OV UN 15 14 13 12 11 0 0 1 0 0 C5:10.0
Self-Resetting Counter. A self-resetting counter is a counter that resets itself in the same scan after the accumulated value reaches the preset value. Often a reset instruction is used in a counter circuit to implement a self-resetting action. However, this should be avoided in a MicroLogix 1000 unless certain precautions are taken, because the result will be an incorrect count value. Following is an explanation of why. Figure 4-26 shows a reset instruction used to implement a selfresetting counter. When the counters input turns on, the accumulated count value will increase to 1. At the same time, the counters count up bit, bit 15, will turn on because its action follows that of the counters input. Since the count up bit reflects the status of the input signal, the PLC uses it to determine if the input signal has made an OFF-to-ON transition. It does this by comparing the current status of the input signal to the value stored in the count up bit address. Figure 4-27 shows the self-resetting counter circuit after several subsequent scans. If the input remains on in the scan following the first OFF-to-ON transition (point A), the MicroLogix will compare 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 the input has not made an OFF-to-ON transition. The controller will continue to make this same comparison every scan (points B and C). Therefore, when the input signal makes an off-to-on transition (point D), the MicroLogix will know it because the PLC will detect that the current status of the input is 1 and that the previous status of the count up bit was 0. Since the PLC senses an OFF-to-ON transition, it will increase its accumulated count value by one. In this circuit, the done bit will turn on since the accumulated value now equals the preset value.
I:0.0/0
DN C5:2 RES
C5:2/DN
Input 1 0 CU (Bit 15) 1 0 DN 1 0 Reset 1 0 Figure 4-26. A reset instruction used to implement a self-resetting counter.
I:0.0/0
DN C5:2 RES
Figure 4-27. The self-resetting counter circuit after several subsequent scans. 18 Module 4
I:0.0/0
DN C5:2 RES
B
Figure 4-28 shows what will happen after the counters done bit turns on. When the done output turns on, the reset bit will also turn on since the done bit provides the input logic to the reset coil. The reset instruction will reset the accumulated value, as well as the count up and done bits, to 0 at the end of the scan. The reset instruction sets the count up bit to 0 (point A), but the input signal has not turned off (point B). This means that in the next scan the PLC will sense an OFF-to-ON transition as it compares the input signal to the count up value (point C), even though no transition has occurred. As a result, the PLC will increase the counters accumulated value, despite the fact that no actual input transition has occurred. Thus, using a reset instruction to implement a self-resetting counter will result in an inaccurate accumulated count value. To avoid this situation, you can use one of the following programming methods to create a self-resetting counter: Use a clear instruction instead of a reset instruction to set the counters accumulated value to 0. Use a move instruction to move a value of 0 into the accumulated word at the end of the scan. Use a reset instruction, but with a one-shot rising instruction programmed at the input to the counter. This one-shot instruction will ensure that the input must turn off and then on again before the PLC will increment its count value. Job Aid 4-1 provides examples of each of these self-resetting counter programming methods. Counting Past The Maximum Count Value. A counter instructions accumulated value has a range from 32,768 to +32,767. Once a counter reaches a count of +32,767, it cannot
C5:2/DN
1 C
A 0
Figure 4-28. An illustration of what will happen after the count up instructions accumulated value is reset.
Module 4
19
go any higher. Therefore, it wraps the accumulated count back around to 32,768 and starts counting up again. To count past the +32,767 count value, you must cascade two counters, making sure that they self-reset in each scan. When two counters are cascaded, they are programmed so that one counter provides the input to the other counter (see Figure 4-29). This way, the second counter counts how many times the first one has reached its preset value. Figure 4-30 shows two cascaded counters that implement a count to 100,000. These cascaded counters have addresses C5:10 and C5:11, and their programming works as follows: The input to the first counter is the event to be counted, while the input to the second counter is a contact that references the first counters done bit. The first counter will increase its count every time the input event occurs. The second counter will increase its count every time the first counters done output turns onthat is, every time the first counters accumulated value equals its preset value. If the first counters preset value is set to 1000 and the second counters preset value is set to 100, they will implement a count to 100,000. Internal output B3:0/0 indicates when the count has reached 100,000 because this internal turns on when the second counters done output turns on. The clear instruction resets the contents of the first counters accumulated word to 0 every time its done bit is enabled, so that the first counter will reset to 0 every time it reaches a count of 1000.
Counter 1
Input
Counter 2
Figure 4-29. Cascaded counter, where counter 1 provides the input to counter 2.
I:0.0/0
CTU COUNT UP C5:10 Counter 1000 Preset 0 Accum CTU COUNT UP C5:11 Counter 100 Preset 0 Accum
CU DN
C5:10/DN
CU DN B3:0/0
C5:11/DN
C5:10/DN
C5:10.2
Figure 4-30. Two cascaded counters that implement a count to 100,000. 20 Module 4
Detected
Job Aid 2-2 provides more information about cascading counters to count past the maximum count. Reading Fast Input Signals. If the input events to be counted are happening at a rate faster than the scan, some of the inputs will not be counted (see Figure 4-31). This is because a PLC only detects inputs that are valid at the beginning of each scan. It will not detect inputs that occur during the scan. If an application requires the counting of fast inputs, you must use a highspeed counter instruction to count them. This instruction is designed to count fast input signal pulses at a frequency of up to 6.6 kilohertz.
Figure 4-31. If the input events to be counted are happening at a rate faster than the scan, some of the inputs will not be counted.
Module 4
21
5 3
(a) + + 0 1 0 1 0 0 1 1
Figure 4-32. (a) Two BCD thumbwheel switches communicating decimal values to a PLC in binary coded decimal form and (b) a decimal-to-BCD conversion table.
22
Module 4
MSB
LSB
3 2 1 0 1 0 1 0 I:0.0
faceone connection for each BCD code bit. If more than one input device is used, then each device requires its own four separate input connections. Figure 4-33 shows a thumbwheel switch connected to the first four input terminals of a MicroLogix PLC. This thumbwheel switch will transmit the BCD-equivalent value of the number 5 to the controller by providing a voltage to terminals 1 and 3, but not to terminals 0 and 2. Note that the PLC will interpret this number as 1010 instead of 0101, which is the actual BCD equivalent of the decimal number 5. This occurs because of the way the switch is wired. The BCD data will be stored in the input file in reverse order, with the most significant bit of the BCD value in the least significant input bit position and vice versa. After the PLC has received the thumbwheel switchs BCD data, the data must be stored in the integer file in the correct order of significance. The ladder program shown in Figure 4-34 performs this task. Each rung of this program contains an examine-ifclosed instruction that references one of the inputs. Each rung also contains an internal coil that references a bit in the integer file, which is where the input data will be transferred. This program operates as follows: The thumbwheels inputs are programmed to transfer their data to the appropriate bit of the integer word to maintain the proper bit significance (i.e., input 3 to bit 0, input 2 to bit 1, input 1 to bit 2, and input 0 to bit 3). When the MicroLogix receives the BCD code equivalent to the number 5, the contacts referencing inputs 1 and 3 will energize. As a result, the internal outputs corresponding to integer word bits 0 and 2 will be on. At the same time, inputs 0 and 2, corresponding to internal outputs 1 and 3, will be off.
23
5
+ 0 MSB 1 0 1 LSB
NOT NOT DC I/0 USEDUSEDCOM
Figure 4-33. A thumbwheel switch connected to the first four input terminals of a MicroLogix PLC.
I:0.0/3
N7:0/0
I:0.0/2
N7:0/1
MSB
LSB
I:0.0/0
N7:0/3
Figure 4-34. Ladder program used to store the BCD data in the integer file in the correct order of significance. Module 4
Consequently, bits 0 through 3 of the integer file will store the value 0101, which is the BCD equivalent of the number 5. Writing BCD Output Data. A BCD output device works the opposite of a BCD input. Figure 4-35 shows a seven-segment indicator connected to the output interface of a MicroLogix 1000. Like an input, a BCD output device requires four output connections to receive a binary coded decimal value from a PLC. The indicator is wired so that its least significant bit is wired to terminal 5 and its most significant bit is wired to terminal 2. Figure 4-36 shows the ladder program used to transfer the BCD data from the integer file to the output device in the correct order. This program uses internal contacts to reference the BCD data stored in the integer file word. The rungs in this program energize based on the status of their reference bits. This transfers the BCD data to the output file via the output coils. The ladder program reverses the data from the integer file so that it is in the appropriate order and place in the output file. BCD I/O Utilization. Using BCD input and output devices can tie up a MicroLogix 1000s I/O interfaces. If an application requires five thumbwheel switches and three seven-segment indicators, 20 input terminals and 12 output terminals must be used for just the BCD devices alone. This leaves no room for other inputs or outputs. As an alternative to BCD I/O devices, you can use a MicroView operator interface instead. This MicroView interface inputs BCD data directly to the controller, replacing the need for thumbwheel switches, seven-segment indicators, and other similar BCD devices. This interface connects directly to the MicroLogixs RS232 communication channel, meaning that it does not utilize any of the I/O terminals. The MicroView interface comes in both a handheld and a panel-mounted model.
24
DC IN +24
5 4 3 2 O:0
VAC VAC VAC VAC VDC O/0 VDC O/1VDC O/2 O/3VDC O/4 O/5 O/6 O/7
0 1
0 1
N7:0/0
O:0/5
N7:0/1
O:0/4
3 2 1 0 0 1 0 1 N7:0 3 2 1 0 0 1 0 1 O:0
N7:0/2
O:0/3
N7:0/3
O:0/2
Figure 4-36.Ladder program used to transfer the BCD data from the integer file to the output device in the correct order. Module 4
Convert-From-BCD Instruction
BCD Decimal Equivalent
A convert-from-BCD instruction is a block instruction that converts the BCD data stored in a MicroLogixs data file into its equivalent decimal value (see Figure 4-37). This instruction block, which is abbreviated by the letters FRD, contains two pieces of information: a source location a destination location
7 6 5 4 0 0 0 1
3 2 1 0 0 1 0 1
N7:0 BCD 15
The source location indicates where the BCD data to be converted is located. The destination location indicates where the decimal-equivalent value should be stored. Figure 4-38 shows the first eight bits of integer file word 0, which contains the BCD-equivalent of the decimal number 15. This data is represented as two sets of 4-bit codes, with one setbits 4 through 7 being the BCD equivalent of the number 1 (0001) and the other setbits 0 through 3being the BCD equivalent of the number 5 (0101). Although the data in word 0 is supposed to represent the decimal number 15, the MicroLogix does not interpret it that way. Because a PLC is a straight binary machine, it interprets the data in word 0 as the binary number 00010101, which is actually the decimal number 21. As a result, you must use a convert-fromBCD instruction to convert the BCD value 15 (00010101) into the binary equivalent of the value 15 (00001111) and store this converted value in a new word location (N7:1).
FRD
7 6 5 4 0 0 0 0
3 2 1 0 1 1 1 1
N7:1 Binary 15
Figure 4-38. A convert-from-BCD instruction used to convert the BCD number 15 into the binary equivalent of the decimal number 15.
N7: 7 N7: 9
Convert-To-BCD Instruction
A convert-to-BCD instruction looks like a convert-from-BCD instruction, but it is abbreviated TOD (see Figure 4-39). A convertto-BCD instruction converts data stored in decimal form into its
25
equivalent BCD value. This instructions source word contains the decimal value to be converted, while its destination word indicates where the converted BCD-equivalent value should be stored. A convert-to-BCD instruction performs the opposite function of a convert-from-BCD instruction. Figure 4-40 shows a convertto-BCD instruction that takes the binary-equivalent decimal value 15 (00001111) and converts it into the BCD-equivalent form of the number 15 (00010101). It then stores this BCD number in a new word. Thus, the convert-to-BCD instruction converts the decimal data into its BCD-equivalent value, which can then be sent to a BCD output device.
7 6 5 4 0 0 0 0
3 2 1 0 1 1 1 1 N7:7 Binary 15
Figure 4-40. A convert-to-BCD instruction used to convert the binary-equivalent decimal value 15 (00001111) into the BCD equivalent form of the number 15 (00010101).
Move Instruction
Like BCD instructions, a move instruction also comes in a block format with both a source and a destination parameter (see Figure 4-41). A move instruction, however, simply moves data from the source word and puts it into the destination word. It does not convert or manipulate the data in any way. The data in a move blocks source parameter can be either a variable value stored in a word, which changes during program execution, or a fixed constant value, which is entered during programming.
Variable Constant
N7:3 N7:11
Source Moved 1 MASK Destination Figure 4-43. Mask parameter of a masked move instruction. 0 Not moved MASKED
The mask parameter of a masked move instruction specifies which bits in the source word are to be moved to the destination word and which bits in the source word are to be masked that is, not moved (see Figure 4-43). If a bit in the mask word contains a 1, then the corresponding bit in the source word will be moved to the destination word. Conversely, if a bit in the mask contains a 0, then the corresponding bit in the source word will not be moved to the destination word. As an example, Figure 4-44 shows a masked move instruction that moves only the first four and last four bits of data in the source word to the destination word. The instruction operates like this: The first four and last four bits of the mask word are set to 1, while the other bits are left as 0. When the masked move instruction is energized, only the first four and last four bits of data will be moved to the destination word. The middle bits in the destination word will not be replaced. They will remain in their previous state, which in this case was all zeros. The bits in the mask register are set to either 1 or 0 in groups of four using the hexadecimal equivalent of each groups binary pattern. Thus, you would use the letter F to indicate that a group of four bits is set to one. You would use a 0 to indicate that a group of four bits is set to zero. This notation is what you see as the mask value in the masked move instruction. Job Aid 4-3 provides more information on using mask codes to filter data and input BCD information.
Source 1 0 1 1 1 1 0 0 1 1 0 0 0 1 0 1 Mask 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 Destination 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 Figure 4-44. A masked move instructions source, mask, and destination values.
Module 4
27
7
+ 0 1 1 1 MSB LSB
NOT NOT DC I/0 USED USED COM
LSB MSB
DC COM
I/4 I/5
Slow
8
+ 1 1 1 1 MSB LSB 3 2 1 0 1 1 1 1 I:0.0 FRD Overflow S2:0/1 Error Fault +32,767
Fast
DC COM
I/4 I/5
Figure 4-46. The thumbwheel switchs value changing from 7 to the number 8. 28 Module 4
To avoid this situation, you must apply ladder logic filtering to the circuit. Ladder logic filtering ensures that the data received from the BCD device is a valid BCD code. This way, the PLC will wait until it has received all of the updated BCD input data before it performs a BCD-to-binary conversion. Figure 4-47 shows a circuit with ladder logic filtering. It contains three rungs, which perform the following functions:
FRD FROM BCD Source N7:0 Dest Overflow Flag S2:0/1 S2:0/1 N7:1 Overflow Trap S2:5/0 U MOV MOVE Source N7:1 Dest N7:10
The first rung contains a convert-from-BCD block that converts the BCD data in word N7:0 to its decimal binary equivalent and stores it in word N7:1. The second rung contains an examine-if-closed contact that references the MicroLogixs status overflow bit. If this contact is on, the convert-from-BCD instruction in rung one has read an invalid BCD code in its source register. This contact drives an unlatch coil that resets the overflow condition so that the MicroLogix will not fault at the end of the scan. This will allow the PLC to keep reading the input data. The third rung contains an examine-if-open instruction that also references the overflow bit. If the convert-from-BCD instruction has received a valid BCD code, then the overflow bit will not be on. Accordingly, this rung will energize, moving the converted BCD value in word N7:1 to word N7:10. When this type of ladder logic programming is used, the destination word of the move instruction (in the previous case, word N7:10) will hold the converted valid BCD value. This destination word should be used when referencing the converted BCD number in the ladder program.
Module 4
29
4-4 Review
A timer ON-delay instruction energizes its output after its input turns on and a certain amount of time has elapsed. A timer OFF-delay instruction de-energizes its output after its input turns off and a certain amount of time has elapsed. A retentive timer instruction works like a timer ON-delay instruction, except that its accumulated value is retained even if the timers input turns off. A trapping circuit is used to implement the instantaneous timer contact in a PLC program. A count up instruction increases its accumulated value by one every time its input makes an OFF-to-ON transition. A count down instruction decreases its accumulated value by one every time its input makes an OFF-to-ON transition. A count down instruction is usually used with a count up instruction to form an up/down counter. A reset instruction is used to reset the accumulated value and control bits of counter instructions, as well as timer ONdelay and retentive timer instructions. A reset instruction cannot be used alone (unless some precautions are taken) to create a self-resetting counter circuit because an incorrect count value will result. A cascaded counter circuit must be created for a counter to count past its maximum count value. A high-speed counter instruction must be used to count fast input signals. BCD input devices require four input terminal connections and four bits of memory, to send their BCD data to the PLC. BCD output devices require four output terminal connections and four bits of memory, to receive BCD data from a PLC. A convert-from-BCD instruction takes the BCD value stored in the source word and stores it in the destination word in binary equivalent form. A convert-to-BCD instruction takes the binary data stored in the source word and stores it in the destination word in BCD-equivalent form. A move instruction moves data from one word location to another without manipulating it. A masked move instruction moves only the source word data bits indicated by ones in the mask to the destination word. Ladder logic filtering is a special type of circuit that prevents the PLC control program from halting operation due to an overflow fault resulting from an invalid BCD value.
30 Module 4
4-5 Job Aids Job Aid 4-1: Self-Resetting Counter Programming Methods
Because a reset instruction cannot be used alone to implement a self-resetting counter circuit, you must use another programming method to implement this type of circuit. Following are three methods that can be used to create a self-resetting counter.
Method 1: Use a clear instruction to set the counters accumulated count value to 0.
Method 2: Use a move instruction to move a source value of 0 into the counters accumulated word at the end of the scan.
Method 3: Use a reset instruction in conjunction with a one-shot rising instruction programmed at the input to the counter.
I:0.0/0
I:0.0/0
TON CTU COUNT UP TIMER T4:0 Counter Time Base Preset Accum
C5:10 1 500 60 0
CU DN
TON CTU COUNT UP TIMER T4:0 Counter Time Base Preset Accum
I:0.0/0
B3:0/0 OSR
C5:10 1 500 60 0
CU DN
TON CTU COUNT UP TIMER T4:0 Counter Time Base Preset Accum
C5:10 500 0
CU DN
C5:I0/DN
C5:I0/DN
C5:10.ACC
MOV MOVE Source 0 Dest C5:10.ACC (Moves a constant of 0 to the accumulated value)
C5:I0/DN
Module 4
31
32,768
Counter
+32,767
To count past the maximum count, you must cascade two counters in a ladder circuit. You cannot try to trick a counter by setting its preset value to the opposite end of the range because the done bit will not behave properly. For example, you could try to count to +32,770 by setting a counters preset value to 32,766, since this value is three counts past the maximum limit once the counter wraps its accumulated value around. However, this will not work for the following reasons: Once the counter wraps back around to 32,768, its overflow bit will turn on. When the overflow bit turns on, the counters done output will turn on, even though its accumulated value is less than its preset value. At this point, the done bit will stay on until the overflow bit is reset or the counter counts back down to +32,767.
32
Module 4
5
+ 0 1 0 1
NOT NOT DC I/0 I/1 I/2 I/3 DC I/4 I/5 COM USED USED COM
To filter and move this BCD data, you could use a masked move instruction to mask out all but the thumbwheel switchs input data and move it to an integer word location. You could then use a bit shift right instruction to shift the BCD data into the integer words first four bits before performing a convert-from-BCD instruction. The next page shows a ladder program that would implement this action in a MicroLogix PLC. This ladder diagram contains a masked move (MVM) instruction in rung 0 to read the thumbwheel switchs input data (inputs I/2 through I/5). The MVM instruction uses a hexadecimal mask value of 003C to move only the desired bits into word N7:0. The bits in this word must then be shifted two positions to the right for the word to contain the correct BCD number in the correct position. The shifting of the two bits is accomplished in rungs 1 through 5. Rung 6 implements a BCD-to-decimal conversion.
Module 4
33
TON MVM MASKED MOVE Source Mask Dest Read Data Input Signal I:0.0/9
LBL
2
Shift Command B3:0/2
TON BSR BIT SHIFT RIGHT File N7:0 Control R6:0 Bit Address N7:0/15 Length 6 TON CTU COUNT UP Counter Preset Accum
EN DN
TON FRD FROM BCD Source Dest Processor Arithmetic Underflow/ OverflowFlag S2:0/1
N7:0 N7:1
CU C5:0 2 0 DN
Not Shifted 2 Times Q2:99 JMP Finished 2 Shifts Reset Counter C5:0
N7:1 N7:10
END
34
Module 4
Following is a detailed explanation of the function of each of the ladder rungs: Rung 0: The XIC contact I:0.0/9 in this rung references an input event that will trigger the MVM instruction, which reads and transfers the thumbwheel switchs BCD input data to word N7:0. If the input data is to be read continuously, rather than conditionally, this XIC contact should be omitted. If this is the case, the I:0.0/9 contacts in rungs 1 and 4 should be omitted as well. Rungs 1, 2, 4, and 5: Rungs 1 and 2 implement an oscillating OFF-to-ON/ON-to-OFF input command for the bit shift right (BSR) instruction in rung 3 by referencing the output of the count up instruction, also located in rung 3. The counter keeps track of how many times the BSR instruction has been executed. These rungs work as follows: If the BSR instruction has been executed less than two times, rung 4 will jump the program to rung 1, which resets rung 2 (if rung 2 is already energized). Subsequently, rung 2 will energize, meaning that the BSR instruction will be executed. If the BSR instruction has already been executed two times, then rung 4 will not be energized, meaning that program execution will move to rung 5. Rung 5 resets the counters accumulated value. Rung 3: The BSR instruction shifts the BCD data bits in the integer word. When the BSR blocks input turns from OFF to ON, the block will shift the contents of word N7:0 one bit to the right. The block uses the following parameters to complete this operation: The file parameter (N7:0) indicates where the data to be shifted is stored. The control parameter (R6:0) stores control data about the BSR instruction (e.g., EN output, DN output, length, etc.). The length parameter (6) specifies the file word bit into which data will be shiftedi.e., word N7:0, bit 5 (the sixth bit). The bit address parameter (N7:0/15) specifies the location of the data to be shifted into the specified file word bit. This bit address will always contain a 0, so each time the BSR instruction is executed, the bits in word N7:0 will be shifted one bit to the right and a 0 will be stored in bit N7:0/5. The counter in this rung simply counts the number of times the BSR instruction has been executed. The counters done output will be energized when the BSR instruction has been executed two times. Rung 6: This rung implements the BCD-to-decimal conversion of the data stored in word N7:0. Once the data has been shifted into the proper position, the convert-from-BCD block will convert the BCD number into its equivalent decimal value. This rung also contains ladder logic filtering to prevent an overflow fault due to an invalid BCD number. Thus, once the PLC determines that a valid BCD number has been converted, the move instruction will transfer the newly converted data to word N7:10, where it will be stored for use by the rest of the control program. Note that this program could be programmed as a subroutine rather than as part of the main control program if you did not want to include it in the main program.
Module 4 35
M O D U L E
F I V E
This final module covers two more categories of programming instructions: comparison instructions and flow control instructions. Comparison instructions are used in a MicroLogix 1000 to compare the values stored in two memory locations. Flow control instructions are used to change the order of execution of instructions in a ladder program. This module contains four sections: 1. Comparison instructions 2. Flow control instructionsalter sequence 3. Flow control instructionshalt execution 4. Flow control instructionsalter I/O scan
Ke y Po i n t s
s understand the different comparison instructions available in the MicroLogix 1000including equal, masked comparison for equal, and the limit test instructions s know the flow control instructions that alter the sequence of program executionincluding the jump, jump to subroutine, and master control reset instructions s understand temporary end and suspend flow control instructions, which halt the execution of the control program s grasp the two flow control instructions that alter the I/O scan the immediate input with mask instruction and the immediate output with mask instruction
Equal Instruction
The equal instruction is a block instruction that looks like the one shown in Figure 5-1. This instruction compares the data values specified by the source A and source B parameters. If these data values are equal, then the equal blocks output will energize, providing continuity to the rest of the rung. The value specified by source A must be a word location in memory (see Figure 5-2). This word location may specify the accumulated value for a timer or counter, the contents of an integer file word, or any other data stored in memory. The value specified by source B may be either a word location or a constant. If source B contains a word location, then it specifies the location of particular data in memory, just as the source A parameter does. If source B is a constant, then this parameter contains a fixed decimal value to which the instruction compares the source A data.
Figure 5-2. In an equal instruction, the value specified by source A must be a word location.The value specified by source B may be either a word location or a constant.
Module 5
I: 0.0/0
O:0/0
An equal instruction is always the first instruction programmed in a rung (see Figure 5-3). This instruction looks at the data stored in the source A word, which may hold a value such as the input value from a set of thumbwheel switches. The equal instruction then compares this source A data to the value indicated by source B. If these two data values are equal, the equal block energizes, providing continuity to the rest of the rung. If the other input conditions in the rung are satisfied, the output will turn on. If the source A and B values are not equal, then the equal block will not be energized (see Figure 5-4). As a result, the output will not be energized, even if the other input conditions are satisfied.
I: 0.0/0
O:0/0
not equal instructionenergizes its output if the source A and B values are not equal to each other less than instructionenergizes its output if the value in source A is less than the value stored in source B less than or equal instructionenergizes its output if the source A value is either less than or equal to the source B value greater than instructionenergizes its output if the value stored in source A is greater than the value stored in source B
Figure 5-4. If the source A and B values are not equal, then the equal block will not be energized.
Module 5
greater than or equal instructionenergizes its output if the source A value is greater than or equal to the source B value
MEQ MASKED EQUAL Source Mask Compare N7:0 N7:10 000F0 N7:2
0000 0000 1111 0000
Figure 5-6. When an MEQ instruction is enabled, it masks out the source word bits denoted by zeroes in the mask.
Module 5
Pressure TWS #1
Volume TWS #2
3
+
5
+
An MEQ instruction is useful for applications such as decoding data from multiple thumbwheel switches. Figure 5-7 shows an example of this type of application in which two thumbwheel switches are connected to terminals 0 through 7 of a MicroLogix 1000. The first thumbwheel switch sends pressure data to the PLC, while the second thumbwheel switch sends volume data. The MicroLogix stores this data in the first eight bits of file N7:0. Figure 5-8 shows a ladder program in which output O:0/0 turns on when the pressure level is 3. The program works like this: The source value for the masked comparison for equal instruction is integer file 0 (N7:0). The mask value is 000F, which will mask out all but the first thumbwheel switchs bits. The compare value is the decimal value 3, which is equivalent to the binary value 11. When the masked comparison block is energized, it compares the masked pressure value (0011) with the compare value (0011). Because they are equal, the instruction block will energize the rung. Note that the masked comparison for equal instruction only compares the bits that are specified by ones in the mask. If the source word had contained any number other than 3, the comparison would have been false.
N7:0 Mask 000F
5 3 TWS #2 TWS #1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 N7:0 Figure 5-7. An MEQ instruction used to decode data from multiple thumbwheel switches.
O:0/0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
Compare 3 10
Figure 5-8. A ladder program in which output O:0/0 turns on when the pressure level is 3. Module 5
If you wanted to compare the volume data instead, you would have to specify a hex mask with the value 00F0 (Figure 5-9). This mask value will only pass and compare the data from the second thumbwheel switch. You would also have to enter an 80 as the compare value rather than 5. This is because the decimal value 80 translates into the binary value to be compared (i.e., the value 0101 located in bits 4 through 7). Because the com5
parison is true, the output will turn on. If you used the decimal value 5, it would generate the wrong binary comparison value (0101 located in bits 0 through 3). Thus, the MEQ instruction would not work correctly because the masked source value would not be identical to the compare value.
O:0/0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0
Compare 80 10
Figure 5-9. A ladder program in which output O:0/0 turns on when the pressure volume level is 5.
LIM LIMIT TEST Low Lim Test High Lim 0 N7:1 100
LIM
LIMIT TEST Low Lim Word Test Constant High Lim Word
LIM
LIMIT TEST Low Lim Word or Constant Test Word High Lim Word or Constant
Figure 5-11. In a limit test instruction, the test value can be either a constant or a word. Module 5
LIM LIMIT TEST 0 Low Lim N7:8 Test 10000 High Lim
To rest of logic
Figure 5-12 illustrates is an example of how a limit test instruction can be used in a process application to ensure that an operator enters a valid parameter into the PLC. In this application, the limit test instructions test value is the word location of the data entered by the operator (word N7:8). The low and high limit values are the minimum and maximum possible valid entries. Thus, if the test value falls within the valid entry range, the limit test instruction will provide continuity to the rest of the rung.
Figure 5-12. A limit test instruction used to ensure that an operator enters a valid parameter into the PLC.
Module 5
JMP
LBL
Jump Instruction
A jump instruction (see Figure 5-13) is a coil instruction that jumps the PLCs program execution to a specified rung, thereby skipping those rungs programmed between the jump instruction and the destination rung. Because it does not reference a particular memory location, a jump instruction can have any numerical address between 0 and 999. A jump coil instruction works in conjunction with a label contact instruction, which specifies which rung to jump to. Figure 5-14 illustrates how a jump instruction works. In this program, the output of the first rung is a jump coil with address 10. The fourth rung begins with a label contact that shares the jump coils address. If input I:0.0/0 is true, jump coil 10 will be energized. This will cause the MicroLogix to jump to the rung containing the label instruction with address 10 and resume program execution from there. Thus, the jump instruction causes the PLC to skip the execution of rungs two and three. If the jump instruction is not energized, then the PLC will evaluate all the rungs of the ladder program as it would normally.
8
I:0.0/0
10 JMP
I:0.0/1
O:0/0
I:0.0/2
O:0/1
10 LBL
I:0.1/0 I:0.1/1
O:0/5
Module 5
Man L1
Auto I/0
Figure 5-15 illustrates how a jump instruction can be used to control the manual or automatic operation of a machine. In this example, if the selector switch connected to input 0 is off, the machine will be in manual mode. If the switch is on, the machine will be in automatic mode. By using jump instructions, you can program two sets of instructionsone set for when the machine is in manual mode and another set for when the machine is in automatic mode. This avoids having to interlock the manual and automatic programming in all of the ladder instructions. Following is a description of how this program works: If the selector switch is on (automatic mode), the jump 99 coil in rung one will be energized. When the jump 99 coil is energized, the PLC will jump the program execution to the rung with label 99. When the controller jumps to label 99, it will start executing the automatic control program, thereby skipping the manual control program. Conversely, if the selector switch is off (manual mode), the controller will execute the manual control program because it will not jump over it. When the PLC finishes the manual program, the controller will encounter a jump 999 instruction that will cause it to jump over the automatic control program. When the controller jumps over the automatic program, it will jump to the rung with label 999. This rung contains a dummy coil that does not control anything. The purpose of this rung is to give the controller some place to jump to when it skips the automatic operation at the end of the program.
OFF ON
(Manual) (Auto)
Module 5
Jump instructions affect program execution in a variety of ways. A jump instruction that jumps forward reduces the program scan time, since it omits the execution of part of the ladder program. Jumping backwards has the opposite effect. It increases the scan time, since it causes the PLC to repeat part of the control program. Both jumping forward and backward are valid uses for jump instructions. In fact, you can even jump forward or backward several times to the same label using multiple jump instructions. Nevertheless, you should be careful not to jump backwards an excessive number of times. If you do, the processors watchdog timer may time out and cause the controller to fault.
SBR SUBROUTINE
RET RETURN
Subroutine Instruction. A subroutine instruction should be programmed at the beginning of the subroutine being called. Although this instruction is not technically necessary, it is a good practice to use it for programming clarity.
10
Figure 5-17. A jump to subroutine instruction and its three associated instructions the subroutine instruction, the return instruction, and the end instruction. Module 5
I:0.0/3
File 6 (SBR)
SBR SUBROUTINE Subroutine Program RET RETURN Subroutine Program(cont'd) END
Return Instruction. A return instruction is used to tell the PLC to stop executing the subroutine and return to the main program. This instruction terminates a subroutine, either conditionally or unconditionally, before the whole subroutine program has been executed. If a subroutine does not contain a return instruction, the controller will execute the subroutine until it reaches the end instruction in the subroutines file. End Instruction. An end instruction is always present as the last instruction in a subroutine file, just as it is in the main ladder program and other program files. This instruction lets the PLC know that it has finished the subroutine. Jump to Subroutine Operation. When a jump to subroutine instruction is enabled, the controller will jump to the subroutine specified and start executing it (see Figure 5-18). If the PLC encounters an energized return instruction in the subroutine, it will jump back to the main program and pick up where it left off. If it does not find an energized return instruction, the controller will wait until it gets to the end of the subroutine before jumping back to the main ladder program. When a subroutine is executed, its outputs remain in their last state, either on or off, until the subroutine is executed again. As explained in Module 1, a MicroLogix 1000 stores the main ladder program in file 2 of the program file section. It stores the subroutines in files 6 through 15 of this same section. Each of the subroutine files can store one subroutine, for a total of 10 subroutines. Although these subroutines do not need to be programmed in the order in which they are called, you should do so anyway. In a MicroLogix 1000, you can nest subroutines (see Figure 5-19). Nesting involves using one subroutine to call another subroutine. You can do this up to eight times in a MicroLogix program,
Main Program
JSR
Level 1 SBR 6
SBR
Level 2 SBR 7
SBR
Level 3 SBR 8
SBR JSR9
Level 8 SBR 13
SBR JSR
RET
Module 5
11
meaning that the subroutine calls can be eight levels deep. The controller will generate a subroutine stack overflow error if more than eight subroutines are nested in a program. Conversely, the controller will generate a subroutine stack underflow error if the program contains more return instructions than jump to subroutine instructions. Note that you can only nest three levels of subroutines if you are using the selectable timed interrupt and high-speed counter files to store additional subroutines. To use subroutines to implement the manual/automatic selector switch program discussed earlier, you would use a rung containing two jump to subroutine instructions (see Figure 5-20). The first JSR instruction references subroutine 6, which stores the manual control program. The second JSR instruction references 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 execute it. When the selector switch is on, the controller will jump to the automatic subroutine and execute it instead. A jump to subroutine instruction can reduce the program scan time just as a jump instruction can, since it avoids the unnecessary evaluation of certain parts of the program. A jump to subroutine instruction can also simplify the main ladder program by allowing complex routines to be performed outside the main program. Moreover, subroutines can be used to program tasks that occur many times in the main ladder program. A lookup table routine is a good example of this kind of task. By using jump to subroutine instructions to go to the subroutine for this repetitive task, you can avoid having to program the task over and over again in the main control program.
Man Auto L1 I/0 OFF (Manual) ON (Auto)
L2 I:0.0/0
JSR JUMP TO SUBROUTINE SBR File Number 6 JSR JUMP TO SUBROUTINE SBR File Number 7
I:0.0/0
Figure 5-20. Jump to subroutine instructions used to control the manual or automatic operation of a machine.
12
Module 5
A master control reset instruction, which is also called an MCR instruction (see Figure 5-21), creates a fence around a group of ladder rungs. If the MCR instruction is energized, then the controller 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 form a conditional fence around a group of rungs. If the input logic to the first MCR is energized, the programmed logic within the fence will be executed. If the input logic to the first MCR is not satisfied, then the controller will skip the fenced logic and resume program execution after the second MCR instruction. This second MCR instruction must be unconditional, meaning that it is always active because it has no driving input logic. When an MCR fence is deactivated, all of the nonretentive outputs within the MCR fence will turn off, regardless of the status of their input conditions. Only the retentive outputs will retain their last status, either ON or OFF. Figure 5-22 shows a ladder program with two fenced timers to demonstrate how MCRs work. One of these timers is an ONdelay timer; the other is a retentive timer. Both timers are located within the MCR fence. This means that neither timer will start timing, even if its input is on, unless the first MCR instruction is on. When the first MCR instruction turns on, both timers will be enabled if their inputs are on. Thus, the timers will start timing, and if the MCR zone stays on long enough, both timers will time out. When the first MCR eventually turns off, the ON-delay timers output will turn off, since all nonretentive outputs in an MCR fence are reset when the fence turns off. The retentive timers output will remain on.
MCR TON TIMER ON-DELAY Timer T4:0 1.0 Time Base 10 Preset 0 Accum RTO RETENTIVE TIMER ON Timer T4:1 1.0 Time Base 10 Preset 0 Accum EN DN
MCR Fence EN DN
MCR
Module 5
13
The circuit in Figure 5-22 works much the same way if the timers start timing and then the MCR fence turns off before either timer has timed out. In this situation, the timers will start timing when the first MCR instruction turns on. However, when the MCR turns off, the timers will turn off too, even though their inputs may still be on. As a result, the accumulated value of the ON-delay timer will be reset to 0. The retentive timer, however, will retain its accumulated value. To reset the retentive timers accumulated value, you would need to add a reset instruction outside of the MCR fence (see Figure 5-23). If this reset instruction was located inside the fence, it could only reset the retentive timer when the MCR zone was activated. When using MCR instructions, you should never use a jump instruction to jump inside an MCR zone. If you do, the logic you jump to inside the MCR fence will be evaluated, regardless of whether the MCR is on. This can cause a hazardous situation. Also, you should be aware that although nesting is permitted with subroutines, it is not allowed with MCR zones.
MCR TON TIMER ON-DELAY Timer T4:0 1.0 Time Base 10 Preset 0 Accum RTO RETENTIVE TIMER ON Timer T4:1 1.0 Time Base 10 Preset 5 Accum EN DN MCR Fence EN DN
Figure 5-23. A ladder program with two fenced timers that uses a reset instruction to reset the RTO instruction.
14
Module 5
This section discusses flow control instructions that interrupt the execution of the control program. Two flow control instructions perform this type of function. They are: the temporary end instruction the suspend instruction
A temporary end instruction (see Figure 5-24) is a coil instruction that stops the execution of the control program at the point where the temporary end coil is located. It works as follows (see Figure 5-25): If the temporary end coil is on, the PLC will stop executing the control program at the temporary end instruction and perform an update of the outputs.
TND
The PLC will then begin its next scan by reading the inputs and executing the control program again, starting from the top. If the temporary end coil is not on as the PLC performs this next scan, the controller will continue with its scan until it reaches either the end of the program or another energized temporary end instruction.
Figure 5-26. A control program with two sectionsone section that evaluates an operators entry values and another section that runs a conveyor belt. Module 5
Temporary end instructions are often used to test or troubleshoot certain parts of a control program. They allow you to test part of the control program with the inputs and outputs on-line, without having to run through the rest of the program. For example, Figure 5-26 shows a control program with two sections one section that evaluates an operators entry values and another section that runs a conveyor belt. If you want to test the
15
operator entry section without turning on the conveyor, then you would program an unconditional temporary end after the first section. This allows you to run just the top section over and over again until you know that it is working properly. After that, you can take out the temporary end instruction and run the whole program. You can use a temporary end instruction in the main program and any of its subroutines stored in files 6 through 15. However, you cannot use a temporary end instruction in the user-error fault routine (file 3), the high-speed counter interrupt routine (file 4), or the selectable timed interrupt routine (file 5). If you do, the PLC will generate a fault.
SUS SUSPEND Suspend ID Status (File 2) 1 1 2 Word 7 Figure 5-28. When a suspend instruction is activated, its ID number is stored in word 7 of the status file. 112
Suspend Instruction
Like a temporary end instruction, a suspend instruction (see Figure 5-27) is used for testing or troubleshooting a control program. A suspend instruction causes the controller to stop executing the control program and enter an idle mode. When it does this, the controller de-energizes all outputs. However, it does not clear the bits in the status file. This allows you check the status bits to retrieve information about the controllers operation and why it stopped. A suspend instruction has an ID number that can range between 32,768 and +32,767. When a suspend instruction is activated, its ID number is stored in word 7 of the status file (see Figure 5-28). This indicates where the controller was in the control program when its operation was suspended. A suspend instruction is useful, for example, for halting the control program when an overflow occurs to allow troubleshooting. To do this, you would program a suspend instruction, such as the one in Figure 5-29, which operates as follows:
S2:0/1
112
Figure 5-29. A suspend instruction used to halt the control program when an overflow occurs to allow troubleshooting. Module 5
16
The suspend instructions input logic is a contact referencing a math overflow bit (S:0/1). If this overflow bit is energized, the suspend instruction will be energized. Hence, the controller will halt the program execution.
SBR #7
JSR JUMP TO SUBROUTINE SBR File Number 7 SUS SUSPEND Suspend ID 223 Check
At this point, you can review the logic programmed before the suspend instruction to see why the overflow occurred. The ID number, which is 112 in this case, indicates that the suspend was triggered by a math overflow. Other suspend instructions may have different IDs to indicate other reasons for the program halt. You can also use a suspend instruction after a subroutine to allow you to check the subroutines data before resuming the main program (see Figure 5-30). In some critical applications, you may also use one or more inputs to drive one or more suspend instructions. This kind of programming turns off the outputs if certain critical error conditions occur.
Figure 5-30. A suspend instruction used after a subroutine to allow a check of the subroutines data before resuming main program execution.
Module 5
17
Stored to word I:0.0 Figure 5-32. The operation of an immediate input with mask instruction.
18
Module 5
L1 LS I/2
L2
It then stores this data to the input word denoted by the slot parameter. The input bits that are not masked are not updated; thus, these bits are left in their previous state. The PLC uses the updated input data to evaluate all the rungs located after the immediate input instruction. Figure 5-33 shows an example of an IIM application in which a limit switch is connected to input terminal 2 of a MicroLogix 1000. To update the data about this input during the ladder program, the program contains an IIM instruction whose slot parameter is I:0.0, since this is the input word that maps the limit switch. The IIM instructions mask value is 0004 to mask out all but the data for bit 2. Thus, if the limit switch was off when the PLC started its scan but has since turned on, the immediate input instruction will interrupt the scan to read the current status of the limit switch. It will then update the new data about the limit switchs logic status in address I:0.0/2. The rest of the program will now use this updated input data. The mask address specified in an IIM instruction determines how many inputs will be updated by the instruction. To update all of the inputs for a 16 I/O MicroLogix, you must specify a slot parameter of I:0.0 and a mask value of 03FF. This will update all 10 input bits of the MicroLogixs input file. To update all the input bits of a 32 I/O MicroLogix, you must program two consecutive immediate input instructions (see Figure 5-34). The first instruction must have a slot parameter of I:0.0 and a mask of FFFF to update all the bits of this word. The second instruction must have a slot parameter of I:0.1 and a mask of 000F, since a 32 I/O MicroLogix only uses the first four bits of word I:0.1 for inputs.
15141312 1110 9 8 7 6 5 4 3 2 1 0
0000 0000 0110 0100 0000 0000 0000 0100 0000 0000 0000 0100
To I:0.0/2 Figure 5-33. An immediate input with mask block used to update the status of a limit switch connected to input terminal 2 of a MicroLogix 1000.
Figure 5-34. Two consecutive immediate input with mask instructions used to update all the input bits of a 32 I/O MicroLogix. Module 5 19
L1 O/0 PL1
L2
O/1
PL2
15141312 1110 9 8 7 6 5 4 3 2 1 0
0000 0000 0001 1000 0000 0000 0000 0011 0000 0000 0000 0000
Figure 5-36. An immediate output with mask instruction used to update the status of two pilot lights.
20
Module 5
5-5 Review
An equal instruction compares two values to see if they are equal to each other. Other basic comparison instructions (not equal, less than, less than or equal, greater than, and greater than or equal) also compare two values, but they each test for a different comparison condition. The masked comparison for equal instruction uses a mask value to compare part of the data in the source location to a comparison value. A limit test instruction checks to see if a test value falls within a certain range of values. A jump instruction causes a controller to jump over the execution of a certain set of ladder rungs. A jump to subroutine instruction causes the controller to stop executing the main control program and start executing a subroutine program. A master control reset instruction forms a conditional fence around a set of ladder rungs. A temporary end instruction stops program execution before the end of the whole ladder program. A suspend instruction halts program execution and turns off the outputs while maintaining the status file data. An immediate input with mask instruction forces the PLC to halt program execution and immediately update the status of the input devices. An immediate output with mask instruction forces the PLC to halt program execution and immediately update the status of the output devices.
Module 5
21