BCD data addition
This FP instruction adds two BCD data specified by s1 and s2 if the trigger EN is TRUE. The result is stored in d.
Input
Output
Sum
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*)
dwSummand1: DWORD:=16#12342000;
(*summand at input s1 is added to summand at input s2*)
dwSummand2: DWORD:=16#00003678;
dwResult: DWORD;
(*result after 0->1 leading
edge from start:
16#12345678*)
END_VAR
When the variable bStart changes from FALSE 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_ADD_BCD!,,15,1,23,6,,?DEN?D@'s1'?Ds2?AENO?Cd);
B(B_CONTACT,,bStart,8,2,10,4,R);
B(B_VARIN,,dwSummand1,13,3,15,5,);
B(B_VARIN,,dwSummand2,13,4,15,6,);
B(B_VAROUT,,dwResult,23,3,25,5,);
L(1,3,8,3);
L(10,3,15,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart) then
FP_ADD_BCD(dwSummand1, dwSummand2, dwResult);
END_IF;