Decrement
This FP instruction subtracts 1 from the 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
start: BOOL:=FALSE;
(*activates the function*)
decrement_value: DINT:=131081;
(*result after a 0->1 leading
edge from start: 16*)
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 := 5 ;
NETWORK_BODY
B(B_F,FP_DEC!,,14,1,20,5,,?DEN?Dd?Ad?AENO);
B(B_CONTACT,,start,4,2,6,4,R);
B(B_VARIN,,decrement_value,12,3,14,5,);
B(B_VAROUT,,decrement_value,20,3,22,5,);
L(1,3,4,3);
L(6,3,14,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(start) then
FP_DEC(decrement_value);
END_IF;