CNT_UPDN: Upward & downward counter
The CNT_UPDN (FB446) block forms a slope-controlled upward/downward counter.
Functionality
The block at the upward counter input [CntUp] counts upward to max the counter limit [CntValLm] on an increasing slope, or downward at the downward counter input [CntDn] to the lower counter limit 0. The counting increments are 1.
When the upper counter limit is reached, the counter stops and [LmRd] = 1 (Yes) is set.
When the lower counter limit is reached, the counter stops and [ZeRd] = 1 (Yes) is set.
If the block has increasing slopes at inputs [CntUp] and [CntDn], the counter keeps its value.
The present counter value is at output [CntVal], the present counter states at output [LmRd] (upper limit reached [CntValLm] or exceeded), or [ZeRd] (counter value 0 reached or dropped below).
If the upper counter limit is exceeded because the counter started at a start value above the limit, or because the upper limit was set to a value below the present counter value, then [LmRd] = 1 (Yes). For further counter pulses at input [CntUp], the counter retains its present counter value; counting downward via counter pulses at input [CntDn] remains possible.
Reset the counter via the reset input [CntReset]. If [CntReset] 1 (Yes), then the counter is set to 0.
The counter can also be set to a start value [SttVal]. [SttVal] represents the present counter value if [SetStt] is 1 (Yes). If there is a negative counter start value [SttVal], value "0" is set for the counter at the [SetStt] signal ([SetStt] = 1).
Caution
- [SetStt] and [CntReset] are not slope-controlled.
- When using this block, remember that the counter can be incremented or decremented only after the second machine cycle because of slope control.
The counter can accept values above the counter upper limit [CntValLm], as values above [CntValLm] are possible for the counter start value [SttVal]. The upper counter limit [CntValLm] allows for negative values. The number of possible counting increments to reach the counter limit depends on the start value (or [CntReset]), the counting direction, the present counter value, and if the present counter value is above the counter limit.
When starting a new upward counting process, [CntReset] and [CntUp] can be performed simultaneously. The counter is initialized accordingly and upward counting begins.
When starting a new downward counting process, [CntDn] and [SetStt] can be performed simultaneously. The counter is initialized accordingly and downward counting begins.
If there is a simultaneous [CntReset], it has priority.
Inputs
Pin | E | Description |
CntUp | p | Count up |
CntDn | p | Count down |
CntReset | p | Reset counter. |
CntValLm | pa | Counter limit. |
SetStt | pa | Set start value. |
SttVal | pa | Start value. |
Outputs
Pin | E | Description |
CntVal | a | Counter value |
LmRd | a | Limit reached. |
ZeRd | a | Zero reached |
Input values
Pin | Description | Data type | Default value | E.g. Engineering unit or Text group | Min. | Max. |
CntUp | Count up. | Boolean | 0 (No) | No, Yes |
|
|
CntDn | Count down. | Boolean | 0 (No) | No, Yes |
|
|
CntReset | Reset counter. | Boolean | 0 (No) | No, Yes |
|
|
CntValLm | Counter value limit. | Integer | 0 |
|
|
|
SetStt | Set start value. | Boolean | 0 (No) | No, Yes |
|
|
SttVal | Start value. | Integer | 0 |
|
|
|
Output values
Pin | Description | Data type | Default value | E.g. Engineering unit or Text group | Min. | Max. |
CntVal | Counter value. | Integer | 0 |
|
|
|
LmRd | Limit reached. | Boolean | 0 (No) | No, Yes |
|
|
ZeRd | Zero reached | Boolean | 0 (No) | No, Yes |
|
|
Application
The block is used to count events which can be evaluated via a slope. These for examples are switches of twin-actuators (pumps, fans, compressors) in order to change the control aggregate as per a defined order. Additionally, maintenance messages can be generated in dependence of these switches.
Process response
The block is processed with the values at the inputs from the second process cycle onward, as the values at the inputs are considered valid only then. Default values are issued during the first process cycle.
Note: A continuous signal at input [CntUp] or [CntDn] is recognized as an increasing slope on startup.
Troubleshooting
Standard (see General rules and information).