03 Sequence control

Last modified by Mora Zhou on 2023/11/22 15:46

Contact instructions

Operation start, series connection, parallel connection

LD, LDI, AND, ANI, OR, ORI

LD: Normally open contact instruction. LDI: Normally closed contact instruction.

Extract the ON/OFF information of the device specified in (s) as the result of the calculation.

AND: Normally open contact series connection instruction. ANI: Normally closed contact series connection instruction.

Extract the ON/OFF information of the device specified in (s), and perform an AND operation with the calculation result so far as the calculation result.

OR: Parallel connection instruction of 1 normally open contact. ORI: Parallel connection instruction of 1 normally closed contact

Extract the ON/OFF information of the device specified in (s), and perform an OR operation with the result of the operation so far as the result of the operation.

新建 DOCX 文档_html_4debca1045bae382.png

Content, range and data type

ParameterContentRangeData typeData type (tag)
(s)Device used as contact---BitANY_BOOL

Device used

Instruction

Parameter

Devices

Offset modification

XYMSSM

T

(bit)

C

(bit)

LC

(bit)

HSC

(bit)

D.b[D]
LD

Parameter 1

LDI

Parameter 1

AND

Parameter 1

ANI

Parameter 1

ORParameter 1
ORIParameter 1

Features

  • LD, LDI

• The LD instruction is a normally open contact instruction, and the LDI instruction is a normally closed contact instruction. The ON/OFF information *1 of the specified device is extracted as the operation result.

*1: When the bit of the word device is specified, it is turned on/off according to 1/0 of the specified bit.

  • AND, ANI

• The AND instruction is a normally open contact serial connection instruction, and the ANI instruction is a normally closed contact serial connection instruction. It extracts the ON/OFF information*1 of the specified bit device and performs an AND operation with the result of the operation so far. This value is used as the result of the operation.

*1: When the bit of the word device is specified, it is turned on/off according to 1/0 of the specified bit.

• There is no limit to the number of serial contacts, and this instruction can be used any time continuously.

• After the OUT instruction, it is called cascade output through the contact OUT to other coils. As long as the sequence is good, it can be repeated any number of times.

  • OR, ORI

• The OR instruction is a parallel connection instruction for a normally open contact, and the ORI instruction is a parallel connection instruction for a normally closed contact. It extracts the ON/OFF information*1 of the specified device and compares it with the calculation result so far. Perform an OR operation and use the value as the result of the operation.

*1: When the bit of the word device is specified, it is turned on/off according to 1/0 of the specified bit.

• OR and ORI instructions start from the step where the instruction is located, and connect in parallel to the step where the previous LD and LDI instructions are located.

• There is no limit to the number of parallel connections.

Key point

When specifying the bit of a word device, the bit is specified with a hexadecimal number. (For example, b11 of D0 will become "D0.B")

Error code

Error codeContent
4085H(S) read address exceeds the device range

Example

(1) LD instruction (the logic operation of a contact starts)

新建 DOCX 文档_html_948abbe4cfba788f.png

(2) LDI instruction (the logic operation of contact b starts)

新建 DOCX 文档_html_f0c869bb728ed108.png

(3) AND instruction (a contact in series)

新建 DOCX 文档_html_7b398a86610c200b.png

(4) ANI instruction (series b contact)

新建 DOCX 文档_html_da691d599e7b4879.png

(5) OR instruction (a contact in parallel)

新建 DOCX 文档_html_3a6ee5ecf3044f3f.png

(6) ORI instruction (a contact in parallel)

新建 DOCX 文档_html_463b9ee471040d5.png

(7) Offset modification

The devices used in the LD, LDI, AND, ANI, OR, ORI instructions can all be indexed with D data devices (the status register S cannot be modified).

D0 to D7999 can be used in index modification.

When the devices are input (X) and output (Y), the value of the index register is converted into an octal number and then added.

Example

