Down counter
This is a user-defined function from a system function block. Counters realized with the CT_FUN function are down counters. The count area SV (set value) is 1 to 32767.
Input
count contact (down)
each time a rising edge is detected at Count, the value 1 is subtracted from the elapsed value EV until the value 0 is reached
reset contact
each time a rising edge is detected at Reset, the value 0 is assigned to EV and the signal output C is reset; each time a falling edge is detected at Reset, the value at SV is assigned to EV
Set value
value of EV after a reset procedure
Input/output
Internal memory containing the internal values and states, which corresponds to the instance memory of the associated FB.
Output
signal output
is set when EV becomes 0
Elapsed value
current counter value
The value can be changed during counting operation by writing to the variable from the programming editor.
In order to work correctly, the CT_FUN function needs to be reset each time before it is used.
The number of available counters is limited and depends on the settings in the system registers 5 and 6. The compiler assigns a NUM* address to every counter instance. The addresses are assigned counting downwards, starting at the highest possible address.
The basic function CT (down counter) uses the same NUM* address area (Num input). In order to avoid errors (address conflicts), the CT function and the CT_FUN function should not be used together in a project.
Time chart