-

TO_WORD

Type Function
Description The overloaded function TO_WORD converts an input value of various data types into an output value of the data type WORD (see description of the input for the supported data types).
Parameters Input

IN

Output

OUT
Conversion rules
  • The conversion is done by copying the input value bitwise to the output value, i.e., a binary transfer from the input data type to the output data type is performed.
  • Input size > output size: If the input data type has a bigger size than the WORD output, only the bits 0 to 15 of the input value are considered.
  • Input size < output size: If the input data type is smaller than the WORD output, the "unused" bits of the WORD are set to FALSE (e.g. bits 8 to 15 for BYTE_TO_WORD or SINT_TO_WORD).
  • If the range and precision of the input data type can be mapped to the range and precision of the output type, an implicit type conversion can be performed instead of using this function.
    For the TO_WORD function, this applies to BOOL and BYTE inputs.
STRING conversion
Error behavior Error behavior
Examples Examples in ST
Additional information EN/ENO behavior