Conversion instructions
204
Part II IEC Instructions
REAL_TO_TIME
REAL into TIME
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.
PLC types
Availability of REAL_TO_TIME (see page 1330)
Data type I/O Function
REAL input input data type
TIME output conversion result
Description
REAL_TO_TIME converts a value of the data type REAL to a value of the data time TIME. 10ms of
the data type TIME correspond to 1.0 REAL unit, e.g. when REAL = 1.0, TIME = 10ms; when
REAL = 100.0, TIME = 1s. The value of the data type real is rounded off to the nearest whole
number for the conversion.
Data types
Example
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. Since constants are entered directly at the
function's input contact pins, only the output variable need be declared in the header.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
Body
By clicking on the monitor icon while in the online mode, you can see the result 0.00ms
immediately. Since the value at the REAL input contact is less than 0.5, it is rounded down to 0.0.
LD
ST
When programming with structured text, enter the following:
result_time:= REAL_TO_TIME(0.499);