Chapter 7 Second Development Platform VP3000
368
API Instruction code Operand Function
163 TSUB P S
1
, S
2
, D
Time subtraction
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
TSUB
Continuous
execution
type
TSUBP
Pulse
execution
type
32-bit instruction
- - - -
Associated flag:
M1020: Zero flag
M1022: Carry flag
M1068 RTC error
X Y M K H KnX KnY KnM T C D
S
1
S
2
D
Caution for using operand
See the specification of each model for the scope of device’s usage.
Description
S
1
: time minuend
S
2
: time subtrahend
D: time difference
Add the hour, minute, second that S
1
designates and the hour, minute, second that S
2
designates, the result is stored in the hour, minuet, second of the register that D designates.
If S
1
, S
2
exceed the range, it’s operation error, so the instruction is not executed. M1067,
M1068 = ON, and record fault code 0E1A (HEX) in D1067.
If the difference is a negative, borrow flag M1021 = ON, and the result of the negative number
plus 24 hours will be displayed in the register D designates.
If the difference equals to 0 (00:00:00), zero flag M1020 = ON.
Example
When X10 = ON, TSUB instruction is executed. The hour, minute, second that D0–D2 designate
minus the hour, minute, second that D10–D12 designates, the result is stored in the register
that D20–D22 designates.
X10
TSUB D0 D10 D20