In yesterday's article I covered the advantage of using verbose tag names in place of pages of comments to document programmable controller programs.

Beyond that, there are some other tools available that can help you with organization.

Focusing on Rockwell Automation Studio 5000 software, both User-Defined Data Types (UDDTs) as well as Add-On Instructions (AOIs) should be used whenever the application allows for it.

Both are derived from the principles of Object-Oriented Programming (OOP), which simply means that you can take something that you use often and make it into an “object” similar to how an XIO or an OTE is an object. Then you can just drag and drop into the program and use it repeatedly.

UDDTs allow you to group together variable types into a structure.

For example, if you created a UDDT called “Motor_Start_Stop_Station”, it would contain four internal variables called “Start_Pushbutton”, “Stop_Pushbutton”, “Motor_Overload” and “Motor_Starter” (see Figure 3).

Figure 3. Creating UDDT Structure – Image by Carlo Zaskorski

Then to use this UDDT, you simply create a new variable of the type “Motor Start_Stop_Station” and it will have the same addressable sub-element as the UDDT it's base on, as show in the examples below:

Figure 4. Creating UDDT Variable – Image by Carlo Zaskorski
Figure 5. Using UDDT Variable in Logic – Image by Carlo Zaskorski

AOIs allow you to create logic modules that you can drop into your program as needed.

This is great when a certain bit of logic is repeated multiple times in a program.

Another benefit of this is that the global logic can be changed in one place if a modification must be made and it will apply to all the instances of usage.

Creating an AOI is similar to creating a UDDT in that you must define internal variables that will be linked to, and define them as input or output variables as well as whether they are required or optional:

Figure 6. Defining AOI variable names and properties – Image by Carlo Zaskorski

You must then define the internal logic:

Figure 7. Example of logic defined inside of an AOI – Image by Carlo Zaskorski

After that, you have to create a variable for the AOI as it is an object, which will be used as the AOI name when it is dragged into a routine to be used in the program.

The AOI can then be used as any other object or instruction (XIC, XIO, CPT, etc.). In the Figure 8 example, it is combined with a UDDT that is providing the linked variable names.

Figure 8. Ladder routine with an AOI that also uses a UDDT – Image by Carlo Zaskorski

And while in my above example I use a simple motor start stop station, AOIs can also be used with more complicated code as well as custom application logic.

At the end of the day, taking advantage of features such as UDDTs and AOIs can help streamline the program and make it easier to implement changes to commonly used logic and data.

And perhaps after reading these two articles you'll come to the same conclusion that I did: That comments had their place when the programming software was more basic, but that new versions have so many more features (and so many fewer limitations) that the better way to program today is to maximize your program's organization to enable you to limit or eliminate the need to comments to it.

Written by Carlo Zaskorski
Controls Engineer, Product Manager, and Freelance Blogger
Edited by Shawn Tierney

Have a question or comment on this article? Join our community to take part in the discussion! You'll also find all of our courses at (328 views)

Carlo Zaskorski