Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 15 of 60

C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 134 to 143

Pages 134 to 143 of 586

The original document is the PDF (3.4 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Omron C200HE-CPU42-E

Page 134

Section 4-7

Inputting, Modifying, and Checking the Program

The previous diagram B can be written as shown below to ensure correct execution. In mnemonic code, the execution condition is stored at the branching point using the TR bit as the operand of the OUTPUT instruction. This execution condition is then restored after executing the right-hand instruction by using the same TR bit as the operand of a LOAD instruction

TR 0 00000

00001 Instruction 1 00002 Instruction 2

Diagram B: Corrected Using a TR bit

Address

Instruction

00000 00001 00002 00003 00004 00005 00006

LD OUT AND Instruction 1 LD AND Instruction 2

Operands 00000 0 00001

TR

TR

0 00002

In terms of actual instructions the above diagram would be as follows: The status of IR 00000 is loaded (a LOAD instruction) to establish the initial execution condition. This execution condition is then output using an OUTPUT instruction to TR 0 to store the execution condition at the branching point. The execution condition is then ANDed with the status of IR 00001 and instruction 1 is executed accordingly. The execution condition that was stored at the branching point is then re-loaded (a LOAD instruction with TR 0 as the operand), this is ANDed with the status of IR 00002, and instruction 2 is executed accordingly. The following example shows an application using two TR bits.

TR 0 00000

TR 1 00001

00002 Instruction 1 00003 Instruction 2

00004 Instruction 3 00005 Instruction 4

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014

LD OUT AND OUT AND Instruction 1 LD AND Instruction 2 LD AND Instruction 3 LD AND NOT Instruction 4

Operands TR TR

00000 0 00001 1 00002

TR

1 00003

TR

0 00004

TR

0 00005

In this example, TR 0 and TR 1 are used to store the execution conditions at the branching points. After executing instruction 1, the execution condition stored in TR 1 is loaded for an AND with the status IR 00003. The execution condition stored in TR 0 is loaded twice, the first time for an AND with the status of IR 00004 and the second time for an AND with the inverse of the status of IR 00005. TR bits can be used as many times as required as long as the same TR bit is not used more than once in the same instruction block. Here, a new instruction block is begun each time execution returns to the bus bar. If, in a single instruction block, it is necessary to have more than eight branching points that require the execution condition be saved, interlocks (which are described next) must be used.

116

Page 135

Section 4-7

Inputting, Modifying, and Checking the Program

When drawing a ladder diagram, be careful not to use TR bits unless necessary. Often the number of instructions required for a program can be reduced and ease of understanding a program increased by redrawing a diagram that would otherwise required TR bits. In both of the following pairs of diagrams, the bottom versions require fewer instructions and do not require TR bits. In the first example, this is achieved by reorganizing the parts of the instruction block: the bottom one, by separating the second OUTPUT instruction and using another LOAD instruction to create the proper execution condition for it. Note Although simplifying programs is always a concern, the order of execution of instructions is sometimes important. For example, a MOVE instruction may be required before the execution of a BINARY ADD instruction to place the proper data in the required operand word. Be sure that you have considered execution order before reorganizing a program to simplify it. TR 0 00000

00001 Instruction 1

Instruction 2

00000 Instruction 2 00001 Instruction 1

00000

00003 Instruction 1

TR 0 00001

00002

00004 Instruction 2

00001

00002

00003 Instruction 1

00000

00001

00004 Instruction 2

Note TR bits are only used when programming using mnemonic code. They are not necessary when inputting ladder diagrams directly. The above limitations on the number of branching points requiring TR bits, and considerations on methods to reduce the number of programming instructions, still hold. Interlocks

The problem of storing execution conditions at branching points can also be handled by using the INTERLOCK (IL(02)) and INTERLOCK CLEAR (ILC(03)) instructions to eliminate the branching point completely while allowing a specific execution condition to control a group of instructions. The INTERLOCK and INTERLOCK CLEAR instructions are always used together.

117

Page 136

Section 4-7

Inputting, Modifying, and Checking the Program

When an INTERLOCK instruction is placed before a section of a ladder program, the execution condition for the INTERLOCK instruction will control the execution of all instruction up to the next INTERLOCK CLEAR instruction. If the execution condition for the INTERLOCK instruction is OFF, all right-hand instructions through the next INTERLOCK CLEAR instruction will be executed with OFF execution conditions to reset the entire section of the ladder diagram. The effect that this has on particular instructions is described in 5-10 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03). Diagram B can also be corrected with an interlock. Here, the conditions leading up to the branching point are placed on an instruction line for the INTERLOCK instruction, all of lines leading from the branching point are written as separate instruction lines, and another instruction line is added for the INTERLOCK CLEAR instruction. No conditions are allowed on the instruction line for INTERLOCK CLEAR. Note that neither INTERLOCK nor INTERLOCK CLEAR requires an operand. 00000 IL(02)

