CTU vs CTD: PLC Counter Instructions Compared


Flat vector diagram comparing a CTU count-up and CTD count-down PLC counter instruction side by side with accumulated value bars and ladder rung connections

CTU and CTD are the two most fundamental counter instructions in PLC ladder logic. They look almost identical on a rung, they share the same basic parameters, and yet they count in opposite directions and solve different problems. Picking the wrong one does not usually cause a crash, but it does make your logic harder to read and your HMI displays confusing. This post lays out exactly how each instruction works, where each one fits best, and what to watch out for in the real world.

What Is CTU vs CTD in a PLC?

CTU (Count Up) and CTD (Count Down) are IEC 61131-3 counter function blocks used in PLC ladder logic. CTU increments its accumulated value by one on each rising edge of its count input and sets its done output when the accumulated value reaches the preset. CTD decrements from a loaded preset toward zero and sets its done output when the accumulated value reaches zero. Both instructions require an explicit reset to clear the accumulated value and allow reuse.

How CTU Works: Counting Up to a Target

CTU starts at zero and counts toward a preset value you define. Each false-to-true transition on the count input adds one to the accumulated value. When accumulated equals preset, the done bit (DN in Rockwell, Q in IEC/Siemens) turns on. The accumulated value keeps climbing past the preset if you do not reset it, so leaving a reset path out of your rung is a real bug waiting to happen.

In Studio 5000, a CTU uses a COUNTER data type tag. The three members you touch most are PRE (the target count), ACC (the running total), and .DN (the done bit). There is also an overflow bit .OV that sets if ACC wraps past the DINT ceiling, though you will rarely see that outside a very long-running production counter with no reset. For a deep look at all three counter instructions together, the post on PLC Counter Instructions: CTU, CTD and CTUD Explained covers the full picture.

Always pair a CTU with a reset path. A forgotten RES means the counter hits DN, you reset with an HMI button, but the ACC is still sitting at the preset value waiting to re-trigger immediately. Drive the reset on the same scan the operator presses the button, not one scan later.

How CTD Works: Counting Down to Zero

CTD works in reverse. You load a preset and the accumulated value decrements by one on each rising edge. The done bit sets when ACC reaches zero. On Rockwell Logix, the CTD done bit is .DN just like CTU. On Siemens S7-1200 using the IEC CTD block, the output is Q, and it goes true when CV (current value) is less than or equal to zero.

The CTD load input is important and often overlooked. Before counting down, you need to load the preset into the accumulated value. In Rockwell Logix, a separate MOV instruction into the counter.ACC before enabling the count is the standard approach. In Siemens IEC CTD, there is a dedicated LD (load) input on the function block: drive it true and PV (preset value) gets copied into CV automatically. Miss the load step and your CTD starts from whatever leftover value is in ACC, which is a classic first-time mistake.

Flat vector diagram of a CTD PLC counter instruction block showing a preset value loading and the accumulated value decrementing to zero to trigger the done bit
CTD loads a preset then decrements on each count pulse. The done bit fires at zero.

CTU vs CTD: Direct Comparison

ParameterCTUCTD
DirectionCounts up (ACC increases)Counts down (ACC decreases)
Done conditionACC >= PREACC <= 0
Starting ACC value0 (after reset)Loaded from PRE or MOV
Load input needed?NoYes (LD on IEC; MOV in Logix)
Reset clears ACC to00 (IEC) or retains until next load
Overflow riskYes, if no reset and counts continueUnderflow if ACC goes below 0 (platform-dependent)
CTU vs CTD: key parameter differences across IEC 61131-3 implementations

When to Use CTU vs CTD: Real Application Examples

Use CTU when you are accumulating toward a target

CTU is the natural fit any time you are building up to something. Counting parts on a conveyor to trigger a box full alarm, counting machine cycles to schedule maintenance, counting rejected parts to halt a line after too many failures. The HMI display of ACC naturally reads as progress: you are at 47 of 100. In the PLC Bottle Filling Machine example, a CTU tracks how many bottles a filler has completed in the current shift, with the DN bit kicking off a batch report.

CTU also pairs cleanly with a one-shot rising edge upstream of the count input. This is important because many proximity sensors stay high for several scan cycles as a part moves past them. Without the one-shot, your CTU would count multiple times per part. The pattern is: sensor energizes, OSR fires once, CTU increments once. Done.

Use CTD when you are dispensing or depleting from a known quantity

CTD shines when the quantity to track is a remaining amount. A hopper holding 500 tablets, a reel of labels with 2000 left, a pallet with 24 carton slots still empty. You load the known quantity into the preset, count down as items are used, and the done bit fires when stock is gone. The HMI shows remaining count without any math on the display side, which operators find more intuitive than watching a CTU approach its preset from below.

I used this exact approach on a tablet press commissioning years ago. The machine counted tablets dispensed into each bottle, and the customer wanted the HMI to show tablets remaining. Using CTD meant the display just read ACC directly. With CTU we would have needed a subtraction block on the HMI or in the PLC just to derive the same number. CTD saved the display math and made the logic self-documenting.

