Remainder of BCD data division
This FP instruction calculates the remainder of a BCD data division where the value specified by s1 is divided by s2. The remainder is stored in d.
Input
Dividend, divisor
Output
Remainder
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 fuction*)
dwDividend: DWORD:=16#00001110;
(*dividend*)
dwDivisor: DWORD:=16#00000047;
(*divisor*)
dwRemainder: DWORD:=0;
(*result after 0->1 leading edge
from start: 16#00000029*)
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_VARIN,,dwDividend,12,3,14,5,);
B(B_VARIN,,dwDivisor,12,4,14,6,);
B(B_VAROUT,,dwRemainder,22,3,24,5,);
B(B_F,FP_MOD_BCD!,,14,1,22,6,,?DEN?D@'s1'?Ds2?AENO?Cd);
B(B_CONTACT,,bStart,10,2,12,4,);
L(1,3,10,3);
L(12,3,14,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF (bStart) then
FP_MOD_BCD(s1 := dwDividend,
s2 := dwDivisor,
d => dwRemainder);
END_IF;