CTU & CTD in PLC in hindi #6

Опубликовано: 05 Апрель 2026
на канале: GENX TECH
2,016
45

The CTU command is used to count an event which happens logically or externally and places that value in the counter's Accumulator. The accumulated value is maintained even during FALSE rung conditions and can only be reset back to 0 (zero) by the RES command. The CU (Count Up Enable) bit is set when rung conditions are TRUE and remains TRUE until the rung goes FALSE or until the RES instruction is enabled. The Done bit is set when the accumulated value is equal to or greater than the preset value and is reset when the accumulated value is less than the preset. Unlike the other commands, the CTU has an overflow (OV) bit, this bit is set when the accumulated value wraps around to -32,768 (from +32,767) and continues counting up from there. The OV bit can be reset by the RES command or when the accumulated value goes below +32,767.

The CTU command uses fields similar to timers. They contain a counter address (C5:x) with "x" being the counter number, a Preset value field, and an Accumuator value field. Like the timers, the Preset and Accum bits are addressable and can be changed or updated through internal logic.





################


The CTD, also known as the Count Down, instruction is used to decrement the value of the counter associated with it. This instruction will detect a FALSE to TRUE transition of the logic leading to it and decrease the “Accum” value of the counter by 1. The effect of using this instruction is the exact opposite of what the CTU Instruction does to the counter. Just like its counterpart, this instruction will be found in a rung which will count a certain number of events. Due to the fact that it decrements the value, the use cases need to be very specific in order to be clear to the next programmer.

You can use the CTD instruction for every single application of the CTU instruction. In other words, it is just a matter of preference. That being said, an experienced programmer will allow the program to flow naturally; using the instruction as it would make sense in the real world. The most basic example which comes to mind would be a start countdown where the values need to decrement from 10 down to 0.

Example & Usage of CTD
Here’s a real-world scenario of a CTD instruction:

A Micrologix 1100 Allen Bradley PLC is used to control a process.
A “High Level Alarm” is indicated by an internal bit B3:0/15.
A CTD instruction is tied to Counter C5:2.
The Counter C5:2 has a “Preset” of -5. The number 5 represents the maximum number of times the alarm can be triggered before requiring an acknowledgment from the operator.
When the bit B3:0/15 goes HIGH, the CTD instruction is energized and the counter decrements the “Preset” value.
When the bit B3:0/15 goes LOW, followed by HIGH, the CTD instruction is energized and the counter decrements again.
The counter will continue to increment until “Accum” = -5.
When “Accum” of C5:2 Counter is equal to -5, the C5:2.DN bit is HIGH.
The C5:2.DN bit is used to set an internal bit B3:1/0.
The B3:1/0 bit is left HIGH until a button tied to the bit B3:1/1 is set to HIGH. This action allows the Counter to reset and resume the process.

@#######################

Data Types Allowed for CTD
The CTD leverages a specific data structure, called the Counter, present in most PLC systems.

Counter – The high-level instruction specification of all the inner structures.
.PRE – Integer specifying up to which value the timer will count.
.ACC – Integer specifying the current time value of the timer.
.CU – Boolean value which is set to HIGH when the counter is energized to count up.
.CD – Boolean value which is set to HIGH when the counter is energized to count down.
.DN – Boolean value which is set to HIGH when the timer is finished counting.
.OV – Boolean value which is set to HIGH when the counter is overflown.
Note: The overflow status signifies that the counter has reached the logical limit of 32767 and had to wrap back to the value of -32768.
Note2: To avoid overloading the counter, make sure to program proper measures into your software.
.UN – Boolean value which is set to HIGH when the counter is underflown.
Note: The underflow status signifies that the counter has reached the logical limit of -32768 and had to wrap back to the value of 32767.
Note2: To avoid overloading the counter, make sure to program proper measures into your software.