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)

Code generation (Advanced)


Often, there is a need to duplicate the same logic many times, but with different variable tags. This can be easily accomplished in Logix5000 using Notepad and a simple code generation trick (of the true Logix5000 masters).

Getting ready

In order to complete this recipe, you will need to have completed the previous recipe on Functional Block Diagrams.

How to do it...

  1. First, we will open our existing Ladder Logic Routine using Controller Organizer and double-clicking on the VALVES routine.

  2. Select both the valve rungs and copy them to the clipboard by clicking on the numbers 0 and 1 while holding Ctrl and then right-clicking on the rung and selecting Copy Rung (or pressing Ctrl + C).

  3. Next, open Notepad and paste the following copied rungs onto it by selecting Edit | Paste (or by pressing Ctrl + V):

    NEQ(FC1001_PV,FC1001_SP)TON(FC1001_TON,?,?);
    XIC(FC1001_TON.DN)OTL(FC1001_FLT);   
  4. You will notice that the Ladder Logic has been copied in a programming language called Instruction List (IL), which is defined as part of the IEC 61131 standard. Now that the code is in plain text IL, we can edit and duplicate it more easily.

  5. Now we will duplicate the code two more times for the remaining three valves we will add to our project. Copy and paste the following code two more times in Notepad:

    NEQ(FC1001_PV,FC1001_SP)TON(FC1001_TON,?,?);
    XIC(FC1001_TON.DN)OTL(FC1001_FLT);
    NEQ(FC1001_PV,FC1001_SP)TON(FC1001_TON,?,?);
    XIC(FC1001_TON.DN)OTL(FC1001_FLT);   NEQ(FC1001_PV,FC1001_SP)TON(FC1001_TON,?,?);
    XIC(FC1001_TON.DN)OTL(FC1001_FLT);
  6. Next, we will modify the tag prefix used on each copy we've made. Each tag of the first IL copy should be changed from FC1001 to FC1002 and so on:

    NEQ(FC1002_PV,FC1002_SP)TON(FC1002_TON,?,?);
    XIC(FC1002_TON.DN)OTL(FC1002_FLT);
    NEQ(FC1003_PV,FC1003_SP)TON(FC1003_TON,?,?);
    XIC(FC1003_TON.DN)OTL(FC1003_FLT);
    NEQ(FC1004_PV,FC1004_SP)TON(FC1004_TON,?,?); XIC(FC1004_TON.DN)OTL(FC1004_FLT);
  7. Next, we will copy all of our newly edited IL code in Notepad to our clipboard by selecting all of it and then navigating to the drop-down menu Edit | Copy (or by pressing Ctrl + C).

  8. Returning to our RSLogix 5000 Ladder Logic Routine, we will now paste the IL code into our routine. Right-click on the last rung of our routine that has the (end) label and select Edit Rung (or press the Enter key). The Rung IL code editing text field will appear at the top of Ladder Logic.

  9. Select the entire contents of the Rung IL code in the text field and press the Delete key to clear it.

  10. Next, paste the code we've created in Notepad into the Rung edit IL code text field by right-clicking on it and selecting Paste (or by pressing Ctrl + V).

  11. Now we will add our updated IL code to our Ladder Logic Routine by pressing the green check mark button beside the IL code edit form field.

  12. We will need to add the missing tags and timer blocks before we can verify and download our application.

How it works...

Anytime we copy Ladder Logic to the clipboard, it is stored in both Ladder Logic (used internally by RSLogix 5000) and in the text-based IL programming language, and can be pasted into Notepad or other text-editing applications. IL is a low-level IEC standard language that all other IEC programming languages can be converted to. IL is most often used on old handheld programmers.