AKF_ZVR: Incremental/decremental counter
Original instructions
Function description
The derived function block is used for incrementing/decrementing.
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 does not change. 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 or equal to the setpoint.
In the case of -> 1 edge at the IN_F input, the actual value (ZIWO) is increased by 1 and compared to the setpoint value (ZSWO).
In the case of -> 1 edge at the IN_B input, the actual value (ZIWO) is decreased by 1 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 ZIWOZSWO
Representation in FBD
Representation:
Representation in LD
Representation:
Representation in IL
Representation:
CAL AKF_ZVR_Instance (IN_F:=TriggerInputIncrementing,
    IN_B:=TriggerInputDecrementing, S:=SetInput,
    SW:=PresetSetpointValue, R:=ResetInput,
    ZIW:=InternalCurrentValueControl,
    ZSW:=InternalSetpointValueControl, Q=>Output,
    ZIWO=>DisplayCurrentValue, ZSWO=>DisplaySetpointValue)
Representation in ST
Representation:
AKF_ZVR_Instance (IN_F:=TriggerInputIncrementing,
    IN_B:=TriggerInputDecrementing, S:=SetInput,
    SW:=PresetSetpointValue, R:=ResetInput,
    ZIW:=InternalCurrentValueControl,
    ZSW:=InternalSetpointValueControl, Q=>Output,
    ZIWO=>DisplayCurrentValue, ZSWO=>DisplaySetpointValue) ;
Parameter description
Description of the input parameters:
Parameters
Data type
Meaning
IN_F
Trigger input, incrementing
IN_B
BOOL
Trigger input, decrementing
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 the output parameters:
Parameters
Data type
Meaning
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 Incremental counter AKF_ZVR
(1) 
If IN_F becomes "1" and R is "0", the current value is increased by "1".
(2) 
If IN_B becomes "1" and R is "0", the actual value is decreased by "1".
(3) 
If S becomes "1", the preset setpoint value is accepted.
(4) 
If IN_F becomes "1" and R is "0", the current value is increased by "1". If this causes the actual value to reach the setpoint value, Q is set to "1".
(5) 
If R becomes "1", the actual value and Q are set to "0".
(6) 
If IN_B becomes "1" and R is "0", the actual value is decreased by "1". If this causes the actual value to fall below the setpoint value, Q is set to "0".
(7) 
If IN_B becomes "1" and R is "0", the actual value is decreased by "1". If this causes the actual value to reach the setpoint value, Q is set to "1".