Function blocks
148 Function blocks for TwinSAFE logic components
3.22 The function block COUNTER
3.22.1 Functional description
The FB Counter is used to realize an up/down counter. The inputs Reset, CountUp and CountDown are
of data type BOOL. The outputs Error, CounterOut and CounterZero are also of data type BOOL. The
output ActValue indicates the current internal counter value and can be of data type INT16, UINT16,
INT32 or UINT32. The parameters Preset Value and Counter Limit can be used to parameterize the
counter.
A logical 1 signal at the Reset input causes the internal counter value to be set to the value that is
parameterized via Preset Value. A rising edge at the CountUp input increments the internal counter value
by 1. A rising edge at the CountDown input decrements the internal counter value by 1. Once the counter
value specified under CounterLimit is reached, the output CounterOut is set. Once the counter value 0 is
reached, the output CounterZero is set.
When the TwinSAFE group is started (Run=1), ActValue is set to PresetValue. When the group is
stopped, ActValue is set to 0.
Figure 3-92: Function block COUNTER