Rockwell Automation Publication 1756-RM094M-EN-P - November 2022 51
Chapter 5 Modular Programming Techniques
Guidelines for
Add-On Instructions
An Add-On Instruction encapsulates commonly used functions or device controls. It is not
intended for use as a high-level hierarchical design tool. Once an Add-On Instruction is defined
in a project, it behaves similarly to the built-in instructions that are already available in the
programming software. The Add-On Instruction appears on the instruction toolbar and in the
instruction browser.
Add-On Instruction Design Concepts
To be sure that specific data is passed into or out of the Add-On Instruction, use a required
parameter. A required parameter must be passed as an argument in order for a call to the
instruction for verification. To pass a required parameter in ladder diagrams and in structured
text, specify an argument tag for the parameter.
• In a function block diagram, required Input parameters and Output parameters must be
wired.
• In a ladder diagram, InOut parameters must have an argument tag.
• If a required parameter lacks an associated argument, the routine that contains the call
to the Add-On Instruction does not verify.
Guideline Description
Create Add-On Instructions in relay ladder,
function block diagram, or structured text
languages.
Supports all Add-On Instructions and most built-in instructions. Excludes JSR/SBR/RET, JXR, FOR/BRK (relay ladder),
SFR, SFP, SAR, IOT, and EVENT instructions.
GSV/SSV instructions in an Add-On Instruction cannot reference the Module, Message, Axis, Motion Group, or Coordinate
System class names.
Add-On Instructions support function block, relay ladder, and structured text programming languages. Each of the
Add-On Instruction logic areas can be any language. For example, the main logic can be function block and the prescan
logic can be relay ladder.
You can create safety Add-On Instructions in a safety task.
An Add-On Instruction supports parameters:
• Input (copied in)
• Output (copied out)
• InOut (passed by reference)
• For Version 24 and earlier, you are limited to 512 total parameters: Input parameter + Output parameter + local tags
(no limit on the number of InOut parameters)
• For Version 28 and later, you are limited to 40 InOut parameters, but no limit on the number of Input or Output
parameters)
• 2 MB maximum data instance (parameters and locals)
• Alarm, axis, axis group, coordinate system, message, motion group, and produced/consumed tags must exist at the
program or controller scope and passed as an InOut parameter
• Can include references to controller-scoped tags, program-scoped tags, and immediate values.
• Input and Output parameters are limited to atomic (BOOL, SINT, INT, DINT, REAL) data types. Use the InOut parameter
for LINT, user-defined, and structure data types.
• DINT data types provide optimal execution.
• Default values of parameters and local tags are used to initialize the data structure when a tag is created of the
instruction’s data type. When an existing parameter or local tag's default value is modified, the existing tag instances
for that instruction are not updated. When a parameter or local tag is added to the instruction definition, the tag's
default value is used in the existing tags.
Create and modify offline only.
Online operation supports monitoring.
Modifications to Add-On Instructions are made offline. Make changes once to the Add-On Instruction definition to affect
all instances.
An Add-On Instruction executes like a routine.
A task with a higher execution priority can interrupt an Add-On Instruction. Use a UID/UIE instruction pair to make sure
an Add-On Instruction’s execution is not interrupted by a higher priority task.
If you have many parameters or specialized options, consider multiple Add-On Instructions
Calling many Add-On Instructions impacts scan time
The code within an Add-On Instruction can access
data that is specified only via parameters or
defined as local.
Copy the local data to a parameter if you want to programmatically access it outside of an Add-On Instruction.
Use optional Scan mode logic to set up, initialize,
or reset the Add-On Instruction code.
An Add-On Instruction can have logic along with the main logic for the instruction.
• Prescan logic executes on controller startup.
• Postscan logic executes on SFC Automatic reset.
• EnableInFalse logic executes when rung condition is false.
Apply code signatures to Add-On Instructions for
revision control.
Add-On Instructions can be sealed with a code signature. Use the code signature for revision control and to identify any
changes. For safety controllers, the signature can be used to get TÜV certification for a safety Add-On Instruction. For
more information, see the Logix 5000 Controllers Add-On Instructions Programming Manual, publication 1756-PM010
.