Description
You use the "Count down" instruction to decrement the value of the specified counter by the count of one on a rising edge at the start input. The count is decremented until the limit of "0" is reached. When the limit is reached, the counter value is no longer changed on a positive signal edge.
The "Count down" instruction needs a preceding logic operation for the edge evaluation and can only be placed on the right edge of the network.
Parameters
The following table shows the parameters of the "Count down" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|---|---|---|---|---|
|
<operand> |
Input |
BOOL |
I, Q, M, T, C, D, L |
Start input |
|
<counter> |
InOut/Input |
COUNTER |
C |
Counter whose value is decremented. |
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
When the signal state of the operand "TagIn_1" changes from "0" to "1" (positive signal edge), the counter "Counter_1" is preset with the value "100".
The value of "Counter_1" is incremented by the count of one when the signal state of the "TagIn_2" operand changes from "0" to "1".
If the "TagIn_3" operand returns signal state "1", the value of "Counter_1" is reset to "0".