Mitsubishi PLC CMP Comparison Instruction
S1 and 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 stores the result in the destination operand. For example:
This is a three-operand instruction that performs an algebraic comparison of the source values (e.g., -2 < 1). All source and destination operands are treated as binary data. In the program, M0, M1, and M2 operate based on the outcome of the comparison. When M100 > C20, M0 turns on; when K100 = C20, M1 turns on; and when K100 < C20, M2 turns on. If X0 is OFF, the CMP instruction will not execute, and the status of M0, M1, and M2 remains unchanged.
If the operands for the CMP instruction are incomplete or invalid (e.g., only one or two operands are specified, or an incorrect operand like XDTC is used as the destination), the program may encounter errors.
In practical applications, the elevator's automatic floor display is activated by M1. This instruction is widely used in industrial control systems to manage logic decisions based on numerical comparisons. Understanding how each bit and register functions is essential for accurate programming and troubleshooting. Whether you're working with analog or digital inputs, mastering the CMP instruction can significantly improve your ability to design efficient and reliable control systems.
Pcb Assembly Line,Pcb Prototype Assembly,Pcb Layout Design Services,order custom pcb
Dongguan Jinglin Communication Technology Co., Ltd. , https://www.jlpcba.com