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 Structured Text program (Simple)

In this recipe, we will explain a typical-use case for Structured Text (ST) programming. In our exercise, we will develop a simple Structured Text program for calculating the flow rate based on our valve position.

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 the Controller Organizer and select New Routine.

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


    • Description: Process Calculations

    • Type: Structured Text

  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 the 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 CALCULATIONS in the JSR element.

  5. We will use a simple linear equation to calculate the Flow value based on our Valve position. Enter in the following structured text comment and simple formula code as shown in the following screenshot:

    //Linear flow calculation based on valve position FC1001_FLOW := FC1001_PV*0.83823;
  6. The tag FC1001_FLOW must be added to our controller, so right-click on the FC1001_FLOW tag in our structured text and select New Tag "FC1001_FLOW".

  7. On the New Tag form, enter the following values:

    • Name: FC1001_FLOW

    • Description: Flow estimated based on valve position

    • Type: REAL

    • Scope: FirstController

  8. Then click on OK.

How it works...

Structured Text (ST) is similar to traditional programming languages, such as Pascal, C, and BASIC, except that it will run continuously from start to finish as if it were contained within a loop. Structured Text is a great place to put complex formulas that would be difficult to implement using Ladder Logic.

There's more...

More information on ST can be found in the Rockwell publication Logix5000 Controllers Structured Text available at