Technical Article

Introduction to Add-on Instructions for PLC Ladder Logic Programming

August 20, 2022 by Dennis Lynch

Learn how to take advantage of the powerful AOI feature that comes standard in Allen-Bradley / Rockwell PLCs using RSLogix 5000 and Studio 5000 Software.

What is an Add-On Instruction?

An add-on Instruction (AOI) is a feature introduced by Rockwell Software in version 16 of RSLogix 5000 programming software for Controllogix and CompactLogix PLCs. An AOI enables a user to develop and package PLC code in user-defined instruction that is reused throughout their program. 

The reused code appears as a simple instruction or function block, much like many of the built-in instructions included in the RSLogix 5000 software. Traditional, non-PLC programmers may find an AOI analogous to a function in other programming languages.

 

Are Add-on Instructions Better for PLC Programming?

There are numerous advantages of add-on Instructions:

  • AOIs allow you to develop and test code and then reuse it throughout your program and even across multiple PLC programs. This can reduce errors and promote consistency.
  • If a mistake is found or enhancement is needed after implementing an AOI, updates can be made to the AOI definition or logic and all instances of the AOI may be updated.
  • Logic can appear simplified when using an AOI as it appears in the logic as one instruction or function block instead of many lines of code, rungs, or function blocks.
  • The AOI can be shared across projects by exporting the AOI, which can then be imported into another project.  
  • If source protection is enabled, the code inside the AOI can be protected from view or changes in the case of proprietary code.
  • The AOI has built-in revision tracking and can be locked from editing.
  • The AOI can include documentation and help for users.

 

Some disadvantages of add-on Instructions are:

  • You cannot edit AOIs online. All edits must be made offline and downloaded to the PLC.
  • There is a slight increase in the amount of memory used with AOIs when compared to the amount of memory used with the equivalent logic outside of an AOI.
  • Not all built-in instructions can be used in an AOI. Although most built-in instructions are available, there is a handful that is not.

 

Figure 1. More complex code, such as this ladder logic routine on the left, runs inside a simplified AOI structure.
 

How do I make an Add-on Instruction for a PLC?

Creating an AOI is a fairly straightforward procedure, but before jumping in and programming the designer should carefully formulate a plan and work out the framework and logic “on paper” before starting the configuration in the software.  

There are four main parts that need to be configured, with several, optional, steps that can be completed to enhance and polish the AOI. The first step in creating an AOI definition is naming the AOI and choosing which type of PLC programming language the AOI will be written in.  

The AOI can be one of three types: Ladder diagram, function block, or structured text. This first step is configured under the General tab in the instruction's definition as shown below. Optional information such as description, revision, revision notes, and vendor are also part of the configuration under this tab.

 

Figure 2. Add-on Instruction General tab in the Studio 5000 / RSLogix 5000 Software. Image courtesy of Rockwell Automation

 

The second part that needs to be configured when creating an AOI is the external parameters that will pass from/to the AOI. These are configured on the Parameters tab as shown below. 

Here you will define the input and output parameters name, data type, and default value. This step does not necessarily have to be done before creating the logic, as you will have the opportunity to create the parameters as you create the logic, but it can be beneficial to do so before creating the logic. 

 

Figure 3. Creating Add-on instruction parameters by choosing appropriate names and data types for input and output information. Image courtesy of Rockwell Automation

 

Once the external parameters have been created, the next logical step would be to create the logic that will run inside the AOI. The logic, whether it is ladder, function block, or structured text will reference the parameters created in the second step and perform the logic function as programmed.

At this point, local tags are also created/configured as the logic is entered into the configuration of the AOI. Local tags will not be available outside of the AOI and can only be referenced inside the AOI. Local tags will include instruction tags, constants, and other variables needed to perform the logic as programmed.



Figure 4. The logic inside an AOI can be ladder, function block, or structure text as in the example above.

 

There are several optional parts of the AOI that the user may or may not choose to configure.  

  • Scan Modes
  • Signature
  • Change History
  • Help

Although the AOI can only have one logic routine that runs when the AOI is used, the user can configure special scan modes that operate logic on special instances such as Prescan, Postscan, and Fault. These options are configured on the Scan mode tab.

The instruction signature is another optional feature that can be configured. The instruction signature tracks the revision history of the instruction and creates a timestamp and signature ID that can be used to determine if an AOI has been modified.

The change history, although technical, not optional, has no user-configurable parameters. It simply tracks the last change that was made to the instruction and displays the Windows user name and date/time of the change.

The AOI has built-in documentation or a help feature that is optional, but highly recommended feature to take advantage of. The designer of the AOI can document the instruction for later recall by the user of the instruction. The help configuration is fairly free form and allows the designer a standard text editor to display the help of the instructions. The Help configuration tab can be seen in the picture below.

 

Figure 5. Add-on Instruction help configuration tab allows the creator of the AOI to leave detailed documentation for future users. Image courtesy of Rockwell Automation

 

When can my PLC Program Benefit From Using Add-on Instruction?

Although the AOI is a very powerful and versatile feature, it is not right for every application. Add-on Instructions work great when there is a specific, repetitive piece of logic that will be used in multiple places in a program or throughout a facility. An AOI is not typically the right tool for rare complex logic that is only to be used once in a program or at a facility.  

The exception to this would be in the case where the designer would like to protect their logic or package it in a more user-friendly shell. Add-on Instructions cannot be created online and needs to be extensively tested before being used and disseminated to other projects or to be used by coworkers. Although changes are possible, the consequences of the changes and the process for the changes are not as easy as other normal changes that can be made online in the PLC. This article is merely a brief introduction to add-on Instructions and hopefully will get you motivated to try using them.  

For a more in-depth complete overview and reference, see Allen-Bradley publication 1756-PM010I-EN-P “Logix 5000 Controllers Add On Instructions”.

 


Want to test your knowledge of PLCs? You think you N.O. a lot about ladder logic? Are you a normally-open or normally-closed minded engineer?

Check out our PLC Programming worksheet!