(D) CMP (P) Comparison —— This instruction performs an algebraic comparison between the data of two source operating elements and sends the result to the target element to determine its status.
Source Operating Elements: K/H KnX KnY KnM KnS TCDV/Z
Target Component: YMS
Format: LD X0
CMP(P) K100 C20 M0
When X0 turns from OFF to ON:
If K100 > C20 current value, then M0 = 1
If K100 = C20 current value, then M1 = 1
If K100 < C20 current value, then M2 = 1
When CMP is executed continuously, it runs once per scan cycle when the condition is met.
(D) ZMP (P) Interval Comparison —— Compares one data with the interval of two source components and sends the result to the target component to determine its state.
Source Operating Elements: K/H KnX KnY KnM KnS TCDV/Z
Target Component: YMS
Format: LD X0
ZCP(P) K100 K120 C30 M3
When X0 turns from OFF to ON:
If K100 > C30 current value, then M3 = 1
If K100 ≤ C30 ≥ K120, then M4 = 1
If K120 < C30 current value, then M5 = 1
When ZCP is executed continuously, it runs once per scan cycle when the condition is met.
(D) MOV (P) Transfer —— Transfers the data from the source operating element to the target component.
Source Operating Elements: K/H KnX KnY KnM KnS TCDV/Z
Target Components: KnY KnM KnS TCDV/Z
Format: LD X0
MOV(P) K100 D10
When X0 turns from OFF to ON, the value 100 is transferred to D10.
When executed in continuous mode, MOV runs once per scan cycle when the condition is satisfied.
For 32-bit data transfer using DMOV, component pairs are used. The first digit of the pair can be odd or even, but for safety, it's recommended to use even numbers as the first component in a pair.
When the transfer instruction is executed, the constant is automatically converted to binary and stored in the target component.
SMOV(P) Shift Transfer —— Converts the source component’s data into BCD code and shifts it to the target component as required.
Source Operating Elements: K/H KnX KnY KnM KnS TCDV/Z
Target Components: KnY KnM KnS TCDV/Z
Range of m: K/H is 1–4, meaning the value of D1 cannot exceed 9999.
n: KH
Example Format: D1=1685, D2=0
LD X0
SMOV(P) D1 K4 K2 D2 K3
When X0 turns from OFF to ON:
Convert D1=1685 to BCD: 0001 0110 1000 0101
Convert D2=0 to BCD: 0000 0000 0000 0000
Shift the rightmost 2 bits of D1’s BCD code starting from the 4th bit from the right to the 2nd position from the right in D2, keeping the 1st and 4th bits unchanged. Now D2 becomes 0000 0001 0110 0000, which equals 160.
When SMOV is executed continuously, it runs once per scan cycle when the condition is met.
(D) CML (P) Negated Transmission —— Converts the data in the source component into binary, inverts each bit (0→1, 1→0), and transfers it to the specified target component.
Source Operating Elements: K/H KnX KnY KnM KnS TCDV/Z
Target Components: KnY KnM KnS TCDV/Z
Example: D0=11
LD X0
CML(P) D0 K1Y0
When X0 turns from OFF to ON:
Convert D0=11 to binary: 1010
Invert the bits: 0101
Output to K1Y0: Y0=0, Y1=1, Y2=0, Y3=1
When CML is executed continuously, it runs once per scan cycle when the condition is met.
Sharing these PLC programming tips with fellow enthusiasts who love automation and control systems. Whether you're a beginner or an expert, there's always something new to learn in the world of PLCs!
Wire Winding & Tying Machine,Stator Winding Machine,Winding Machine Motor,Cable Coiling Machine
Kunshan Bolun Automation Equipment Co., Ltd , https://www.bolunmachinery.com