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

The text of a manual · part 8 of 27

SYSMAC C20P/C28P/C40P/C60P P-type Programmable Controllers Operation Manual: SECTION 4, pages 45 to 52

Pages 45 to 52 of 211, from SYSMAC C20P/C28P/C40P/C60P P-type Programmable Controllers Operation Manual

The original document is the PDF (2.2 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 C28P

Page 45

Section 4–3

The Ladder Diagram 0000

0003 Instruction 1

TR 0 0001

0002

0004 Instruction 2

0001

0002

0003 Instruction 1

0000

0004

0001

Instruction 2

Note TR bits are only used when programming using mnemonic code and are not necessary when inputting ladder diagrams directly, as is possible from a GPC. 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. When an Interlock instruction is placed at a branching point of an instruction line and the execution condition for the Interlock instruction is ON, each branch line is established as an new instruction line, with the first condition on each branch line corresponding to a Load or Load NOT instruction. If the execution condition for the Interlock instruction is OFF, all instructions on the right side of the branch lines leading from the branching point receive an OFF execution condition through the first Interlock Clear instruction. The effect that this has on particular instructions is described in 5–7 Interlock and Interlock Clear – IL(02) and ILC(03). Diagram B from the above example can also be corrected with an interlock. As shown below, this requires one more instruction line for the Interlock Clear instruction. 0000

IL(02)

0001 Instruction 1 0002 Instruction 2

ILC(03)

Diagram B: Corrected with an Interlock

If 0000 is ON in the above version of diagram B, the status of 0001 and that of 0002 would determine the execution conditions for instructions 1 and 2, respectively, on independent instruction lines. Because here 0000 is ON, this would produce the same results as ANDing the status of each of these bits, as would occur if the interlock was not used, i.e., the Interlock and Interlock

37

Page 46

Section 4–3

The Ladder Diagram

Clear instructions would not affect execution. If 0000 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 from its branching point through the next Interlock Clear instruction. 0000

IL(02)

0001 Instruction 1 0002

IL(02)

0003

0004 Instruction 2

0005 Instruction 3 0006 Instruction 4

ILC(03)

If 0000 in the above diagram was OFF (i.e., if the execution condition for the first Interlock instruction was 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 0000 was ON, the status of 0001 would be loaded to form the execution condition for instruction 1 and then the status of 0002 would be loaded to form the first execution status for that instruction line, i.e., the execution condition for the second Interlock instruction. If 0002 was OFF, instructions 2 through 4 would be executed with OFF execution conditions. If 0002 was ON, 0003, 0005, and 0006 would each start a new instruction line. Because all branch lines following branching points with Interlock instructions form independent instruction lines, interlocked sections of programs can be redrawn without branching points. The following diagram executes exactly like the one above and would be input in exactly the same order using the same instructions. 0000 IL(02) 0001 Instruction 1 0002 IL(02) 0003

0004 Instruction 2

0005 Instruction 3 0006 Instruction 4

ILC(03)

This type of interlock diagram appears when inputting ladder diagrams directly, as is possible from a GPC.

38

Page 47

Section 4–3

The Ladder Diagram

It’s interesting to notice that if any instructions are added to an interlocked section of a diagram, they in essence branch from the branching point where the Interlock instruction is located, regardless of whether they are drawn that way or whether they are drawn connected directly to the bus bar. If we add a third instruction between instruction 2 and the Interlock Clear instruction to diagram B from above, we can connected it either as another branch line following the branch line for instruction 2 or directly to the bus bar. In either case, the diagram, when rewritten into the type of display shown above for GPC displays, would be the same. Both diagrams would naturally execute exactly the same.

0000

IL(02)

0001

0000

IL(02)

0001

Instruction 1

Instruction 1

0002

0002 Instruction 2

Instruction 2

0003

0003 Instruction 3

Instruction 3

ILC(03)

ILC(03)

0000 IL(02) 0001 Instruction 1 0002 Instruction 2 0003 Instruction 3

ILC(03)

When drawing interlocked sections of ladder diagrams, either form may be used. The non-branching form will be used in the remainder of this manual.

4–3–5

Jumps A specific section of a program can be skipped according 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. In the following example, Instructions 1 and 2 would not be executed when IR 0000 is OFF and execution would skip immediately to the Jump End instruction without change the status of any bits or words in between. If IR 0000 is ON, the program would be executed as if the jump did not exist.

39

Page 48

Section 4–4

Controlling Bit Status 0000 JMP(04) 0001

Instruction 1 0002 Instruction 2

JME(05)

Diagram B: Corrected with a Jump

Execution of programs containing multiple Jump instructions for one Jump End instruction resembles that of similar interlocked sections. The following diagram is the same as that used for the interlock example above, except redrawn with jumps. This diagram, however, would not execution the same, as has already be described, i.e., interlocks would reset certain parts of the interlocked section but jumps would not affect any status between the Jump and Jump End instructions.

0000 JMP(04) 00 0001 Instruction 1 0002 JMP(04) 00 0003

0004 Instruction 2

0005 Instruction 3 0006 Instruction 4

JME(05) 00

Jump diagrams can also be drawn as branching instruction lines if desired and would look exactly like their interlock equivalents. The non-branching form, which is the form displayed on the GPC, will be used in this manual.

4–4

Controlling Bit Status There are five instructions that can be used generally to control individual bit status. These are the Output or OUT, Output NOT or OUT NOT, Differentiate Up, Differentiate Down, and Keep instructions. All of these instruction appear as the last instruction in an instruction line and take a bit address for an operand. Although details are provided in 5–6 Bit Control Instructions, these instructions 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.

4–4–1

OUT and OUT NOT The OUT and OUT NOT instructions are used to control the status of the designated operand bit according to the execution condition. With the OUT instruction, the operand bit will be turned ON as long as the execution condi-

40

Page 49

Section 4–4

Controlling Bit Status tion is ON and will be turned OFF as long as the execution condition is OFF. With the OUT NOT instruction, the operand bit will be turned ON as long as the execution condition is OFF and turned OFF as long as the execution condition is ON. These appear as follows: 0000 0100

0001 0101

In the above examples, bit 0500 will be ON as long as 0000 is ON and bit 0501 will be OFF as long as 0001 is ON. Here, 0000 and 0001 would be input bits and 0500 and 0501 output bits assigned to the Units controlled by the PC, i.e., the signals coming in through the input points assigned 0000 and 0001 are controlling the output points assigned 0500 and 0501, respectively. The length of time that a bit is ON or OFF can be controlled by combining the OUT or OUT NOT instruction with Timer instructions. Refer to Examples under 5–11–1 Timer – TIM for details.

4–4–2

Differentiate Up and Differentiate Down Differentiate Up and Differentiate Down instructions are used to turn the operand bit ON for one scan at a time. The Differentiate Up turns ON the operand bit for one scan after the execution condition when it goes from OFF to ON; the Differentiate Down instruction turns ON the operand bit for one scan after the execution condition when it goes from ON to OFF. The following example shows the same I/O bits as above, but this time they are controlled by Differentiate Up and Down instructions. 0000 DIFU(13) 0500

0001 DIFD(14) 0501

Here, 0500 will be turned ON for one scan after 0000 goes ON. The next time DIFU(13) 0500 is executed, 0500 will be turned OFF, regardless of the status of 0000. With the Differentiate Down instruction, 0501 will be turned ON for one scan after 0001 goes OFF (0501 will be kept OFF until then) and will be turned ON the next time DIFD(14) is executed.

4–4–3

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 and the execution condition for the Interlock instruction is ON.

41

Page 50

Section 4–5

The End Instruction

In the following example, HR 000 will be turned ON when 0002 is ON and 0003 is OFF. HR 000 will then remain ON until either 0004 or 0005 turns ON.

0002

0003

S: set input

KEEP(11) HR 000

0004

R: reset input

0005

4–4–4

Self-maintaining Bits 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. 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 in other bits occur. 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 000 is turned OFF by turning ON both 0004 and 0005.

0002

0003

0004 HR 000 0005

HR 000

4–5

The End Instruction The last instruction in any program must be the End instruction. When the CPU scans the program, it executes all instructions up to the first End instruction before returning to the beginning of the program and beginning execution again. Although an End instruction can be placed at any point in a program, which is sometimes done when debugging, no instructions past the first End instruction will be executed until it is removed.

0000

0001 Instruction

END(01)

42

Program execution ends here.

Page 51

Section 4–6

Programming Precautions

If there is no End instruction anywhere in the program, the program will not be executed at all.

4–6

Programming Precautions The number of conditions that can be used in series or parallel is unlimited. Therefore, use as many conditions as required to draw a clear diagram. Although very complicated diagrams can be drawn with instruction lines almost forming mazes, there must not be any conditions on instruction lines running vertically between two other instruction lines. Diagram A shown below, for example, is not possible, and should be redrawn as diagram B. 0000

0002 Instruction 1

0004 0001

0003 Instruction 2

Diagram A

0001

0002

0004

Instruction 1 0000

0000

0003

0004

Instruction 2 0001

Diagram B

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. 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 redrawn as diagram B. If an instruction must always be executed (e.g., if an output must always be kept ON while the program is being executed), the Always ON Flag (1813) in the SR area can be used.

Instruction

Diagram A

1813 Instruction

Diagram B

There are, however, 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 condi-

43

Page 52

Section 4–7

Program Execution tion 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–5–2 AND Load and OR Load for more details and 7–5 Inputting, Modifying and Checking the Program for further examples.

0000 0207

0001

0207

Diagram A:

0001

0207 0207

0000

Diagram B:

4–7

Program Execution When program execution is started, the CPU scans the program from top to bottom, checking all conditions and executing all instructions accordingly as it moves down the bus bar. It is important that instructions be placed in the proper order so that, for example, the desired data is moved to a word before that word is used as the operand for an instruction. Remember that an instruction line is completed to the terminal instruction at the right before executing any instruction lines branching from the first instruction line to other terminal instructions at the right. Program execution is only one of the tasks carried out by the CPU as part of the scan time. Refer to Section 6 Program Execution Timing for details.

44