03 Sequence control
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (tag) |
(s) | Device used as contact | --- | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||||||
X | Y | M | S | SM | T (bit) | C (bit) | LC (bit) | HSC (bit) | D.b | [D] | ||
LD | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
LDI | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
AND | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
ANI | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
OR | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
ORI | Parameter 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 code | Content |
4085H | (S) read address exceeds the device range |
Example
(1) LD instruction (the logic operation of a contact starts)
(2) LDI instruction (the logic operation of contact b starts)
(3) AND instruction (a contact in series)
(4) ANI instruction (series b contact)
(5) OR instruction (a contact in parallel)
(6) ORI instruction (a contact in parallel)
(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
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
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Devices used as contacts | - | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||||||
X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | [D] | ||
LD | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
LDI | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
AND | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
ANI | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
OR | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
ORI | Parameter 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.
• 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, ANDF | ANDP status | ANDF status | |
Bit device | Bit specification of word device | ||
OFF→ON | 0→1 | ON | OFF |
OFF | 0 | OFF | OFF |
ON | 1 | OFF | OFF |
ON→OFF | 1→0 | OFF | ON |
- 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, ORF | ORP status | ORF status | |
Bit device | Bit specification of word device | ||
OFF→ON | 0→1 | ON | OFF |
OFF | 0 | OFF | OFF |
ON | 1 | OFF | OFF |
ON→OFF | 1→0 | OFF | ON |
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)
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)
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:
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
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
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
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)
• 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
Features
Invert the results of operations up to the INV instruction.
Operation result before INV instruction | Operation result after INV instruction is executed |
OFF | ON |
ON | OFF |
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.
Example
INV instruction (reverse operation result)
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
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)
(2) MEF instruction (ON at the falling edge of the operation result)
Output instructions
OUT instruction (except timers and counters)
Output the results of the previous OUT instruction to the specified device.
Circuit program
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(d) | ON/OFF device number | - | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||||||
X | Y | M | S | SM | D.b | T | C | LC | HSC | [D] | ||
OUT | Parameter 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.
Condition | Calculation result | Coil / specified position |
When using bit devices | OFF | OFF |
ON | ON | |
When using word devices | OFF | 0 |
ON | 1 |
Error code
Error code | Content |
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.
(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:
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:
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(d) | Set (ON) bit device number/bit specification of word device | - | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||
X | Y | M | S | SM | D.b | [D] | ||
SET | Parameter 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.
Devices | Device status |
Bit Device | Turn on the coil and contact |
Bit specification of word device | Set 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.
Error code
Error code | Content |
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.
(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:
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:
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(d) | Reset bit device number/bit specification of word device or reset word device number | - | Bit/word/double word | ANY_ELEMENTARY |
Device used
Instruction | Parameter | Devices | Offset modification | ||||||||||||||||
X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | T | C | D | R | SD | LC | HSC | [D] | ||
RST | Parameter 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.
Devices | Device status |
Bit Device | Turn on the coil and contact |
Timer, counter | Set the current value to 0, set the coil and contact to OFF |
Bit specification of word device | Set the specified position to 0 |
Word device | Set 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.
Error code
Error code | Content |
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.
(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
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
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(d) | Pulsed device | - | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||
X | Y | M | S | SM | D.b | [D] | ||
PLF | Parameter 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.
Error code
No Error code
Example
PLF instruction (differential output of falling edge)
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.
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(d) | Pulsed device | - | Bit | ANY_BOOL |
Device used
Instruction | Parameter | Devices | Offset modification | |||||
X | Y | M | S | SM | D.b | [D] | ||
PLS | Parameter 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.
✎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)
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.
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.