RSLogix 500 Data Types and Cross Referencing
Cross Reference and Data Structures Introduction
Many of those who start with PLC programming are faced with the challenge of deciphering code written by someone else. In fact, most PLC programming jobs will require you to work with existing code rather than write it from scratch. This task creates a challenge for novice PLC programmers as the interface in RSLogix 500 as well as RSLogix 5000 is unlike any other. Therefore, it’s easy to become frustrated trying to figure out where a certain tag is being used, how it ties into the logic and why it’s being used in certain places.
The second challenge many PLC programmers come across as they get started in RSLogix 500 lies in the data structures. The specification of each tag may be confusing to a beginner and unclear when it’s used as word, bit or byte in different instructions.
In this tutorial, we’re going to look at the “cross-referencing” function of RSLogix 500 (Similar to RSLogix 5000), go over the steps on how to use it and cover how it can help you trace existing code faster and understand what’s going on in the PLC. Before we get into cross-referencing however, we will take a deep dive into the different data structures we have available in RSLogix 500, explain how they are specified and discuss the basics of data in RSLogix 500 based PLCs.
RSLogix 500 Data Structures
We’ve introduced data structures in RSLogix and Studio 5000 in a separate tutorial (RSLogix 500 Data Structures). However, they’re created and used in a different manner in RSLogix 500. We will revisit their creation and use here.
In an RSLogix 500 application, the user will find currently specified data structures in the IO tree under the section called "Data Files" (See below). Note that this is different from RSLogix 5000.
You will notice that every data structure is specified by a letter, an integer as well as string.
- Example: N17 - DATAFRMHMI is specified by “N”, “17” and “DATAFRMHMI”.
The letter will specify the type of data being used. The number specifies an incremental position of this data register. The string specifies the name of the data structure. Note that the name is optional, but recommended. The “N18” register above, does not have a name attached to it.
Basic RSLogix 500 Data Types
As a PLC programmer, it’s important to know the most commonly used data types. Here’s a list of those we recommend you become familiar with:
- Binary [B] | The equivalent of a boolean or a piece of data capable of being set to 0 OR 1.
- Integer [N] | A 16-bit register capable of storing values between -32768 and 32767.
- Float [F] | A register that will store analog (decimal) values.
- Timer [T] | A special register that will contain a structure used in TON and TOF instructions that will time certain events.
- Counter [C] | A special register that will count a number of occurring events through the use of the CTU and CTD instructions.
In the screenshot above, you’ll also notice that there are two elements at the start of the data file with labels [O0 - Outputs] and [I1 - Inputs]. These data structures are created by the PLC once the user specifies the hardware used within the system. In other words, you will find all the input and output tags used within the program inside of these two structures. Their type will depend on the I/O of the system.
Understanding Specific Data Types
Now that we’ve covered the different data types, it’s time to give more information with regards to their layout.
When the user right-clicks a data structure and selects “Properties”, he will be presented with the same configuration window as the one when a new data structure is created. In this window, the user will find multiple key parameters.
At the very top, as discussed above, we find the three elements that will be displayed in the “Data Files” section: File, Type and Name of the register. Below, we will find the “Elements” and “Last” fields. Within the “Elements” field, the user will specify the number of elements within the data structure. In other words, this would be equivalent to an array in RSLogix 5000 or other programming languages.
Based on the number of elements within the array, the PLC will specify the “Last” element of the array. In the example above, we have an array of 20 elements which dictates that the elements will be numbered as follows: N17:0, N17:1, N17:2, ...., N17:18, N17:19.
Lastly, we can declare the scope within which the set of elements may be used. The typical “best-practice” approach is to keep the elements confined to the program they will be used. If they must be used within multiple programs, they should be set to “Global”. That being said, this feature is not used frequently in RSLogix 500; most elements are set to “Global” by default.
Definition | Array - A combination of a certain number of the same elements.
Example of a new Array of 10x Integers in RSLogix 500
Array Data File for the Array Above
Notice that the array of ten elements is created as the tenth (10) element of type “N”. The Data File above displays each element of the array that will be addressed as N10:0, N10:1, N10:2, …, N10:8 and N10:9 as the last element per the specification.
Working with Data Type - Boolean in RSLogix 500
The most fundamental data type is a boolean. It is a structure that may take the value of "0" or "1". This type of a tag will be used for most sensors, valves, relays, motor starters and other field devices. Based on our experience, most field devices will be operated through a boolean tag.
Creating an Array of Boolean Tags in RSLogix 500
- Step 1 - Right-click on "Data Files".
- Step 2 - Click on "New..."
- Step 3 - Specify a "Type" of "Binary"
- Step 4 - Specify a "Name" (In our example, the name is BOOLEAN1)
- Step 5 - Specify a "Description" (In out example, the description is the same as the name)
- Step 6 - Specify a number of elements (In our example the number of elements is 10)
- Step 7 - Press "OK"
Notice that at this point, you should see a new element appear under the "Data Files" structures that has been created based on your specifications. Here's the one we have in our tree:
At this point, you may double-click this data file. You should see the following window open:
You should immediately notice that the file contains elements specified on the left side as B11:0, B11:1, B11:2, ..., B11:8, B11:9. However, each one of those elements contains 16 bits. In fact, each one of those elements is a 16-bit integer each bit of which can be used in PLC programming, ladder logic and otherwise. In other words, we've created a total of 16 x 10 = 160 bits of usable data by specifying 10 binary files.
Using a Boolean Tag in RSLogix 500
Once the data file is created, it's possible to use it within our ladder logic. Each bit within the file specified above will be addressed as follows:
- B11:0 - B11:0/0, B11:0/1, B11:0/2, ..., B11:0/14, B11:0/15
- B11:1 - B11:1/0, B11:1/1, B11:1/2, ..., B11:1/14, B11:1/15
- B11:2 - B11:2/0, B11:2/1, B11:2/2, ..., B11:2/14, B11:2/15
- B11:8 - B11:8/0, B11:8/1, B11:8/2, ..., B11:8/14, B11:8/15
- B11:9 - B11:9/0, B11:9/1, B11:9/2, ..., B11:9/14, B11:9/15
Let's look at an example of an XIC Instruction and an OTE Instruction that utilizes one of those bits.
In the rung above, we notice that the integer is specified above while the bit of the integer used is specified below the instruction. Note that the XIC and OTE instructions are only able to use boolean values. Therefore it's not possible to specify "B11:0" alone. The bit must be used.
To specify the bit, you'll have to either double-click the bit and change it.
Cross-Referencing Tags in RSLogix 500
Cross-Referencing allows a programmer to quickly find all the uses of a specific tag within the program. This action is extremely convenient as you can easily see where the tag is being used, which instructions are using the tag and jump to the location of said instruction.
To cross-reference a tag, simply right-click on it and select "cross-reference".
Once you hit "cross-reference", a new window will open. Let's see an example below and analyze how it works.
At the very top of the window, we can see the address as well as a description of our boolean tag - "B3:0/0 - Fault Reset". Everything below this line and above the next tag is referencing this specific tag.
Below that line, we see a line that calls out an OTE Instruction usage - "OTE - File #4 FAULTS - 1"
- "OTE" - This references the instructions within which the tag is being used.
- "File #4 FAULTS" - This is a reference to the subroutine number and name the tag is being used in.
- "1"- This is a reference to the rung in which this instruction is found.
What's extremely important is that the same instruction can be used in multiple rungs across a single program. We can see such an example in the XIO call for the same boolean tag. In this case, the cross-reference is made for rungs 6, 9, 12, 15, 18, 21, 24, 27, 30, 33.
The plc programmer may click any one of those numbers to be brought to the instruction at that specific location. This is extremely helpful as you can easily jump to every location a specific bit is being used in.
Knowing how to deal, create and use different data structures is a fundamental skill of any plc programmer. Likewise, knowing how to cross-reference calls to these data structures will aid you in your troubleshooting efforts immensely. We recommend that you create a program in which you practice creating these different structures, assigning them to different instructions and see if you can cross-reference them as explained above.