Share this

Characteristics of PLC instruction execution (based on FX series programmable controllers)

2026-04-06 05:44:59 · · #1

1. General expression form and characteristics of function instructions

The expression format of function instructions is shown in the table below:

Function instructions are numbered from FNC00 to FNC249. Each function instruction has a mnemonic.

2. Data length

The function instructions can process 16-bit and 32-bit data.

As shown in the diagram, the first instruction moves the data in D10 to D12, processing 16-bit data. The second instruction moves the data in D21 and D20 to D23 and D22, processing 32-bit data.

3. Function instruction types

The function instructions of the FX series PLC are available in two forms: continuous execution and pulse execution.

The program on the left is an example of continuous execution. When X2 is ON, the above instruction is executed repeatedly in each scan cycle. The program on the right is an example of pulse execution; this instruction is only valid when X1 changes from OFF to ON.

4. Bit element

Bit element: A component that only handles ON/OFF states is called a bit element.

Word components: Components that process data are called word components. www.plcs.cn

Combinations of bit elements: Bit elements can also be used to form word elements for data processing. Combinations of bit elements are represented by Kn plus the first element number. Four bit elements are combined into a unit, where n in KnM0 is the number of groups.

5. Index registers V and Z

Index registers are used in transfer and compare instructions to modify the element number of the operand. Their operation is the same as that of ordinary data registers. The dot (.) in [D.] indicates that an index register can be added. For 32-bit instructions, V is the high 16 bits and Z is the low 16 bits. When using an index register in a 32-bit instruction, only Z needs to be specified; in this case, Z represents both V and Z.

II. Program Flow Control Function Instructions

Conditional jump instruction CJ

Subroutine call instruction CALL and return instruction SRET

Interrupt return instruction IRET, interrupt enable instruction EI, and interrupt disable instruction DI

The main program ends with the command FEND.

Watch Timer Refresh Command (WDT)

The FOR instruction to start a loop and the NEXT instruction to end a loop

1. Conditional jump instruction CJ

The CJ and CJP instructions are used to skip a portion of a sequential program, reducing scan time. An explanation of the CJ conditional jump instruction is shown in the figure.

2. Subroutine call instruction CALL and return instruction SRET

Subroutines should be written after the main program; that is, the subroutine label should be written after the FEND instruction, and the subroutine must end with the SRET instruction.

3. Interrupt return instruction IRET, interrupt enable instruction EI, and interrupt disable instruction DI

PLCs are generally in an interrupt-disabled state. The program segment between instructions EI and DI is the interrupt-enabled interval, while the segment between DI and EI is the interrupt-disabled interval. When the program execution reaches the interrupt-enabled interval and an interrupt request signal is received, the PLC stops executing the main program and executes the corresponding interrupt subroutine. When an interrupt return instruction IRET is encountered, the PLC returns to the breakpoint and continues executing the main program.

4. Main program termination command FEND

The FEND instruction indicates the end of the main program and the beginning of a subroutine. When the program executes the FEND instruction, it performs output processing, input processing, and monitors the timer refresh. After completion, it returns to step 0.

The FEND instruction is typically used in conjunction with the CJ-P-FEND, CALL-P-SRET, and I-IRET structures (P represents the program pointer, and I represents the interrupt pointer). The pointer and subroutine of the CALL instruction, and the interrupt pointer and interrupt subroutine, should all be placed after the FEND instruction. Subroutines called by the CALL instruction must end with the subroutine return instruction SRET. Interrupt subroutines must end with the interrupt return instruction IRET.

5. Watch Timer Refresh Command (WDT)

If the scan time (from step 0 to END or FEND) exceeds 100ms, the Mitsubishi PLC will stop running. In this case, the WDT instruction should be inserted into the appropriate program step (scan time not exceeding 100ms) to refresh the watchdog timer.

6. The FOR instruction to start a loop and the NEXT instruction to end a loop

The program between FOR and NEXT is executed n times (specified by the operands) before the program following the NEXT instruction is executed. The number of loop iterations n ranges from 1 to 32767. If the value of n is between -32767 and 0, the number of loop iterations is set to 1.

FOR and NEXT always appear in pairs, with FOR preceding NEXT. The FOR~NEXT loop instruction can be nested up to 5 levels.

The CJ command can be used to exit the FOR~NEXT loop.

Read next

Enhanced Application Design of Capacitive Touch Sensors

It seems that suddenly, capacitive sensors are everywhere. They're installed in car seats to control airbag configur...

Articles 2026-02-22