8-digit BCD addition
The 8-digit BCD equivalent constant or 8-digit BCD data specified by s and the 8-digit BCD data specified by d are added together if the trigger EN is in the ON-state. The result is stored in d.
Input
Addend, 32-bit area for 8-digit BCD data or equivalent constant
Output
Augend and result, 32-bit area for 8-digit BCD data
Instead of using this F instruction, we recommend using the corresponding FP7 instruction: FP_ADD_BCD
When this instruction is used, the area for the augend d is overwritten by the added result. If you want to avoid the overwrite, we recommend using the instruction F43_DBADD2.
if the calculated result is 0.
if the result exceeds the range of 8-digit BCD data (overflow).
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
start: BOOL:=FALSE;
(*activates the function*)
summand: DWORD:=16#12342000;
(*this value will be added
to the output_value*)
output_value: DWORD:=16#00003678;
(*result after 0->1 leading
edge from start:
16#12345678*)
END_VAR
When the variable start 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_VARIN,,summand,10,2,12,4,);
B(B_VAROUT,,output_value,21,2,23,4,);
B(B_F,F41_DBADD!,Instance,12,0,19,4,,?DEN?D@'s'?AENO?Cd);
B(B_CONTACT,,start,8,1,10,3,R);
L(19,3,21,3);
L(1,2,8,2);
L(10,2,12,2);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(start) then
F41_DBADD(summand, output_value);
END_IF;