Address

Instruction

00000 00001 00002 00003 00004 00005 00006

LD IL(02) LD Instruction 1 LD Instruction 2 ILC(03)

00001 Instruction 1 00002 Instruction 2

ILC(03)

Operands 00000 --00001 00002 ---

If IR 00000 is ON in the revised version of diagram B, above, the status of IR 00001 and that of IR 00002 would determine the execution conditions for instructions 1 and 2, respectively. Because IR 00000 is ON, this would produce the same results as ANDing the status of each of these bits. If IR 00000 is OFF, the INTERLOCK instruction would produce an OFF execution condition for instructions 1 and 2 and then execution would continue with the instruction line following the INTERLOCK CLEAR instruction. As shown in the following diagram, more than one INTERLOCK instruction can be used within one instruction block; each is effective through the next INTERLOCK CLEAR instruction.

00000 IL(02) 00001 Instruction 1 00002 IL(02) 00003

00004 Instruction 2

00005 Instruction 3 00006 Instruction 4

ILC(03)

118

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013

LD IL(02) LD Instruction 1 LD IL(02) LD AND NOT Instruction 2 LD Instruction 3 LD Instruction 4 ILC(03)

Operands 00000 --00001 00002 --00003 00004 00005 00006 ---

Page 137

Section 4-7

Inputting, Modifying, and Checking the Program

If IR 00000 in the above diagram is OFF (i.e., if the execution condition for the first INTERLOCK instruction is OFF), instructions 1 through 4 would be executed with OFF execution conditions and execution would move to the instruction following the INTERLOCK CLEAR instruction. If IR 00000 is ON, the status of IR 00001 would be loaded as the execution condition for instruction 1 and then the status of IR 00002 would be loaded to form the execution condition for the second INTERLOCK instruction. If IR 00002 is OFF, instructions 2 through 4 will be executed with OFF execution conditions. If IR 00002 is ON, IR 00003, IR 00005, and IR 00006 will determine the first execution condition in new instruction lines.

4-7-8 Jumps A specific section of a program can be skipped according to a designated execution condition. Although this is similar to what happens when the execution condition for an INTERLOCK instruction is OFF, with jumps, the operands for all instructions maintain status. Jumps can therefore be used to control devices that require a sustained output, e.g., pneumatics and hydraulics, whereas interlocks can be used to control devices that do not required a sustained output, e.g., electronic instruments. Jumps are created using the JUMP (JMP(04)) and JUMP END (JME(05)) instructions. If the execution condition for a JUMP instruction is ON, the program is executed normally as if the jump did not exist. If the execution condition for the JUMP instruction is OFF, program execution moves immediately to a JUMP END instruction without changing the status of anything between the JUMP and JUMP END instruction. All JUMP and JUMP END instructions are assigned jump numbers ranging between 00 and 99. There are two types of jumps. The jump number used determines the type of jump. A jump can be defined using jump numbers 01 through 99 only once, i.e., each of these numbers can be used once in a JUMP instruction and once in a JUMP END instruction. When a JUMP instruction assigned one of these numbers is executed, execution moves immediately to the JUMP END instruction that has the same number as if all of the instruction between them did not exist. Diagram B from the TR bit and interlock example could be redrawn as shown below using a jump. Although 01 has been used as the jump number, any number between 01 and 99 could be used as long as it has not already been used in a different part of the program. JUMP and JUMP END require no other operand and JUMP END never has conditions on the instruction line leading to it.

