Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
PLC Data Types & Structures - Allen Bradley PLC RSLogix 5000 Basics Programming BOOL INT DINT Arrays
Intermediate

PLC Data Types & Structures - Allen Bradley PLC RSLogix 5000 Basics Programming BOOL INT DINT Arrays

Allen Bradley
PLC Programming
RSLogix 5000
Studio 5000
Ladder Logic

Introduction

We’ve had a lot of questions about the different PLC Data Types & Data Structures over the last few months. Working with the basic structures in ladder logic is straightforward for some, but challenging for many. BOOLs, INTs, DINTs, SINTs as well as the arrays of those structures are at the core of every programming language, but aren’t fully understood by most PLC programmers.

In this tutorial, we’re exploring the data structures that are at the base of PLC programming and go over the key usages of the booleans, integers and double integers.

Booleans [BOOL] in PLC Programming – XIC, XIO, OTE Instructions

The most fundamental programming block is a boolean which stores the value equal to 0 or 1. A boolean is used for most basic instructions and to evaluate most logic within PLC programming.

At the point of creating a tag through laying out logic or by using the tag creator, the user may specify the data type for the tag. Through the tag creation tab, the data type is specified within the “Data Type” tab. Note that once the tag is created online, it’s impossible to change the type. The workaround to make that happen would require the user to delete the tag and re-create it again.

PLC Data Types & Structures - Allen Bradley PLC RSLogix 5000 Basics Programming BOOL INT DINT Arrays

By typing in the tag “Data Type”, a window is opened from which the user may choose the type of tag one wants to create. Note that the types listed here will include the default Allen Bradley as well as custom UDTs.

As a beginner, you’ll be creating a lot of Boolean tags while programming. Most basic instructions such as the XIC, XIO and OTE utilize BOOLs. It’s important to keep in mind that creating a large number of BOOLs can be done through different means. The first way is to use individual booleans from within DINTs as we’ll see in the next section. The second way is to create arrays of BOOLs as we will see in the last section.

Creating & Understanding INTs and DINTs

An INT and a DINT are the next structures we’ll explore. An INT, as the name suggests, is used to hold an integer. The structure within a PLC can be broken down into 16 distinct booleans which correlates to the fact that an integer is 16 bits.

You’d create an INT just like you would a boolean. Once created, the tag can be used in multiple instructions we’ve reviewed in previous tutorials: Mathematical (MOV, MUL, ADD, SUB, etc.), Comparison (EQU, LES, GRT, etc.) & many more. INTs are used to store steps of a sequence, number of repetitions, setpoints and much more.

Once an INT tag is created, it’s possible to view each separate bit through the tag browser. By clicking the “+” button, the tag is broken down into individual bits along with the main tag listed at the top. Note that as discussed above, the data types are listed in each row with the main tag being INT (or DINT) and the ones below being BOOLs.

PLC Data Types & Structures - Allen Bradley PLC RSLogix 5000 Basics Programming BOOL INT DINT Arrays Studio

The DINT data structure is a Double INT; in other words, within the Allen Bradley world, this equates to 32 bits of data. Creating a DINT structure on the PLC will result in the same scenario as above, except that the structure will have 32 BOOLs instead of 16 as shown above.

Working with Arrays of Data in Programmable Logic Controllers [PLC]

Arrays are structures of data present in every programming language. They’re effectively structures which contain a fixed (in certain languages a variable) number of simple data structures. In other words, An array of BOOLs is simply a certain number of BOOL tags within a single element.

So what’s the advantage of an Array and why should anyone care?

  • Arrays allow programmers to organize certain elements.

By placing all the inputs and output tags into separate arrays, the programmer and those who will work on the system in the future can easily track the flow of data to and from each array. Furthermore, within Allen Bradley software (RSLogix 500, RSLogix 5000 and Studio 5000), it’s possible to cross reference the entire array making it easy to figure out where each individual tag is being used. You’d have to reference each individual tag if they weren’t grouped into an array.

Note that organization of elements is open to interpretation. One programmer may create a separate array for inputs and outputs. Another may choose to create an array for each individual card. Another may choose to group elements by physical area within a plant. There’s no “one-size-fits-all” solution when it comes to arrays.

  • Arrays can be used in advanced functions.

Many PLC functions are specifically designed to work with arrays of elements. Some of the basic examples which we’ve covered in separate posts are FOR Instructions, FIFO Instructions such as FFL and FFU, and many others. The reason for this is that arrays are easy to manipulate thus making certain instructions rely on their sequential structure. Example: an FFL instruction will insert an element at a certain position of an array and shift the rest of the elements up or down. Without an array, this would be impossible to accomplish.

Working with Arrays in RSLogix Allen Bradley PLCs

Now that you’ve convinced that arrays are great, let’s go over their definition within PLCs.

Just like in many other languages, arrays are defined with square brackets: “[” and “]”. The number within the brackets will indicate the number of elements within an array. An array may contain elements of any type; standard Allen Bradley elements or UDTs (User Defined Data Type).

To create an array, start by creating a tag as per the usual. Within the TYPE field, specify the type followed by the brackets enclosing the number of elements. Here’s an example of an array:

DataStructuresRSLogix5000PLCArrays

By expanding the array of elements, the user will be presented with all the tags within the array along with their element number in the array. Note that this is how a specific tag within the array may be called from within the logic. In other words, You’d need to specify the element if you want to perform an operation on a single tag. Ex: MOV from Tag[0] to Tag [7].

Conclusion

Understanding data structures and constructs within PLC programming, or any other software language, is critical. By properly leveraging these basic structures, programmers create efficient logic which relies on functions available within the programming environments.

The most basic, and most utilized, structures within RSLogix 5000 are the BOOl, INT and DINT. The Boolean, or BOOL is simply a binary value which can be either “0” or “1”. The INT is an integer which is composed of 16 booleans while the DINT is a double integer which is composed of 32 bits.

Arrays are an important construct which allow the programmer to group multiple elements. The maina dvantages of arrays are structured data of the same type and access to advanced functions which rely on such structures.