UTC-Time LWORD format specification

The TwinCAT UTC-Time components are coded in LWORD in the following way:

Bit

Component

Type

Value range

Description

0..31

secondSinceEpoch

DT

0..16#FFFFFFFF

Number of whole seconds since January 1, 1970.

32..55

fractionOfSecond

T_UINT24

0..16#FFFFFF

Seconds fraction encoded as 24-bit number.

56

Quality.LeapSecondsKnown

BIT

0..1

Quality of the leap second (0:=unknown, 1:=known).

57

Quality.ClockFailure

BIT

0..1

Quality of the timer (0:=good, 1:=erroneous).

58

Quality.ClockNotSynchronized

BIT

0..1

Quality of the time synchronization (0:=synchronized, 1:=not synchronized).

59

Quality.Accuracy0

BIT

0..1

Accuracy of the time information (precision of the fraction of a second). The accuracy bits determine the number of significant bits of the T_UtcTime.fractionOfSecond component.

60

Quality.Accuracy1

BIT

0..1

61

Quality.Accuracy2

BIT

0..1

62

Quality.Accuracy3

BIT

0..1

63

Quality.Accuracy4

BIT

0..1

The UTC-Time.fractionOfSecond component is coded in the 24 bits of the type T_UINT24 in the following way:

Bit

Component

Value

0

fractionOfSecond[0].0

0.5 s

1

fractionOfSecond[0].1

0.25 s

2

fractionOfSecond[0].2

0.125 s

3

fractionOfSecond[0].3

0.0625 s

4

fractionOfSecond[0].4

0.03125 s

5

fractionOfSecond[0].5

0.015625 s

6

fractionOfSecond[0].6

0.0078125 s

7

fractionOfSecond[0].7

0.00390625 s

8

fractionOfSecond[1].0

0.001953125 s

9..15

fractionOfSecond[1].1..7

etc.

16..23

fractionOfSecond[2].0..7

-/-

Samples

The table below contains some fraction-of-a-second values and the values of the fractionOfSecond array elements after the conversion.

Fraction of a second

T_UINT24

Description

0 s

[0,0,0]

All bits have the value: 0.

0.75 s

[3,0,0]

Bits 0 and 1 are set. Value calculation: 0.5 s + 0.25 s = 0.75 s.

0.875 s

[7,0,0]

Bits 0, 1 and 2 are set. Value calculation: 0.5 s + 0.25 s + 0.125 s = 0.875 s.

0.5625 s

[9,0,0]

Bits 0 and 3 are set. Value calculation: 0.5 s + 0.0625 s = 0.5625 s.

Coding of the precision in the UTC-Time.Quality.Accuracy0..4 bits.

Precision

Accuracy0

Accuracy1

Accuracy2

Accuracy3

Accuracy4

E_UtcTimeAccuracy

0-bit

0

0

0

0

0

Zero

1-bit

0

0

0

0

1

_01

2-bit

0

0

0

1

0

_02

3-bit

0

0

0

1

1

_03

4-bit

0

0

1

0

0

_04

5-bit

0

0

1

0

1

_05

6-bit

0

0

1

1

0

_06

7-bit

0

0

1

1

1

_07

8-bit

0

1

0

0

0

_08

9-bit

0

1

0

0

1

_09

10-bit

0

1

0

1

0

_10

11-bit

0

1

0

1

1

_11

12-bit

0

1

1

0

0

_12

13-bit

0

1

1

0

1

_13

14-bit

0

1

1

1

0

_14

15-bit

0

1

1

1

1

_15

16-bit

1

0

0

0

0

_16

17-bit

1

0

0

0

1

_17

18-bit

1

0

0

1

0

_18

19-bit

1

0

0

1

1

_19

20-bit

1

0

1

0

0

_20

21-bit

1

0

1

0

1

_21

22-bit

1

0

1

1

0

_22

23-bit

1

0

1

1

1

_23

24-bit

1

1

0

0

0

_24

Impermissible

1

1

n

n

n

_25_invalid.._30_invalid

Not specified

1

1

1

1

1

Unspecified

Samples

The table below contains some LWORD values and the values after conversion to a formatted Binary-Time string and the structured type: T_UtcTime.

LWORD

STRING(39)

T_UtcTime

Description

16#0000000000000000

'UT#1970-01-01-00:00:00.000000000|000|0'

STRUCT(0)

All components have the value 0. Date: January 1, 1970. Time: 00:00:00. Fraction of a second: 0 ms. Precision: 0 bit.

16#C4000000386D4380

'UT#2000-01-01-00:00:00.000000000|001|3'

STRUCT(secondSinceEpoch:=DT#2000-01-01-00:00:00, fractionOfSecond:=[0,0,0], quality:=(ClockNotSynchronized:=1, Accuracy3:=1, Accuracy4:=1))

Date: January 1, 2000. Time: 00:00:00. Fraction of a second: 0 ms. Timer is not synchronized. Precision: 3-bit.

16#A4000001386D4380

'UT#2000-01-01-00:00:00.500000000|001|5'

STRUCT(secondSinceEpoch:=DT#2000-01-01-00:00:00, fractionOfSecond:=[1,0,0], quality:=(ClockNotSynchronized:=1, Accuracy2:=1, Accuracy4:=1))

Date: January 1, 2000. Time: 00:00:00. Fraction of a second: 500 ms. Timer is not synchronized. Precision: 5-bit.

16#81000000FFFFFFFF

'UT#2106-02-07-06:28:15.000000000|100|1'

STRUCT(secondSinceEpoch:=DT#2106-02-07-06:28:15, fractionOfSecond:=[0,0,0], quality:=(LeapSecondsKnown:=1, Accuracy4:=1))

Date: February 7, 2106. Time: 06:28:15. Fraction of a second: 0 ms. Leap seconds are unknown. Precision: 1-bit.

16#C2000007FFFFFFFF

'UT#2106-02-07-06:28:15.875000000|010|3'

STRUCT(secondSinceEpoch:=DT#2106-02-07-06:28:15, fractionOfSecond:=[7,0,0], quality:=(ClockFailure:=1, Accuracy3:=1, Accuracy4:=1))

Date: February 7, 2106. Time: 06:28:15. Fraction of a second: 875 ms. Timer signals an error. Precision: 3-bit.

16#1C000007FFFFFFFF

'UT#2106-02-07-06:28:15.875000000|001|24'

STRUCT(secondSinceEpoch:=DT#2106-02-07-06:28:15, fractionOfSecond:=[7,0,0], quality:=(ClockNotSynchronized:=1, Accuracy0:=1, Accuracy1:=1))

Date: February 7, 2106. Time: 06:28:15. Fraction of a second: 875 ms. Timer is not synchronized. Precision: 24-bit.