CTD (Counter Down)
Counts down from preset value; output activates when count reaches zero.
The CTD (Counter Down) function block decrements a counter value (CV) by 1 on each rising edge of the count down input (CD). It is typically loaded with a preset value (PV) using the load input (LD). The output (Q) goes TRUE when CV reaches 0 or below. CTD counters are used for countdown applications such as remaining inventory tracking, countdown sequences, and batch remaining quantity displays.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| CD | BOOL | Count down input - decrements on rising edge |
| LD | BOOL | Load input - loads PV into CV |
| PV | INT | Preset value (initial count) |
Outputs
| Name | Type | Description |
|---|---|---|
| Q | BOOL | Counter done - TRUE when CV <= 0 |
| CV | INT | Current counter value |
Ladder Logic Example
// Ladder Logic - CTD Counter (Remaining Parts) // // |----[ Load_Batch ]-------[CTD Remaining]--------| // | CD: Part_Dispensed | // | LD: Load_Batch | // | PV: 50 | // | Q: Batch_Empty |
Structured Text Example
VAR
Remaining : CTD;
Part_Dispensed : BOOL;
Load_Batch : BOOL;
Batch_Empty : BOOL;
END_VAR
Remaining(CD := Part_Dispensed, LD := Load_Batch, PV := 50);
Batch_Empty := Remaining.Q;20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use CTD instruction in TIA Portal with IEC_Counter data type.
Allen-Bradley (Studio 5000)
No native CTD; implement using CTU and subtracting from preset, or use math instructions.
CODESYS
Standard CTD available in Standard library.
Common Applications
- Remaining inventory count
- Countdown sequences
- Dispensing quantity control
- Remaining cycle count
Common Mistakes to Avoid
- Forgetting to load the counter before counting down
- Not handling the case when CV goes below 0
Frequently Asked Questions
What is CTD (Counter Down) in PLC programming?
Counts down from preset value; output activates when count reaches zero. The CTD (Counter Down) function block decrements a counter value (CV) by 1 on each rising edge of the count down input (CD). It is typically loaded with a preset value (PV) using the load input (LD).
What are common applications of CTD (Counter Down)?
CTD (Counter Down) is commonly used for: Remaining inventory count, Countdown sequences, Dispensing quantity control, Remaining cycle count.
How do I use CTD (Counter Down) in different PLC platforms?
Siemens: Use CTD instruction in TIA Portal with IEC_Counter data type. Allen-Bradley: No native CTD; implement using CTU and subtracting from preset, or use math instructions. CODESYS: Standard CTD available in Standard library.
Related Function Blocks
CTU (Counter Up)
Counts up on each rising edge; output activates when count reaches preset.
View Reference →CTUD (Counter Up/Down)
Counts both up and down with separate done outputs for each direction.
View Reference →CTU with Auto-Reset
Counter that automatically resets after reaching preset, creating repeating count cycles.
View Reference →HSC (High-Speed Counter)
Hardware-accelerated counter for high-frequency pulse inputs beyond normal scan rate.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects