Search on WeChat
Smart Control EducationSiemens PLC Programming Instructions
1. Bit Logic Instructions
1.1 -||- Normally Open Contact (Address) 1.2 -|/|- Normally Closed Contact (Address) 1.3 XOR Bitwise Exclusive OR 1.4 -|NOT|- Signal Flow Reversal 1.5 -( ) Output Coil 1.6 -(#)- Intermediate Output 1.7 -(R) Coil Reset 1.8 -(S) Coil Set 1.9 RS Reset-Set Trigger 1.10 RS Set-Reset Trigger 1.11 -(N)- RLO Falling Edge Detection 1.12 -(P)- PLO Rising Edge Detection 1.13 -(SAVE) Save RLO to BR Memory 1.14 MEG Address Falling Edge Detection 1.15 POS Address Rising Edge Detection
2. Comparison Instructions2.1 CMP?I Integer Comparison 2.2 CMP?D Double Integer Comparison 2.3 CMP?R Real Number Comparison
3. Conversion Instructions3.1 BCD_IBCD Code to Integer 3.2 I_BCD Integer to BCD Code 3.3 I_DINT Integer to Double Integer 3.4 BCD_DIBCD Code to Double Integer 3.5 DI_BCD Double Integer to BCD Code 3.6 DI_REAL Double Integer to Floating Point 3.7 INV_I Binary Complement of Integer 3.8 INV_DI Binary Complement of Double Integer 3.9 NEG_I Binary Negative of Integer 3.10 NEG_DI Binary Negative of Double Integer 3.11 NEG_R Floating Point Negation 3.12 ROUND Round to Double Integer 3.13 TRUNC Truncate Decimal to Double Integer 3.14 CEIL Ceiling 3.15 FLOOR Floor
4. Counter Instructions4.1 S_CUD Increment/Decrement Counter 4.2 S_CU Increment Counter 4.3 S_CD Decrement Counter 4.4 -(SC) Set Initial Value of Counter 4.5 -(CU) Increment Counter Coil 4.6 -(CD) Decrement Counter Coil
5. Data Block Instructions5.1 -(OPN) Open Data Block: DB or DI
6. Logic Control Instructions6.1 -(JMP) Unconditional Jump 6.2 -(JMP) Conditional Jump 6.3 -(JMPN) Jump if Not 6.4 LABEL Label
7. Integer Arithmetic Operation Instructions7.1 ADD_I Integer Addition 7.2 SUB_I Integer Subtraction 7.3 MUL_I Integer Multiplication 7.4 DIV_I Integer Division 7.5 ADD_DI Double Integer Addition 7.6 SUB_DI Double Integer Subtraction 7.7 MUL_DI Double Integer Multiplication 7.8 DIV_DI Double Integer Division 7.9 MOD_DI Return Remainder of Double Integer
8. Floating Point Arithmetic Operation Instructions
8.1 Basic Instructions 8.1.1 ADD_R Real Number Addition 8.1.2 SUB_R Real Number Subtraction 8.1.3 MUL_R Real Number Multiplication 8.1.4 DIV_R Real Number Division 8.1.5 ABS Floating Point Absolute Value Operation
8.2 Extended Instructions 8.2.1 SQR Floating Point Square 8.2.2 SQRT Floating Point Square Root 8.2.3 EXP Floating Point Exponential Operation 8.2.4 LN Floating Point Natural Logarithm Operation 8.2.5 SIN Floating Point Sine Operation 8.4.6 COS Floating Point Cosine Operation 8.2.7 TAN Floating Point Tangent Operation 8.2.8 ASIN Floating Point Inverse Sine Operation 8.2.9 ACOS Floating Point Inverse Cosine Operation 8.2.10 ATAN Floating Point Inverse Tangent Operation
9. Assignment Instructions9.1 MOVE Assignment
10. Program Control Instructions10.1 -(Call) Call FC/SFC from Coil (No Parameters) 10.2 CALL_FB Call FB from Block 10.3 CALL_FC Call FC from Block 10.4 CALL_SFB Call SFB from Block 10.5 CALL_SFC Call SFC from Block 10.6 -(MCR<) Main Control Relay On 10.7 -(MCR>) Main Control Relay Off 10.8 -(MCRA) Main Control Relay Start 10.9 -(MCRD) Main Control Relay Stop 10.10 -(RET) Return
11. Shift and Loop Instructions
11.1 Shift Instructions 11.1.1 SHR_I Integer Right Shift 11.1.2 SHR_DI Double Integer Right Shift 11.1.3 SHL_W Word Left Shift 11.1.4 SHR_W Word Right Shift 11.1.5 SHL_DW Double Word Left Shift 11.1.6 SHR_DW Double Word Right Shift
11.2 Loop Instructions 11.2.1 ROL_DW Double Word Left Rotate 11.2.2 ROR_DW Double Word Right Rotate
12. Status Bit Instructions12.1 OV -||- Overflow Exception Bit 12.2 OS -||- Storage Overflow Exception Bit 12.3 UO -||- Unordered Exception Bit 12.4 BR -||- Exception Bit Binary Result 12.5 ==0-||- Result Bit Equals “0” 12.6 <>0-||- Result Bit Not Equal “0” 12.7 >0-||- Result Bit Greater than “0” 12.8 <0-||- Result Bit Less than “0” 12.9 >=0-||- Result Bit Greater than or Equal to “0” 12.10 <=0-||- Result Bit Less than or Equal to “0”
13. Timer Instructions13.1 S_PULSE Pulse S5 Timer 13.2 S_PEXT Extended Pulse S5 Timer 13.3 S_ODT On Delay S5 Timer 13.4 S_ODTS Retentive On Delay S5 Timer 13.5 S_OFFDT Off Delay S5 Timer 13.6 -(SP) Pulse Timer Coil 13.7 -(SE) Extended Pulse Timer Coil 13.8 -(SD) On Delay Timer Coil 13.9 -(SS) Retentive On Delay Timer Coil 13.10 -(SF) Off Delay Timer Coil
14. Word Logic Instructions14.1 WAND_W Word AND Operation 14.2 WOR_W Word OR Operation 14.3 WAND_DW Double Word AND Operation 14.4 WOR_DW Double Word OR Operation 14.5 WXOR_W Word XOR Operation 14.6 WXOR_DW Double Word XOR Operation

Long press to scan the QR code above
Receive the Most Comprehensive Mitsubishi and Siemens PLC Instruction Table
Bonus Basic Data for PLC Beginners, Programming Cases
Basic Logic Instructions of Mitsubishi FX Series PLC
Input and Output Instructions (LD/LDI/LDP/LDF/OUT) (1) LD (Input Instruction) A normally open contact connected to the left bus, each logic line starting with a normally open contact uses this instruction.
(2) LDI (Inverse Instruction) A normally closed contact connected to the left bus, each logic line starting with a normally closed contact uses this instruction.
(3) LDP (Rising Edge Instruction) A normally open contact connected to the left bus for rising edge detection, only activates for one scan cycle at the rising edge of the specified element (from OFF to ON).
(4) LDF (Falling Edge Instruction) A normally closed contact connected to the left bus for falling edge detection.
(5) OUT (Output Instruction) An instruction that drives the coil, also known as the output instruction.
Usage Instructions for Input and Output Instructions: 1) LD and LDI instructions can be used for input contacts connected to the left bus as well as to perform block logic operations with ANB and ORB instructions;
2) LDP and LDF instructions only maintain activation for one scan cycle when the corresponding element is valid.
3) The target elements for LD, LDI, LDP, and LDF instructions are X, Y, M, T, C, S; 4) OUT instruction can be used multiple times (equivalent to parallel connection of coils), for timers and counters, a constant K or data register should be set after the OUT instruction.
5) The target elements for OUT instruction are Y, M, T, C, and S, but cannot be used for X.
Contact Series Instructions (AND/ANI/ANDP/ANDF) (1) AND (AND Instruction) A normally open contact series connection instruction, completing a logical AND operation. (2) ANI (AND NOT Instruction) A normally closed contact series connection instruction, completing a logical NAND operation. (3) ANDP Rising edge detection series connection instruction. (4) ANDF Falling edge detection series connection instruction.

