Byte distribution
This FP instruction disintegrates the input value at s into the number of bytes specified at n_Bytes and distributes the bytes to the addresses starting at d_Start.
Input
Input value
Number of bytes to be distributed, range: 0–65535
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
The bit data equivalent to 16#C405F134 is disintegrated into 4 bytes.
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;
dwSourceData: DWORD:=16#C405F134;
iNumberOfBytes: INT:=4;
wResult: WORD:=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 := 6 ;
NETWORK_BODY
B(B_F,FP_DIVIDE_BYTES!,,14,1,24,6,,?DEN?D@'s'?Dn_Bytes?AENO?Cd_Start);
B(B_VARIN,,dwSourceData,12,3,14,5,);
B(B_VARIN,,iNumberOfBytes,12,4,14,6,);
B(B_VAROUT,,wResult,24,3,26,5,);
B(B_CONTACT,,bStart,5,2,7,4,);
L(7,3,14,3);
L(1,3,5,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF (bStart) then
FP_DIVIDE_BYTES(s := dwSourceData,
n_Bytes := iNumberOfBytes,
d_Start => wResult);
END_IF;