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 contact, c, will energize at.

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 CTUD 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 increases or decreases each time the instruction is energized.
    • There are 3 input signals for the instruction
      • Count up signal
      • Count down signal
      • Reset signal
    • The counter contact c turns ON when the value of CC is equal to or greater than v.
      • The counter contact c will remain ON if either the count up or count down signal is energized and the value of CC is equal to or greater than v.
  • If the value of CC is 0, the instruction will not continue executing.
    • If the reset signal is energized, CC will reset to 0.
      • 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

CTUD

CTUD count-up/count-down instruction overview showing CC incrementing and decrementing, energizing contact C when CC is greater than or equal to v.

The CTUD instruction starts from 0 and counts up to the largest value, 65,535 (unsigned). The CTUD instruction also counts down from the current value, CC, until it reaches 0. The count number is saved in a counter data register, CC. If the value of CC is greater than or equal the value of v, the counter contact, C, energizes.

Initial CTUD ladder diagram with C2.8 = 0, CC2.8 = 0, and set value CS2.8 = 5.

The initial value of the BOOL counter data register, C2.8, is 0. The initial value of the WORD current count data register, CC2.8, is 0. The initial value of the WORD set count data register, CS2.8, is 5.

CTUD ladder diagram after M2.0 turns ON, incrementing CC2.8 to 1.

When the contact, M2.0, is powered ON (1), the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 1.

CTUD ladder diagram showing count progression as CC2.8 continues increasing from 1.
CTUD ladder diagram showing CC2.8 continuing to increase toward set value CS2.8 = 5.
CTUD ladder diagram showing CC2.8 approaching set value CS2.8 = 5.

When the contact, M2.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 5.

Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, is set to 1.

Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, is set to 1. As a result, the coil, Y0.5, is energized.

When the contact, M2.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 6.

When the contact, M2.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 6.

Since CC2.8 is greater than or equal to CS2.8, the BOOL counter data register, C2.8, remains 1.

Since CC2.8 is greater than or equal to CS2.8, the BOOL counter data register, C2.8, remains 1. As a result, the coil, Y0.5, remains energized.

When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 5.

When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 5.

Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, remains 1.

Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, remains 1. As a result, the coil, Y0.5, remains energized.

When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 4.

When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 4.

Since CC2.8 is less than CS2.8, the BOOL counter data register, C2.8, is set to 0.

Since CC2.8 is less than CS2.8, the BOOL counter data register, C2.8, is set to 0. As a result, the coil, Y0.5, is deenergized.

When the contact, M2.2, is powered ON (1), the current count data register, CC2.8, is reset to 0.

When the contact, M2.2, is powered ON (1), the current count data register, CC2.8, is reset to 0.

Ladder Diagram Example for MapleLogic CTUD instruction.
CTUD ladder diagram after M2.0 turns ON, incrementing CC2.8 to 1.