CTU (Functionblock) |
Top Previous Next |
CTU is an Up counter. This function block will increment the "cv" value with one on each rising edge on the "cu" input. When the "cv" variable reaches "pv", or is above, the output "q" will go high - otherwise it will be low. If a high signal is present on the "r" input, the counter will be reset ("cv" will be set to 0).
Input: cu : BOOL (true/false) On the leading edge of this input, the "cv" will be incremented with 1. When the "cv" value is equal to, or above, the value for "pv", "q" will be high.
r : BOOL (true/false) Reset input. When this input is high, the counter value will be kept at 0.
pv : INT (0..32767) Preset value for the counter.
Output: cv : INT (-32768..32767) The current value of the counter.
q : BOOL (true/false) Output from the counter. See description for "cu".
Declaration: FUNCTION_BLOCK CTU;
Example: INCLUDE rtcu.inc |