CNT_DN: Downward counter
The CNT_DN (FB445) block is a slope-controlled downward counter with lower counter limit 0.
Functionality
If an increasing slope exists at input "Count down" [CntDn], the "CNT_DN" block reduces the counter value [CntVal] by one. The counting increments are 1.
Note: In order to recognize a slope, the block must pass two machine cycles. As a result, the counts occur at the earliest after the second machine cycle.
Counter limit.
- If the counter value reaches or drops below the counter limit 0, output "Zero reached" [ZeRd] = 1 (Yes) is set and the downward counter is stopped.
- If a negative counter start value [SttVal] is present and a falling slope at [SetStt], the counter [CntVal] = 0 and [ZeRd] = 1 (Yes) is set.
- The number of possible counting increments to the counter limit depends on the start value [SttVal] (or [CntReset]) and the counter value.
Reset counter
- If the input "Reset counter" is [CntReset] = 1 (Yes), the counter value remains at [CntVal] = 0 (not slope-controlled).
- A new counter process can be started simultaneously with [SetStt] and [CntDn]. In case of a dropping slope at [SetStt], the counter is initialized and counted down.
- If there is a simultaneous [CntReset], it has priority.
Set start value.
- If the input "Set start value" is [SetStt] = 1 (Yes), the counter value remains at [CntVal] = [SttVal] (not slope-controlled).
- If [SetStt] = 0 (No), the counter starts at start value [SttVal].
- If the start value [SttVal] is negative, the counter starts at value "0".
Inputs
Pin | E | Description |
CntDn | p | Count down |
CntReset | p | Reset counter. |
SetStt | pa | Set start value. |
SttVal | pa | Start value. |
Outputs
Pin | E | Description |
CntVal | a | Counter value |
ZeRd | a | Zero reached |
Input values
Pin | Description | Data type | Default value | E.g. Engineering unit or Text group | Min. | Max. |
CntDn | Count down. | Boolean | 0 (No) | No, Yes |
|
|
CntReset | Reset counter. | Boolean | 0 (No) | No, Yes |
|
|
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 |
|
|
|
ZeRd | Zero reached | Boolean | 0 (No) | No, Yes |
|
|
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] is recognized as an increasing slope on startup.
Troubleshooting
Standard (see General rules and information).