新建 DOCX 文档_html_2223c9497674fa0b.png

When the value of D0 is 10, X012 determines LD contact ON (conduction)/OFF (non-conduction).

(8) Bit specification in the data register

Among the devices used in the LD, LDI, AND, ANI, OR, and ORI instructions, the bits of the data register (D) can be specified.

When executing the bit specification of the data register, enter "." after the number of the data register (D), and then enter the bit number (0 to F). The usable data registers are specified in bits, but only 16-bit data registers are valid.

Please specify the bit number in the order of 0,1,2,…9,A,B,…F starting from the lower bit.

Example

新建 DOCX 文档_html_8df6b0ab1c78035b.png

The third bit of D0 determines the LD contact ON (conduction)/OFF (non-conduction).

Pulse calculation starts, pulse series connection, pulse parallel connection

LDP, LDF, ANDP, ANDF, ORP, ORF

• LDP: Rising edge pulse operation start instruction.

Turns on only at the rising edge (OFF→ON) of the bit device specified in (s).

• LDF: Falling edge pulse operation start instruction.

Turns on only at the falling edge (ON→OFF) of the bit device specified in (s).

• ANDP: Rising edge pulse series connection instruction, ANDF: Falling edge pulse series connection instruction. The previous operation result up to that time is ANDed with the bit device specified in (s) as the operation result.

• ORP: Parallel connection instruction for rising edge pulse/ORF: Parallel connection instruction for falling edge pulse. The operation result up to that time is ORed with the bit device specified in (s) as the operation result.

新建 DOCX 文档_html_73c09fbfd2ecd992.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)Devices used as contacts-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.b[D]
LDParameter 1
LDIParameter 1
ANDParameter 1
ANIParameter 1
ORParameter 1
ORIParameter 1

Features

  • LDP, LDF

• The LDP instruction is a rising edge pulse operation start instruction, which turns on only at the rising edge (OFF→ON) of the specified bit device. When the bit of the word device is specified, it turns on only when the specified bit changes from 0→1. In the case of only the LDP instruction, it is the same as the pulsed instruction(P) of the instruction executed while ON.

When the circuit that uses the LDP instruction is replaced with a circuit that does not use the LDP instruction, the situation is as follows.

新建 DOCX 文档_html_950644bad27c889.png

• The LDF instruction is a falling edge pulse instruction, which turns on at the falling edge (ON→OFF) of the specified bit device. When the bit of the word device is specified, it turns on only when the specified bit changes from 1→0.

  • ANDP, ANDF

• The ANDP instruction is a series connection instruction for rising edge pulses, and the ANDF instruction is a series connection instruction for falling edge pulses. The AND operation is performed with the operation result up to that time as the operation result. The ON/OFF information used in ANDP instructions and ANDF instructions is shown in the table below.

Device specified in ANDP, ANDFANDP statusANDF status
Bit deviceBit specification of word device
OFF→ON0→1ONOFF
OFF0OFFOFF
ON1OFFOFF
ON→OFF1→0OFFON
  • ORP, ORF

• The ORP instruction is a parallel connection instruction for rising edge pulses, and an ORF instruction is a parallel connection instruction for falling edge pulses. The OR operation is performed with the operation result up to that time as the operation result. The ON/OFF information used in ORP instructions and ORF instructions is shown in the table below.

Device specified in ORP, ORFORP statusORF status
Bit deviceBit specification of word device
OFF→ON0→1ONOFF
OFF0OFFOFF
ON1OFFOFF
ON→OFF1→0OFFON

Error code

There is no operation error.

Example

(1) LDP, ANDP, ORP instructions (calculation starts when a rising edge is detected, serial connection, parallel connection)

新建 DOCX 文档_html_27383c10594a9db2.gif

新建 DOCX 文档_html_3827d78368188647.png

新建 DOCX 文档_html_aaf20335abd9ab2c.png

