Click here to learn the biblical way to get to heaven! (The most important page on this site)


Disclaimer: This document is written in the hope that you can utilize for your own education to gain knowledge of PLC systems (should you decide to utilize this document). Although I believe the information in this document to be accurate, it is YOUR responsibility to verify this information before implementing it in any way, especially when damage to personnel or equipment could result. By continuing to read this document, you agree to hold no one who writes, modifies, or distributes this document liable in any way (even negligence). Due to the wide variety of plant applications, some of the examples in this document may be prohibited at your location, or could cause damage to equipment, or harm personnel.
[Visit my Church Website] -- [Return to Index Page] -- [View Training Courses] -- [Contact ATI for Training] *Copyright 2005
Author: Ricky Bryce (Montgomery County, IL)
VPS Hosting Referral Code MJDCDJYou can have your very own virtual server though VPSLink! Using REFERRAL code MJDCDJ you will receive a 10% discount on your new account, and I will get a service credit on my account. My personal preference is the Link 2 package running XEN for starting out (You can upgrade any time). You can choose from a variety of Linux distributions such as CENTOS, Fedora, Debian, and Ubuntu. This is a great package for learning Linux, and setting up your own web page, or email server.

Working with User Defined Data Types


A User Defined Data type allows the user to create his own data structure offline. To understand user defined Data Types, you must first understand pre-defined data types. In the PLC-5, T4:0 was a variable with the timer data type. T4:0 contained several members: T4:0.ACC, T4:0.PRE, T4:0/DN, T4:0/EN, and T4:0/TT.


In ControlLogix, a variable such as lubedelay can be created, and given the data type of “Timer”. Once this assignment is made, the variable “lubedelay” can be expanded to reveal all of it's components: lubedelay.ACC, lubedelay.PRE, lubedelay.DN, lubedelay.TT, and lubedleay.EN. All of these variables are updated by a timer instruction in logic.


The timer object is always on the 'menu' as a pre defined data type, but you don't have any timers by default. You have to set up a variable in the tag database, and assign that variable the timer data type. You would now have a timer.


Instead of using the data structure of a timer, you may want to create your own data structures. For example, you may want to create a data type called 'TankAlarm', and have the alarm data type consist of some members such as HighLevel, and LowLevel.


Now any tag you assign a TankAlarm data type will inherit both the HighLevel and LowLevel members.


Data structures and data types are not directly usable by the logic. Setting up a User Defined Data type merely puts an item on a menu. You don't actually have an instance of the item until you declare a tag with your data type.


For example: Steak and Shake sells hamburgers (or steak burgers). Seeing the hamburger on a menu does not allow you to utilize the product in any way until you order at least one instance of the menu item. The same is true for the timer example we used earlier. The timer data structure is always available, but you don't have any timers until you create a tag with the timer data type.


Let's take a look at the timer data structure to see what members it consists of, and then we will create our own data structure for TankAlarms.

Simple UDT's


In an open project, locate the Data Types folder in the controller organizer window. Under the Data Types folder, you will find the Predefined data types. Expand the Predefined data types folder, and double click TIMER.





Notice the members of the Timer Data Structure. Any tag we assign in the tag database as a timer will inherit all of these members.







When you create MyTimer with the timer type, the tag can be expanded to reveal all the components.:





Next, we are going to create a User Defined Data structure called “TankAlarm”. This data structure will have two members: HighLevel, and LowLevel.


Right Click on the User-Defined folder under Data Types, and select “New Data Type”.





The name of this data type will be TankAlarm. The two members, HighLevel, and LowLevel, will each have a bool data type.





Now that “TankAlarm” is an available data type, we can now create an instance of this data type in the tag database.


In this example, I created a tag called MyTank, and gave it the TankAlarm data type. MyTank inherited the members of the TankAlarm data type. We can now have XIC's and OTE's in logic that use MyTank.LowLevel, and MyTank.Highlevel variables.




Here is an example of what logic might look like to populate these bits:




Nesting UDT's


Additional information may be needed for MyTank. Status information may also be available. The TankStatus data type will consist of three members: Level, Draining, and Filling. Let's go ahead and set up this data type, then we will nest TankAlarm, and TankStatus members into a tank data type. This will provide us with all the information we need about MyTank all in one area. Lets do this one step at a time.


First, Create a UDT for TankStatus as shown (Right click the User-Defined folder and select 'new data type'):





Notice that Level is an actual value, so it will have to be DINT. Filling and Draining are either true or false, so their type is BOOL. Apply your changes.


We can use the TankStatus Data type in the tag database as it is, but we would have to create a separate tagname, which is not good. Remember our goal is to organize data.


To have all the data under one tagname, we are going to have to create another data structure that has the members TankStatus and TankAlarm. Each of those data structures have their own members.



Create the data structure as shown:






Now go to the Controller Tag Database, and create 3 tags, Tank1, Tank2, and Tank3 each having the data type of 'Tank'. Look what happens!




All three Tanks had the 'Tank' data type. (Recall that the tank data type consisted of two members, alarm and status.



Remember also that alarm and status had their own structures as well. Expand the alarm and status tags.




All the data for each Tank is now well organized. These tags should then be incorporated into the input and output data mapping routines.