TO_TIME block

Short summary

Name

TO_TIME

→POU type

→function

Category

IEC-block, Convert

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg implementer-specific realization ; see "Functionality"

and

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/error.svg currently restricted and images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg more possible than defined in IEC-standard;
see "
Explicit conversion according to IEC-standard"

Graphical interface

images/download/thumbnails/414781148/TO_TIME-version-1-modificationdate-1534929941304-api-v2.png

Available since

  • version 1.0.0 (for logi.CAD 3) – initial variant

  • version 1.66.0 (for logi.CAD 3) – enhancement: DATE_AND_TIME, DATE and TIME_OF_DAY for IN

Functionality

The blocks serves for explicitly converting the value connected to input IN into a value of data type TIME.

If the connected value is within the range of values overlapping for the data type of the input and for the result value TIME, the blocks returns this value.

Implementer-specific realization

The IEC-standard defines that it is an error when the connected value is not within the range of values overlapping for the data type of the input and for the data type of the return value as well as that the behavior in the case of such an error is implementer specific. The general behavior of the conversion blocks in logi.CAD 3 is as follows: The non-overlapping value range is not considered to be an error. Moreover, the following is valid:

  • If the connected value is of a data type not being REAL or LREAL: T he higher bytes (= bytes not within the range of values) are truncated.

  • If the connected value is of the data type REAL or LREAL: The return value of the block depends on the compiler and target system (see "Effects of the compiler settings on the execution" for details).

Observe as well:

  • If a value of data type DATE_AND_TIME or DATE is connected to the input, this value is converted to seconds, relative to the lower limit D#1970-01-01 of DATE and the lower limit DT#1970-01-01-00:00:00.000_000_000 of DATE_AND_TIME respectively.

  • If converting data types to the TIME data type and vice versa, the conversion is always based on seconds.

Explicit conversion according to IEC-standard

The IEC-standard defines an explicit conversion of the following data types to TIME:

LTIME

This data type LITME is currently not supported in logi.CAD 3.

Inputs, return value


Identifier

→Data type

Description

Inputs:

IN

REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY

value to be converted

Return value:

TIME


Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
VAR
result : TIME;
END_VAR
result := TO_TIME(IN := SINT#12); (* The variable 'result' evaluates to value 'T#12s' of TIME. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.