Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Chapter 2: Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL). 2.1 2.2 2.3 2.4 2.5 2.6 PLC Operation using scanning technique. Understanding Relay Ladder Diagram (RLL). Basic Instructions of RLL. Motor control using PLC, two push buttons and motor starter. Adding two indicators for the developed RLL. PLC Programming. 2.1 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Programmable Logic Controller (PLC) And Relay Ladder Logic(RLL) PLC stands for programmable logic controller. PLCs are electronic control devices that are used in variety of industries, ranging from manufacturing plants to processing plants. A PLC is a device that was invented to replace the necessary sequential relay circuits for machine control and to replace analog controller. The PLC works by looking at its inputs (both logic and continues types) and depending upon their state, turning on/off its outputs. Examples: PLCs used in automotive assembly plants, automotive parts manufacturing plants, mineral processing plants, semi-conductor manufacturing plants, steel mills ….etc. The user enters a program, usually via software, that gives the desired results. The PLC has three components; 1) Central Processing Unit CPU, 2) Inputs, 3) Outputs. We could consider the PLC to be a box of hundreds of separate relays, counters, timers and data storage locations. Do these counters, timers, etc. really exist? No, they "physically" don't exist but rather they are simulated and can be considered software counters, timers, etc. The internal relays are simulated through bit locations in registers, as shown in Fig. 2.1. Analog Input Networking module Analog Ouput Modem Fig. 2.1 Internal structure of a PLC. The functions of these modules are given as follows: INPUT RELAYS-(contacts): These are connected to the outside world. They physically exist and receive signals from switches, sensors, etc. Typically they are not relays but rather they are transistors. These inputs are called discrete or logic inputs. INTERNAL UTILITY RELAYS-(contacts): These relays do not receive signals from the outside world nor do they physically exist. They are simulated relays and are what enables a PLC to eliminate external relays. There are also some special relays that are dedicated to performing only one task. Some are always on while some are always off. Some are on only once during power-on and are typically used for initializing data that was stored. 2.2 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) COUNTERS: These again do not physically exist. They are simulated counters and they can be programmed to count pulses. Typically these counters can count up, down or both up and down. Since they are simulated they are limited in their counting speed. Some manufacturers also include high-speed counters that are hardware based. We can think of these as physically existing. Most of the time these counters can count up, down or up/down. TIMERS: These also do not physically exist. They come in many varieties and increments. The most common type is an on-delay type. Others include off-delay and both retentive and non-retentive types. Increments vary from 1ms through 1s. OUTPUT RELAYS-(coils):These are connected to the outside world. They physically exist and send on/off signals to solenoids, lights, etc. They can be transistors, relays, or triacs depending upon the model chosen. DATA STORAGE: Typically there are registers assigned to simply store the data. They are usually used as temporary storage for math or data manipulation. They can also typically be used to store data when power is removed from the PLC. Upon power-on they will still have the same contents as before when power has been removed. ANALOG MODELS: This covers analog inputs and outputs. The analog models cover reading analog signals from sensor, provides analog signal such as thermocouples, strain gauges, thermistor, pressure sensor….etc. The analog output signals can be used to command external controller e.g. servomotors amplifier, solenoid amplifier …etc. USER INTERFACE INPUT: Which contains extra push-bottoms that can be configured by the user to set/reset logic output devices e.g. relays outputs, or can be used as a storage of messages that can be displayed on liquid crystal display. Furthermore, some of these interfaces has led which can be configured by the user. NETWORKING MODULES: Larger PLCs could have serial port that can be used for networking a multiple of PLCs that are to be programmed from one main computer or sending/receiving data between PLC network. Furthermore, some of the PLCs are equipped with remote control module (modem) to program the PLC from long distance computer. The CPU of the PLC contains a microprocessor, which means that a PLC is basically a specialized computer that has been designed to control the operation of machines and processes within the harsh environment of the plant. The language used to program the PLC to perform the logic required to connect the filed input to its outputs is called Relay Ladder Logic (RLL). The RLL language is programmed by means of special software using personal computer (connected to the PLC using serial port) or hand-held programmer which has led or liquid-crystal display and keyboard as illustrated in Fig. 2.2. Hand-held programmer or PC communication Input Module (logic or continuous) +24V DC User interface CPU & Memory Output module (logic or continuous modules) M S N Serial port Power Supply 2.3 Fig. 2.2 PLC structure, user communication and interfaces modules interconnections. Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) RAM and EPROM memory are used to store the program instructions in the PLC. The computer or hand-held programmer can be used to load and save the RLL programs into the PLC. The physical input and output modules can be discrete or analog I/O modules and can be selected and specified when purchasing the PLC, and depend on the number of the required I/O lines. The discrete I/O modules connects field inputs devices of the ON/OFF nature like limit switches, push button switches, solenoids, solenoid valve or electro-mechanical relay ..etc. Each discrete I/O module supply voltage source. Since these voltages can be of different magnitude or types, I/O modules are available at various AC & DC voltages ratings as shown in Table 2.1. Furthermore, the inputs and outputs are connected to LED’s to indicate the operation of the I/O module Table 2.1: common ratings for discrete I/O interface modules. Interface input module Interface output modules 24 V AC/DC 12-48 V AC 48 V AC/DC 120 V AC 230 V AC/DC 230 V DC 5 V (TTL) 5 V DC (TTL) 2.1 PLC Operation using scanning technique A PLC works by continually scanning a program. We can think of this scan cycle as consisting of 3 important steps, as shown in Fig. 2.3. There are typically more than three steps but we can focus on the important parts and ignore the others. Typically the others are checking the system and updating the current internal counter and timer values. Fig. 2.3 Scanning technique in PLC. 2.4 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Step 1: CHECK INPUT STATUS: First the PLC takes a look at each input to determine if it is on or off. In other words, is the sensor connected to the first input on? How about the second input? How about the third. It records this data into its memory to be used during the next step. Step 2: EXECUTE PROGRAM: Next the PLC executes your program one instruction at a time. Maybe your program said that if the first input was on then it should turn on the first output. Since it already knows which inputs are on/off from the previous step it, will be able to decide whether the first output should be turned on based on the state of the first input. It will store the execution results for use later during the next step. Step 3: UPDATE OUTPUT STATUS: Finally the PLC updates the status of the outputs. It updates the outputs based on which inputs were on during the first step and the results of executing your program during the second step. Based on the example in step 2, it would now turn on the first output because the first input was on and your program said to turn on the first output when this condition is true. After the third step the PLC goes back to step one and repeats the steps continuously. One scan time is defined as the time it takes to execute the 3 steps listed above. The total response time of the PLC is a fact that we have to consider when shopping for a PLC. The PLC takes a certain amount of time to react to changes. In many applications speed is not a concern, in others though. The PLC can only see an input turn on/off when it's looking. In other words, it only looks at its inputs during the check input status part of the scan. Fig. 2.4 Variation of scanning time on detecting the high-speed inputs. In Fig. 2.4 the input 1 is not seen until scan 2. This is because when input 1 turned on, scan 1 had already finished looking at the inputs. Input 2 is not seen until scan 3. This is also because when the input turned on scan 2 had already finished looking at the inputs. Input 3 is never seen. This is because when scan 3 was looking at the inputs, signal 3 was not on yet. It turns off before scan 4 looks at the inputs. Therefore signal 3 is never seen by the PLC. This illustrates the importance of scanning time of the PLC. 2.5 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) 2.2 Understanding Relay Ladder Diagram (RLL) To understand the programming of PLC relay ladder diagram, let us start with simple case of relay control system. We can think of a relay as an electromagnetic switch. Apply a voltage to the coil results in a magnetic field is generated. This magnetic field sucks the contacts of the relay in, causing them to make a connection. These contacts can be considered to be a switch. They allow current to flow between 2 points thereby closing the circuit. Power circuit Control circuit Fig. 2.5 Simple control circuit of a bell Let's consider the following example. Here we simply turn on a bell whenever a switch is closed, as shown in Fig. 2.5. We have 3 real-world parts; A switch, a relay and a bell. Whenever the switch closes we apply a current to the bell causing it to sound. The bottom circuit indicates the DC control circuit. The top circuit indicates the AC control circuit. Here we are using a DC relay to control an AC circuit. That’s the benefit of using relay. When the switch is open no current can flow through the coil of the relay. As soon as the switch is closed, however, current runs through the coil cause a magnetic field to build up. This magnetic field causes the contacts of the relay to close. Now AC current flows through the bell and we hear it. Fig. 2.6 shows a typical industrial relay. Fig. 2.6 A typical industrial relay. Next, we would like to replace the relay control system with PLC control system using relay ladder logic. After seeing a few of these it will become obvious why its called a ladder diagram. We have to create one of these because, unfortunately, a PLC doesn't understand a 2.6 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) schematic diagram. It only recognizes code. Fortunately most PLCs have software, which convert ladder diagrams into code. This shields us from actually learning the PLC's code. The PLC doesn't understand terms like switch, relay, bell, etc. It prefers input, output, coil, contact, etc. It doesn't care what the actual input or output device actually is. It only cares that its an input or an output. First we replace the battery with a symbol. This symbol is common to all ladder diagrams. We draw what are called bus bars. These simply look like two vertical bars. One on each side of the diagram. Think of the left one as being + voltage and the right one as being ground. Further think of the current (logic) flow as being from left to right. Next we give the inputs a symbol. In this basic example we have one real world input. (i.e. the switch) We Fig. 2.7 Contact relay symbol. give the input that the switch will be connected to, the symbol shown below. Fig. 2.7 shows the symbol for contact of switch or relay. Next we give the outputs a symbol. In this example we use one output (i.e. the bell). We give the output that the bell will be physically connected to the symbol shown below. Fig. 2.8 shows the symbol used as the output coil or relay. Fig. 2.8 Output relay symbol. The AC supply is an external supply so we don't put it in our ladder. The PLC only cares about which output it turns on and not what's physically connected to it. Second, we must tell the PLC where everything is located. In other words we have to give all the devices an address. Where is the switch going to be physically connected to the PLC ? How about the bell? We start with a blank road map in the PLCs town and give each item an address. Could you find your friends if you didn't know their address? You know they live in the same town but which house? The PLC town has a lot of houses (inputs and outputs) but we have to figure out who lives where (what device is connected where). We'll get further into the addressing scheme later. The PLC manufacturers each do it a different way! For now let's say that our input will be called "0000". The output will be called "500", as shown in Fig. 2.9. Finally, we have to convert the schematic into a logical sequence of events. This is much easier than it sounds. The program we're going to write tells the PLC what to do when certain events take place. In our example we have to tell the PLC what to do when the operator turns on the switch. Obviously we want the bell to sound but the PLC doesn't know that. 2.7 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Fig. 2.9 RLL for bell control circuit. The Fig. 2.9 shows the final converted diagram (RLL) for bell control system. Notice that we eliminated the real world relay from needing a symbol. 2.3 Basic Instructions of RLL Main input instructions Normally open contact : Normally closed contact : Main output instructions Normally open relay Normally closed relay Fig. 2.10 Main instructions in RLL. Example 1: Draw ladder logic for the control circuit shown in Fig. 2.11: Fig.2.11 Control and RLL for AND Boolean operation. The Boolean logic equation for this control circuit: Coil = SW1 . SW2 Example 2: 2.8 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Redraw the relay ladder logic of Example 1, using normally closed switch for SW2 ? The amended RLL is shown in Fig. 2.12: Fig. 2.12 Amended RLL using Normally closed switch for switch SW2. The Boolean logic equation will be : Coil = SW1 . SW2 2.4 Motor control using PLC, two push buttons and motor starter Here two push buttons switches (Start/Stop) are used to switch the motor on/off. These switches are connected to the two PLC inputs discrete type), as shown in Fig. 2.13. One of the output ports (discrete outputs) of the PLC used to switch motor starter on/off, which will start/stop the electric motor. The control steps of the electric motor using RLL is shown in Fig. 2.14. Motor starter Output Motor PLC Input Two bush bottom switches Fig. 2.13 Motor control using PLC, motor starter and two push bottoms. 1 2 3 4 2.9 Go to step 1 Fig. 2.14 Developed RLL for motor control. Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) 2.5 Adding two indicators for the developed RLL Here two indicators to be added to the developed circuits. Red color to indicates that the motor is off, and green color to indicates that the motor is running. The amended RLL is shown in Fig. 2.15. Motor starter Output Motor Two indicators PLC Input Input Two push bottom switches Fig. 2.15 Amended RLL for motor control after adding two indicators. The modified RLL is given as follows: Fig. 2.15 (a)RLL when Start push button undressed, (b)RLL when Start push button pressed 2.10 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) 2.6 PLC Programming The programming technique through serial port via PC and using special software provided by the manufacturer, as shown in Fig. 2.16 or using hand programmer. Fig. 2.16 PLC Programming technique using PC computer through serial port. In case of PC program, a special software program must be installed in the PC which is provided by the manufacturer to write and edit user Relay Ladder Logic (RLL). This also transfers the program between PLC and PC computer and vise versa. The program developed to be friendlier with user during RLL development, as shown in Fig. 2.17. Fig. 2.17 Example of RLL developed using TPDS software for Toshiba PLC. Because the PLC uses Relay Ladder Logic diagrams, the convention from any existing relay ladder to programmed relay ladder logic is simple. Each rung is a combination of input conditions (symbols) connected from left to right, with the symbol that represents the output at the far right. The symbols that represent the inputs are connected in series, parallel, or some combination to obtain the desired logic. The following examples show how PLC can be used to carry out different control logics, as shown in Fig. 2.18. Note, any combination logic called Boolean equation. Example 3: Develop a relay-ladder logic that allows four switches in a room to control a single light? The RLL is shown in Fig. 2.19. SW1 Light LIGHT=SW1+SW2+SW3+SW4 SW2 SW3 SW4 2.11 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) Boolean or Logic Function SW1 SW1 SW2 LAMP { Relay Ladder Diagram} LAMP =SW1 and SW2 LAMP= SW1 . SW2 SW2 Lamp { Relay Ladder Logic } LAMP SW1 { Relay Ladder Diagram} SW2 LAMP =SW1 OR SW2 LAMP= SW1 + SW2 SW1 Lamp { Relay Ladder Logic } SW2 SW1 SW3 Lamp SW1 SW3 Lamp SW2 SW4 { Relay Ladder Logic } LAMP =(SW1 OR SW2) AND SW3 LAMP= (SW1 + SW2) . SW3 SW2 { Relay Ladder Logic } LAMP= (SW1.SW3) +(SW2.SW4)+SW5 SW5 SW1 SW3 Y20 SW2 SW4 Y20 Y20=(SW1+ SW2) . SW3 LAMP= SW4 . Y20 Or LAMP=(SW1+ SW2) . SW3 . SW4 Lamp Fig. 2.18 Development of RLL for different control logics. 2.12 Manufacturing Automation using PLCs CHAPTER 2 SW1 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) SW3 Y20 SW2 SW4 Y20 SW1 SW3 SW2 SW4 SW4 SW1 Y20 SW3 Y20=(SW1+ SW2) . SW3 LAMP= SW4 . Y20 Or LAMP=(SW1+ SW2) . SW3 . SW4 Lamp Y20 Lamp Y20 Y20 Y20=(SW1.SW3)+(SW1.SW4) +(SW2.SW3)+(SW2.SW4) LAMP= SW4 . Y20 Or LAMP= ((SW1.SW3)+(SW1.SW4) +(SW2.SW3)+(SW2.SW4)) . SW4 Y20=SW1. SW3+Y20.SW3 LAMP= SW4 . Y20 Note: 1st Boolean equation is memory or filp-flop. SW4 Y20 Lamp Fig. 2.18 Development of RLL for different control logics Example 4: Modify the developed relay-ladder logic given in example 3 such that these switches are enabled/disabled using external supervisor through switch (SW5) ? SW1 SW5 LIGHT=(SW1+SW2+SW3+SW4) . SW5 Light SW2 SW3 SW4 Fig. 2.20 Modified RLL by adding external switch SW5, refer example 4. 2.13 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) PROBLEMS 2.1) Develop the RLL diagrams for the following Boolean equations : F1 = A . B + A . B F2 = sw1 . sw2 . sw3 . sw4 F3 = ( sw1 . sw2 . sw3) + sw4 Y = (A.B.C + D ) . (E.F) 2.2) Drive the Boolean equations for the following relay ladder logics (a) SW1 SW3 SW4 Y20 Y20 SW4 Y20 Lamp (b) SW1 SW3 SW4 SW6 SW1 Y20 SW2 SW5 2.3) Develop a relay ladder logic that will switch on the motor on/off in automatic and manual (called jog) modes? (ans: SW1: START push bottom, SW3 STOP push bottom, SW2 JOG or Manual operating mode, and Y20 memory that will run the relay that will switch the motor on) SW1 SW3 Y20 Y20 SW2 Y20 Y20 motor 2.14 Manufacturing Automation using PLCs CHAPTER 2 Programmable Logic Controller (PLC) and Relay Ladder Logic (RLL) 2.4) Give examples of where a PLC could be used? 2.5) Why would relays be used in place of PLC? (ans: for some cases is simple and cost effective) 2.6) List the advantages of a PLC over relay control? 2.15