Multiply
MUL multiplies the values of the input variables with each other and writes the result into the output variable.
Input
1st input: multiplicand
2nd input: multiplicator
Output
Output as input: result
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
enable: BOOL:=FALSE;
multiplicand: INT:=0;
multiplicator: INT:=0;
result: INT:=0;
END_VAR
In this example the input variables (multiplicand, multiplicator and enable) have been declared. Instead, you may enter constants directly into the function (enable input e.g. for tests).
If enable is set (TRUE), the multiplicant is multiplied with the multiplicator. The result will be written into result.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 8 ;
NETWORK_BODY
B(B_F,E_MUL-2!,Instance,8,1,14,6,,?DEN?D?D?AENO?C);
B(B_VARIN,,multiplicand,6,3,8,5,);
B(B_VARIN,,multiplicator,6,4,8,6,);
B(B_VAROUT,,result,14,3,16,5,);
B(B_CONTACT,,enable,3,2,5,4,);
L(1,3,3,3);
L(5,3,8,3);
L(1,0,1,8);
END_NETWORK_BODY
END_NET_WORK
END_BODY