AC 2010-1983: INSTRUCTIONAL ALGORITHMS ENHANCE STUDENT UNDERSTANDING OF PLC LADDER LOGIC PROGRAMMING

James Rehg, (Retired) James A. Rehg is a freelance writer and co-owner of Text On Demand, a company specializing in information presentation and documentation. He retired after 40 years of teaching with the last 10 years at Penn State University.

Glenn Sartori, Retired Glenn J. Sartori is a freelance writer and co-owner of Text On Demand, a company that specializes in presenting and documenting technical information. Glenn spent 40 years in the aerospace industry at several companies and recently retired from The Boeing Company. Page 15.751.1

© American Society for Engineering Education, 2010 Instructional Algorithms Enhance Student Understanding Of PLC Ladder Logic Programming

Abstract

This paper presents two techniques that helps students transition from ladder logic concepts to programmable logic controller (PLC) ladder logic programming. The first technique presents a very structured algorithmic process for the selection of PLC ladder logic input contact configurations for a given control problem. The second technique describes the use of ladder logic building blocks for the commonly used ladder logic instructions in the development of larger PLC ladder logic programs.

Students, familiar with relay ladder logic (RLL) control, know that input switch and sensor contacts are wired into the relay logic rung to provide power flow to the output field device, which is wired into the output side of the ladder. If the normally open (NO) contacts of the switch are used in RLL, then the contact symbol for input switch is a NO contact symbol. The field device wired into the output side of the rung is energized or de-energized based on the state of the input contacts. PLC ladder logic inputs are logical representations of memory bits in the input register. Selection of the correct input instruction, examine if closed or examine if open, depends on: the type input field device contact used, NO or NC; the state of the input, active or not active; and the desired state of the output field device, energized or not energized. The selection table process and algorithm presented in the paper leads students to the correct PLC ladder logic input choice. The process also helps them understand the relationship between the physical field device input and output hardware, and the software logic represented in the PLC ladder logic program.

As students incorporate PLC ladder logic instructions into a software solution for a sequential control problem, they are faced with PLC instructions that support two or more output options. Timers, for example, have three output options depending on the type of control required by the sequential control problem. The paper describes how instruction options are structured into multi-rung program building blocks with specific control functions. Students are better able to select an instruction, and the instruction output option most appropriate for a control requirement, when they understand the operation of smaller building blocks. Large ladder logic programs are just combinations of these instruction building blocks.

Use of both of these student learning techniques in teaching PLC programming has demonstrated their effectiveness in moving students from relay ladder logic to an understanding or PLC ladder logic programming. Page 15.751.2 Selecting XIC and XIO Input Instructions

Students learning PLCs are often confused when selecting the correct XIC (examine if closed) or XIO (examine if open) input instructions for the PLC ladder rung. An input field device with an NC contact configuration does not necessarily have an examine if open (-| / |-) instruction type representing it in the PLC rung. PLC input rung instructions must be selected using a process that looks at the input field device contact type (NO or NC) and its operational condition (activated or not activated). In addition, the input rung instruction selected, XIC or XIO, is affected by the requirement for the output field device to be either on or off. Therefore, learning a process that will always Figure 1 Process fluid heating tank work is critical.

The process system in Figure 1, employed to heat a process liquid, is used here to illustrate the selection of input instructions given a process operational statement. Process input field devices include: • Two float switches – a low level (L1) that is normally open (NO) and a high level (L2) that is normally closed. • A temperature switch – one switch (TS1), which is activated by a temperature over 185° F, that has one normally closed (NC) contact and one NO contact. • Two momentary push button switches – an NC stop (PB1) and an NO start (PB2). The output field devices include: • Two contactors with overloads – one for the heater and one for the pump. • A solenoid operated outlet valve. The process operation for the heater is described as follows:

