CTD - Down Counter Function Block

Help Contents


The CTD function block decrements a count for each rising edge until the count reaches zero.


CDBOOL R_EDGEInputA rising edge decrements the counter value CV by 1.
LDBOOLInputResets the output Q and the counter value CV.
PVINTInputThe counter limit value.
QBOOLOutputSet to true when the counter value CV reaches PV.
CVINTInputThe current counter value.

The Up Counter is logically equivalent to:

Function_Block CTD
        Var_Input CD : BOOL R_EDGE; LD : BOOL; PV : INT; End_Var
        Var_Output Q : BOOL; CV : INT; End_Var

        IF LD THEN
            CV := PV;
        ELSEIF CU AND (CV > 0)
            CV := CV - 1;

        Q := (CV <= 0);

Standards Compliance

Table 36.2a - IEC 61131-3 Second Edition.

Table 44.2a - IEC 61131-3 Third Edition.

Further Information

Standard Function Blocks

To learn about other standard function blocks.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.