32.8.2.1 Explanation of the CTD and CTDP Instructions

Counter variables in CTD and CTDP instructions are structure variables. The following table lists the internal structures.

Counter Variable

Counter Variable

Variables Settings

Description

VariableName.R

Bit Variable

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 CTD and CTDP instructions are ON, if the counter reset bit variable .R is OFF, the current value .CV will decrease by 1.

When the current value .CV is less than 0, the counter output bit .Q turns ON. When the counter reset bit variable .R turns ON, the preset value .PV is copied to the current value variable .CV. And, the counter output variable .Q turns OFF.

Program Example

CTD

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, the CTD instruction's preset value .PV is copied to the current value .CV. In the program example, 5 is copied to the current value .CV.

  2. When the positive transition normally open instruction turns ON, the operation error counter .CV value (current value) decreases by 1.

  3. When the value of the operation error counter .CV value (current value) is 0 or less, the operation error counter .Q of the CTD instruction turns ON, and the OUT instruction in rung 4 outputs the error detection message.

CTDP

The difference between CTD and CTDP instructions is whether the .CV value increases 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.