Decrements a counter on each rising edge of the count input and outputs TRUE when the current value .CV reaches 0.
The CTD (Count-Down) and CTDR instructions implement an IEC 61131-3 down-counter:
.CD — .CV decrements by 1..CV <= 0 — Output .Q becomes TRUE..LD (Load) is TRUE — .CV loads the preset value .PV and .Q becomes FALSE. You can wire an optional boolean variable to the LD input slot on the action node or reload the counter using the R qualifier.Alt or right-click -> Edit Qualifier & Instruction).PV (for example 50) and optionally assign a load variable in the LD input slot.from automation_machine import ActionQualifier, ActionInstruction
step.add_action("counter_name", "Count down", qualifier=ActionQualifier.P, instruction=ActionInstruction.CTD, preset_value=50)
ActionQualifier.P to count once per step activationActionInstruction.CTD or ActionInstruction.CTDRPV, for example 50).PV into .CV| Variable | Type | Description |
|---|---|---|
.CD |
BOOL |
Count-down input — rising edge decrements .CV |
.LD |
BOOL |
Load input — sets .CV to .PV and .Q to FALSE |
.Q |
BOOL |
Output signal — TRUE when .CV <= 0 |
.PV |
INT |
Preset starting count |
.CV |
INT |
Current remaining count |