Building Ladder Diagram programs (Simple)

Exclusive offer: get 50% off this eBook here
Instant PLC Programming with RSLogix 5000 [Instant]

Instant PLC Programming with RSLogix 5000 [Instant] — Save 50%

Learn how to create PLC programs using RSLogix 5000 and the industry's best practices using simple, hands-on recipes with this book and ebook

$19.99    $10.00
by Austin Scott | October 2013 | Open Source

This article by Austin Scott, the author of the book, Instant PLC Programming with RSLogix 5000, explains how to create some PLC programs for our newly-created project. We will learn how to create Ladder Logic programs in RSLogix 5000 by drafting a basic Ladder Logic alarm timer routine. We are going to add an alarm that will be triggered if the valve position set point and current analog input position of the valve differ for more than five seconds.

(For more resources related to this topic, see here.)

There are several editions of RSLogix 5000 available today, which are similar to Microsoft Windows' home and professional versions. The more "basic" (less expensive) editions of RSLogix 5000 have many features disabled. For example, only the full and professional editions, which are more expensive, support the editing of Function Block Diagrams, Graphical Structured Text, and Sequential Function Chart. In my experience, Ladder Logic is the most commonly used language. Refer to http://www.rockwellautomation.com/rockwellsoftware/design/rslogix5000/orderinginfo.html for more on this.

Getting ready

You will need to have added the cards and tags from the previous recipes to complete this exercise.

How to do it...

  1. Open Controller Organizer and expand the leaf Tasks | Main Tasks | Main Program. Right-click on Main Program and select New Routine as shown in the following screenshot:

  2. Configure a new Ladder Logic program by setting the following values:
    • Name: VALVES
    • Description: Valve Control Program
    • Type: Ladder Diagram
  3. For our newly created routine to be executed with each scan of the PLC, we will need to add a reference to it in MainRoutine that is executed with each scan of the MainTask task.
  4. Double-click on our MainRoutine program to display the Ladder Logic contained within it.
  5. Next, we will add a Jump To Subroutine (JSR) element that will add our newly added Ladder Diagram program to the main task and ensure that it is executed with each scan.

  6. Above the Ladder Diagram, there are tab buttons that organize Ladder Elements into Element Groups. Click on the left and right arrows that are on the left side of Element Groups and find the one labeled Program Control. After clicking on the Program Control element group, you will see the JSR element. Click on the JSR element to add it to the current Ladder Logic Rung in MainRoutine.

  7. Next, we will make some modifications to the JSR routine so that it calls our newly added Ladder Diagram. Click on the Routine Name parameter of the JSR element and select the VALVES routine from the list as shown in the following screenshot:

  8. There are three additional parameters that we are not using as part of the JSR element, which can be removed. Select the Input Par parameter and then click on the Remove Parameter icon in the toolbar above the Ladder Diagram. This icon looks as shown in the following screenshot:

  9. Repeat this process for the other optional parameter: Return Par.
  10. Now that we have ensured that our newly added Ladder Logic routine will be scanned, we can add the elements to our Ladder Logic routine. Double-click on our VALVES routine in the Controller Organizer tab under the MainTask task.
  11. Find the Timer/Counter element group and click on the TON (Timer On Delay) element to add it to our Ladder Diagram.
  12. Now we will create the Timer object. Enter the name in the Timer field as FC1001_TON. Right-click on the TIMER object tag name we just entered and select New "FC1001_TON" (or press Ctrl + W).
  13. In the New Tag form that appears, enter in the description FAULT TIMER FOR FLOW CONTROL VALVE 1001 and click on OK to create the new TIMER tag.
  14. Next, we will configure our TON element to count to five seconds (5,000 milliseconds). Double-click on the Preset parameter and enter in the value 5000, which is in milliseconds.
  15. Now, we will need to add the condition that will start the TIMER object. We will be adding a Less Than (LES) element from the Compare element group. Be sure to add the element to the same Ladder Logic Rung as the Timer on Delay element.
  16. The LES element will compare the valve position with the valve set point and return true if the values do not match. So set the two parameters of the LES element to the following:
    • FC1001_PV
    • FC1001_SP

  17. Now, we will add a second Ladder Logic Rung where a latched fault alarm is triggered after TIMER reaches five seconds.
  18. Right-click under the first Ladder Logic Rung and select Add Rung (or press Ctrl + R).
  19. Find the Favorites element group and select the Examine On icon as shown in the following screenshot:

  20. Click on ? above the Examine On tab and select the TIMER object's Done property, FC1001_TON.DN, as shown in the following screenshot. Now, once the valve values are not equal, and the TIMER has completed its count to five seconds, this Ladder Logic Rung will be activated as shown in the following screenshot:

  21. Next, we will add an Output Latched element to this Ladder Logic Rung. Click on the Output Latched element from the Favorites element group with our new rung selected.

  22. Click on ? above the Output Latched element and type in the name of a new base tag we are going to add as FC1001_FLT. Press Enter or click on the element to complete the text entry.
  23. Right-click on FC1001_FLT and select New "FC1001_FLT" (or press Ctrl + W).
  24. Set the following values in the New Tag form that appears:
    • Description: FLOW CONTROL VALVE 1001 POSITION FAULT
    • Type: Base
    • Scope: FirstController
    • Data Type: Bool
  25. Click on OK to add the new tag. Our new tag will look like the following screenshot:

  26. It is considered bad practice to latch a bit without having the code to unlatch the bit directly below it. Create a new BOOL type tag called ALARM_RESET with the following properties:
    • Name: ALARM_RESET
    • Description: RESET ALARMS
    • Type: Base
    • Scope: FirstController
    • Data Type: BOOL
  27. Click on OK to add the new tag. Then add the following coil and OTU to unlatch the fault when the master alarm reset is triggered.

  28. Finally, we will add a comment so that we can see what our Ladder Diagram is doing at a glance.
  29. Right-click in the far-right area of the first Ladder Logic Rung (where the 0 is) and select Edit Rung Comment (Ctrl + D).
  30. Enter the following helpful comment:

    TRIGGER FAULT IF THE SETPOINT OF THE FLOW CONTROL VALVE 1001 IS NOT EQUAL TO THE VALVE POSITION

