Digit distribution
This FP instruction disintegrates the input value at s into the number of digits specified at n_Digits and distributes the digits to the addresses starting at d_Start.
Input
Input value
Number of digits to be distributed, range: 0–4
For n_Bytes=0, the instruction is not executed
Output
Starting address of the data area for the results. The size is n_Bits * 2 words.
if the area specified using the index modifier exceeds the limit.
if the value at n_Bytes is out of range
if the value at n_Bytes yields a result which is greater than the data area specified by d_Start
if the area specified using the index modifier exceeds the limit.
if the value at n_Bytes is out of range
if the value at n_Bytes yields a result which is greater than the data area specified by d_Start
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:=TRUE;
wData_input: WORD:=16#7310;
awOutput_distrib: ARRAY [0..3] OF WORD:=[4(0)];
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_DIVIDE_DIGITS!,,9,0,19,5,,?DEN?D@'s'?Dn_Digits?AENO?Cd_Start);
B(B_CONTACT,,bStart,4,1,6,3,);
B(B_VARIN,,wData_input,7,2,9,4,);
B(B_VARIN,,4,7,3,9,5,);
B(B_VAROUT,,awOutput_distrib[0],19,2,21,4,);
L(6,2,9,2);
L(1,2,4,2);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
If (bStart) then
FP_DIVIDE_DIGITS(s := wData_input, n_Digits := 4, d_Start => awOutput_distrib[0]);
End_if;