In the above figure, when X000 to X002 changes from OFF to ON, M0 or M1 only maintains ON for 1 operation cycle.

(2) LDF, ANDF, ORF instructions (calculation starts when a falling edge is detected, serial connection, parallel connection)

新建 DOCX 文档_html_25f75cd2184b446c.gif

新建 DOCX 文档_html_85b81e1e1a420c57.png

In the above figure, when X000 to X002 changes from ON to OFF, M0 or M1 only maintains ON for 1 operation cycle.

(3) Bit specification of data register (D)

In the devices used for LDP, LDF, ANDP, ANDF, ORP, ORF instructions, the bits of the data register (D) can be specified.

To specify the bit of the data register, enter "." after the number of the data register (D), and then enter the bit number (0 to F). The usable data registers are specified in bits, but only 16-bit data registers are valid.

Please specify the bit number in the order of 0,1,2,...9,A,B,...F starting from the low order.

Example:

新建 DOCX 文档_html_c7028515b1f19432.png

The third bit of D0 determines the LDP contact ON (conduction)/OFF (non-conduction) when it changes from OFF to ON.

Combining instructions

Series connection and parallel connection of Circuit program blocks

ANB, ORB

Perform AND operation or OR operation between block A and block B, and use it as the result of the operation.

Circuit program

新建 DOCX 文档_html_ce628cf66494663d.png

Features

  • ANB

• Perform AND operation of block A and block B and use it as the result of the operation.

• The Sign of the ANB instruction is not a contact Sign, but a connection Sign.

  • ORB

• Perform OR operation of block A and block B, and use it as the result of the operation.

• The ORB instruction connects circuit blocks with 2 or more contacts in parallel. The parallel connection of only 1 contact uses OR instruction and ORI instruction, without ORB instruction.

• The Sign of the ORB instruction is not a contact Sign, but a connection Sign.

Error code

There is no operation error.

Example

新建 DOCX 文档_html_f67e0512993c8de9.png

Push, read, and pop of calculation results

MPS, MRD, MPP

• MPS: Store the calculation result (ON/OFF) before the MPS instruction.

• MRD, MPP: Read the operation result stored by the MPS instruction, and start the operation from the next step with the operation result.

Circuit program

新建 DOCX 文档_html_b1f19e624d81311a.png

Features

  • MPS

• Store the operation result (ON/OFF) before the MPS instruction.

• The MPS instruction can be used continuously up to 11 times. If the MPP instruction is used in the middle, the number of uses of the MPS instruction will be -1.

  • MRD

• Read the operation result stored by the MPS instruction, and start the operation from the next step with the operation result.

  • MPP

• Read the operation result stored by the MPS instruction, and start the operation from the next step with the operation result.

• Clear the operation result stored by the MPS instruction.

• The used number of MPS instructions will be -1.

Error code

There is no operation error.

Example

MPS, MRD, MPP instructions (push stack, read stack, pop stack)

新建 DOCX 文档_html_d284a65ea6c513bb.png

• After using the MPS instruction to store the intermediate result of the operation, it drives the output Y002.

• After reading the storage content using MRD instruction, drive output Y003.

The MRD instruction can be programmed multiple times.

• Use the MPP instruction to replace the MRD instruction in the final output loop, so as to reset it while reading the above-mentioned stored content.

Invert the result of operation

INV

Invert the results of operations up to the INV instruction.

Circuit program

新建 DOCX 文档_html_382e3f914f1c04dd.png

Features

Invert the results of operations up to the INV instruction.

Operation result before INV instructionOperation result after INV instruction is executed
OFFON
ONOFF

Error code

There is no operation error.

Point

• The INV instruction executes the operation as a result of the previous operation, so it should be used in the same position as the AND instruction. INV instruction cannot be used in the position of LD and OR instructions.

• When the INV instruction and ANB instruction are used together for ladder operation, pay attention to the inverted range.

新建 DOCX 文档_html_4b05e4cf8f442b5d.png

