TO_TOD block

Short summary

Name

TO_TOD

→POU type

→function

Category

IEC-block, ConvertEnh, block with internal error diagnostic

Conform to →IEC-standard

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/414781153/TO_TOD-version-1-modificationdate-1534929960618-api-v2.png

Available since

version 1.65.0 (for logi.CAD 3)

Functionality

The blocks serves for explicitly converting the value connected to input IN into a value of data type TOD (= TIME_OF_DAY).

If the connected value is within the range of values overlapping for the data type of the input and for the result value TOD, the blocks returns this value. The conversion of the connected value is based on seconds, relative to the lower limit TOD#00:00:00 of TOD ( see under "Example for usage within ST-editor" and "Range of values for conversions" for lower and upper limits per data type).

Explicit conversion according to IEC-standard

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

LDATE_AND_TIME, DATE_AND_TIME, LTIME_OF_DAY

The data type LDATE_AND_TIME and LTIME_OF_DAY are 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:

TOD


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:

Internal error diagnostic for block

The block checks the data type of the value connected to input IN and the return value respectively, before the block is executed. The output ENO of the block is set to value FALSE (or an equivalent), in case of the data type DATE_AND_TIME with a date part outside of the the valid range of values (analogously to the TO_DATE block).

Example for usage within ST-editor

The calculated values are evaluated by using the Assert block .

FUNCTION_BLOCK ExampleToTOD
VAR
result : TOD;
END_VAR
result := TO_TOD(IN := SINT#12);
Assert(result = TOD#00:00:12);
END_FUNCTION_BLOCK

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.

Range of values for conversions

The range of values for the conversions is determined by the lower and upper of the data types. This lower and upper limit per data type is listed under "Supported data types (in ST)".
Keep the following in mind: Input values out of the quoted range of values are interpreted as seconds according to the table and return a return value < TOD#00:00:00 or ≥ TOD#24:00:00.


Data type
for IN

Lower limit

Upper limit

Literal for IN

Return value

Literal for IN

Return value

BOOL

0

TOD#00:00:00

1

TOD#00:00:01

BYTE

16#00

TOD#00:00:00

16#FF

TOD#00:04:15

DATE

any value

TOD#00:00:00

any value

TOD#00:00:00

DINT

0

TOD#00:00:00

86_399

TOD#23:59:59

DT

DT#1970-01-01-00:00:00

TOD#00:00:00

DT#1970-01-01-23:59:59.999

TOD#23:59:59.999

DWORD

16#0000_0000

TOD#00:00:00

16#0001_517F

TOD#23:59:59

INT

0

TOD#00:00:00

32_767

TOD#09:06:07

LINT

0

TOD#00:00:00

86_399

TOD#23:59:59

LREAL

LREAL#0.0

TOD#00:00:00

LREAL#86_399.999

TOD#23:59:59.999

LWORD

16#0000_0000_0000_0000

TOD#00:00:00

16#0000_0000_0001_517F

TOD#23:59:59

REAL

REAL#0.0

TOD#00:00:00

REAL#86_399.999

TOD#23:59:59.999

SINT

0

TOD#00:00:00

127

TOD#00:02:07

TIME

T#0s

TOD#00:00:00

T#23h59m59.999s

TOD#23:59:59.999

TOD

TOD#00:00:00

TOD#00:00:00

TOD#23:59:59.999_000_000

TOD#23:59:59.999

UDINT

0

TOD#00:00:00

86_399

TOD#23:59:59

UINT

0

TOD#00:00:00

65_535

TOD#18:12:15

ULINT

0

TOD#00:00:00

86_399

TOD#23:59:59

USINT

0

TOD#00:00:00

255

TOD#00:04:15

WORD

16#00

TOD#00:00:00

16#FFFF

TOD#18:12:15