1. Read real-time clock TRD

1. Read real-time clock TRD

1.1. Instruction Description

The instruction reads the current time and date from the hardware clock and loads them into 8 consecutive time buffers starting from address T. Among them, the year is represented by 2 bytes.

T (Dn-Dn+7) Description Data
0 Year (2000-2099) Current Year
1 Month (1-12) Current month
2 Date (1-31) Current Date
3 Hour (0-23) Current Hour
4 Minutes (0-59) Current minute
5 seconds (0-59) current second
6 00 Reserved
7 What day of the week (0-6) The current day of the week, 0=Sunday

1.1.1. Setting and using BCD format

1) In 【 Project Settings 】=>【 Other 】=>【 Real time Clock Detection 】, select 【 BCD Code 】.

(2)Under this setting, the data of the TRD instruction will be represented in BCD code format. For example, 2020 will be represented as hexadecimal H2020.

1.1.2. Setting and using decimal format

(1)In 【 Project Settings 】=>【 Other 】=>【 Real time Clock Detection 】, select 【 Decimal 】.

(2)Under this setting, the data of TRD instruction will be represented as usual and BCD code will not be used.

1.1.3. Attention:

  1. Oue HMI+PLC All-in-one could not use the function below

1.2. The valid operands of the instruction

Input/Output Data Type operand Description
D 16 bit integer D Time

1.3. Example (decimal format)

Command table

NETWORK 000

LD X000

ANDP M1020

TRD D0 // 时间读入到D0~D7,假设当前时间是(2020/05/01,12:30:20)

MOV D0 D100 // 年份,D100=2020

MOV D1 D101 // 月份,D101=5

MOV D2 D102 // 日期,D102=1

MOV D3 D103 // 小时,D103=12

MOV D4 D104 // 分钟,D104=30

MOV D5 D105 // 秒,D105=20

MOV D7 D106 // 星期五,D106=5

TRD11

图1 TRD11

TRD12

图2 TRD12

1.4. 实例(BCD格式)

指令表

NETWORK 000

LD X000

ANDP M1020

TRD D0//Read time into D0~D7, assuming the current time is (2020/05/01, 12:30:20)

BIN D0 D100//Year, D100=2020

BIN D1 D101//Month, D101=5

BIN D2 D102//Date, D102=1

BIN D3 D103//hour, D103=12

BIN D4 D104//minute, D104=30

BIN D5 D105//seconds, D105=20

BIN D7 D106//Friday, D106=5

TRD21

图3 TRD21

TRD22

图4 TRD22