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).
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:
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:
You must then define the internal logic:
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.
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 news tip? Share it with us here.
Have a question on this topic? Click here to scroll down to the comment link
Enjoy the benifits of membership! Insider news, rewards, & more: Patreon.com/automation
- The Realities of Project Management: Know When to Hold ‘Em, Know When to Fold ‘Em - December 23, 2019
- The Realities of Project Management: The Project Czar - December 5, 2019
- The Realities of Project Management: The Second Effort - November 21, 2019
Click HERE to scroll down to view or leave comments