CTD (Count-Down Counter)
Decrements a counter on each rising edge of the count input and outputs TRUE when the current value .CV reaches 0.
Description
The CTD (Count-Down) and CTDR instructions implement an IEC 61131-3 down-counter:
- Rising edge on
.CD:.CVdecrements by1. .CV <= 0: Output.QbecomesTRUE..LD(Load) isTRUE:.CVloads the preset value.PVand.QbecomesFALSE. You can wire an optional boolean variable to theLDinput slot on the action node or reload the counter using theRqualifier.
Syntax
Sequence Visual Editor
- Select an action on a step and open the Instruction picker (
Altor right-click -> Edit Qualifier & Instruction). - Select Counters -> CTD (or CTDR) and choose the P (Pulse) qualifier.
- Enter the starting count in
PV(for example50) and optionally assign a load variable in theLDinput slot.

The PV chip holds the start value of the down counter.
Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("counter_name", "Count down", qualifier=ActionQualifier.P, instruction=ActionInstruction.CTD, preset_value=50)
Parameters
- name: Counter instance name
- description: Action description
- qualifier:
ActionQualifier.Pto count once per step activation - instruction:
ActionInstruction.CTDorActionInstruction.CTDR - preset_value: Starting count (
PV, for example50) - LD (optional operand): Boolean variable that loads
.PVinto.CV
Counter Variables
| 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 |