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 a Sequential Function Chart (Intermediate)

In the following recipe, we will demonstrate the usage of a Sequential Function Chart (SFC) by building a backwash process using a step-by-step guide.

Getting ready

To complete this recipe, you should have completed the previous exercises.

How to do it...

  1. First, we will need to declare our new routine. Right-click on MainProgram of Controller Organizer and select New Routine.

  2. In the New Routine form that appears, enter or select the following:

    • Name: BACKWASH

    • Description: Backwash Sequence

    • Type: Sequential Function Chart

  3. Then click on OK.

  4. In order 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 MainTask. Repeat Steps 3 to 7 of the Building Ladder Diagram programs recipe (or copy and paste the existing JSR), but use the routine name BACKWASH in the JSR element.

  5. Now we will add an Action to Step_000 that was created by default. Right-click on Step_000 and select Add Action.

  6. Now we will add the initialization values for our SFC using ST syntax. Double-click on the box with ? at the bottom of Action_000 and enter the following structured text as shown in the following screenshot:

  7. An icon with a red cross will appear to the side of Action_000, indicating that there is an error with the ST we have added. The error is due to the fact that BACKWASH_START and BACKWASH_FLT do not yet exist in our program.

  8. We can easily add these values by right-clicking on the BACKWASH_START_PB tag in the Action_000 box and selecting the New Tag "BACKWASH_START_PB" option.

  9. The New Tag form will appear, which will allow us to create our new tag as follows:



    • Type: BOOL

    • Scope: FirstController

  10. Repeat the same process for the second new tag by right-clicking on the tag BACKWASH_FLT and the New Tag form and entering the following values:

    • Name: BACKWASH_FLT


    • Type: BOOL

    • Scope: FirstController

  11. Next, we will add the Transition conditional value that will start our Backwash sequence. Double-click on the Tran_000 question mark and enter the following logical statement (which is equivalent to BACKWASH_START_PB=1) BACKWASH_START_PB.

  12. Now we can add our backwash sequence step. Select the Transition box Tran_000 and then click on the Step element icon in the SFC element group above our SFC program. The step box, Step_001, will be added and automatically connected to Tran_000 (because we selected it before adding our new step).

  13. Next, we can add an action to Step_001 that will represent our backwash process. Right-click on Step_001 and select Add Action.

  14. Now we will add our action ST to the action element by double-clicking on ? in Action_001 and entering FC1001_SP:=100;.

  15. Let's add a delay to Step_001 in order to give our backwash time to complete. Right-click on Step_001 and select the Step Properties menu option. On the Step Properties form, set the Preset field to 30000 ms (30 seconds). Click on OK.

  16. Next, we will add a Selection Branch Diverge in order to reset our sequence or trigger a fault if there is a problem. Select Step_001 and then click on the Selection Branch Diverge Element icon just above our sequence chart. The icon is shown in the following screenshot:

  17. A Selection Branch Diverge can also allow you to execute one or another sequence, while Simultaneous Branch Diverge will execute two sequences in parallel. Our sequence will automatically reset and await another backwash if the valve has successfully opened, 100 percent. Select Tran_001 and click on the ? icon to set the logical statement that will execute this Selection Branch. Type in the following structured text logical statement: FC1001_PV=100.

  18. We want our sequence to reset after it has completed the backwash, so we will connect a flow line from our transition Tran_001 to the top element in our sequence, Step_001. Click on the connector box under Trans_001 and drag it to the connector box on top of Step_000.

  19. If our valve fails to open, we want to raise a fault before resetting our sequence. Select Tran_002, click on ?, and enter the following structured text logical statement; FC1001_PV<>100.

  20. In order to raise a fault, we will need to add a Step. Select Tran_002 and click on the Step Element icon.

  21. Add an action to our newly created step, Step_002, by right-clicking and selecting Add Action.

  22. Double-click on ? of our newly added action and add the following ST code:

  23. In order to make our sequence easy to understand, let's add a Text Box comment. Click on the Text Box element to add it to the sequence diagram and drag it to the right of the sequence. Enter in the following comment: Backwash fault triggered if valve FC1001 fails to open.

How it works...

The previous programs we have developed are ideal for a single state whereas SFC routines are well suited for more complex processes that require simultaneous operations. SFCs are steps that are connected to transitions. A flow line will connect the step and transition in the sequence. Transitions are the triggers between each step and each step acts as a collection of actions. A Selection Branch Diverge will follow one or the other path and a Simultaneous Branch Diverge will execute two sequences at the same time.

There's more...

More information on SFC can be found in the Rockwell publication Logix5000 Controllers Sequential Function Charts available at In the interest of saving time in the last exercise, I did not follow the best practice of providing useful names to the steps and transitions.

Renaming sequence steps and transitions

In the previous exercise, we left the default names for our steps, actions, and transitions as they were. It is easy to rename the SFC elements to make the sequence easier to read and maintain. Simply double-click on the SFC name to rename it.