The CTD function block decrements a count for each rising edge until the count reaches zero.
| Parameter | Type | Direction | Description |
|---|---|---|---|
| CD | BOOL R_EDGE | Input | A rising edge decrements the counter value CV by 1. |
| LD | BOOL | Input | Resets the output Q and the counter value CV. |
| PV | INT | Input | The counter limit value. |
| Q | BOOL | Output | Set to true when the counter value CV reaches PV. |
| CV | INT | Input | The 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;
END_IF;
Q := (CV <= 0);
End_Function_Block
IEC 61131-3 Second Edition: Table 36.2a.
IEC 61131-3 Third Edition: Table 44.2a.
To learn about other standard function blocks.
To learn about the different types supported by Fernhill SCADA.
To learn about other IEC 61131-3 Common Elements.
For the meaning of terms used in Fernhill SCADA.