FP_DIVIDE_BYTES

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.

Parameters

Input

s (BOOL, WORD, DWORD)

Input value

n_Bytes (INT, DINT, UINT, UDINT)
  • Number of bytes to be distributed, range: 0–65535

  • For n_Bytes=0, the instruction is not executed

Output

d_Start (WORD)

Starting address of the data area for the results. The size is n_Bits * 2 words.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • 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

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • 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

Example

The bit data equivalent to 16#C405F134 is disintegrated into 4 bytes.

  1.  (1) Offset 0
  2.  (2) Offset 1
  3.  (3) Offset 2
  4.  (4) Offset 3

Example

POU header

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

POU body

When the variable bStart is set to TRUE, the function is carried out.

LD body

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

ST body

IF (bStart) then
    FP_DIVIDE_BYTES(s := dwSourceData,
                    n_Bytes := iNumberOfBytes,
                    d_Start => wResult);
END_IF;

Modified on: 2019-04-17Feedback on this pagePanasonic hotline