BCD data multiplication
This FP instruction multiplies the BCD data specified by s1 and s2 if the trigger EN is TRUE. The result is stored in d.
Input
Multiplicand
Multiplier
Output
Product
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
bStart: BOOL:=FALSE;
(*activates the function*)
dwMultiplicand: DWORD:=16#00000010;
(*multiplicant*)
dwMultiplicator: DWORD:=16#00000666;
(*multiplicator*)
dwResult: DWORD:=0;
(*result after a 0->1 leading
edge from start: 16#00006660*)
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_F,FP_MUL_BCD!,,14,1,22,6,,?DEN?D@'s1'?Ds2?AENO?Cd);
B(B_CONTACT,,bStart,7,2,9,4,);
B(B_VARIN,,dwMultiplicand,12,3,14,5,);
B(B_VARIN,,dwMultiplicator,12,4,14,6,);
B(B_VAROUT,,dwResult,22,3,24,5,);
L(9,3,14,3);
L(1,3,7,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF (bStart) then
FP_MUL_BCD(s1 := dwMultiplicand, s2 := dwMultiplicator, d => dwResult);
END_IF;