32.8.3.1 Explanation of the CTUD and CTUDP Instructions

Counter variables in CTUD and CTUDP instructions are structure variables. The following table lists the internal structures.

Counter Variable

Counter Variable

Variables Settings

Description

VariableName.R

Bit Variable

  • Up Counter

Resets the current value. Clear (0).

  • Down Counter

Resets the current value. (Preset Value)

VariableName.Q

Bit Variable

Turns ON when the current value reaches the preset value.

VariableName.UP

Bit Variable

Counts up when the variable is ON.

VariableName.QU

Bit Variable

For Up/Down counters, turns ON when the current value reaches the preset value.

VariableName.QD

Bit Variable

For Up/Down counters, turns ON when the current value reaches 0 or less.

VariableName.PV

Integer Variable

Preset value

VariableName.CV

Integer Variable

Process Variable

When the .UP bit of CTUD and CTUDP instructions is ON, they operate the same as CTU instructions. When the .UP bit is OFF, CTUD and CTUDP instructions operate the same as CTD instructions.

When .UP is ON (counts up) and if .CV (current value) is larger than .PV (preset value), .Q turns ON when the current value reaches the preset value and .QU turns ON.

When .UP is OFF (counts down) is OFF and .CV (current value) is 0 or less, then .Q turns ON when the current value reaches the preset value and .QD turns ON.

Program Example

CTUD

In the following example, if five operation errors are counted within 1 minute, an error will be displayed.

In the program example, the timer instruction is not shown. Only the one-minute timer start trigger for timer start is shown.

To count operation errors, create a separate error input trigger.

  1. When the normally open instruction of the one-minute timer turns ON, the OUT instruction assigned to counter .R (reset) turns ON. When the operation error counter .R (reset) turns ON, if .UP is ON, the CTU instruction is executed, and .CV (current value) is cleared to zero. If .UP is OFF, the CTD instruction is executed, and .PV (preset value) is copied to .CV (current value).

  2. When the positive transition normally open instruction in rung 3 turns ON, and if .UP is ON, the .CV value increases by 1. If .UP is OFF, the .CV value (current value) decreases by 1.

  3. When .UP is ON, and the .PV value (preset value) and the .CV value become equal, .Q and .QU turn ON. When .UP is OFF, and the .CV value (current value) is less than 0, Q and .QD turn ON.

  4. The operation error counter .Q of the CTUD instruction (turns ON when the current value reaches the preset value) turns ON and the OUT instruction outputs the error detection message.

CTUDP

The difference between CTUD and CTUDP instructions is whether the .CV value increases or decreases as a level counter, or as a positive transition counter. The difference in program creation is that a positive transition normally open instruction located on rung 3 to detect operation errors is a normally open instruction. There is no difference in operation other than how the input is determined.