The leader in industrial automation and control solutions

Instruction Parameters

Supported PLC Series

PLC-AESPLC-FBPLC-ES

Supported Data Registers

MXYKLFTCSZRQD@DConstant
c
v

Supported Flags

FlagBitSupport
ErrorF11.0
ZeroF11.1
CarryF11.2

Number of Steps

Steps
3

Operands

OperandDescription
cThe first operand.
Entries are only counter data registers.
vThe second operand.
Entries are unsigned WORD data registers or constants.
This is the value the counter value, c, will be reset to.

The unsigned value range is 0 ~ 65,535 (216-1).
The Hexadecimal value range is H0000 ~ HFFFF.

Signed value entries will be treated as unsigned values.

Notice

Error Flag (F11.0) Notice

The error flag, F11.0, will be ON for one scan when the address of the data register assigned by Z exceeds its range. The valid range of the data register Z is Z128 ~ Z1023 when using Function Block implementation. F11.0 turns ON when the value of the data register, CC, exceeds the range of 0 ~ 65,535 (unsigned).

Instruction Behavior

The CTD instruction behaves as follows:

  • The data register C assigned to c is a BOOL data register.
    • CS and CC express the detailed value of the data register C assigned to c.
      • CC is a WORD data register used for the current count value of c.
      • CS is a WORD data register used for the count setting value of c.
        • The value of CS is equal to the value of v.
  • The value of CC decreases each time the instruction is energized.
    • The counter contact c turns ON when the value of CC is equal to 0.
      • The counter contact c will remain ON as long as CC is equal to 0 only.
    • If the value of CC is 0, the instruction will not continue executing.
    • If the reset signal is energized, CC will reset to v.
      • The counter contact c will turn OFF.
  • The counter contact assigned to c can be used as an A or B contact.
  • When the counter contact meets the RST instruction, the contact is turned OFF (0), but the value of CC is maintained.

Ladder Diagram Examples

CTD

CTD count-down instruction overview showing CC decrementing from v to 0, energizing contact C when CC equals 0.

The CTD instruction starts from the value v, and counts down to 0. The count number is saved in a counter data register, CC. If the value of CC is equal to 0, the counter contact, C, energizes.

Initial CTD ladder diagram with C0.0 = 0, CC0.0 = 8, and set value CS0.0 = 8.

The initial value of the BOOL counter data register, C0.0, is 0. The initial value of the WORD current count data register, CC0.0, is 8. The initial value of the WORD set count data register, CS0.0, is 8.

CTD ladder diagram after M1.0 turns ON, decrementing CC0.0 to 7.

When the contact, M1.0, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC0.0, to 7.

CTD ladder diagram showing count progression as CC0.0 continues decreasing from 7.
CTD ladder diagram showing CC0.0 continuing to decrease.
CTD ladder diagram showing CC0.0 decreasing toward 1.

When the contact, M1.0, is powered ON (1) again, the counter instruction counts down by 1, decreasing the current count data register, CC0.0, to 1.

Ladder Diagram Example for MapleLogic CTD instruction.
When the contact, M1.0, is powered ON (1) again, the counter instruction counts down by 1, decreasing the current count data register, CC0.0, to 0.

When the contact, M1.0, is powered ON (1) again, the counter instruction counts down by 1, decreasing the current count data register, CC0.0, to 0.

Since CC0.0 is equal to CS0.0, the BOOL counter data register, C0.0, is set to 1.

Since CC0.0 is equal to CS0.0, the BOOL counter data register, C0.0, is set to 1. As a result, the coil, Y0.2, is energized.

When the contact, M1.1, is powered ON (1), the value the current count data register, CC0.0, resets to 8.

When the contact, M1.1, is powered ON (1), the value the current count data register, CC0.0, resets to 8. Since CC0.00 is greater than CS10, the BOOL counter data register, C0.0, is set to 0. As a result, the coil, Y0.2, is deenergized.

Ladder Diagram Example for MapleLogic CTD instruction.
CTD ladder diagram after M1.0 turns ON, decrementing CC0.0 to 7.