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).
In order to complete this recipe, you will need to have completed the previous recipe on Functional Block Diagrams.
First, we will open our existing Ladder Logic Routine using Controller Organizer and double-clicking on the VALVES routine.
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).
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);
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.
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);
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
toFC1002
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);
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).
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.
Select the entire contents of the Rung IL code in the text field and press the Delete key to clear it.
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).
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.
We will need to add the missing tags and timer blocks before we can verify and download our application.
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.