CTD (Count Down) decrements its counter value by one each time its rung transitions from false to true — typically counting a loaded quantity down toward empty.
Join 1900+ learners practicing PLC programming
How it works
CTD is CTU’s mirror: same preset/accumulator/status structure, same one-count-per-rising-edge rule, opposite direction. The natural mental model is depletion — load the counter with a quantity, then count down as items leave: bottles out of a magazine, doses out of a batch, free slots out of a buffer.
Here is the detail that trips up everyone who moves between platforms, and it is worth being precise about. In the IEC 61131-3 CTD function block (CODESYS, TIA Portal, OpenPLC), the LD input loads CV with the preset PV, each CD pulse decrements CV, and the Q output turns on when CV ≤ 0 — Q genuinely means "empty". In Allen-Bradley Logix, CTD was designed as the partner of CTU on the same counter tag: a CTD pulse decrements ACC, but the DN bit still means ACC ≥ PRE, exactly as it does for CTU. Logix DN on a CTD does not mean "reached zero" — it means "still at or above preset". If you want an empty signal in Logix, compare ACC to zero with a LEQ/EQU instruction.
That design difference reveals the intended Logix idiom: CTU and CTD instructions on separate rungs addressing the same counter, one incrementing on the in-feed sensor, one decrementing on the out-feed sensor. ACC then tracks the live quantity in the zone and DN tells you when the zone holds at least PRE items. The standalone load-and-count-down pattern, by contrast, is the native IEC CTD shape.
Like all counters, CTD is retentive and edge-sensitive: false rungs and power cycles leave the value untouched, pulses shorter than a scan get missed, and clearing or reloading takes an explicit act — RES plus a MOV of the start quantity in Logix, or a pulse on the LD input in IEC.
Across vendors
| Platform | Name / syntax | Notes |
|---|---|---|
| Allen-Bradley (Studio 5000 / RSLogix) | CTD | Decrements ACC on the rung’s rising edge. DN still means ACC ≥ PRE (designed to pair with a CTU on the same tag). Detect empty with LEQ Counter.ACC 0. |
| IEC 61131-3 (CODESYS, OpenPLC) | CTD FB | Pins CD, LD, PV in; Q, CV out. LD loads CV := PV; Q is true while CV ≤ 0. The natural load-then-deplete counter. |
| Siemens (TIA Portal) | CTD | IEC-style CTD with an instance DB; LD load input, Q at CV ≤ 0. Legacy STL S_CD counters appear in migrated S7-300/400 code. |
| Mitsubishi (GX Works) | Down / bidirectional counters | FX-series 32-bit counters C200–C234 count up or down depending on direction flags M8200–M8234; there is no separate CTD mnemonic in basic FX ladder. |
The one fact to carry between platforms: Allen-Bradley CTD’s DN bit and IEC CTD’s Q output answer different questions (at-or-above-preset vs at-zero). Porting logic without translating that difference produces counters that "work" and lie.
In practice
| New_Stick_Loaded CTD Mag_Counter | |-----] [------------------------------[ LD PV=50 ]-| | Label_Applied CTD Mag_Counter | |-----] [------------------------------[ CD ]-| | Mag_Counter.Q Refill_Beacon | |-----] [--------------------------------------( )-------|
A labeller magazine holds 50 labels. Loading a new stick pulses LD, setting CV to 50; every applied label pulses CD, counting down. Q fires the refill beacon at zero. To warn before running dry, compare CV instead — for example LEQ Mag_Counter.CV 5 driving a pre-warning — which is usually more useful than the hard empty signal.
| Entry_Eye CTU Zone_Count | |-----] [------------------------------[ PRE 8 ]-| | Exit_Eye CTD Zone_Count | |-----] [------------------------------[ same counter ]-| | Zone_Count.DN Zone_Full | |-----] [--------------------------------------( )-------|
Both instructions address the same counter tag: entries increment ACC, exits decrement it, so ACC is the live number of parts in the zone. DN (ACC ≥ 8) holds off the upstream conveyor while the zone is full — and here the Logix DN semantics are exactly what you want, which is why the pairing exists.
In an IEC platform the equivalent single block is CTUD, which exposes both the full (QU) and empty (QD) conditions — see the CTUD page.
Gotchas
Treating Logix CTD.DN as an empty signal
In Studio 5000, DN means ACC ≥ PRE for both CTU and CTD. A rung waiting for CTD.DN to detect zero waits forever (or worse, triggers while stock remains). Compare ACC against 0 explicitly, or use the IEC-style CTUD QD output.
Never reloading the counter
A depletion counter needs a load event: RES + MOV of the start quantity in Logix, or an LD pulse in IEC. Without it the second batch starts from zero — or from a negative count.
Letting ACC go negative unnoticed
Extra exit pulses (sensor chatter, a hand waved through the beam) keep decrementing below zero. Guard the CD rung with a GRT ACC 0 condition, or clamp/alarm on negative counts — a zone showing −3 parts is telling you a sensor lies.
Mixing up which sensor drives which instruction
In CTU/CTD pairs, swapping the entry and exit sensors inverts the whole zone model and DN becomes a "zone empty-ish" bit. Name the rung comments explicitly ("entry increments", "exit decrements") — future-you is the maintenance tech at 3 a.m.
Drop the instruction on a rung in the browser simulator, toggle the inputs, and watch the rung state, accumulator values and outputs update scan by scan.
Questions
CTD (Count Down) decrements its counter value by one each time its rung (or CD input) transitions from false to true. It is used to count a known quantity down toward zero — stock in a magazine, spaces in a buffer — or paired with a CTU on the same counter to track a live quantity.
It depends on the platform, and the difference matters. In IEC 61131-3 (CODESYS, TIA Portal) the CTD Q output turns on when CV ≤ 0 — it signals empty. In Allen-Bradley Logix, CTD shares the counter’s DN bit with CTU and DN means ACC ≥ PRE — to detect empty in Logix, compare ACC to zero with LEQ or EQU.
IEC CTD blocks have a dedicated LD input: pulse it true and CV is loaded with the preset PV. Allen-Bradley CTD has no load pin — use a MOV instruction to write the start quantity into Counter.ACC (often paired with RES) when the process reloads.
Yes — in Allen-Bradley that is the intended idiom: a CTU rung increments and a CTD rung decrements the same counter tag, so ACC tracks a bidirectional quantity and DN reports "at or above preset". In IEC platforms the same job is done in one instruction: the CTUD function block.