Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Instant PLC Programming with RSLogix 5000

You're reading from  Instant PLC Programming with RSLogix 5000

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781849698443
Pages 68 pages
Edition 1st Edition
Languages

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:

    • Name: CALCULATIONS

    • 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 http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm007_-en-p.pdf.

arrow left Previous Chapter
You have been reading a chapter from
Instant PLC Programming with RSLogix 5000
Published in: Oct 2013 Publisher: Packt ISBN-13: 9781849698443
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}