﻿ PLC Ladder Diagrams for Electrical Engineers (Beginners)

Back

# PLC Ladder Diagrams for Electrical Engineers (Beginners)

## Introduction to PLC ladder diagrams //

As an introduction to ladder diagrams, consider the simple wiring diagram for an electrical circuit inFigure 1a. The diagram shows the circuit for switching on or off an electric motor. We can redraw this diagram in a different way, using two vertical lines to represent the input power rails and stringing the rest of the circuit between them. Figure 1b shows the result. Both circuits have the switch in series with the motor and supplied with electrical power when the switch is closed.

The circuit shown in Figure 1b is termed a ladder diagram.

With such a diagram the power supply for the circuits is always shown as two vertical lines with the rest of the circuit as horizontal lines. The power lines, or rails as they are often termed, are like the vertical sides of a ladder with the horizontal circuit lines like the rungs of the ladder. The horizontal rungs show only the control portion of the circuit.

In the case of Figure 1 it is just the switch in series with the motor. Circuit diagrams often show the relative physical location of the circuit components and how they are actually wired.

With ladder diagrams no attempt is made to show the actual physical locations and the emphasis is on clearly showinghow the control is exercised.

Figure 2 (see below) shows an example of a ladder diagram for a circuit that is used to start and stop a motor using push buttons. In the normal state, push button 1 is open and push button 2 closed.

When button 1 is pressed, the motor circuit is completed and the motor starts. Also, the holding contacts wired in parallel with the motor close and remain closed as long as the motor is running. Thus when the push button 1 is released, the holding contacts maintain the circuit and hence the power to the motor. To stop the motor, button 2 is pressed. This disconnects the power to the motor and the holding contacts open. Thus when push button 2 is released, there is still no power to the motor.

Thus we have a motor which is started by pressing button 1 and stopped by pressing button 2.

A very commonly used method of programming PLCs is based on the use of ladder diagrams. Writing a program is then equivalent to drawing a switching circuit.

The ladder diagram consists of two vertical lines representing the power rails. Circuits are connected as horizontal lines, i.e., the rungs of the ladder, between these two verticals.

Convention 1 //

The vertical lines of the diagram represent the power rails between which circuits are connected. The power flow is taken to be from the left-hand vertical across a rung.

Convention 2 //

Each rung on the ladder defines one operation in the control process.

Convention 3 //

A ladder diagram is read from left to right and from top to bottom, Figure 3 showing the scanning motion employed by the PLC. The top rung is read from left to right. Then the second rung down is read from left to right and so on.

When the PLC is in its run mode, it goes through the entire ladder program to the end, the end rung of the program being clearly denoted, and then promptly resumes at the start. This procedure of going through all the rungs of the program is termed a cycle. The end rung might be indicated by a block with the word END or RET for return, since the program promptly returns to its beginning.

Convention 4 //

Each rung must start with an input or inputs and must end with at least one output. The term input is used for a control action, such as closing the contacts of a switch, used as an input to the PLC. The term output is used for a device connected to the output of a PLC, e.g., a motor.

Convention 5 //

Electrical devices are shown in their normal condition. Thus a switch, which is normally open until some object closes it, is shown as open on the ladder diagram. A switch that is normally closed is shown closed.

Convention 6 //

A particular device can appear in more than one rung of a ladder. For example, we might have a relay that switches on one or more devices. The same letters and/or numbers are used to label the device in each situation.

Convention 7 //

The inputs and outputs are all identified by their addresses, the notation used depending on the PLC manufacturer. This is the address of the input or output in the memory of the PLC.

Figure 4 shows standard IEC 1131-3 symbols that are used for input and output devices. Some slight variations occur between the symbols when used in semi-graphic form and when in full graphic.

Note that inputs are represented by different symbols representing normally open or normally closed contacts. The action of the input is equivalent to opening or closing a switch. Output coils are represented by just one form of symbol.