Use CTUD when both directions matter

If parts enter a buffer zone from one end and leave from another, you need a single accumulated value that both increments and decrements. That is the CTUD (Count Up/Down) instruction. It has separate CU and CD inputs but shares one ACC. A CTU and CTD on separate tags cannot do this cleanly. CTUD is covered in depth in PLC Counter Instructions: CTU, CTD and CTUD Explained if you need the full detail on that instruction.

Platform Differences You Need to Know

Rockwell Logix (Studio 5000): CTU and CTD each use a COUNTER data type. Reset uses a separate RES instruction. The done bit is .DN. Overflow is .OV, underflow is .UN. The accumulated value is a DINT, so the maximum count before overflow is 2,147,483,647, which is effectively unlimited for production counting.

Siemens S7-1200 and S7-1500 (TIA Portal): These platforms use IEC-compliant CTU and CTD function blocks from the IEC_Counter library. The data type is a multi-instance DB. CTD has a LD (load) input that copies PV into CV when true. The Q output is the done bit. The R (reset) input on CTU and the LD input on CTD are inline on the block rather than separate instructions. If you are building programs in TIA Portal, the post on S7-1200 Timers in TIA Portal shows the same IEC block pattern applied to timers, so the mental model transfers directly.

Mitsubishi GX Works3: Counter coils use C addresses (C0 to C199 for 16-bit counters). An OUT C0 K100 instruction sets the preset to 100. The counter increments each scan the coil rung is true and the input transitions, then the contact C0 closes at setpoint. Reset uses RST C0. High-speed counters use a separate HSC function. For a full walkthrough of the GX Works3 environment, see the GX Works3 Getting-Started Guide.

Omron Sysmac: CNT (count) and CNTR (reversible count) instructions handle up and down counting. The Omron Sysmac Studio Getting-Started Guide shows how the instruction set is organized if you are new to that platform.

A Practical CTD Ladder Logic Example: Parts Remaining in a Magazine

The rung below uses a CTD on a Rockwell Logix platform to track parts remaining in a feed magazine. A load command (triggered once at machine start or after a reload) moves the preset into ACC. Each time a part exits the magazine, the proximity sensor fires a one-shot, and CTD decrements. When ACC hits zero, the done bit sets a low-stock alarm and disables the feeder. The HMI reads Feeder_CTD.ACC directly as parts remaining.

CTD Magazine Parts-Remaining Counter with Low-Stock Alarm (Studio 5000). Ladder logic (5 rungs): Rung 0: examine if Feeder_ReloadCmd is on (XIC), then examine if Reload_OS is on (XIC), then MOV on 200. Rung 1: examine if PartExit_Prox is on (XIC), then examine if PartExit_OS is on (XIC), then examine if Feeder_LowStock is off (XIO), then CTD on Feeder_CTD. Rung 2: examine if Feeder_CTD.DN is on (XIC), then examine if LowStock_OS is on (XIC), then latch output Feeder_LowStock (OTL). Rung 3: examine if Feeder_LowStock is on (XIC), then examine if HMI_LowStockAck is on (XIC), then examine if Feeder_CTD.DN is off (XIO), then unlatch output Feeder_LowStock (OTU). Rung 4: examine if Feeder_LowStock is off (XIO), then examine if Sys_Running is on (XIC), then energize output Feeder_Enable (OTE). Rung 1: On a reload command rising edge, MOV loads 200 into Feeder_CTD.ACC. Rung 2: Each part-exit proximity sensor rising edge decrements the CTD by one, guarded by the low-stock flag so counting stops at zero. Rung 3: When ACC reaches zero, a one-shot latches the low-stock alarm. Rung 4: Operator acknowledge clears the latch once the magazine is refilled. Rung 5: Feeder runs only while no low-stock alarm is active.

