Count Down (CTD)
    The CTD instruction counts downward each time the rung-condition-in transitions from false to true.
The CTD instruction is typically used with a CTU instruction that references the same counter structure.
When rung-condition-in is set to true and .CD is false, .ACC will be decremented by one. When rung-condition-in is false, .CD will be cleared to false.

Available Languages
Ladder Diagram
_v1.png/_jcr_content/renditions/original)
Operands 
     IMPORTANT: 
    
Unexpected operation may occur if:
- Output tag operands are overwritten.
- Members of a structure operand are overwritten.
- Except when specified, structure operands are shared by multiple instructions.
Ladder Diagram
| Operand | Data Type | Format | Description | 
|---|---|---|---|
| Counter | COUNTER | tag | Counter structure | 
| Preset | DINT | immediate | Value of Counter.PRE. | 
| Accum | DINT | immediate | Value of Counter.ACC. | 
COUNTER Structure
| Mnemonic | Data Type | Description | 
|---|---|---|
| .CD | BOOL | The countdown enable bit contains rung-condition-in when the instruction was last executed. | 
| .DN | BOOL | The done bit when clear indicates the counting operation is complete. | 
| .OV | BOOL | The overflow bit when set indicates the counter incremented past the upper limit of 2,147,483,647. | 
| .UN | BOOL | The underflow when set indicates the counter decremented past the lower limit of -2,147,483,648. | 
| .PRE | DINT | The preset value specifies the value which the accumulated value must reach before the instruction indicates it is done. | 
| .ACC | DINT | The accumulated value specifies the number of transitions the instruction has counted. | 
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Index through arrays for array-indexing faults.
Execution
Ladder Diagram
| Condition/State | Action Taken | 
|---|---|
| Prescan | The .CD bit is set to true to prevent invalid decrements during the first program scan. | 
| Rung-condition-in is false | Set Rung-condition-out to Rung-condition-in See CTD Flow Chart (False) | 
| Rung-condition-in is true | Set Rung-condition-out to Rung-condition-in See CTD Flow Chart (True) | 
| Postscan | N/A | 
CTD Flow Chart (False)

CTD Flow Chart (True)

Example
Ladder Diagram

In this example, a conveyor brings parts into a buffer zone.
        
- Rung 1: Each time a part enters, limit_switch_3 is enabled for a scan and counter_2 increments by 1. When the part clears, limit_switch_3 is no longer enabled.
- Rung 2: Each time a part leaves, limit_switch_4 is enabled for a scan and counter_2 decrements by 1.
- Rung 3: If there are 15 parts in the buffer zone, counter_2.DN becomes enabled and conveyor_A is disabled, stopping the conveyor from bringing in any more parts until the buffer has room for more parts.
- Rung 0: An operator can manually reset the conveyor system by toggling the restart bit, which resets counter_2’s status and accumulator.
Provide Feedback