Lib.Mervis.v1_0.IncrementalCounter
A helper block used for handling counter inputs that are at risk of overflow.
program test var inp: lib.mervis.v1_0.IncrementalCounter; end_var inp(); end_program
Name | Data Type | Retain | Mandatory Connection | Meaning |
In | udint | No | Yes | Counter input value |
Set | bool | No | No | Counter reset |
Overflow | udint | No | No | Maximum counter input value for overflow handling (if =0, not used) |
Step | udint | No | No | |
PulseWeight | real | No | No | Pulse weight, used to convert the counter value to a physical value |
Offset | real | No | No | Pulse count offset, used to convert the counter value to a physical value |
Name | Data Type | Meaning |
Out | udint | Output |
Weighted | real | Output converted to a physical value using PulseWeight and Offset |
OverflowFlag | bool | Overflow flag |
OverflowCount | udint | Counter overflow count |
The block is used to handle the value from a counter that frequently overflows. The block contains an internal 32-bit counter, which always increments by the number of incoming pulses (the difference from the previous computation cycle). If this difference is negative, it is considered an overflow, and the behavior depends on the Overflow parameter:
The Weighted output is calculated as a linear transformation of the internal counter state, i.e., Weighted = PulseWeight * Out + Offset