SUB (Subtraction)
Subtracts a value from the target variable each time the action executes.
Description
The SUB instruction performs a subtraction operation on the target variable. When the action activates, it subtracts the specified value (defaulting to 1) from the current value of the variable.
This is commonly used for decrementing counters, counting down remaining items, or adjusting numeric setpoints.
When using
SUBwith theN(non-stored) qualifier, the subtraction runs every scan cycle while the step is active. If you only want to subtract once when the step activates, useActionQualifier.P(pulse) instead.
Syntax
- step: the parent step object (from
self.add_step()) - variable_name: the numeric variable to modify
- qualifier: typically
ActionQualifier.Pfor a single subtraction on step activation - instruction: must be
ActionInstruction.SUB
Sequence Visual Editor

Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("variable_name", "Description", qualifier=ActionQualifier.P, instruction=ActionInstruction.SUB)
See Also
- ADD (Addition): add to a variable
- MUL (Multiplication): multiply a variable
- DIV (Division): divide a variable
- CTD (Count-Down Counter): dedicated count-down function block
- Action Qualifiers Overview
- Instructions Overview