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.



Engineers' Choice Awards
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by Control Engineering subscribers.
System Integrator Giants
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
System Integrator of the Year
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.
How to Maximize Factory Automation Efficiency with Low Cost Machine Vision
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Wireless Reliability in Harsh Environments
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
Human Factors and the Impact on Plant Safety
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
August 2018
Augmented reality and virtual reality education, autotuning PID control, cybersecurity advice, educating engineers
July 2018
Ladder logic best practices and object-oriented programming, safety instrumented systems, enclosure design issues and challenges, process control advice
June 2018
Discrete and process sensor fundamentals, autotuning controls, system integrator roundtable
Edge Computing
This article collection contains several articles on how today's technologies heap benefits onto an edge-computing architecture such as faster computing, better networking, more memory, smarter analytics, cloud-based intelligence, and lower costs.
Data Center Design
Data centers, data closets, edge and cloud computing, co-location facilities, and similar topics are among the fastest-changing in the industry.
PLCs
Programmable logic controllers (PLCs) represent the logic (decision) part of the control loop of sense, decide, and actuate. Featured articles in this digital report compare PLCs and programmable automation controllers (PACs), industrial PCs, and robotic controllers.
SIDB

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

August 2018
SCADA standardization, capital expenditures, data-driven drilling and execution
June 2018
Machine learning, produced water benefits, progressive cavity pumps
April 2018
ROVs, rigs, and the real time; wellsite valve manifolds; AI on a chip; analytics use for pipelines
John O. Ayuk, PE, CFSE, PMP, CAP
Automation Engineer; Wood Group
Doug Baker
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
Data Centers: Impacts of Climate and Cooling Technology
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
Safety First: Arc Flash 101
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
Critical Power: Hospital Electrical Systems
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
Engineers' Choice Awards
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by Control Engineering subscribers.
System Integrator Giants
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
System Integrator of the Year
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.
How to Maximize Factory Automation Efficiency with Low Cost Machine Vision
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Wireless Reliability in Harsh Environments
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
Human Factors and the Impact on Plant Safety
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
August 2018
Augmented reality and virtual reality education, autotuning PID control, cybersecurity advice, educating engineers
July 2018
Ladder logic best practices and object-oriented programming, safety instrumented systems, enclosure design issues and challenges, process control advice
June 2018
Discrete and process sensor fundamentals, autotuning controls, system integrator roundtable
Edge Computing
This article collection contains several articles on how today's technologies heap benefits onto an edge-computing architecture such as faster computing, better networking, more memory, smarter analytics, cloud-based intelligence, and lower costs.
Data Center Design
Data centers, data closets, edge and cloud computing, co-location facilities, and similar topics are among the fastest-changing in the industry.
PLCs
Programmable logic controllers (PLCs) represent the logic (decision) part of the control loop of sense, decide, and actuate. Featured articles in this digital report compare PLCs and programmable automation controllers (PACs), industrial PCs, and robotic controllers.
SIDB

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

August 2018
SCADA standardization, capital expenditures, data-driven drilling and execution
June 2018
Machine learning, produced water benefits, progressive cavity pumps
April 2018
ROVs, rigs, and the real time; wellsite valve manifolds; AI on a chip; analytics use for pipelines
John O. Ayuk, PE, CFSE, PMP, CAP
Automation Engineer; Wood Group
Doug Baker
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
Data Centers: Impacts of Climate and Cooling Technology
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
Safety First: Arc Flash 101
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
Critical Power: Hospital Electrical Systems
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
Engineers' Choice Awards
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by Control Engineering subscribers.
System Integrator Giants
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
System Integrator of the Year
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.
How to Maximize Factory Automation Efficiency with Low Cost Machine Vision
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Wireless Reliability in Harsh Environments
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
Human Factors and the Impact on Plant Safety
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
August 2018
Augmented reality and virtual reality education, autotuning PID control, cybersecurity advice, educating engineers
July 2018
Ladder logic best practices and object-oriented programming, safety instrumented systems, enclosure design issues and challenges, process control advice
June 2018
Discrete and process sensor fundamentals, autotuning controls, system integrator roundtable
Edge Computing
This article collection contains several articles on how today's technologies heap benefits onto an edge-computing architecture such as faster computing, better networking, more memory, smarter analytics, cloud-based intelligence, and lower costs.
Data Center Design
Data centers, data closets, edge and cloud computing, co-location facilities, and similar topics are among the fastest-changing in the industry.
PLCs
Programmable logic controllers (PLCs) represent the logic (decision) part of the control loop of sense, decide, and actuate. Featured articles in this digital report compare PLCs and programmable automation controllers (PACs), industrial PCs, and robotic controllers.
SIDB

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

August 2018
SCADA standardization, capital expenditures, data-driven drilling and execution
June 2018
Machine learning, produced water benefits, progressive cavity pumps
April 2018
ROVs, rigs, and the real time; wellsite valve manifolds; AI on a chip; analytics use for pipelines
John O. Ayuk, PE, CFSE, PMP, CAP
Automation Engineer; Wood Group
Doug Baker
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
Data Centers: Impacts of Climate and Cooling Technology
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
Safety First: Arc Flash 101
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
Critical Power: Hospital Electrical Systems
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
click me