Learn PLCs free
CountersBeginnerIEC 61131-3

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

NameTypeDescription
CDBOOLCount down input - decrements on rising edge
LDBOOLLoad input - loads PV into CV
PVINTPreset value (initial count)

Outputs

NameTypeDescription
QBOOLCounter done - TRUE when CV <= 0
CVINTCurrent 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

S

Siemens (TIA Portal)

Use CTD instruction in TIA Portal with IEC_Counter data type.

AB

Allen-Bradley (Studio 5000)

No native CTD; implement using CTU and subtracting from preset, or use math instructions.

C

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.

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.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →