4-digit BCD division, destination can be specified
The 4-digit BCD equivalent constant or the 16-bit area for 4-digit BCD data specified by s1 is divided by the 4-digit BCD equivalent constant or the 16-bit area for 4-digit BCD data specified by s2 if the trigger EN is in the ON-state.
Input
Dividend, 16-bit area for BCD data or 4-digit BCD equivalent constant
Divisor, 16-bit area for BCD data or 4-digit BCD equivalent constant
Output
Quotient, 16-bit area for BCD data (remainder stored in the system variable sys_iDivRemainder
The quotient is stored in the area specified by d and the remainder is stored in the system variable sys_iDivRemainder.
if the calculated result is 0.
Instead of using this F instruction, we recommend using the corresponding FP7 instruction: FP_MOD_BCD, FP_DIV_MOD_BCD, FP_DIV_BCD
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 fuction*)
dividend: WORD:=16#0037;
(*dividend*)
divisor: WORD:=16#0015;
(*divisor*)
output_value: WORD:=0;
(*result after 0->1 leading edge
from start: 16#0002*)
END_VAR
When the variable start 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_CONTACT,,start,5,1,7,3,);
B(B_VARIN,,dividend,7,2,9,4,);
B(B_VARIN,,divisor,7,3,9,5,);
B(B_VAROUT,,output_value,15,2,17,4,);
B(B_F,F52_BDIV!,Instance,9,0,15,5,,?DEN?D@'s1'?Ds2?AENO?Cd);
L(1,2,5,2);
L(7,2,9,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
END_BODY
IF start then
F52_BDIV(dividend, divisor, output_value);
END_IF;
LD |
start |
(* EN = start; Starting signal for the F52_BDIV function. *) |
F52_BDIV |
dividend, divisor, output_value |
(* s1 = dividend (source1) *) (* s2 = divisor (source2) *) (* d = output_value (destination) *) |
(* s1 / s2 = d *) |
||
ST |
out |
(* option *) |