Example

INV instruction (reverse operation result)

新建 DOCX 文档_html_715361cb76e4a13c.png

Pulse operation result

MEP, MEF

• MEP: Turns on when the operation result before the MEP instruction is a rising edge, and turns off when it is not a rising edge.

• MEF: Turns on when the operation result before MEF instruction is a falling edge, and turns off when it is not a falling edge.

Circuit program

新建 DOCX 文档_html_28f44b3762e4a354.png

Features

  • MEP

• When the operation result before the MEP instruction is a rising edge (OFF→ON), it becomes ON (conduction state). When the operation result before the MEP instruction is other than the rising edge, it turns off (non-conduction state).

• When using the MEP instruction, if multiple contacts are connected in series, pulse processing will be easier.

  • MEF

• When the operation result before the MEF instruction is a falling edge (ON→OFF), it becomes ON (conduction state). When the operation result before the MEF instruction is other than the falling edge, it turns OFF (non-conduction state).

• When using the MEF instruction, if multiple contacts are connected in series, pulse processing will be easier.

Error code

There is no operation error.

Point

• For MEP instructions and MEF instructions, if the indexed contacts are pulsed by subroutines, FOR to NEXT instructions, etc., they may not operate normally.

• The MEP instruction and MEF instruction perform actions based on the previous calculation results, so they should be used in the same position as the AND instruction. The MEP instruction and MEF instruction cannot be used in the position of LD instruction and OR instruction.

Example

(1) MEP instruction (ON at the rising edge of the operation result)

新建 DOCX 文档_html_1dbdc74ad3b7875.png

(2) MEF instruction (ON at the falling edge of the operation result)

新建 DOCX 文档_html_59ffaf2ed3543b09.png

Output instructions

OUT instruction (except timers and counters)

Output the results of the previous OUT instruction to the specified device.

Circuit program

新建 DOCX 文档_html_635bed7829c89cb.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(d)ON/OFF device number-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
XYMSSMD.bTCLCHSC[D]
OUTParameter 1
  • Refer to OUT T instruction when using T;
  • Refer to OUT C instruction when using C, LC, HSC;
  • Offset modification cannot be used when using S device.

Features

Outputs the results of the previous OUT instruction to the specified device.

ConditionCalculation resultCoil / specified position
When using bit devicesOFFOFF
ONON
When using word devicesOFF0
ON1

Error code

Error codeContent
4086H(D) write address exceeds the device range

Example

(1) When using bit devices

The device programmed with the OUT instruction executes ON/OFF according to the state of the drive contact, and the parallel OUT instruction can be used continuously for many times.

In the following program example, OUT M101 followed by OUT M100 means this.

However, if multiple OUT instructions are used for the same device number, it will become a dual output (double coil). Please be careful.

新建 DOCX 文档_html_52169275b8a6b44c.png

新建 DOCX 文档_html_24c27f07fc29051c.png

(2) Offset modification

All the devices used in the OUT instruction can be indexed with the D data device (the status register S cannot be modified).

D0 to D7999 can be used in index modification.

When the devices used are input (X) and output (Y), the value of the index register is converted to an octal number and then added.

Example:

新建 DOCX 文档_html_3c362c2623291a7f.png

When the value of D0 is 10, when X0 is ON (conducting), the Y12 contact is ON (conducting).

(3) Bit specification in the data register

Among the devices used in the OUT instruction, the bit of the data register (D) can be specified.To specify the bit of the data register, enter "." after the number of the data register (D), and then enter the bit number (0 to F). The usable data registers are specified in bits, but only 16-bit data registers are valid.

Please indicate the positioning number in the order of 0,1,2,...9,A,B,...F starting from the low order.

Example:

新建 DOCX 文档_html_700bcac03b22d7ee.png

In the example on the left, the state of X1 determines the ON (conduction)/OFF (non-conduction) of the third bit in D0.

