Tags and Datatypes 2


Introduction to Tags and Datatypes

It’s very important to understand Tags and Datatypes in the ControlLogix processor.    The ControlLogix memory is made of of two main areas.   Tags store data, and Tasks (logic) manipulate data.   In contrast, the datatype is the way data is structured within a tag.  When we added I/O, RSLogix / Studio 5000 automatically created some Controller Tags to view and control the I/O.   We can create other tags as well for use in our project, such as tags for timers, integers, and other Boolean bits.

To see what data types are available, simply open up the DataTypes folder. The default set of datatypes are in the “Predefined” folder”. In newer versions of Studio 5000, this will be under “Assets”.

For example:  If we have a tag called “ValveShut”, we can make this a BOOL Tag.   As a result, the tag “ValveShut” would consist of only one bit.   The tag can only have 2 states:  1 or 0.

In the same way, we could create a tag called “ValvePosition”.    This might be a DINT (Double Integer) tag.    At this point, you could store a value of 0 to 100 (percent) into this tag.     A DINT tag contains 32 individual bits, which represent a numeric value when interpreted by the processor.

In like manner, we could create a tag called “TransitionTimer”.    If we give this tag a TIMER datatype, it will inherit all the members we need for a timer (Accumulated Value, Preset, ENable bit, DoNe bit, and Timer Timing bit).

Controller Tags vs. Program Tags and parameters

Tags

Controller tags are global.   In summary, almost anything can access a controller tag.    Any program, or any other controller can access a controller tag.

In the same fashion, local tags and parameters are local to the program they reside in.    The advantage of local tags is that they are in their own namespace.   This means that we can have two programs that use the same tag names for timers, counters, integers, etc….   The tags will not interfere with each other if they are local tags or parameters.

Creating a tag

Before we create a tag, be sure you are offline or that the keyswitch is in “Remote”.  There are several ways to create a tag.    Let’s create a simple bool tag called “ValveShut”.    We’ll make this a controller tag, so it will be global, and any program can access this tag.    One way to do this is to right click the controller tag database, and create a new tag.

For this example, we’ll just double click the controller tag database, and choose “Edit Tags”.  At the bottom of the Controller Tag Database, we’ll create the tag called “ValveShut”, and the datatype will be “BOOL”.   You are now free to use this tag as you see fit in logic!

Create Tag

Other ways to Create Tags

There are a few other ways that you might create tags. One way is to right click on the Controller Tags (or program tags) in the Controller organizer window. From here you can create a tag.

Another way is very handy. While you are developing your logic, simply type the name of the new tag on an instruction. Of course, this is undefined. It does not exist yet. After that, right click the undefined tag. From here, you can create a new tag. Simply choose the scope of the tag. After that, Studio 5000 will default to the same scope for the next tags that you create using this method.

Summary of Tags and Datatypes

Simply put, tags are variables. You can create tags to use in your logic just as you can with any other programming language. When you create a tag, you will assign a data type to that tag. The data type is just the way data is structured within the tag.

For more information, visit the ControlLogix Category page!

— Ricky Bryce


Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Tags and Datatypes

    • Ricky Post author

      I’m glad you are able to use the information. Please feel free to check out the other ControlLogix posts from the menu bar at the top of the page. You can also search for any ControlLogix topic on the site. Take care, –Ricky