To illustrate the drawing of the rung of a ladder diagram, consider a situation where the energizing of an output device, such as a motor, depends on a normally open start switch being activated by being closed. The input is thus the switch and the output the motor. Figure 5a shows the ladder diagram.

Starting with the input, we have the normally open symbol j j for the input contacts. There are no other input devices and the line terminates with the output, denoted by the symbol ( ). When the switch is closed, i.e., there is an input, the output of the motor is activated.

Only while there is an input to the contacts is there an output. If there had been a normally closed switch | / | with the output (Figure 5b), then there would have been an output until that switch was opened. Only while there is no input to the contacts is there an output. In drawing ladder diagrams the names of the associated variable or addresses of each element are appended to its symbol.

Thus Figure 6 shows how the ladder diagram of Figure 5a would appear using (a) Mitsubishi, (b) Siemens, (c) Allen-Bradley, (d) ex Telemecanique (Schneider Electric) notations for the addresses. Thus, Figure 6a indicates that this rung of the ladder program has an input from address X400 and an output to address Y430.

When wiring up the inputs and outputs to the PLC, the relevant ones must be connected to the input and output terminals with these addresses.

# PLC Ladder Logic Functions for Electrical Engineers (Beginners)

## TRUE or FALSE condition //

To understand programmable logic controllers (PLCs) and their applications, you must first understand the logic concepts behind them. We’ll will explain the relationship between Boolean algebra and logic contact symbology, so that you will be ready to learn about PLC processors and ladder logic functions and diagrams.

The binary concept shows how physical quantities (binary variables) that can exist in one of two states can be represented as 1 or 0.

Now, you will see how statements that combine two or more of these binary variables can result in either a TRUE or FALSE condition, represented by 1 and 0, respectively.

Programmable logic controllers (PLCs) make decisions based on the results of these kinds of logical statements.

Operations performed by digital equipment, such as programmable controllers, are based on three fundamental ladder logic functions – AND, OR, and NOT. These functions combine binary variables to form statements. Each function has a rule that determines the statement outcome (TRUE or FALSE) and a symbol that represents it.

There are many control situations requiring actions to be initiated when a certain combination of conditions is realized. Thus, for an automatic drilling machine, there might be the condition that the drill motor is to be activated when the limit switches are activated that indicate the presence of the workpiece and the drill position as being at the surface of the workpiece.

Such a situation involves the AND logic function, condition A and condition B having both to be realized for an output to occur. This section is a consideration of such logic functions.

1. AND function
2. OR function
3. NOT function
4. NAND function
5. NOR function
6. Exclusive OR (XOR) function

### 1. AND logic function

Figure 1a shows a situation where an output is not energized unless two, normally open, switches are both closed. Switch A and switch B have both to be closed, which thus gives an AND logic situation. We can think of this as representing a control system with two inputs A and B (Figure 1b). Only when A and B are both on is there an output.

Thus if we use 1 to indicate an on signal and 0 to represent an off signal, then for there to be a 1 output we must have A and B both 1.

Such an operation is said to be controlled by a logic gate and the relationship between the inputs to a logic gate and the outputs is tabulated in a form known as a truth table.

Thus for the AND gate we have //

 Inputs Output A B 0 0 0 0 1 0 1 0 0 1 1 1

An example of an AND gate is an interlock control system for a machine tool so that it can only be operated when the safety guard is in position and the power switched on.

Figure 2a shows an AND gate system on a ladder diagram.

The ladder diagram starts with | |, a normally open set of contacts labeled input A, to represent switch A and in series with it | |, another normally open set of contacts labeled input B, to represent switch B. The line then terminates with O to represent the output. For there to be an output, both input A and input B have to occur, i.e., input A and input B contacts have to be closed (Figure 2b).

In general // On a ladder diagram contacts in a horizontal rung, i.e., contacts in series, represent the logical AND operations.

### 2. OR logic function

Figure 3a shows an electrical circuit where an output is energized when switch A or B, both normally open, are closed. This describes an OR logic gate (Figure 3b) in that input A or input B must be on for there to be an output.

