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

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.

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}