How it works...

We have created our first Ladder Logic Diagram and linked it to the MainTask task. Now, each time that the task is scanned (executed), our Ladder Logic routine will be run from left to right and top to bottom.

There's more...

More information on Ladder Logic can be found in the Rockwell publication Logix5000 Controllers Ladder Diagram available at http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm008_-en-p.pdf.

Ladder Logic is the most commonly used programming language in RSLogix 5000. This recipe describes a few more helpful hints to get you started.

Understanding Ladder Rung statuses

Did you notice the vertical output eeeeeee on the left-hand side of your Ladder Logic Rung? This indicates that an error is present in your Ladder Logic code. After making changes to your controller project, it is a good practice to Verify your project using the drop-down menu item Logic | Verify | Controller. Once Verify has been run, you will see the error pane appear with any errors that it has detected.

Element help

You can easily get detailed documentation on Ladder Logic Elements, Function Block Diagram Elements, Structured Text Code, and other element types by selecting the object and pressing F1.

Copying and pasting Ladder Logic

Ladder Logic Rungs and elements can be copied and pasted within your ladder routine. Simply select the rung or element you wish to copy and press Ctrl + C. Then, to paste the rung or element, select the location where you would like to paste it and press Ctrl + V.

Summary

This article took a first look at creating new routines using ladder logic diagrams. The reader was introduced to the concept of Tasks and also learns how to link routines. In this article, we learned how to navigate the ladder elements that are available, how to find help on each element, and how to create a simple alarm timer using ladder logic.

Resources for Article:


Further resources on this subject:


Instant PLC Programming with RSLogix 5000 [Instant] Learn how to create PLC programs using RSLogix 5000 and the industry's best practices using simple, hands-on recipes with this book and ebook
Published: October 2013
eBook Price: $19.99
See more
Select your format and quantity:

About the Author :


Austin Scott

Austin Scott, in 2006, founded Synergist SCADA, a successful company that provided vendor-neutral SCADA architecture and development. Synergist has also developed a suite of engineering tools, including Citect Power Tools and Active Network Security. In July 2013, Synergist was acquired by Cimation LLC as the catalyst for its growing Canadian operations and ongoing product development.

With more than a decade of industrial automation and software development experience, Austin has worked on large-scale, high-profile projects across North America and globally, incorporating most major SCADA platforms.

Austin's professional focus includes developing and refining custom software solutions to enhance the productivity of SCADA developers, improve integration between SCADA data and corporate applications, and cyber security, especially the detection of unauthorized access to SCADA networks and forensic analysis of SCADA breaches.

Cimation and its 250 talented employees serve North America's energy industry with automation and controls, industrial IT, and enterprise data solutions (inc. SCADA).

Forbes recently ranked Cimation number 22 on its second annual America's Most Promising Companies list. Cimation was the only energy consulting firm ranked in the list's top 25. The Forbes America's Most Promising Companies list is comprised of 100 privately held, high-growth companies with bright futures. Most of the companies ranked on this year's list, Cimation included, fall into the technology category. Since its inception in 2009, Cimation has grown 1,397 percent in revenue.

Cimation is headquartered in Houston with regional offices in Calgary, Denver, Pittsburgh, New Orleans, and Lafayette.

Books From Packt


LÖVE for Lua Game Programming
LÖVE for Lua Game Programming

 CryENGINE Game Programming with C++, C#, and Lua
CryENGINE Game Programming with C++, C#, and Lua

 UnrealScript Game Programming Cookbook
UnrealScript Game Programming Cookbook

Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner’s Guide
Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner’s Guide

Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide
Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide

 DirectX 11.1 Game Programming
DirectX 11.1 Game Programming

 Slick2D Game Development
Slick2D Game Development

 iPhone Game Blueprints
iPhone Game Blueprints


No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
p
c
W
u
1
Y
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software