Skip to main content

FB_COUNTER

Description Function Block

The FB_COUNTER function block is used to implement an incrementing and decrementing counter. The ActValue specifies the current internal counter value. The counter can be parameterized by means of the PresetValue and CounterLimit inputs.

For a logic 1 signal at the bReset input, the internal counter value is set to the value which is parameterized by means of PresetValue. For a rising edge at the bCountUp input, the internal counter value is incremented by 1. For a rising edge at the bCountDown input, the internal counter value is decremented by 1. As soon as the counter value specified in CounterLimit is reached, the bCounterOut output is set. When the counter value reaches 0, the bCounterZero output 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.

EL6900

The FB_COUNTER function block is not supported by the EL6900.

EL6900_COUNTER.png
Table 38. VAR_INPUT

Name

Data Type

Initial Value

Description, Parameter Values

bReset

BOOL

FALSE

Rising edge resets the counter to the PresetValue value.

bCountUp

BOOL

FALSE

Rising edge increments the internal counter value by 1.

bCountDown

BOOL

FALSE

Rising edge decrements the internal counter value by 1.

PresetValue

SAFELINT

0

Initialization value to which the counter is set at Reset.

Only a constant value is permitted (no variable)

CounterLimit

SAFELINT

0

When this value is reached, the bCounterOut output is set to TRUE.

Only a constant value is permitted (no variable)



Table 39. VAR_OUTPUT

Name

Data Type

Initial Value

Description, Parameter Values

bCounterOut

SAFEBOOL

FALSE

Set to TRUE when the internal counter value has reached the value of CounterLimit.

bCounterZero

SAFEBOOL

FALSE

Set to TRUE when the internal counter value is less than or equal to 0.

ActValue

SAFEUSINT

0

Current value of the internal counter value

Permitted data types: UINT, INT, UDINT, DINT

bError

SAFEBOOL

FALSE

TRUE: The ActValue output has an overflow or underflow.

FALSE: No error has occurred.