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
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.
You will need to have added the cards and tags from the previous recipes to complete this exercise.
How to do it...
- 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:
- Configure a new Ladder Logic program by setting the following values:
- Name: VALVES
- Description: Valve Control Program
- Type: Ladder Diagram
- 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.
- Double-click on our MainRoutine program to display the Ladder Logic contained within it.
- 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.
- 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.
- 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:
- 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:
- Repeat this process for the other optional parameter: Return Par.
- 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.
- Find the Timer/Counter element group and click on the TON (Timer On Delay) element to add it to our Ladder Diagram.
- 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).
- 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.
- 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.
- 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.
- 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:
- Now, we will add a second Ladder Logic Rung where a latched fault alarm is triggered after TIMER reaches five seconds.
- Right-click under the first Ladder Logic Rung and select Add Rung (or press Ctrl + R).
- Find the Favorites element group and select the Examine On icon as shown in the following screenshot:
- 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:
- 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.
- 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.
- Right-click on FC1001_FLT and select New "FC1001_FLT" (or press Ctrl + W).
- 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
- Click on OK to add the new tag. Our new tag will look like the following screenshot:
- 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
- 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.
- Finally, we will add a comment so that we can see what our Ladder Diagram is doing at a glance.
- Right-click in the far-right area of the first Ladder Logic Rung (where the 0 is) and select Edit Rung Comment (Ctrl + D).
- 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.
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.
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.
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:
- DirectX graphics diagnostic [Article]
- Flash 10 Multiplayer Game: Game Interface Design [Article]
- HTML5 Games Development: Using Local Storage to Store Game Data [Article]
|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|
eBook Price: $19.99
About the Author :
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.