00000 JMP(04) 01 00001 Instruction 1 00002 Instruction 2

JME(05) 01

Diagram B: Corrected with a Jump

Address

Instruction

00000 00001 00002 00003 00004 00005 00006

LD JMP(04) LD Instruction 1 LD Instruction 2 JME(05)

Operands 00000 01 00001 00002 015

This version of diagram B would have a shorter execution time when 00000 was OFF than any of the other versions.

119

Page 138

Section 4-8

Controlling Bit Status

The other type of jump is created with a jump number of 00. As many jumps as desired can be created using jump number 00 and JUMP instructions using 00 can be used consecutively without a JUMP END using 00 between them. It is even possible for all JUMP 00 instructions to move program execution to the same JUMP END 00, i.e., only one JUMP END 00 instruction is required for all JUMP 00 instruction in the program. When 00 is used as the jump number for a JUMP instruction, program execution moves to the instruction following the next JUMP END instruction with a jump number of 00. Although, as in all jumps, no status is changed and no instructions are executed between the JUMP 00 and JUMP END 00 instructions, the program must search for the next JUMP END 00 instruction, producing a slightly longer execution time. Execution of programs containing multiple JUMP 00 instructions for one JUMP END 00 instruction is similar to that of interlocked sections. The following diagram is the same as that used for the interlock example above, except redrawn with jumps. The execution of this diagram would differ from that of the diagram described above (e.g., in the previous diagram interlocks would reset certain parts of the interlocked section, however, jumps do not affect the status of any bit between the JUMP and JUMP END instructions).

00000 JMP(04) 00 00001 Instruction 1 00002 JMP(04) 00 00003

00004 Instruction 2

00005 Instruction 3 00006 Instruction 4

JME(05) 00

4-8

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013

LD JMP(04) LD Instruction 1 LD JMP(04) LD AND NOT Instruction 2 LD Instruction 3 LD Instruction 4 JME(05)

Operands 00000 00 00001 00002 00 00003 00004 00005 00006 00

Controlling Bit Status There are five instructions that can be used generally to control individual bit status. These are the OUTPUT, OUTPUT NOT, DIFFERENTIATE UP, DIFFERENTIATE DOWN, and KEEP instructions. All of these instructions appear as the last instruction in an instruction line and take a bit address for an operand. Although details are provided in 5-9 Bit Control Instructions, these instructions (except for OUTPUT and OUTPUT NOT, which have already been introduced) are described here because of their importance in most programs. Although these instructions are used to turn ON and OFF output bits in the IR area (i.e., to send or stop output signals to external devices), they are also used to control the status of other bits in the IR area or in other data areas.

120

Page 139

Section 4-8

Controlling Bit Status

4-8-1 DIFFERENTIATE UP and DIFFERENTIATE DOWN DIFFERENTIATE UP and DIFFERENTIATE DOWN instructions are used to turn the operand bit ON for one cycle at a time. The DIFFERENTIATE UP instruction turns ON the operand bit for one cycle after the execution condition for it goes from OFF to ON; the DIFFERENTIATE DOWN instruction turns ON the operand bit for one cycle after the execution condition for it goes from ON to OFF. Both of these instructions require only one line of mnemonic code.

00000 DIFU(13) 00200

Address

Instruction

00000 00001

LD DIFU(13)

Address

Instruction

00000 00001

LD DIFD(14)

Operands 00000 00200

00001 DIFD(14) 00201

Operands 00001 00201

Here, IR 00200 will be turned ON for one cycle after IR 00000 goes ON. The next time DIFU(13) 00200 is executed, IR 00200 will be turned OFF, regardless of the status of IR 00000. With the DIFFERENTIATE DOWN instruction, IR 00201 will be turned ON for one cycle after IR 00001 goes OFF (IR 00201 will be kept OFF until then), and will be turned OFF the next time DIFD(14) 00201 is executed.

