Skip to main content

7.2.5 CTUD_DINT

Function

CTDU_DINT is called an up-down counter, used to accumulate the number of input pulses (0->1 or 1->0) at the input end.

LD graphics

Alt ​​text

Parameter description

Interface variablesDeclarationData typeDescription
CUVar_InputBOOLUp-count signal input terminal
CDVar_InputBOOLCountdown signal input terminal
RVar_InputBOOLReset input, CV clear
LDVar_InputBOOLLoad preset value, set CV to PV
PVVar_InputDINTPreset value
QUVar_OutputBOOLAdd counter status
QDVar_OutputBOOLStatus of the down counter
CVVar_OutputDINTThe value of the current count

Corresponding syntax

  • Counting range: -2147483648~2147483647
  • The rest of the syntax refers to CTUD_INT
  • Function block example:
warning

Function block usage requires global declaration of an instance

Example

  • LD example is shown in the following animation: alt text

  • ST example is shown in the following code:

CTUD_DINT_1(
CU:=UP,
CD:=DOWN,
R:=RESET,
LD:=LOAD,
PV:=1,
QU=>OUT,
QD=>OUT2,
CV=>cVar
);
IF OUT THEN
IVar:=iVar+1;
ELSE
iVar:=0;
END_IF;
IF OUT2 THEN
iVar2:=iVar2+1;
else
iVar2:=0;
END_IF;