3. Instruction Set Operands: S 1 : “Hour” for comparison (K0~K23) S 2 : “Minute” for comparison (K0~K59) S 3 : “Second” for comparison (K0~K59) S : Current time of RTC (occupies 3 consecutive devices) D : Comparison result (occupies 3 consecutive devices) Explanations: 1. TCMP instruction compares the time set in S 1 , S 2 , S 3 with RTC current value in S and stores the comparison result in D . 2. S: “Hour” of current time of RTC. Content: K0~K23. S +1: “Minute” of current time of RTC. Content: K0~K59. S +2 : “Second” of current time of RTC. Content: K0~K59. 3. Usually the time of RTC in S is read by TRD instruction first then compared by TCMP instruction.
If operand S exceeds the available range, operation error occurs and M1067 = ON, M1068 = ON. D1067 stores the error code 0E1A (HEX). Program Example: 1. When X0 = ON, the instruction executes and the RTC current time in D20~D22 is compared with the set value 12:20:45. Comparison result is indicated by M10~M12. When X0 goes from ON→OFF, the instruction is disabled however the ON/OFF status of M10~M12 remains. 2. Connect M10 ~ M12 in series or in parallel to obtain the results of , , and ≠ ≧≦ . X0 3-413 API Mnemonic Operands Function Controllers 160 TCMP P Time compare ES2/EX2 SS2 SA2 SX2 SE Typ e OP Bit Devices Word devices Program Steps X Y M S K H KnX KnY KnM KnS T C D E F TCMP, TCMPP:
11 steps S 1 * * * * * * * * * * * S 2 * * * * * * * * * * * S 3 * * * * * * * * * * * S * * * D * * * PULSE 16-bit 32-bit SA2 SX2 SE SA2 SA2 ES2/EX2 SS2 ES2/EX2 SS2 SX2 ES2/EX2 SS2 SX2 SE SE TCMP K12 K20 K45 D20 M10 M10 ON when 12:20:45 > M11 ON when 12:20:45 = M12 ON when 12:20:45 TCMP K12 K20 K45 D20 M10