CTD Magazine Parts-Remaining Counter with Low-Stock Alarm (Studio 5000)Ladder logic
Toggle inputs
Rung 0
Ladder logic rung: examine if Feeder_ReloadCmd is on (XIC), then examine if Reload_OS is on (XIC), then MOV on 200 examine if Feeder_ReloadCmd is on (XIC), then examine if Reload_OS is on (XIC), then MOV on 200 XIC Feeder_ReloadCmd Feeder_ReloadCmd Feeder_ReloadCmd OSR Reload_OS Reload_OS Reload_OS OSR MOV 200 Feeder_CTD.ACC MOVSource200200DestFeeder_CTD.ACCFeeder_CTD.ACC
Rung 1
Ladder logic rung: examine if PartExit_Prox is on (XIC), then examine if PartExit_OS is on (XIC), then examine if Feeder_LowStock is off (XIO), then CTD on Feeder_CTD examine if PartExit_Prox is on (XIC), then examine if PartExit_OS is on (XIC), then examine if Feeder_LowStock is off (XIO), then CTD on Feeder_CTD XIC PartExit_Prox PartExit_Prox PartExit_Prox OSR PartExit_OS PartExit_OS PartExit_OS OSR XIO Feeder_LowStock Feeder_LowStock Feeder_LowStock CTD Feeder_CTD 200 0 CTDCounterFeeder_CTDFeeder_CTDPreset200200Accum00
Rung 2
Ladder logic rung: examine if Feeder_CTD.DN is on (XIC), then examine if LowStock_OS is on (XIC), then latch output Feeder_LowStock (OTL) examine if Feeder_CTD.DN is on (XIC), then examine if LowStock_OS is on (XIC), then latch output Feeder_LowStock (OTL) XIC Feeder_CTD.DN Feeder_CTD.DN Feeder_CTD.DN OSR LowStock_OS LowStock_OS LowStock_OS OSR OTL Feeder_LowStock Feeder_LowStock Feeder_LowStock L
Rung 3
Ladder logic rung: examine if Feeder_LowStock is on (XIC), then examine if HMI_LowStockAck is on (XIC), then examine if Feeder_CTD.DN is off (XIO), then unlatch output Feeder_LowStock (OTU) examine if Feeder_LowStock is on (XIC), then examine if HMI_LowStockAck is on (XIC), then examine if Feeder_CTD.DN is off (XIO), then unlatch output Feeder_LowStock (OTU) XIC Feeder_LowStock Feeder_LowStock Feeder_LowStock XIC HMI_LowStockAck HMI_LowStockAck HMI_LowStockAck XIO Feeder_CTD.DN Feeder_CTD.DN Feeder_CTD.DN OTU Feeder_LowStock Feeder_LowStock Feeder_LowStock U
Rung 4
Ladder logic rung: examine if Feeder_LowStock is off (XIO), then examine if Sys_Running is on (XIC), then energize output Feeder_Enable (OTE) examine if Feeder_LowStock is off (XIO), then examine if Sys_Running is on (XIC), then energize output Feeder_Enable (OTE) XIO Feeder_LowStock Feeder_LowStock Feeder_LowStock XIC Sys_Running Sys_Running Sys_Running OTE Feeder_Enable Feeder_Enable Feeder_Enable
energizedTip: click a contact in the diagram to flip its bit.
Rung 1: On a reload command rising edge, MOV loads 200 into Feeder_CTD.ACC. Rung 2: Each part-exit proximity sensor rising edge decrements the CTD by one, guarded by the low-stock flag so counting stops at zero. Rung 3: When ACC reaches zero, a one-shot latches the low-stock alarm. Rung 4: Operator acknowledge clears the latch once the magazine is refilled. Rung 5: Feeder runs only while no low-stock alarm is active.

Common Mistakes with CTU and CTD

  • Forgetting to load CTD before first use: ACC starts at 0 and done fires instantly on the first scan.
  • Not one-shotting the count input: a sensor held high for 5 scans gives you 5 counts instead of 1.
  • Resetting too early: issuing RES in the same rung as the DN bit means the counter never stays done long enough for downstream logic to see it. Use a latch (OTL) to capture DN first.
  • Mixing up CTU and CTD done conditions: CTU DN is ACC >= PRE; CTD DN is ACC <= 0. They are not symmetric, and assuming they are leads to off-by-one logic errors.
  • Ignoring the overflow and underflow bits: on Logix, if ACC wraps, the OV or UN bit sets but does not fault the PLC. Your count silently corrupts. Check these bits during commissioning.
On Siemens S7-1200 IEC CTD, the CV data type is INT by default in some library versions, giving a maximum of 32,767. If your preset exceeds that, switch the block to DINT explicitly in the instance DB. Silently clipping the preset at 32,767 on a long production run is a nasty bug to track down.

Connecting Counter Logic to the Rest of Your Program

Counter done bits behave exactly like any other internal bit in your program. You can use them as contacts in other rungs, map them to HMI tags, or feed them into set-reset flip-flop logic to latch alarms. The ACC value is just an integer tag, so you can compare it against a setpoint with a GEQ or LES instruction to trigger intermediate actions before DN fires.

For a broader look at how PLC internal bits, flags and coils interact with instructions like counters and timers, that post covers the addressing side of things in detail. And if you want to see counters embedded inside a larger sequence, the PLC Pump Station Exercise and Car Wash PLC Exercise both use cycle counters as part of the complete program.

Diagnosing counter issues in a running machine is straightforward with online monitoring. The PLC Troubleshooting with Online Monitoring post walks through how to watch ACC in real time and force test inputs to verify your count logic before production starts. If you are seeing counts that seem wrong, also check whether an intermittent sensor fault is generating spurious pulses.


If you want to go deeper on counter instructions, the full three-instruction breakdown in PLC Counter Instructions: CTU, CTD and CTUD Explained covers CTUD and the edge cases in detail. For related timing logic that often works alongside counters, PLC Timer Ladder Logic: 5 Practical Examples shows real working circuits you can adapt. And if you want to test any of this without physical hardware first, How to Simulate Ladder Logic Without a PLC gets you set up quickly.

Was this helpful?

Related Blogs