The process liquid is heated when the liquid level is above the low-level float switch, L1, and when the process temperature is below 185° F. The tank is drained when the process temperature is above 185° F, and liquid is above the low-level float switch. The NO contacts of TS1, the temperature switch, are used for control of the drain valve. An energized drain valve opens the drain.

The selection table in Figure 2 illustrates a selection strategy for the input PLC temperature switch instruction in the rung that controls the drain valve. When the design is performed, the Page 15.751.3 temperature switch requires an instruction on the ladder rung using either an XIC or XIO instruction. The instruction type selected, XIC or XIO, depends on how the control statement Page 15.751.4 represent NO contacts with an activated field device. Note in column 3 that an active NO switch has closed contacts. 3. Determine the desired condition, on or off, for the output field device in column 4. Locate the corresponding row from the two rows selected in step 2.

Tank example – Since the outlet valve must be turned on (column 4) or opened, the parameters across row 4 describe the operation of the input and output field devices for this problem. For example, an active NO input field device is turning on the ladder output OTE instruction, so that the output field device is on. Therefore, the closed contacts on the input field device must make the rung true.

4. With the row (4) determined, the type of input instruction required for the problem is listed in column 6.

Tank example – The rung input instruction must be examine if closed or XIC (-| |-) for this application. The XIC instruction is true when the NO input field device contact is closed. This true XIC instruction allows power flow to the output coil, which energizes the outlet valve.

Figure 3 Ladder logic solution for the process heater tank problem Page 15.751.5 The solution for the process tank problem is illustrated in Figure 3. Although the process was demonstrated using input and output field devices, it works equally well with internal input bits and internal output bits. After working through several examples, the process for picking XIC and XIO instructions becomes clear and dependence on the chart in Figure 2 diminishes. The chart illustrates the relationship between inputs, outputs, and input instructions.

Standard PLC Ladder Logic Programming Aids

Students are often introduced to PLC programming with pedagogy similar to that used for a traditional text based programming languages. Namely, teach the syntax for the instruction when entered into the program code, and describe how values in the affected data registers are modified when the instruction executes. Students are then required to group instructions into code sequences to produce a desired programming result. Following this process for PLC program creation creates Figure 4 PLC TON timer instruction considerable confusion because the structure and syntax of PLC programs, called ladder logic, is entirely different from the syntax of high level languages like or BASIC.

For example, the operation of the PLC on-delay timer instruction (TON) in Figure 4, which starts the timing process when the instruction is active, is introduced by teaching timer parameter selection and action of input and output control bits during a timing cycle. Timer parameters are described as follows: timer name or number (T4:5), time base (0.01 or 1 second per increment), preset (total number of increments), and accumulator value (the number of increments accumulated). At this Figure 5 PLC TON timer in ladder logic point the three timer output bits are introduced: the (EN) enable (a bit to indicate that the timer is active), the (TT) timer timing (a bit to indicate an active timer with an accumulator value less than the preset value), and the (DN) done (a bit to indicate an active timer with an accumulator value equal to or greater than the preset value).

Next the instruction is used in a line of code or, in the case of a PLC, the instruction is placed into a ladder logic rung. Figure 5 illustrates the initial programming step for the TON timer Page 15.751.6 instructions. The timer instruction is an output; therefore, the instruction is placed on the far right side of the rung. An input instruction is placed on the left side of the rung to establish the input condition necessary to activate the timer.

Teaching the TON Instruction

Using the traditional instructional approach, lectures on the PLC Figure 6 Two rung timer solution for pump TON timer instruction starts with procedures delay problem for selecting and setting timing parameters, timing diagrams to describe the relationship of timer input and output bits for various true and false conditions, and the addressing syntax for timer data. At this point students understand the structure of the PLC timer, where it is placed in the ladder logic rung, and the output bits available for control of a field device. However, students still find it difficult to know which output bits to use for control and how to handle different types of field device input contacts. An example control problem illustrates how a problem statement is linked to standard ladder logic rungs illustrated in Figure 7a and 7b.

