Increments a counter on each rising edge of the count input and outputs TRUE when the current value .CV reaches the preset value .PV.
The CTU (Count-Up) and CTUR instructions implement an IEC 61131-3 up-counter:
.CU — .CV increments by 1..CV >= .PV — Output .Q becomes TRUE..R (Reset) is TRUE — .CV resets to 0 and .Q becomes FALSE. You can wire an optional boolean variable to the R input slot on the action node or reset the counter using an action with the R qualifier.Alt or right-click -> Edit Qualifier & Instruction).PV (for example 100) and optionally assign a reset variable in the R input slot.from automation_machine import ActionQualifier, ActionInstruction
step.add_action("counter_name", "Count up", qualifier=ActionQualifier.P, instruction=ActionInstruction.CTU, preset_value=100)
ActionQualifier.P to count once per step activationActionInstruction.CTU or ActionInstruction.CTURPV, for example 100).CV to 0| 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 |