-

*_TO_BUF

Type Function block
Description Copies elementary data types from a variable, an array or elements of a user-defined structure to a byte stream. Little-/Big-Endian format is possible for the byte stream. Therefore an automatic data format conversion is supported.

This function block is useful for the data transfer or the communication among applications which are executed on different hardware platforms (Little-/Big-Endian).

Operation

After a rising edge has been put to the REQ input, the copy process starts. As defined in the BUF_FORMAT parameter, the data are converted into Little-/Big-Endian format. The size of the destination BUFFER is checked before copying.

After the copy process has finished correctly, DONE is set to TRUE. In case of any occurred errors, ERROR is set to TRUE and STATUS gets a value unequal to zero which represents the current error message. These values are kept until a falling edge is put to the REQ input. A new rising edge at REQ starts a new copy process.

Timing diagram
Notes
  • ' * ' is a placeholder for the supported data types. The FB is available for the data types BYTE, WORD, DWORD, LWORD, SINT, INT, DINT, LINT, UDINT, UINT, ULINT, USINT, TIME, REAL, LREAL, STRING, WSTRING, LTIME, LDATE, LTOD, and LDT.
  • For the STRING/WSTRING data type the operation is different to the following described. For information about the handling of the STRING_TO_BUF/WSTRING_TO_BUF function block click here.
  • It is not allowed to use the same addresses for the source and the destination.
  • Function blocks have to be instantiated. The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used. The instance name must be unique within the POU.
Parameters Inputs

REQ

BUF_FORMAT

BUF_OFFS

BUF_CNT

Input/Output

SRC

BUFFER

Outputs

DONE

ERROR

STATUS
Additional information