Back to tutorials
Intermediate

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

By
Vladimir Romanov
|
December 27, 2019
Table of Contents

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.

Video Tutorial

Back to tutorials

Got a question or comment?

Related Tutorials

Beginner

Opto 22 groov RIO Getting Started

The groov RIO module from Opto 22 has been released only a few months ago. The groov RIO is a feature packed piece of hardware that is easy to install, configure and deploy for many different field applications. The module comes pre-loaded with an array of software tools used across the industry and is ready to hit the floor running out of the box. Furthermore, the module is equipped with user configurable input and output nodes that have the capability unlike anything else on the market.

August 2, 2020
|
By
Vladimir Romanov
Beginner

Micro800 PLC Programming Getting Started

The Micro800 Control Systems by Rockwell Automation provide a cost effective solution for small to medium automation systems. The controllers within this family are typically used on stand alone machines or small process applications. The family offers five distinct controller types that are further customizable through add-on modules: Micro810, Micro820, Micro830, Micro850 and Micro870.Micro800 Programmable Logic Controllers Getting StartedUnlike the other Rockwell Automation controllers, this line of PLCs is programmed through a dedicated software: Connected Components Workbench. From within this tool, the programmer can flash the firmware, load the program and monitor the state of the controller. Furthermore, Connected Components Workbench (CCW) is often used to program other non-PLC Rockwell Automation devices such as Variable Frequency Drives (VFDs) and certain Safety Relays.

July 26, 2020
|
By
Vladimir Romanov
Beginner

An Introduction to DeviceNet Industrial Networks

In this tutorial you will learn about the DeviceNet industrial network, go over a basic offline configuration, and explore some advanced features.

July 24, 2020
|
By
Jacques Venter