DVP-ES2/EX2/EC5/SS2/SA2/SX2/SE&TP Operation Manual - Programming
API
Mnemonic Operands Function
163 TSUB P
Time subtraction
Type
OP
Bit Devices Word devices Program Steps
X Y M S K H KnX
KnY
KnM
KnS
T C D E F
TSUB, TSUBP: 7 steps
SS2
SX2
SS2
SX2
SS2
SX2
Operands:
S
1
: Time minuend (occupies 3 consecutive devices) S
2
: Time subtrahend (occupies 3
consecutive devices) D: Subtraction result (occupies 3 consecutive devices)
Explanations:
1. TSUB instruction subtracts the time value (Hour, Minute Second) S
1
with the time value (Hour,
Minute Second) S
2
and stores the result in D.
2. If operand S
1
, S
2
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.
20:20:05 14:30:08 05:49:57
X0
TSUB D0 D10 D20
D0 20(Hour)
D1 20(Min)
D2 05(Sec)
D20 05(Hour)
D21 49(Min)
D22 57(Sec)
D10 14(Hour)
D11 30(Min)
D12 08(Sec)
If the subtraction result is a negative value (less than 0), Borrow flag M1021 = ON.
X0
TSUB D0 D10 D20
05:20:30 19:11:15 10:09:15
D0 05(Hour)
D1 20(Min)
D2 30(Sec)
D20 10(Hour)
D21 09(Min)
D22 15(Sec)
D10 19(Hour)
D11 11(Min)
D12 15(Sec)