SET instruction

When the execution instruction turns ON, the device specified in (d) will be in the following state.

• Bit device: Turn on the coil and contact.

• Bit specification of word device: Set the specified position to 1.

新建 DOCX 文档_html_15b6f5f733a8361d.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(d)Set (ON) bit device number/bit specification of word device-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
XYMSSMD.b[D]
SETParameter 1

*1: Offset modification cannot be used when using S devices.

Features

When the execution instruction turns ON, the device specified in (d) will be in the following state.

DevicesDevice status
Bit DeviceTurn on the coil and contact
Bit specification of word deviceSet the specified position to 1

The device that is turned on will remain on even if the execution instruction turns off. The device that is turned ON by the SET instruction can be turned OFF by the RST instruction.

新建 DOCX 文档_html_594cb1456a9831b1.png

✎Note: For the output relay (Y), if the SET instruction and the RST instruction are executed in the same operation, the instruction result close to the END instruction (end of program) will be output.

Error code

Error codeContent
4086H(d) In the case of using offset, the offset address exceeds the device range

Example

(1) When using bit devices

The parallel SET instruction could be used multiple times in succession. In the following program example, this is the case for the program with SET Y000 followed by RST Y000.

新建 DOCX 文档_html_4d89f9ebac17bedb.png

(2) Offset modification

All the devices used in the SET instruction can be indexed with D data devices (The status register S cannot be modified).

D0 to D7999 can be used in index modification.

When the devices used are input (X) and output (Y), the value of the index register is converted into octal number and then added.

Example:

新建 DOCX 文档_html_a75aaa4df9f02b33.png

When the value of D0 is 10, when X0 is ON (conduction), the Y12 contact is ON (conduction), X0 is OFF (non-conduction), and the Y12 contact remains unchanged.

(3) Bit specification in the data register

Among the devices used in the SET instruction, the bits of the data register (D) can be specified.

To specify the bit of the data register, enter "." after the number of the data register (D), and then enter the bit number (0 to F). The usable data registers are specified in bits, but only 16-bit data registers are valid.

Please specify the bit number in the order of 0,1,2,…9,A,B,…F starting from the lower bit.

Example:

新建 DOCX 文档_html_4fa02000dd7cc7c8.png

In the example on the left, the state of X1 is ON (conduction), and the third bit in D0 is ON (conduction). The state of X1 is OFF (non-conduction), and the state of the third bit in D0 remains unchanged.

RST instruction

When the RST input turns ON, the device specified in (d) will change to the following state.

• Bit device: Turn off the coil and contact.

• Timers and counters: Set the current value to 0, and set the coil and contact to OFF.

• Bit specification of word device: Set the specified position to 0.

• Word device, module access device, index register: Set the content to 0.

新建 DOCX 文档_html_15b6f5f733a8361d.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(d)Reset bit device number/bit specification of word device or reset word device number-Bit/word/double wordANY_ELEMENTARY

Device used

InstructionParameterDevicesOffset modification
XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bTCDRSDLCHSC[D]
RSTParameter 1

*1: Offset modification cannot be used when using S devices.

Features

When the execution Instruction is ON, the specified device will be in the following state.

DevicesDevice status
Bit DeviceTurn on the coil and contact
Timer, counterSet the current value to 0, set the coil and contact to OFF
Bit specification of word deviceSet the specified position to 0
Word deviceSet the content to 0

When the execution instruction is OFF, the device status does not change.

The function when specifying a word device with the RST instruction is the same as the following Circuit program.

新建 DOCX 文档_html_bc583793d90dd044.png

✎Note: 

For timers and counters, when the RST instruction is executed in the program, subroutine, and interrupt program where the RST instruction is jumped, the timer and counter may remain unchanged after reset, and the timer and counter will not operate.

Error code

Error codeContent
4086H(d) write address exceeds the device range

Example

(1) Use bit device