4-8-2 KEEP The KEEP instruction is used to maintain the status of the operand bit based on two execution conditions. To do this, the KEEP instruction is connected to two instruction lines. When the execution condition at the end of the first instruction line is ON, the operand bit of the KEEP instruction is turned ON. When the execution condition at the end of the second instruction line is ON, the operand bit of the KEEP instruction is turned OFF. The operand bit for the KEEP instruction will maintain its ON or OFF status even if it is located in an interlocked section of the diagram. In the following example, HR 0000 will be turned ON when IR 00002 is ON and IR 00003 is OFF. HR 0000 will then remain ON until either IR 00004 or IR 00005 turns ON. With KEEP, as with all instructions requiring more than one instruction line, the instruction lines are coded first before the instruction that they control.

00002

00003

S: set input

HR 0000

00004

00005

KEEP(11)

R: reset input

Address

Instruction

00000 00001 00002 00003 00004

LD AND NOT LD OR KEEP(11)

Operands

HR

00002 00003 00004 00005 0000

4-8-3 Self-maintaining Bits (Seal) Although the KEEP instruction can be used to create self-maintaining bits, it is sometimes necessary to create self-maintaining bits in another way so that they can be turned OFF when in an interlocked section of a program.

121

Page 140

Section 4-9

Work Bits (Internal Relays)

To create a self-maintaining bit, the operand bit of an OUTPUT instruction is used as a condition for the same OUTPUT instruction in an OR setup so that the operand bit of the OUTPUT instruction will remain ON or OFF until changes occur in other bits. At least one other condition is used just before the OUTPUT instruction to function as a reset. Without this reset, there would be no way to control the operand bit of the OUTPUT instruction. The above diagram for the KEEP instruction can be rewritten as shown below. The only difference in these diagrams would be their operation in an interlocked program section when the execution condition for the INTERLOCK instruction was ON. Here, just as in the same diagram using the KEEP instruction, two reset bits are used, i.e., HR 0000 can be turned OFF by turning ON either IR 00004 or IR 00005.

00002

00003

00004

00005 HR 0000

HR 0000

4-9

Address

Instruction

00000 00001 00002 00003 00004 00005

LD AND NOT OR AND NOT AND NOT OUT

Operands

HR

HR

00002 00003 0000 00004 00005 0000

Work Bits (Internal Relays) In programming, combining conditions to directly produce execution conditions is often extremely difficult. These difficulties are easily overcome, however, by using certain bits to trigger other instructions indirectly. Such programming is achieved by using work bits. Sometimes entire words are required for these purposes. These words are referred to as work words. Work bits are not transferred to or from the PC. They are bits selected by the programmer to facilitate programming as described above. I/O bits and other dedicated bits cannot be used as works bits. All bits in the IR area that are not allocated as I/O bits, and certain unused bits in the AR area, are available for use as work bits. Be careful to keep an accurate record of how and where you use work bits. This helps in program planning and writing, and also aids in debugging operations.

Work Bit Applications

Examples given later in this subsection show two of the most common ways to employ work bits. These should act as a guide to the almost limitless number of ways in which the work bits can be used. Whenever difficulties arise in programming a control action, consideration should be given to work bits and how they might be used to simplify programming. Work bits are often used with the OUTPUT, OUTPUT NOT, DIFFERENTIATE UP, DIFFERENTIATE DOWN, and KEEP instructions. The work bit is used first as the operand for one of these instructions so that later it can be used as a condition that will determine how other instructions will be executed. Work bits can also be used with other instructions, e.g., with the SHIFT REGISTER instruction (SFT(10)). An example of the use of work words and bits with the SHIFT REGISTER instruction is provided in 5-15-1 SHIFT REGISTER – SFT(10). Although they are not always specifically referred to as work bits, many of the bits used in the examples in Section 5 Instruction Set use work bits. Understanding the use of these bits is essential to effective programming.

122

Page 141

Section 4-9

Work Bits (Internal Relays)

Work bits can be used to simplify programming when a certain combination of conditions is repeatedly used in combination with other conditions. In the following example, IR 00000, IR 00001, IR 00002, and IR 00003 are combined in a logic block that stores the resulting execution condition as the status of IR 24600. IR 24600 is then combined with various other conditions to determine output conditions for IR 00100, IR 00101, and IR 00102, i.e., to turn the outputs allocated to these bits ON or OFF.

Reducing Complex Conditions

00000

00001 24600

00002

00003

24600

00004

