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

The text of a manual · part 17 of 68

Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 4 Writing and Inputting the Program, pages 137 to 145

Pages 137 to 145 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual

The original document is the PDF (3.8 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.

Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204

Page 137

Section

Inputting, Modifying, and Checking the Program

4-7

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

124

The problem of storing execution conditions at branching points can also be handled by using the INTERLOCK (IL(002)) and INTERLOCK CLEAR (ILC(003)) 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.

Page 138

Section

Inputting, Modifying, and Checking the Program

4-7

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(002) and ILC(003). 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(002)

Address

Instruction

00000 00001 00002 00003 00004 00005 00006

LD IL(002) LD Instruction 1 LD Instruction 2 ILC(003)

00001 Instruction 1 00002 Instruction 2

ILC(003)

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(002) 00001 Instruction 1 00002 IL(002) 00003

00004 Instruction 2

00005 Instruction 3 00006 Instruction 4

ILC(003)

Address

Instruction

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

LD IL(002) LD Instruction 1 LD IL(002) LD AND NOT Instruction 2 LD Instruction 3 LD Instruction 4 ILC(003)

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

125

Page 139

Section

Inputting, Modifying, and Checking the Program

4-7

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(004)) and JUMP END (JME(005)) 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(004) 01 00001 Instruction 1 00002 Instruction 2

JME(005) 01

Diagram B: Corrected with a Jump

Address

Instruction

00000 00001 00002 00003 00004 00005 00006

LD JMP(004) LD Instruction 1 LD Instruction 2 JME(005)

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.

126

Page 140

Section

Controlling Bit Status

4-8

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(004) 00 00001 Instruction 1 00002 JMP(004) 00 00003

00004 Instruction 2

00005 Instruction 3 00006 Instruction 4

JME(005) 00

4-8

Address

Instruction

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

LD JMP(004) LD Instruction 1 LD JMP(004) LD AND NOT Instruction 2 LD Instruction 3 LD Instruction 4 JME(005)

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.

127

Page 141

Section

Controlling Bit Status

4-8

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(013) 00200

Address

Instruction

00000 00001

LD DIFU(013)

Address

Instruction

00000 00001

LD DIFD(014)

Operands 00000 00200

00001 DIFD(014) 00201

Operands 00001 00201

Here, IR 00200 will be turned ON for one cycle after IR 00000 goes ON. The next time DIFU(013) 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(014) 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(011)

R: reset input

Address

Instruction

00000 00001 00002 00003 00004

LD AND NOT LD OR KEEP(011)

Operands 00002 00003 00004 00005 HR 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.

128

Page 142

Section

Work Bits (Internal Relays)

4-9

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 00002 00003 HR 0000 00004 00005 HR 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(010)). An example of the use of work words and bits with the SHIFT REGISTER instruction is provided in 5-15-1 SHIFT REGISTER – SFT(010). 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.

129

Page 143

Section

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

4-9

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

130

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).

Page 144

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(013)). When IR 00000 turns ON, IR 22500 will be turned ON for one cycle and then be turned OFF the next cycle by DIFU(013). 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(013) 22500 22500 00100 00001

00002

00004

00003

00005

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010

LD DIFU(013) 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

00004

00002

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.

131

Page 145

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

Diagram B

132

Operands 00001 00207 00000 00207