Book Image

Instant PLC Programming with RSLogix 5000

Book Image

Instant PLC Programming with RSLogix 5000

Overview of this book

RSLogix5000 is a user friendly IEC61131-3-compliant interface for programming the current generation of Rockwell Automation PLCs, which includes Ladder Diagrams (LD), Graphical Function Block Diagrams (FBD), Graphical Structured Text (ST), and Sequential Function Charts (SFC). Instant PLC Programming with RSLogix 5000 captures the core elements of PLC programming with RSLogix 5000 with a minimal investment of time. We will avoid getting into control theory and focus on condensing the information specific to RSLogix 5000. We have selected the key areas of RSLogix and provide a step-by-step approach to teaching them. This book start by follows the steps involved in creating a new RSLogix 5000 project and configuring racks, slots, and channels. Next, we will create routines using the various languages available in RSLogix 5000, troubleshooting and resolving issues we encounter along the way. Finally, we will dive into the advanced features, such as online changes, code generation, task management, and user-defined structures. You will also learn object-oriented PLC programming techniques using advanced features like user-defined types (UDTs) that improve the maintainability, uniformity, and readability of our routines. We also highlight the strengths and limitations of online changes and demonstrate techniques to maximize flexibility. You will learn everything you need to get up and running with RSLogix 5000 as well as best practices used by industry experts.
Table of Contents (7 chapters)

Building Ladder Diagram programs (Simple)

Now we will start to create some PLC programs for our newly created project. In this recipe, 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.


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 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:


    • 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:


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

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.