Counter Function Block

The Counter function block counts the inputs leading-edge transitions.

If the enable is "true" and the input transitions from "false" to "true", then count is incremented or decremented.

If preset is set to "true", count equals preset value. The function block keeps track of the previous state of the input from iteration to iteration so that it can detect a transition. This is cleared upon power-up or reset.

Figure 1: Counter Function Block

Figure 2: Counter Property Sheet

Inputs

Input Name

Description

Input

Numeric: Binary Point value 0-1, Default: Null

Enable

 

Numeric: Binary value: 0-1, Default: Null

Preset

Preset input will set the counter to preset value

Numeric: Binary value: 0-1, Default: Null

Presetvalue

Numeric: 32 Bit Floating value: >=-inf-<inf, Default: Null

Count value

Counter will increment or decrement by this value. Positive value is used to increment, and negative value is used to decrement.

Numeric: 32-Bit floating value: >=-inf-<inf, Default: Null

Stop at Zero

The counter will stop counting when this input is enabled.

Numeric: Binary value: 0-1, Default: Null

Table 1: Inputs of Counter Function

Output

Output Name

Description

Count

Counter value

Table 2: Output of Counter Function

Parameters

Parameter Name

Description

Input

(In & Par)

Numeric: Binary Point value 0-1, Default: Null.

Enable

(In & Par)

Numeric: Binary value: 0-1, Default: Null.

Preset

(In & Par)

Preset input will set the counter to preset value

Numeric: Binary value: 0-1, Default: Null.

Presetvalue

(In & Par)

Numeric: 32 Bit Floating value: >=-inf-<inf, Default: Null.

Count value

(In & Par)

 

Counter will increment or decrement by this value. Positive value is used to increment, and negative value is used to decrement.

Numeric: 32-Bit floating value: >=-inf-<inf, Default: Null.

Stop at Zero

(In & Par)

The counter will stop counting when this input is enabled.

Numeric: Binary value: 0-1, Default: Null.

Out Save

Master Sync Enabled : If you set it to "true" the last output will be set as output for one cycle after the controller restarts. The application can use it to return to the same state before the controller restart.

Count: To enable or disable the Count feature.

Table 3: Parameters of Counter Function

Figure 3: Counter Behavior Diagram

Examples:

Incremental counter from Preset value of 5 and counter value of 1. The count value increased from 5 to 6.

Decremental counter from Preset value of 5 and counter value of -1. The count value decreased from 5 to 4. The counter value will stop at 0.

Refer to General Description for general information about IRM N4 Function Blocks.