Minimum value
MIN detects the input variable with the lowest value.
Input
1st input: value 1
2nd input: value 2
Output
result, whichever input variable's value is smallest
This function can be expanded to a maximum of 28 input contacts, see also modifying elements.
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
value_1: INT:=0;
(*all types allowed*)
value_2: INT:=0;
(*all types allowed*)
minimum_value: INT:=0;
(*all types allowed*)
END_VAR
In this example the input variables (value_1 and value_2) have been declared. Instead, you may enter a constant directly at the input contact of a function.
Value_1 and value_2 are compared with each other. The lower value of the two is written into minimum_value.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_VARIN,,value_1,7,0,9,2,);
B(B_VARIN,,value_2,7,1,9,3,);
B(B_VAROUT,,minimum_value,14,0,16,2,);
B(B_F,MIN-2!,Instance,9,0,14,3,,?D?D?C);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
minimum_value:=MIN(value_1, value_2);
LD |
value_1 |
MIN |
value_2 |
ST |
minimum_value |