AKF_ZR: Decremental counter
Original instructions
Function description
The derived function block is used for downwards counting.
With a "1"signal at the R input, the actual value and the Q output are set to"0".
With a 0 -> 1 edge at the S input, the SW input accepts the setpoint value which is then displayed at the ZSWO output. The actual value is set to the setpoint value. A comparison of setpoint value/actual value will not take place until a setpoint value has been accepted at least once.
The Q output is set to "1" if the actual value is greater than "0" and less than the setpoint value.
Given a 0 -> 1 edge at the IN input, the actual value (ZIWO) is decreased by 1 (to 0 as a minimum) and compared to the setpoint value (ZSWO).
The ZIW and ZSW inputs can be used to change the setpoint value (ZSW) and the actual value (ZIW) online.
NOTE: In order for the counter to work correctly, the variable (actual value) which is established at ZIW must also be established at ZIWO. The variable (setpoint), which is established at ZSW has also to be established at ZSWO.
EN and ENO can be configured as additional parameters.
Formula
Q = 1, if 0 < ZIWO < ZSWO
Representation in FBD
Representation:
Representation in LD
Representation:
Representation in IL
Representation:
CAL AKF_ZR_Instance (IN:=TriggerInput, S:=SetInput,
    SW:=PresetSetpointValue, R:=ResetInput,
    ZIW:=InternalCurrentValueControl,
    ZSW:=InternalSetpointValueControl, Q=>Output,
    ZIWO=>DisplayCurrentValue, ZSWO=>DisplaySetpointValue)
Representation in ST
Representation:
AKF_ZR_Instance (IN:=TriggerInput, S:=SetInput,
    SW:=PresetSetpointValue, R:=ResetInput,
    ZIW:=InternalCurrentValueControl,
    ZSW:=InternalSetpointValueControl, Q=>Output,
    ZIWO=>DisplayCurrentValue, ZSWO=>DisplaySetpointValue) ;
Parameter description
Description of input parameters:
Parameter
Data type
Description
IN
Trigger input
S
BOOL
Set input
SW
Preset setpoint value
R
BOOL
Reset input
ZIW
INT
Control of the internal actual value
ZSW
INT
Control of internal setpoint value
Description of output parameters:
Parameter
Data type
Description
Q
BOOL
Output
ZIWO
INT
Count value (display of actual value)
ZSWO
INT
Display of setpoint value
NOTE: the same variable should be assigned to the pin ZIW and ZIWO and the same variable should be assigned to the Pin ZSW and ZSWO also, or the function block can't execute normally.
Timing diagram
Timing diagram for AKF_ZR backwards counter:
(1) 
If S becomes "1" and R is "0", the preset setpoint value SW is accepted and displayed at the ZSWO output.
(2) 
If IN becomes "1", the actual counter value is decreased by "1" and Q set to "1".
(3) 
If IN becomes "1", the current counter value is decreased by "1".
(4) 
If IN becomes "1", the current counter value is decreased by "1". If this causes the counter value (ZIWO) to become "0", the Q output is set to "0".
(5) 
If R becomes "1", the current counter value is set to "0".
(6) 
If S becomes "1" and R is "0", the preset setpoint value SW is accepted and Q is set to "0".