Usage Instructions for Contact Series Instructions: 1) AND, ANI, ANDP, ANDF are instructions for connecting single contacts in series, there is no limit to the number of series connections, and they can be used repeatedly. 2) The target elements for AND, ANI, ANDP, ANDF are X, Y, M, T, C, and S. 3) OUT M101 instruction then drives Y4 through T1 is called continuous output.
Contact Parallel Instructions (OR/ORI/ORP/ORF) (1) OR (OR Instruction) Used for single normally open contact in parallel, achieving logical OR operation. (2) ORI (OR NOT Instruction) Used for single normally closed contact in parallel, achieving logical NOR operation. (3) ORP Rising edge detection parallel connection instruction. (4) ORF Falling edge detection parallel connection instruction.
Usage Instructions for Contact Parallel Instructions: 1) OR, ORI, ORP, ORF instructions are for single contact parallel connections, the left end of the parallel contact connects to LD, LDI, LDP or LPF, and the right end connects to the previous instruction’s corresponding contact. The number of times parallel contact instructions can be used continuously is unlimited; 2) The target elements for OR, ORI, ORP, ORF instructions are X, Y, M, T, C, and S.
Block Operation Instructions (ORB / ANB) (1) ORB (Block OR Instruction) Used for parallel connection between two or more series connected contacts.
Usage Instructions for ORB Instruction: 1) When several series circuit blocks are connected in parallel, each series circuit block should start with LD or LDI instruction;
2) When there are multiple parallel circuit blocks, if ORB instruction is used for each circuit block, there is no limit to the number of parallel circuit blocks;
3) ORB instruction can also be used continuously, but this programming style is not recommended, the number of LD or LDI instructions should not exceed 8, meaning ORB can only be used continuously less than 8 times.
(2) ANB (Block AND Instruction) Used for series connection between two or more parallel connected contacts.
Usage Instructions for ANB Instruction: 1) When parallel circuit blocks are connected in series, the starting point for each parallel circuit block should use LD or LDI instruction;
2) When multiple parallel circuit blocks are connected in series to the previous circuit, there is no limit to the number of times ANB instruction can be used. ANB can also be used continuously, but like ORB, the number of times should be less than 8.
Set and Reset Instructions (SET/RST) (1) SET (Set Instruction) Its function is to set the target element and maintain it.
(2) RST (Reset Instruction) Resets the target element and keeps it in a zero state. The usage of SET and RST instructions, when X0 normally open is activated, Y0 becomes ON and maintains this state, even if X0 is disconnected, Y0’s ON state remains unchanged; only when X1’s normally open closes, Y0 becomes OFF and maintains this state, even if X1 normally open is disconnected, Y0 remains OFF.
Usage Instructions for SET and RST Instructions: 1) The target elements for SET instruction are Y, M, S, and for RST instruction are Y, M, S, T, C, D, V, Z. RST instruction is often used to clear the contents of D, Z, V, and to reset accumulated timers and counters.
2) For the same target element, SET and RST can be used multiple times, and the order can be arbitrary, but the last executor is valid.
Differential Instructions (PLS/PLF) (1) PLS (Rising Edge Differential Instruction) Generates a pulse output for one scan cycle on the rising edge of the input signal
(2) PLF (Falling Edge Differential Instruction) Generates a pulse output for one scan cycle on the falling edge of the input signal. The differential instruction detects the edge of the signal and controls the state of Y0 through set and reset commands.
Usage Instructions for PLS and PLF Instructions: 1) The target elements for PLS and PLF instructions are Y and M;
2) When using PLS, the target element is ON only for one scan cycle after the driving input is ON, M0 is ON only for one scan cycle when the normally open contact of X0 changes from OFF to ON; when using PLF instruction, it only uses the falling edge of the input signal to drive, other than that, it is the same as PLS.
Main Control Instructions (MC/MCR)
1) MC (Main Control Instruction) Used for connecting common series contacts. After executing MC, the left bus moves behind the MC contact.
2) MCR (Main Control Reset Instruction) It is the reset instruction of MC instruction, which restores the original position of the left bus using MCR instruction.
In programming, it often happens that multiple coils are controlled by one or a group of contacts, if the same contacts are inserted into the control circuit of each coil, it will occupy many storage units, using main control instructions can solve this problem.
MC, MCR instructions use MC N0 M100 to achieve the right shift of the left bus, making Y0 and Y1 controlled by X0, where N0 indicates the nesting level, in a non-nested structure, there is no limit to the number of uses of N0; using MCR N0 restores to the original left bus state. If X0 is disconnected, it will skip the instructions between MC and MCR and execute downwards.
Usage Instructions for MC and MCR Instructions: 1) The target elements for MC and MCR instructions are Y and M, but cannot use special auxiliary relays. MC occupies 3 program steps, MCR occupies 2 program steps;
2) Main control contacts are vertical to ordinary contacts in the ladder diagram. Main control contacts are normally open contacts connected to the left bus, serving as the main switch for controlling a group of circuits. Contacts connected to the main control contacts must use LD or LDI instruction.
3) When the input contact of MC instruction is disconnected, the accumulated timers and counters within the MC and MCR maintain their previous states unchanged. Non-accumulated timers and counters, elements driven by OUT instruction will reset, when X0 is disconnected, Y0 and Y1 will become OFF.
4) If MC instruction is used again within a MC instruction area, it is called nesting. The maximum nesting level is 8, numbered in the order N0→N1→N2→N3→N4→N5→N6→N7, each level returns using the corresponding MCR instruction, starting from the largest numbered nested level to reset.
Stack Instructions (MPS/MRD/MPP) Stack instructions are newly added basic instructions in FX series, used for multiple output circuits, providing convenience for programming. In FX series PLC, there are 11 storage units specifically for storing intermediate results of program calculations, called stack memory. (1) MPS (Push Instruction) Sends calculation results into the first segment of stack memory, while moving previously sent data to the next segment of the stack. (2) MRD (Read Stack Instruction) Reads the first segment of data from stack memory (the last pushed data) and continues to keep that data in the first segment of the stack, without moving the data within the stack. (3) MPP (Pop Instruction) Reads the first segment of data from stack memory (the last pushed data) and that data disappears from the stack, while other data in the stack moves up sequentially.
Usage Instructions for Stack Instructions: 1) Stack instructions do not have target elements;
2) MPS and MPP must be used in pairs;
3) Since there are only 11 stack storage units, the maximum stack depth is 11 levels.
Logic Inversion, No Operation, and End Instructions (INV/NOP/END) 1) INV (Inversion Instruction) Executes this instruction to invert the original calculation result. The usage of inversion instruction is as shown in Figure 10, if X0 is disconnected, Y0 is ON, otherwise Y0 is OFF. When using, note that INV cannot be connected to the bus like LD, LDI, LDP, LDF instructions, nor can it be used independently like OR, ORI, ORP, ORF instructions.
2) NOP (No Operation Instruction) Does not perform any operation but occupies one program step. When executing NOP, nothing is done, sometimes NOP instruction can be used to short-circuit certain contacts or to overwrite unwanted instructions. When PLC has executed the clear user memory operation, the contents of user memory all become no operation instructions.
3) END (End Instruction) Indicates the end of the program. If the last part of the program does not write END instruction, the PLC will execute from the first step of user program memory to the last step regardless of how long the actual user program is; if there is an END instruction, when it scans to END, it will end program execution, thus shortening the scan cycle. During program debugging, several END instructions can be inserted into the program, dividing the program into several segments, once confirming that the previous program segment is correct, END instructions can be deleted one by one until debugging is complete.
Step Instructions for FX Series PLC (STL/RET) Step instructions are designed specifically for sequential control. Many control processes in industrial control can be implemented using sequential control, using step instructions for sequential control is both convenient to implement and easy to read and modify.
In FX2N, there are two step instructions: STL (Step Contact Instruction) and RET (Step Return Instruction).
STL and RET instructions can only have step functionality when paired with state device S. For example, STL S200 represents a normally open contact, referred to as STL contact, which is symbolized as -|| ||- in the ladder diagram, it does not have normally closed contacts. Each state device S records one step, for example, when STL S200 is valid (ON), it enters the step represented by S200 (similar to the main switch of this step), starting to execute the work that should be done in this phase and checking if the conditions to move to the next step are met. Once the signal for this step is ON, S200 is turned off to enter the next step, such as S201 step. The RET instruction is used to reset the STL instruction. After executing RET, it returns to the bus and exits the stepping state.
2. State Transition Diagram A sequential control process can be divided into several stages, also known as steps or states, each state has different actions. When the transition conditions between adjacent states are met, the transition is achieved, that is, the system transitions from the previous state to the next state for execution. We often use state transition diagrams (function block diagrams) to describe this sequential control process. Each state is recorded using state device S, and X represents the transition conditions. For example, when X1 is ON, the system transitions from state S20 to state S21.
Each step in the state transition diagram contains three contents: the content driven by this step, the transition conditions, and the target of the instruction transition.
The step drives Y0, when X1 is valid and ON, the system transitions from state S20 to state S21, X1 is the transition condition, and the target of the transition is step S21.
3. Usage Instructions for Step Instructions
1) STL contact is a normally open contact connected to the left bus, when a certain STL contact is activated, the corresponding state is the active step;
2) Contacts connected to STL contact should use LD or LDI instruction, and can only return to the left bus after executing RET;
3) STL contacts can directly drive or drive coils of Y, M, S, T elements through other contacts;
4) Since PLC only executes the circuit blocks corresponding to the active step, when using STL instruction, dual coil outputs are allowed (the sequential control program can drive the same coil multiple times in different steps);
5) Circuit blocks driven by STL contacts cannot use MC and MCR instructions, but CJ instruction can be used;
6) STL instruction cannot be used in interrupt programs and subroutines.

Long press to scan the QR code above
Receive the Most Comprehensive Mitsubishi and Siemens PLC Instruction Table
Bonus Basic Data for PLC Beginners, Programming Cases
The copyright of this article belongs to the original author. If there is any copyright issue, please contact us to delete it in time, thank you!
Search on WeChat
Smart Control Education
△ Click the image to learn PLC courses for free Don’t forget to like + check it out!