CTU (Count-Up Counter)
Increments a counter on each rising edge of the count input and outputs TRUE when the current value .CV reaches the preset value .PV.
Description
The CTU (Count-Up) and CTUR instructions implement an IEC 61131-3 up-counter:
- Rising edge on
.CU:.CVincrements by1. .CV >= .PV: Output.QbecomesTRUE..R(Reset) isTRUE:.CVresets to0and.QbecomesFALSE. You can wire an optional boolean variable to theRinput slot on the action node or reset the counter using an action with theRqualifier.
Syntax
Sequence Visual Editor
- Select an action on a step and open the Instruction picker (
Altor right-click -> Edit Qualifier & Instruction). - Select Counters -> CTU (or CTUR) and choose the P (Pulse) qualifier.
- Enter the target count in
PV(for example100) and optionally assign a reset variable in theRinput slot.

The PV chip holds the preset; the R chip takes an optional reset variable.
Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("counter_name", "Count up", qualifier=ActionQualifier.P, instruction=ActionInstruction.CTU, preset_value=100)
Parameters
- name: Counter instance name
- description: Action description
- qualifier:
ActionQualifier.Pto count once per step activation - instruction:
ActionInstruction.CTUorActionInstruction.CTUR - preset_value: Target count (
PV, for example100) - R (optional operand): Boolean variable that resets
.CVto0
Counter Variables
| Variable | Type | Description |
|---|---|---|
.CU |
BOOL |
Count-up input: rising edge increments .CV |
.R |
BOOL |
Reset input: resets .CV to 0 and .Q to FALSE |
.Q |
BOOL |
Output signal: TRUE when .CV >= .PV |
.PV |
INT |
Preset target count |
.CV |
INT |
Current accumulated count |