1. Comparison instruction CMP
The CMP instruction has three operands: two source operands [S1.] and [S2.], and one destination operand [D.]. This instruction compares [S1.] and [S2.], and stores the result in [D.]. The usage of the CMP instruction is illustrated in the figure.
2. Range Comparison Command ZCP
The ZCP instruction compares an operand [S.] with the interval formed by two operands [S1.] and [S2.], where [S1.] must not be greater than [S2.], and the result is stored in [D.]. The usage of the ZCP instruction is illustrated in the figure.
3. Transfer command MOV
The MOV instruction transfers data from the source operand to the target element, i.e., [S.] → [D.]. The usage of the MOV instruction is shown in the figure. When X0 is ON, the data K100 in the source operand [S.] is transferred to the target element D10. When X0 is OFF, the instruction is not executed, and the data remains unchanged.
4. Shift/Transfer Instruction SMOV
First, the binary source data (D1) is converted into BCD code. Then, the BCD code is shifted and transmitted to achieve data allocation and combination. Two bits (m2=2) starting from the 4th bit (m1=4) of the source data's BCD code are shifted to the 3rd bit (n=3) and 2nd bit of the target D2/, while the 4th and 1st bits of the BCD code in D2/ remain unchanged. Then, the BCD code in the target D2/ is automatically converted into a binary number, which is the content of D2. An error occurs when the BCD code value exceeds 9999.
5. Invert Transfer Command CML
The CML instruction usage is shown in the figure. It inverts each bit of the data in the source operand (automatically converted to binary) before transmitting it.
6. Block Transfer Instruction BMOV
The BMOV instruction transfers a block of n data numbers, starting from the element specified by the source operand, to the specified destination. If the element number is outside the allowed range, data is only transferred up to the allowed range. The usage of the BMOV instruction is illustrated in the figure.
7. Multipoint transfer command FMOV
The FMOV instruction transfers data from a source element to n target elements starting at a specified destination. All n target elements contain identical data. The usage of the FMOV instruction is illustrated in the figure.
8. Data exchange command XCH
The XCH instruction swaps the contents of two target elements, D1 and D2. Instructions for use are shown in the figure.
9. BCD and BIN conversion instructions
BCD converts a binary number in a source element into BCD code and sends it to the target element. For 16-bit or 32-bit binary operands, an error will occur if the conversion result exceeds the range of 0-9999 or 0-99999999.
BCD instructions are often used to convert binary numbers in a PLC into BCD code for output to drive LED displays.
BIN converts the BCD code in the source element into a binary number and sends it to the destination element. The constant K cannot be used as the operand for this instruction. An error will occur if the source operand is not a BCD code.
The BIN instruction is often used to input the set value of a BCD digital switch into a PLC .
Case Study: Material Handling Cart Control
I. Control Requirements
A workshop has 6 workbenches. A material delivery vehicle travels between the workbenches to deliver materials. Each workbench is equipped with a position switch (SQ) and a breathing button (SB).
The specific control requirements are as follows:
(1) The feeding car should be able to stop at any of the six worktables at the position of the stop switch.
(2) Suppose the feeding car is currently stopped at workbench m (SQm is ON), and workbench n calls (SQn is ON). If:
(a) When m>n, the feeding trolley moves to the left until SQn is activated, at which point it stops. That is, when the number of the feeding trolley's stopping position SQ is greater than the number of the call button SB, the feeding trolley moves to the left and stops after reaching the call position.
(b)m
(c) m=n, the feeding car remains stationary. That is, when the number of the feeding car's stopping position SQ is the same as the number of the call button SB, the feeding car does not move.
II. Implementation of PLC Hardware
1. I/O allocation table
2. External wiring of I/O
III. Implementation of PLC Software
The diagram shows that the current position of the feeding car is sent to data register D0, and the calling workstation number is sent to data register D1. Then, by comparing the data in D0 and D1, the running direction and target position of the feeding car are determined.