DVP - ES2/EX2/SS2/SA2/SX2/SE Operation Manual - Programming

API

163

Mnemonic

Operands

Function

Controllers

TSUB

P

Time subtraction

ES2/EX2

SS2

SA2 SX2

 

 

SE

 

 

 

 

 

Type

Bit Devices

 

 

 

 

Word devices

 

 

 

 

 

 

Program Steps

 

OP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

Y

M

S

K

H

KnX

KnY

KnM

KnS

T

C

D

E

 

F

TSUB, TSUBP: 7 steps

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

S1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

*

*

 

 

 

 

 

 

 

 

 

S2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

*

*

 

 

 

 

 

 

 

 

 

D

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

*

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PULSE

 

 

 

 

16-bit

 

 

 

 

32-bit

 

 

 

 

 

 

 

 

 

 

ES2/EX2

SS2

SA2

SX2

ES2/EX2

SS2

SA2

SX2

ES2/EX2

SS2

SA2

SX2

 

 

 

 

 

 

 

 

SE

SE

SE

Operands:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

S1: Time minuend (occupies 3 consecutive devices)

S2: Time subtrahend (occupies 3

 

 

consecutive devices) D: Subtraction result (occupies 3 consecutive devices)

 

 

Explanations:

1.TSUB instruction subtracts the time value (Hour, Minute Second) S1 with the time value (Hour, Minute Second) S2 and stores the result in D.

2.If operand S1, S2 exceed the available range, operation error occurs and M1067 = ON, M1068 = ON. D1067 stores the error code 0E1A (HEX).

3.If the subtraction result is a negative value (less than 0), Borrow flag M1020 = ON and the value in D will be the result of “the negative value pluses 24 hours”.

4.If the subtraction result (remainder) equals 0 (00:00:00), Zero flag M1020 will be ON.

5.Besides using TRD instruction, MOV instruction can also be used to move the RTC value to D1315 (Hour), D1314 (Minute), D1313 (Second) for reading the current time of RTC..

Program Example:

When X0 = ON, TSUB instruction executes and the time value in D0~D2 is subtracted by the time value in D10~D12. The subtraction result is stored in D20~D22.

 

X0

TSUB

D0

D10

D20

 

 

 

 

 

 

 

 

 

 

D0

 

20(Hour)

 

 

D10

14(Hour)

D20

05(Hour)

 

 

 

 

 

D1

 

20(Min)

 

 

D11

30(Min)

D21

49(Min)

 

 

 

 

 

D2

 

05(Sec)

 

 

D12

08(Sec)

D22

57(Sec)

20:20:05 14:30:08 05:49:57

If the subtraction result is a negative value (less than 0), Borrow flag M1021 = ON.

3 - 380

Page 496
Image 496
Delta DVP-ES2/EX2/SS2/SA2/SX2/SE manual KnX KnY KnM KnS TSUB, Tsubp 7 steps