Problem Statement

After learning fundamental timer instruction operation, students are presented with a programming problem. For example:

Draw a PLC ladder logic program that uses a timer to delay the start of a pump for 30 seconds after the NO start contacts of a selector switch change to the NC position.

The rung in Figure 5 is presented in most PLC manufacturers user manuals to describe TON timer operation. However, every timer application must have two rungs. One to activate the timer command or instruction, Figure 5, and the second, Figure 6, to activate the output field device based on the problems statement and the timer output choices. The two rung solution for the example problem is illustrated in Figure 6. The done bit, DN, is used to turn on discrete output bit zero (0), which controls the pump contactor field device. The DN bit is used because the problem requires that the pump start be delayed for 30 seconds after the timer instruction is active.

TON Standard Ladder Logic

An analysis of the problem and solution indicates that the type of contact on the input field device and the type of delay required determine the configuration of the ladder rungs. Six timer and ladder combinations cover all possible TON timer problems. Four of these combinations are Page 15.751.7 illustrated in Figures 7a and 7b. The standard ladder logic application starts with a description of the problem, often in the problem statement, that describes how the timer should function to (a)

(b)

Figure 7a TON Standard ladder logic rungs with maintain type input contacts meet application requirements. For example, the standard logic in Figure 7a(a) describes the output action and input contacts as follows:

Turn on an output device for a set time period when a maintain contact input device changes states

The maintain contact input field device requires only an examine if closed input instruction to activate the timer instruction because the field device contact remains closed. The output is triggered by the DN timer bit since the output is energized after the preset time value has elapsed. The four standard ladder logic rungs address the two different types of input field device contacts and the different timing options. Teaching students these four standards ladder logic solutions allows them to specify a timer solution once the field device trigger contact configuration is identified, and the type of timing function is known.

TOF Standard Ladder Logic

The off-delay timer (TOF) starts the timing period after the TOF instruction is de-activated. So the TT bit becomes true at de-activation and remains true for the preset time delay value. The DN bit is true when the TOF instruction is active and while the TT bit is true. The timer parameters for the TON and TOF instructions are the same. Two standard ladder logic solutions , Figure 8a Page 15.751.8 and 8b, are used to apply the TOF timer in control applications. The problem statement for each (c)

(d)

Figure 7b TON Standard ladder logic rungs with momentary type input contacts application indicates the input field device is a selector switch with either a NC or NO contact. The TT output bit is used in the first standard ladder and the DN is used in the second. The statement for Figure 7a and Figure 8a is the same, but the normal condition for the input field device contacts for the first is NO and for the second is NC. A control application illustrates how students use the standard ladder logic rungs in the total ladder logic solution.

Application Example

The following application illustrates how the standard ladder solution is extracted from a problem statement.

Problem Draw a ladder diagram for a pumping system where the pump requires a 5-second delay before pumping, and if the pump is shut off, it requires a 15-second delay before it can be restarted. Start and stop switches are NO momentary contact push buttons.

Solution Page 15.751.9 Refer to Figures 9 and 10, which show the motor control ladder solution and the timing diagram for the solution. Figure 8a TOF Standard ladder logic rungs with maintain type input contacts and TT output

Problem Statement Analysis—Pump Start

A 5-second delay before pumping—An on-delay timer is needed so Standard Logic from Figures 7a or 7b is used. Since the pump start must occur 5 seconds after the start signal, the Standard Logic in Figure 7a(b) or 7b(d), using the timer DN bit, would satisfy the control requirements. Start switch is a NO momentary contact push button—The momentary contract requires the use of the Standard Logic from Figure 7b(d).

Pump Start Logic

