Conversion instructions
214
Part II IEC Instructions
DWORD_TO_STRING
DOUBLE WORD into STRING
Generates a result string in right-aligned decimal representation, filled with leading spaces up to
the predefined maximum number of characters.
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
Input Output defined as Results in
STRING[2] 'FE'
STRING[4] 'EFFE'
STRING[6] 'CDEFFE'
STRING[8] 'ABCDEFFE'
STRING[10] '00ABCDEFFE'
STRING[12] '0000ABCDEFFE'
16#ABCDEFFE
and so on...
PLC types
Availability of DWORD_TO_STRING (see page 1319)
When using the data type STRING with small PLCs like FP-e or FP0,
make sure that the length of the result string is equal to or greater than
the length of the source string.
For further information refer to the online help: Upgrade Problems with
Data Type STRING
Data type I/O Function
DWORD input input data type
STRING output conversion result
Description
The function DWORD_TO_STRING converts a value of the data type DWORD to a value of the
data type STRING.
Explanation
Data types
Example 1
In this example, the same POU header is used for all programming languages. For an example
using IL (instruction list), please refer to the online help.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
The input variable DWORD_value of the data type DWORD is intialized by the value
16#ABCDEFFE. The output variable result_string is of the data type STRING[10]. It can store a
maximum of 10 characters. Instead of using the variable DWORD_value, you can enter a constant
directly at the function’s input contact in the body.
Body
The DWORD_value of the data type DWORD is converted into STRING[10]. The converted value
is written to result_string. When the variable DWORD_value = 16#ABCDEFFE, result_string
shows '00ABCDEFFE'.