BCD data decrement
This FP instruction subtracts 1 from the BCD data specified by d if the trigger EN is TRUE. The result is stored in d.
Input/output
Data to be decremented by 1 and 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
bStart: BOOL:=FALSE;
(*activates the function*)
dwDecrement_value: DWORD:=16#87654322;
(*result after a 0->1 leding
edge from start:
16#87654321*)
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 := 5 ;
NETWORK_BODY
B(B_F,FP_DEC_BCD!,,18,1,26,5,,?DEN?Dd?Ad?AENO);
B(B_CONTACT,,bStart,12,2,14,4,R);
B(B_VARIN,,dwDecrement_value,14,3,16,5,);
L(1,3,12,3);
L(14,3,18,3);
L(16,4,18,4);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
If DF(bStart) then
FP_DEC_BCD(d := dwDecrement_value);
End_if;