The pump start control is implemented in rungs 0 and 2 in Figure 9. Rung 0 has T4:0, an on- delay timer, used in the Standard Logic from Figure 7b(b). The activation of the start switch makes rung zero true, which initiates the on-delay timer (T4:0/EN and T4:0/TT are true). Since the start switch is a momentary contact type, the I:1/10 instruction is sealed with the T4:0 timer Page 15.751.10 Figure 8b TOF Standard ladder logic rungs with maintain type input contacts and DN output timing bit (T4:0/TT) to keep the rung active while the timer is incrementing the accumulator for the on delay of 5 seconds.

Rung 2 also comes from Figure 7b(b) with the timer DN bit used to start the pump with some some additional input logic added. The operation description for Figure 7b(d) indicates that the DN bit is true for only one scan, just long enough to make the pump output O:2/5 true. Therefore a sealing contact around the DN bit is necessary in rung 2 to keep the pump energized. As a result, the pump output, O:2/5, is true so the pump starts 5 seconds after the start switch is pressed. The remainder of the input logic in rung 2 (T4:1/DN) comes from the timer, T4:1, which is associated with remainder of the control problem. The timing diagram is in Figure 10.

Problem Statement Analysis—Pump Stop

If the pump is shut off, it requires a 15-second delay before it can be restarted—An off-delay timer is needed because the problem statement indicates that some action cannot occur immediately after an input but must be delayed by a fixed delay time. Therefore, Standard Logic Page 15.751.11 from Figures 8a or 8b is used. Additional analysis indicates that the action, delay the restart for 15 seconds, occurs after the delay time has elapsed. This implies that the DN bit is used and not the TT bit, so the restart delay starts when the stop switch changes state. As a result, the Standard Logic in Figure 8b(b) is used for the control requirements.

Figure 9 Motor control ladder logic Stop Pump Logic

TOF timers are used much less frequently than the TON type. In addition, the logical operation of the TOF described in the Standard Logic tables is less straight forward since a true timer rung resets the timer, and the timing action occurs when the TOF instruction is false. Rung 1, Figure 9, is copied from the Standard Logic in Figure 8b(b). The stop PB is a NO momentary contact, which is different from the Standard Logic. Since the stop PB is pressed and released, the NC time for the input is present but short. So when the stop PB is pressed, rung 1 is true, the timer is reset and the DN bit output is true. When the stop PB is released, rung 1 is false, and timing starts while the DN bit remains true.

The output on rung 2 controls the pump. The input logic on rung 2, Figure 9, is a combination of Standard Logic in Figure 7b(d) and 8b(b). These two sets of input instructions start the pump after the 5 second delay and hold it off for 15 seconds after it is stopped. When the stop PB is released the T4:1 off-delay timer starts and keeps the T4:1/DN bit active (examine if open contact open). So the initiation of the

stop push button makes T4:0/ Page 15.751.12 DN output true and the pump Figure 10 Motor control timing diagram output O:2/5 false so the pump turns off. The start of the off-delay timer, however, keeps rung two false for the duration of the T4:1 time so the start push button cannot restart the pump for 15 seconds. Upon completion of the off-delay time of 15 seconds, the T4:1/DN bit returns to the inactive state, and the pump is available to start. The timing diagram is in Figure 10.

Control Solutions with Standard Logic

The example presented here demonstrates how Standard Ladder Logic solutions for the TON and TOF Allen Bradley (AB) RS500 PLC software was used to build a pump control logic solution. Using the standard logic, the proper configuration for rungs 0 and 1 were selected, and input logic from the two standards was combined in rung 2 to control the PLC output instruction driving the pump contactor.

Standard Ladder Logic for many AB instructions is presented in the second reference along with numerous control solutions that use the logic as a programming tool. The standards provide the basic structure or building blocks for creating the solution. In some cases the input logic is expanded when multiple input instructions are required by the control statement. However, the standard logic building blocks provide students with a strategy and starting point in the ladder logic design.

Bibliography

1. Allen Bradley RS500 Users Manual 2. Rehg, J. and Sartori, G., Programmable Logic Controllers, Pearson Publishing, 2007 Page 15.751.13