When X0 is ON (conducting), Y0 is set to OFF, R10 is set to 0, the word device of T10 is set to 0, the bit device is set to OFF, and the word device of C100 is set to 0. The device is turned off.

When X0 is OFF (non-conduction), all states remain unchanged.

新建 DOCX 文档_html_ca5aed9247ba3857.png

(2) Offset modification

All the devices used in the RST instruction can be indexed with D data devices. (The status register S could not be modified)

D0 to D7999 can be used in index modification.

When the devices used are input (X) and output (Y), the value of the index register is converted into an octal number and then added.

Example

新建 DOCX 文档_html_b666b84943b87279.png

When the value of D0 is 10, when X0 is ON (conduction), the Y12 contact is OFF (conduction), X0 is OFF (non-conduction), and the Y12 contact remains unchanged.

(3) Bit specification in the data register

Among the devices used in the RST instruction, the bits of the data register (D) can be specified.

To specify the bit of the data register, enter "." after the number of the data register (D), and then enter the bit number (0 to F). The usable data registers are specified in bits, but only 16-bit data registers are valid.

Please specify the bit number in the order of 0,1,2,…9,A,B,…F starting from the lower bit.

Example

新建 DOCX 文档_html_b666b84943b87279.png

In the example on the left, the state of X1 is ON (conduction), and the third bit in D0 is OFF (conduction). The state of X1 is OFF (non-conduction), and the state of the third bit in D0 remains unchanged.

PLF/Falling edge output

When the PLF instruction is ON→OFF, one scan of the device specified in (d) is ON, and when it is other than ON→OFF, it is OFF.

新建 DOCX 文档_html_15b6f5f733a8361d.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(d)Pulsed device-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
XYMSSMD.b[D]
PLFParameter 1 

Features

When the execution instruction is ON→OFF, the specified device is turned ON, and when the execution instruction is other than ON→OFF, it is turned OFF. When there is one PLF instruction for the device specified in (d) in one scan, the specified device will turn on one scan.

新建 DOCX 文档_html_87ff2fa9f7df8f73.gif

✎Note: 

If the PLF instruction is jumped by the CJ instruction, or the executed subroutine is not called by the CALL(P) instruction, the device specified in (d) may be turned on for more than one scan. Be careful.

Error code

No Error code

Example

PLF instruction (differential output of falling edge)

新建 DOCX 文档_html_fe65278b9e011373.png

In the above figure, when X000 changes from ON to OFF, only one operation cycle of M1 is ON.

PLS/Rising edge output

When the PLS instruction is OFF→ON, one scan of the device specified in (d) is turned ON, and when it is other than OFF→ON, it is turned OFF.

新建 DOCX 文档_html_15b6f5f733a8361d.png

Content, range and data type

ParameterContentRangeData typeData type (label)
(d)Pulsed device-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
XYMSSMD.b[D]
PLSParameter 1 

Features

When the PLS instruction is OFF→ON, one scan of the specified device is turned on, and when it is other than OFF→ON, it is turned off. When there is one PLS instruction for the device specified in (d) in one scan, the specified device turns on one scan.

新建 DOCX 文档_html_698ff9483510a9b2.gif

✎Note: 

If the PLS instruction is jumped by the CJ instruction, or the executed subroutine is not called by the CALL(P) instruction, the device specified in (d) may be turned on for more than one scan. Be careful.

Error code

No Error code

Example

PLS instruction (differential output on rising edge)

新建 DOCX 文档_html_318a6f6b9e832934.png

In the above figure, when X000 changes from OFF to ON, only one operation cycle of M0 is ON.

END/Sequence control program end instruction

Indicates the final end of the program.

新建 DOCX 文档_html_41b16690adeea9a.png

Features

Indicates the end of the program including the main program, subprogram, interrupt program, and event. When the END instruction is executed, the CPU module will end the program being executed.

新建 DOCX 文档_html_e8d2199557a88263.gif