The truth table is //

 Inputs Output A B 0 0 0 0 1 1 1 0 1 1 1 1

Figure 11.10a shows an OR logic gate system on a ladder diagram, Figure 4b showing an equivalent alternative way of drawing the same diagram.

The ladder diagram starts with | |, normally open contacts labeled input A, to represent switch Aand in parallel with it | |, normally open contacts labeled input B, to represent switch B. Either input A or input B have to be closed for the output to be energized (Figure 4c). The line then terminates with O to represent the output.

In general // Alternative paths provided by vertical paths from the main rung of a ladder diagram, i.e., paths in parallel represent logical OR operations.

An example of an OR gate control system is a conveyor belt transporting bottled products to packaging where a deflector plate is activated to deflect bottles into a reject bin if either the weight is not within certain tolerances or there is no cap on the bottle.

### 3. NOT logic function

Figure 5a shows an electrical circuit controlled by a switch that is normally closed. When there is an input to the switch, it opens and there is then no current in the circuit. This illustrates a NOT gate in that there is an output when there is no input and no output when there is an input (Figure 5c). The gate is sometimes referred to as an inverter.

The truth table is //

 Input A Output 0 1 1 0

Figure 5b shows a NOT gate system on a ladder diagram. The input A contacts are shown as being normally closed. This is in series with the output ( ). With no input to input A, the contacts are closed and so there is an output. When there is an input to input A, it opens and there is then no output.

An example of a NOT gate control system is a light that comes on when it becomes dark, i.e., when there is no light input to the light sensor there is an output.

### 4. NAND logic function

Suppose we follow an AND gate with a NOT gate (Figure 6a). The consequence of having the NOT gate is to invert all the outputs from the AND gate. An alternative, which gives exactly the same results, is to put a NOT gate on each input and then follow that with OR (Figure 6b).

The same truth table occurs, namely //

 Inputs Output A B 0 0 1 0 1 1 1 0 1 1 1 0

Both the inputs A and B have to be 0 for there to be a 1 output. There is an output when input A and input B are not 1. The combination of these gates is termed a NAND gate (Figure 7).

An example of a NAND gate control system is a warning light that comes on if, with a machine tool, the safety guard switch has not been activated and the limit switch signalling the presence of the workpiece has not been activated.

### 5. NOR logic function

Suppose we follow an OR gate by a NOT gate (Figure 8a). The consequence of having the NOT gate is to invert the outputs of the OR gate. An alternative, which gives exactly the same results, is to put a NOT gate on each input and then an AND gate for the resulting inverted inputs (Figure 8b).

The following is the resulting truth table //

 Inputs Output A B 0 0 1 0 1 0 1 0 0 1 1 0

The combination of OR and NOT gates is termed a NOR gate. There is an output when neither input A or input B is 1.
Figure 9 shows a ladder diagram of a NOR system. When input A and input B are both not activated, there is a 1 output. When either X400 or X401 are 1 there is a 0 output.

### 6. Exclusive OR (XOR) logic function

The OR gate gives an output when either or both of the inputs are 1. Sometimes there is, however, a need for a gate that gives an output when either of the inputs is 1 but not when both are 1, i.e., has the truth table:

 Inputs Output A B 0 0 0 0 1 1 1 0 1 1 1 0

Such a gate is called an Exclusive OR or XOR gate. One way of obtaining such a gate is by using NOT, AND and OR gates as shown in Figure 10.

Figure 11 shows a ladder diagram for an XOR gate system.

When input A and input B are not activated then there is 0 output. When just input A is activated, then the upper branch results in the output being 1. When just input B is activated, then the lower branch results in the output being 1. When both input A and input B are activated, there is no output.

In this example of a logic gate, input A and input B have two sets of contacts in the circuits, one set being normally open and the other normally closed. With PLC programming, each input may have as many sets of contacts as necessary.