Try a PLC free — no signup
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;

Free to start

Run this block in your browser

Try the instruction on a live rung before you copy it into a project — nothing to install.

Run a PLC counter in your browser

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

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.

Free to start

Wire this block up and run it

Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.

Run a PLC counter in your browser

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad