CTDR (Resettable Count-Down Counter)
Decrements .CV on each rising edge of .CD, sets .Q to TRUE when .CV <= 0, and reloads .CV with .PV when the dedicated LD (Load) operand is TRUE.
Description
CTDR is a count-down counter with an explicit LD (Load) operand chip displayed directly on the action node in the Sequence Editor:
- Rising edge on
.CD:.CVdecrements by1. .CV <= 0: Output.QbecomesTRUE..LD(Load) isTRUE:.CVreloads to.PVand.QbecomesFALSE(assuming.PV > 0).
Syntax
Sequence Visual Editor
- Select an action on a step and open the Instruction picker (Alt or right-click -> Edit Qualifier & Instruction).
- Select Counters -> CTDR and choose the P (Pulse) qualifier.
- Enter the starting count in
PV(for example10) and assign a boolean load variable in theLDoperand chip.
Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("magazine_slots", "Decrement remaining slots", qualifier=ActionQualifier.P, instruction=ActionInstruction.CTDR, preset_value=10, load="magazine_refilled")
Parameters
- name: Counter instance name
- description: Action description
- qualifier:
ActionQualifier.Pto decrement once per step activation - instruction:
ActionInstruction.CTDR - preset_value: Starting count (
PV, for example10) - load (
LD): Boolean variable or expression that reloads.CVwith.PV
Counter Variables
| Variable | Type | Description |
|---|---|---|
.CD |
BOOL |
Count-down input: rising edge decrements .CV |
.LD |
BOOL |
Load input: reloads .CV to .PV and sets .Q to FALSE |
.Q |
BOOL |
Output signal: TRUE when .CV <= 0 |
.PV |
INT |
Preset starting count |
.CV |
INT |
Current remaining count |