Skip to main content

Allen-Bradley Add-On Instructions (AOI) — Creating Reusable PLC Logic

By NFM Consulting 2 min read

Key Takeaway

How to create, configure, and use Add-On Instructions in Studio 5000 to encapsulate reusable logic blocks for Allen-Bradley ControlLogix and CompactLogix PLCs.

Quick Answer

An Add-On Instruction (AOI) is a custom, reusable function block in Studio 5000 that encapsulates logic into a single instruction. AOIs have defined input, output, and local parameters, can be written in Ladder, ST, or FBD, and are portable between projects via L5X export files.

What Is an Add-On Instruction?

AOIs are the Allen-Bradley equivalent of functions or classes in software programming. They allow you to write a piece of logic once — a pump control sequence, a valve interlock, or an analog scaling routine — and reuse it throughout a project or across multiple projects. Each instance of an AOI gets its own set of data, so the same logic can control many different devices without code duplication.

AOI vs Subroutine — Key Differences

  • AOIs have defined parameters (interface), private local tags, and each instance has its own data. They appear as single instructions in the calling routine.
  • Subroutines (JSR/RET) share the calling routine's tag scope, have no formal interface, and are more difficult to reuse across projects.

Creating a New AOI in Studio 5000

  1. Right-click Add-On Instructions in the Controller Organizer and select New Add-On Instruction.
  2. Enter a name (e.g., PumpControl), description, and revision.
  3. Select the programming language for the AOI's logic routine (Ladder, ST, or FBD).

Defining Parameters

  • Input — Read-only values passed into the AOI (e.g., Start command, Fault status)
  • Output — Values calculated by the AOI and returned to the caller (e.g., Run command, Fault alarm)
  • InOut — Parameters passed by reference for read/write access (e.g., UDT structures)
  • Local — Internal tags visible only inside the AOI (e.g., timers, state variables)

Writing the AOI Logic

The AOI contains one or more routines. The Logic routine is the main execution routine, called automatically when the AOI instruction scans. Additional routines can handle Prescan (initialization on first scan) and EnableInFalse (behavior when the rung is false).

Instantiating an AOI

In a calling routine, add the AOI as an instruction (Ladder) or function call (ST/FBD). Create a tag of the AOI's data type — this tag holds all the instance data including parameters and local tags. Multiple instances can coexist, each with independent data.

AOI Versioning and Source Protection

AOIs support revision numbers and revision notes for change tracking. Source protection can lock the AOI logic to prevent modification while allowing instantiation — useful for distributing AOI libraries to customers or other teams.

Example AOI: Pump Control Block

A PumpControl AOI with:

  • Inputs: IN_Start (BOOL), IN_Stop (BOOL), IN_Fault (BOOL), IN_RunFeedback (BOOL)
  • Outputs: OUT_Run (BOOL), OUT_Fault_Alarm (BOOL), OUT_RunHours (REAL)
  • Local: StartTimer (TIMER), RunHoursAccum (DINT)

The logic handles start/stop with seal-in, fault lockout, start failure detection (no run feedback within 10 seconds), and run-hours accumulation.

Importing and Exporting AOIs

Export AOIs as .L5X XML files via right-click > Export. Import into another Studio 5000 project via right-click on Add-On Instructions > Import. The L5X format preserves all parameters, logic, and revision information.

Frequently Asked Questions

Ready to Get Started?

Our engineers are ready to help with your automation project.