Advantages of reusable code for PLCs

 

An Excerpt from Control Engineering Article.  You can find full article here:  http://www.controleng.com/single-article/advantages-of-reusable-code-for-plcs/9a36b0430744ce711017e097341b5460.html

----------------------------

Many programmers base their knowledge and abilities on their experience with Allen-Bradley's products since much of the installed base in manufacturing consists of A-B programmable logic controllers (PLCs). The ControlLogix family was a huge jump in PLC capabilities with enhancements such as being tag-based, allowing the use of user-defined data types (UDTs), and add-on instructions (AOIs). Tags could also be made local to each program, allowing them to be duplicated for re-use.

1. Local vs. global variables. Re-usable code must have variables that apply to each instance of the code; ideally only formatting the data once for the original code. What this means is that a list of tags or symbols should not have to be re-named for each instance or call. For instance, duplicating a subroutine several times and iterating the addresses inside of it, though it saves time, isn't really re-usable code.

2. User-defined data types (UDTs). Creating UDTs allows structures to be built that can be exported from one application to another. They allow components to be described using generic terms such as "Speed", "Start", "Reject", etc. UDTs don't require tag based systems, but they do require advanced use of symbols.

3. Protectable self-contained blocks. It is important that the code be contained in a block that allows variables to be passed in and out, and also protected so that users can't change a specific instance of it. This requires a password or software key.

These are just some of the requirements. Other features like being able to write code in other IEC-compliant PLC languages such as structured text also help make platforms much more powerful and "Rapid Code Development" friendly.

Regardless of whether the platform uses subroutines with local variables or customizable instructions, reusable code is a critical part of creating powerful programs quickly. There are many platforms out there that allow reusable code and each has their own unique methods.

Frank Lamb is the founder of Automation Consulting Services Inc. This article originally appeared on the Automation Primer blog. Automation Primer is a CFE Media content partner. Edited by Chris Vavra, production editor, Control Engineering, CFE Media, cvavra@cfemedia.com.

--------------------------------------------------------------------------

A Note from Bill Schmidt who is a CED Solution Consultant in Nebraska:

4.  Add on Instructions (AOI).  With Add-On Instructions, you can create new instructions for sets of commonly-used logic, provide a common interface to this logic, and provide documentation for the instruction. Add-On Instructions are intended to be used to encapsulate commonly used functions or device control. They are not intended to be a high-level hierarchical design tool. Programs with routines are better suited to contain code for the area or unit levels of your application.

Rockwell Automation
Back to Posts

Archives