Ladder logic 304: Timer application

A sample timer application written in ladder logic provides examples of various programming tips, such as ensuring the programmer knows what the customer wants. See screen captures.

08/13/2015


Figure 1: A useful side benefit of a tag-based programming platform (RSLogix software for a ControlLogix controller from Rockwell Automation is shown) is that the engineer can assign whatever addresses he wants to the tagnames. Courtesy: Automation PrimerA customer asked for a ladder diagram for one motor and two contactors (fast/slow) with auto control where the motor runs for 2 min. in slow. Timed out, the motor runs fast for 5 min. in manual control, when the motor can be started in either fast or slow and latches in until the timer times out. Also, the customer needed the motor to run fast in inch mode when the 2-in. buttons are pressed. Those are a lot of details, but an important part of writing code for an application is determining the specifics of what the customer wants.

One question to pose to the customer is what programmable logic controller (PLC) is being used? Most ladder logic is pretty similar from platform to platform, but addressing and instruction sets vary widely. The images in this article demonstrate the programming process. A useful side benefit of a tag-based programming platform is that the engineer can assign the needed addresses to the tagnames (see Figure 1). 

Programming example

Let's start by defining the outputs. This is not the only way to approach programming, but it's a pretty good one for discrete machinery. Note that all states of the motor control are pretty well defined in Figure 1, though faults and control and system modes are defined in other routines. For added safety, if the slow output is somehow turned on it will disable the fast output and vice-versa. This does not apply if outputs are forced (see Figure 2). 

Figure 2: As an added safety, if the slow output is somehow turned on it will disable the fast output and vice-versa. RSLogix software for a ControlLogix controller from Rockwell Automation is shown. Courtesy: Automation Primer

The timer control part of the application is discussed below, and notes follow about using delay timers for these. There is nothing here to prevent someone from taking the system out of auto or manual mode and ending the cycle early. Also, there is no indication of where the "Inch Two Hand Control Command" (Inch_2HandCtrl) bit came from. Ideally, this would be either a hardware-based, anti-tie-down relay or a software-based, anti-tie-down routine. Do NOT do what is shown in Figure 3. 

In most cases programming shown in Figure 3 is not legal because of safety concerns. If the controlled devices are behind a light curtain or door, the risk might be acceptable for the application.

Figure 3: In most cases this is not legal because of safety concerns. RSLogix software for a ControlLogix controller from Rockwell Automation is shown. Courtesy: Automation Primer

The point is, someone could tape down one of the pushbuttons and operate it with one hand, which defeats the purpose of a "two-hand" control.

Figure 4: Note that there is nothing demonstrating how the fault is acknowledged or reset, or how it is combined with other faults to create a system level fault. RSLogix software for a ControlLogix controller from Rockwell Automation is shown. Courtesy:Faults are shown to elaborate on the 203 faults. Again, note that there is nothing in Figure 4 demonstrating how the fault is acknowledged, reset, or how it is combined with other faults to create a system level fault (see Figure 4).

The programming and explanation in Figure 4 took about three hours to write. The program took about an hour to develop due to the time it takes to create the tags, set up a new processor, set up an input/output (I/O) structure, and various other things. Much of the rest of the time was spent typing and doing screen captures of the logic for import.

Unfortunately, there are not a lot of good examples of ladder logic online, even on PLC manufacturers' websites. Most programmers don't have the extra time to type all of this up and post it. There are some really helpful folks on places like www.plctalk.net and other sites, but most are paid well for their time and can only go so far without providing answers to more complex ladder logic or application questions.

- Frank Lamb is the founder of Automation Consulting Services Inc. This article originally appeared on the Automation Primer blog. Automation Primer is a CFE Media content partner. Edited by Joy Chang, Control Engineering, jchang@cfemedia.com

Key concepts

  • An important part of writing code for an application is determining specifics of what the customer wants.
  • Most ladder logic is similar from platform to platform, but addressing tagnames and instruction sets vary widely.
  • Good examples of ladder logic online are lacking, even on PLC manufacturers' websites.

Consider this

What PLC is being used for a project and what do those who are involved want clarified?

ONLINE extra

- This online version includes an additional screen capture of code. See additional stories from the author below.



shaju , Non-US/Not Applicable, India, 09/12/15 12:28 AM:

Thanks.
John , Ontario, Canada, 10/11/15 10:57 PM:

Timers in CLX are based on milliseconds, so your TONs would be 2 seconds not 2 minutes. Preset would need to be multiplied by 60.

Interlocking the contactors would prevent them from both being energized even with forcing.

Two hand control almost always has logic developed to detect a button that is tied down. Typically called anti tiedown logic. This was developed even before PLCs and involved timers on both inputs.
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
Each year, a panel of Control Engineering and Plant Engineering editors and industry expert judges select the System Integrator of the Year Award winners in three categories.
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Controller programming; Safety networks; Enclosure design; Power quality; Safety integrity levels; Increasing process efficiency
Additive manufacturing benefits; HMI and sensor tips; System integrator advice; Innovations from the industry
Robotic safety, collaboration, standards; DCS migration tips; IT/OT convergence; 2017 Control Engineering Salary and Career Survey
Featured articles highlight technologies that enable the Industrial Internet of Things, IIoT-related products and strategies to get data more easily to the user.
This article collection contains several articles on how automation and controls are helping human-machine interface (HMI) hardware and software advance.
This digital report will explore several aspects of how IIoT will transform manufacturing in the coming years.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

Infrastructure for natural gas expansion; Artificial lift methods; Disruptive technology and fugitive gas emissions
Mobility as the means to offshore innovation; Preventing another Deepwater Horizon; ROVs as subsea robots; SCADA and the radio spectrum
Future of oil and gas projects; Reservoir models; The importance of SCADA to oil and gas
Automation Engineer; Wood Group
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
click me