00005 00100

24600

00005 00101

00004

24600

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016

LD AND NOT OR OR NOT OUT LD AND AND NOT OUT LD OR NOT AND OUT LD NOT OR OR OUT

Operands 00000 00001 00002 00003 24600 24600 00004 00005 00100 24600 00004 00005 00101 24600 00006 00007 00102

00102

00006

00007

Differentiated Conditions

Work bits can also be used if differential treatment is necessary for some, but not all, of the conditions required for execution of an instruction. In this example, IR 00100 must be left ON continuously as long as IR 00001 is ON and both IR 00002 and IR 00003 are OFF, or as long as IR 00004 is ON and IR 00005 is OFF. It must be turned ON for only one cycle each time IR 00000 turns ON (unless one of the preceding conditions is keeping it ON continuously).

123

Page 142

Section 4-10

Programming Precautions

This action is easily programmed by using IR 22500 as a work bit as the operand of the DIFFERENTIATE UP instruction (DIFU(13)). When IR 00000 turns ON, IR 22500 will be turned ON for one cycle and then be turned OFF the next cycle by DIFU(13). Assuming the other conditions controlling IR 00100 are not keeping it ON, the work bit IR 22500 will turn IR 00100 ON for one cycle only. 00000 DIFU(13) 22500 22500 00100 00001

00002

00004

00003

00005

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010

LD DIFU(13) LD LD AND NOT AND NOT OR LD LD AND NOT OR LD OUT

Operands 00000 22500 22500 00001 00002 00003 --00004 00005 --00100

4-10 Programming Precautions The number of conditions that can be used in series or parallel is unlimited as long as the memory capacity of the PC is not exceeded. Therefore, use as many conditions as required to draw a clear diagram. Although very complicated diagrams can be drawn with instruction lines, there must not be any conditions on lines running vertically between two other instruction lines. Diagram A shown below, for example, is not possible, and should be drawn as diagram B. Mnemonic code is provided for diagram B only; coding diagram A would be impossible. 00000

00002 Instruction 1

00004 00001

00003 Instruction 2

Diagram A

00001

00002

00004

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009

LD AND OR AND Instruction 1 LD AND OR AND NOT Instruction 2

Operands

Instruction 1 00000

00000

00004

00003 Instruction 2

00001

Diagram B

00001 00004 00000 00002 00000 00004 00001 00003

The number of times any particular bit can be assigned to conditions is not limited, so use them as many times as required to simplify your program. Often, complicated programs are the result of attempts to reduce the number of times a bit is used.

124

Page 143

Section 4-10

Programming Precautions

Except for instructions for which conditions are not allowed (e.g., INTERLOCK CLEAR and JUMP END, see below), every instruction line must also have at least one condition on it to determine the execution condition for the instruction at the right. Again, diagram A , below, must be drawn as diagram B. If an instruction must be continuously executed (e.g., if an output must always be kept ON while the program is being executed), the Always ON Flag (SR 25313) in the SR area can be used.

Instruction

Diagram A: Incorrect

25313 Instruction

Diagram B

Address

Instruction

00000 00001

LD Instruction

Operands 25313

There are a few exceptions to this rule, including the INTERLOCK CLEAR, JUMP END, and step instructions. Each of these instructions is used as the second of a pair of instructions and is controlled by the execution condition of the first of the pair. Conditions should not be placed on the instruction lines leading to these instructions. Refer to Section 5 Instruction Set for details. When drawing ladder diagrams, it is important to keep in mind the number of instructions that will be required to input it. In diagram A, below, an OR LOAD instruction will be required to combine the top and bottom instruction lines. This can be avoided by redrawing as shown in diagram B so that no AND LOAD or OR LOAD instructions are required. Refer to 5-8-2 AND LOAD and OR LOAD for more details and Section 7 Program Monitoring and Execution for further examples.

00000 00207

00001 00207

Address

Instruction

00000 00001 00002 00003 00004

LD LD AND OR LD OUT

Address

Instruction

00000 00001 00002 00003

LD AND OR OUT

Operands 00000 00001 00207 --00207

Diagram A

00001 00207 00207

00000

Operands 00001 00207 00000 00207

Diagram B

125