Basic logic instructions for Mitsubishi FX series PLCs.
Instruction fetch and output (LD/LDI/LDP/LDF/OUT)
(1) LD (fetch instruction) is an instruction that connects a normally open contact to the left busbar. This instruction is used for every logic line that starts with a normally open contact.
(2) LDI (Invert Instruction) is an instruction that connects a normally closed contact to the left busbar. This instruction is used for every logic line that starts with a normally closed contact.
(3) The rising edge detection instruction of LDP (fetch rising edge instruction) connected to the normally open contact of the left busbar is activated for one scan cycle only when the rising edge of the specified bit element (from OFF→ON).
(4) The falling edge detection command of the normally closed contact connected to the left busbar by the LDF (Falling Edge Command).
(5) OUT (output instruction) is an instruction to drive the coil, also known as an output instruction.
Instructions for using fetch and output commands:
1) The LD and LDI instructions can be used to input the contacts connected to the left busbar, and can also be used in conjunction with the ANB and ORB instructions to implement block logic operations;
2) LDP and LDF instructions are only activated for one scan cycle when the corresponding element is active.
3) The target elements of LD, LDI, LDP, and LDF instructions are X, Y, M, T, C, and S;
4) The OUT instruction can be used several times in a row (equivalent to coils in parallel). For timers and counters, a constant K or a data register should be set after the OUT instruction.
5) The OUT instruction targets Y, M, T, C, and S elements, but cannot be used for X. Contact cascading instructions (AND/ANI/ANDP/ANDF)
(1) AND (AND instruction) A normally open contact is connected in series to perform a logical AND operation.
(2) ANI (AND NOT instruction) is an instruction connected in series with a normally closed contact to perform a logical AND-NOT operation.
(3) ANDP rising edge detection serial connection instruction.
(4) ANDF falling edge detection serial connection instruction.
Instructions for using contact series connection commands:
1) AND, ANI, ANDP, and ANDF all refer to instructions for connecting single contacts in series. There is no limit to the number of times they can be connected in series, and they can be used repeatedly.
2) The target components of AND, ANI, ANDP, and ANDF are X, Y, M, T, C, and S.
3) After the OUTM101 instruction, Y4 is driven through the contact of T1, which is called continuous output.
Contact parallel connection instructions (OR/ORI/ORP/ORF)
(1) OR (or instruction) is used for parallel connection of a single normally open contact to implement the logical "or" operation.
(2) ORI (or NOT instruction) is used for parallel connection of a single normally closed contact to realize the logical "OR" operation.
(3) ORP rising edge detection parallel connection instruction.
(4) ORF falling edge detection parallel connection instruction.
Instructions for using the contact parallel connection instruction:
1) The OR, ORI, ORP, and ORF instructions all refer to the parallel connection of single contacts. The left end of the parallel contact is connected to LD, LDI, LDP, or LPF, and the right end is connected to the right end of the contact corresponding to the previous instruction. There is no limit to the number of times the contact parallel connection instruction can be used consecutively.
2) The target elements of the OR, ORI, ORP, and ORF instructions are X, Y, M, T, C, and S. Block operation instructions (ORB/ANB)
(1) ORB (block or instruction) is used for parallel connection between two or more circuits with two or more contacts connected in series.
Instructions for using the ORB command:
1) When several series circuit blocks are connected in parallel, each series circuit block should start with the LD or LDI instruction;
2) There are multiple circuit blocks connected in parallel. If the ORB instruction is used for each circuit block, there is no limit to the number of circuit blocks connected in parallel.
3) The ORB instruction can also be used consecutively, but this programming style is not recommended. The LD or LDI instruction should not be used more than 8 times, that is, ORB can only be used 8 times consecutively.
(2) ANB (block AND instruction) is used for series connection between two or more circuits with two or more contacts connected in parallel.
Instructions for using the ANB command:
1) When parallel circuit blocks are connected in series, the start of each parallel circuit block is marked with the LD or LDI instruction;
2) When multiple parallel loop blocks are connected in series with the preceding loops in sequence, there is no limit to the number of times the ANB instruction can be used. ANB can also be used continuously, but like ORB, the number of uses is limited to 8 times or less.
Set and reset instructions (SET/RST)
(1) SET (Set instruction) Its function is to set and hold the target element being operated on.
(2) RST (reset instruction) resets the target element and keeps it in a cleared state. When X0 is normally open, Y0 becomes ON and remains in that state. Even if X0 is open, Y0 remains ON. Only when X1 is normally open is closed will Y0 become OFF and remain OFF. Even if X1 is normally open, Y0 remains OFF.
Instructions for using the SET and RST commands:
1) The target elements of the SET instruction are Y, M, and S, while the target elements of the RST instruction are Y, M, S, T, C, D, V, and Z. The RST instruction is often used to clear the contents of D, Z, and V, and is also used to reset the accumulator timer and counter.
2) For the same target component, SET and RST can be used multiple times in any order, but the last executor is effective. Differentiation instructions (PLS/PLF)
(1) PLS (rising edge differential instruction) generates a pulse output for one scan cycle at the rising edge of the input signal.
(2) PLF (falling edge differential instruction) generates a pulse output for one scan cycle at the falling edge of the input signal.
The edge of the signal is detected using the differential instruction, and the state of Y0 is controlled by set and reset commands.
Instructions for using PLS and PLF commands:
1) The target elements of PLS and PLF instructions are Y and M;
2) When using PLS, the target element is ON only within one scan cycle after the drive input is ON, and M0 is ON only within one scan cycle when the normally open contact of X0 changes from open to closed; when using PLF instructions, only the falling edge of the input signal is used for driving, and everything else is the same as PLS.
Master Control Commands (MC/MCR)
(1) MC (Master Control Command) is used to connect the common series contacts. After executing MC, the left busbar moves to the back of the MC contact.
(2) MCR (Master Reset Instruction) It is the reset instruction of the MC instruction, that is, the MCR instruction is used to restore the original position of the left bus.
In programming, it is common to encounter situations where multiple coils are simultaneously controlled by one or a group of contacts. If the same contact is connected in series in the control circuit of each coil, it will occupy a lot of storage units. This problem can be solved by using master control instructions.
The MC and MCR instructions use MCN0M100 to shift the left busbar to the right, bringing Y0 and Y1 under the control of X0. N0 represents the nesting level; in a non-nested structure, N0 can be used an unlimited number of times. MCRN0 restores the original left busbar state. If X0 is disconnected, the instructions between MC and MCR will be skipped and execution will continue downwards.
Instructions for using MC and MCR commands:
1) The target elements of MC and MCR instructions are Y and M, but special auxiliary relays cannot be used. MC occupies 3 program steps, and MCR occupies 2 program steps;
2) The main control contact is perpendicular to the general contacts in the ladder diagram. The main control contact is a normally open contact connected to the left busbar and is the main switch controlling a group of circuits. Contacts connected to the main control contact must use the LD or LDI instruction.
3) When the input contact of the MC instruction is opened, the accumulating timers, counters, and components driven by reset/set instructions within MC and MCR retain their previous states. Non-accumulating timers and counters, and components driven by the OUT instruction, will be reset. In step 22, when X0 is opened, Y0 and Y1 become OFF.
4) Using MC instructions within the same MC instruction block 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, resetting from the highest-numbered nesting level. Stack instructions (MPS/MRD/MPP)
Stack instructions are a new addition to the FX series, used in multi-output circuits to simplify programming. The FX series PLC has 11 memory units specifically designed to store intermediate results of program calculations; these are collectively known as stack memory.
(1) MPS (Push instruction) sends the result of the operation to the first segment of the stack memory, and at the same time moves the previously pushed data to the next segment of the stack.
(2) MRD (Read Stack Instruction) reads the first segment of data (the last data pushed onto the stack) from the stack memory and keeps the data in the first segment of the stack memory. The data in the stack does not move.
(3) MPP (Pop instruction) reads the first data segment of the stack memory (the last data pushed onto the stack) and the data disappears from the stack, while moving the other data in the stack up in sequence.
Instructions for using stack instructions:
1) Stack instructions have no target element;
2) MPS and MPP must be used in pairs;
3) Since there are only 11 storage units in the stack, the stack can have a maximum of 11 levels.
Logical inversion, no-operation, and end instructions (INV/NOP/END)
(1) INV (Inverse Instruction) After executing this instruction, the original calculation result is inverted. The usage of the inverse instruction is shown in Figure 10. If X0 is disconnected, then Y0 is ON; otherwise, Y0 is OFF. When using it, it should be noted that INV cannot be connected to the bus like LD, LDI, LDP, and LDF in the instruction table, nor can it be used alone like OR, ORI, ORP, and ORF instructions in the instruction table.
(2) NOP (No Operation) does not perform any operation, but occupies one program step. Executing NOP does nothing; sometimes it can be used to short-circuit certain contacts or to overwrite unwanted instructions. After the PLC performs a clear user memory operation, the contents of the user memory become entirely NOP instructions.
(3) END (End Instruction) indicates the end of the program. If the END instruction is not written at the end of the program, the PLC will execute from the first step to the last step in the user program memory, regardless of the actual length of the user program. If the END instruction is present, the program execution will end when the END instruction is scanned, thus shortening the scan cycle. During program debugging, several END instructions can be inserted into the program to divide it into several segments. After confirming that the previous program segments are correct, the END instructions can be deleted one by one until the debugging is completed.
Step instructions for FX series PLCs
1. Step instructions (STL/RET)
Step instructions are instructions specifically designed for sequential control. Many control processes in industrial control can be implemented using sequential control, and using step instructions for sequential control is both convenient to implement and easy to read and modify.
The FX2N has two step instructions: STL (step contact instruction) and RET (step return instruction).
The STL and RET instructions only have step functionality when used with state registers S. For example, STLS200 represents a normally open contact, called an STL contact, and its symbol in the ladder diagram is -||||-. It has no normally closed contacts. We use each state register S to record one step. For example, if STLS200 is active (ON), then the system enters the step represented by S200 (similar to the main switch for this step), begins executing the work to be done in this stage, and checks whether the conditions for entering the next step are met. Once the end signal for this step is ON, S200 is turned off, and the system enters the next step, such as step S201. The RET instruction is used to reset the STL instruction. Executing RET will return the system to the bus and exit the stepping state.
2. State Transition Diagram
A sequential control process can be divided into several stages, also called steps or states, each with different actions. A transition occurs when the transition condition between two adjacent states is met, meaning the system moves from one state to the next. We often use state transition diagrams (function table diagrams) to describe this sequential control process. Each state is recorded by a state register S, and X represents the transition condition. For example, when X1 is ON, the system transitions from state S20 to state S21.
Each step in the state transition diagram contains three elements: the content driven by this step, the transition condition, and the target of the instruction transition.
Step Y0 is driven. When X1 is validly 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. Instructions for using step instructions
1) STL contacts are normally open contacts connected to the left busbar. When an STL contact is closed, the corresponding state is active.
2) Contacts connected to STL contacts use LD or LDI instructions, and only return to the left bus after RET is executed; 3) STL contacts can directly drive or drive the coils of Y, M, S, T and other components through other contacts.
4) Since the PLC only executes the circuit block corresponding to the active step, dual coil output is allowed when using STL instructions (the sequential control program can drive the same coil multiple times in different steps).
5) MC and MCR instructions cannot be used in STL contact-driven circuit blocks, but CJ instructions can be used; 6) STL instructions cannot be used in interrupt routines and subroutines.