Mitsubishi PLC CMP Comparison Instruction
S1, S2: KH, KnX, KnY, KnM, KnS, T, C, D, V, Z
D: Y, M, S
The CMP instruction compares the data in the source operands S1 and S2 and sends the result to the destination operand. A program example is shown below:
This is a three-operand instruction that performs an algebraic comparison of the source operand values (e.g., -2 < 1). All source operands and the destination operand are treated as binary data. In the program, M0, M1, and M2 are activated based on the comparison result. For instance, when M100 > C20, M0 turns on; when K100 = C20, M1 turns on; and when K100 < C20, M2 turns on. If the execution condition X0 is OFF, the CMP instruction will not run, and the status of M0, M1, and M2 remains unchanged.
If the operands of the compare instruction are incomplete (e.g., only one or two operands are specified) or if the specified operands do not meet the requirements (such as using XDTC as the destination operand), or if the components of the operands are out of the allowed range, the program may encounter errors.
In practical applications, the automatic floor display in elevators is triggered by M1. This instruction is widely used in industrial control systems for comparing numerical values and making decisions based on those comparisons.
Pcb Assembly Line,Pcb Prototype Assembly,Pcb Layout Design Services,order custom pcb
Dongguan Jinglin Communication Technology Co., Ltd. , https://www.jlpcba.com