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

The text of a manual ยท part 21 of 60

SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 4 Ladder-diagram Programming, pages 180 to 189

Pages 180 to 189 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual

The original document is the PDF (2.1 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 CQM1-CPU21

Page 180

Section

Basic Ladder Diagrams Logic Block Instructions in Series

4-3

To code diagrams with logic block instructions in series, the diagram must be divided into logic blocks. Each block is coded using a LOAD instruction to code the first condition, and then AND LOAD or OR LOAD is used to logically combine the blocks. With both AND LOAD and OR LOAD there are two ways to achieve this. One is to code the logic block instruction after the first two blocks and then after each additional block. The other is to code all of the blocks to be combined, starting each block with LOAD or LOAD NOT, and then to code the logic block instructions which combine them. In this case, the instructions for the last pair of blocks should be combined first, and then each preceding block should be combined, working progressively back to the first block. Although either of these methods will produce exactly the same result, the second method, that of coding all logic block instructions together, can be used only if eight or fewer blocks are being combined, i.e., if seven or fewer logic block instructions are required. The following diagram requires AND LOAD to be converted to mnemonic code because three pairs of parallel conditions lie in series. The two means of coding the programs are also shown.

00000

00002

00004 10000

00001

Address 00000 00001 00002 00003 00004 00005 00006 00007 00008

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

00003

Operands 00000 00001 00002 00003, 00004 00005, 10000

00005

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008

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

Operands 00000 00001 00002 00003 00004 00005, - 10000

Again, with the method on the right, a maximum of eight blocks can be combined. There is no limit to the number of blocks that can be combined with the first method. The following diagram requires OR LOAD instructions to be converted to mnemonic code because three pairs of conditions in series lie in parallel to each other.

00000 00001 10001

00002 00003

00004 00005

161

Page 181

Section

Basic Ladder Diagrams

4-3

The first of each pair of conditions is converted to LOAD with the assigned bit operand and then ANDed with the other condition. The first two blocks can be coded first, followed by OR LOAD, the last block, and another OR LOAD, or the three blocks can be coded first followed by two OR LOADs. The mnemonic code for both methods is shown below. Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008

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

Operands 00000 00001 00002 00003, 00004 00005, 10001

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008

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

Operands 00000 00001 00002 00003 00004 00005, - 10001

Again, with the method on the right, a maximum of eight blocks can be combined. There is no limit to the number of blocks that can be combined with the first method. Combining AND LOAD and OR LOAD

Both of the coding methods described above can also be used when using AND LOAD and OR LOAD, as long as the number of blocks being combined does not exceed eight. The following diagram contains only two logic blocks as shown. It is not necessary to further separate block b components, because it can coded directly using only AND and OR. 00000 00001

00002 00003 10001

00201

00004

Block a

Block b

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007

LD AND NOT LD AND OR OR AND LD OUT

Operands 00000 00001 00002 00003 00201 00004, 10001

Although the following diagram is similar to the one above, block b in the diagram below cannot be coded without separating it into two blocks combined with OR LOAD. In this example, the three blocks have been coded first and then OR LOAD has been used to combine the last two blocks followed by AND LOAD to combine the execution condition produced by the OR LOAD with the execution condition of block a.

162

Page 182

Section

Basic Ladder Diagrams

4-3

When coding the logic block instructions together at the end of the logic blocks they are combining, they must, as shown below, be coded in reverse order, i.e., the logic block instruction for the last two blocks is coded first, followed by the one to combine the execution condition resulting from the first logic block instruction and the execution condition of the logic block third from the end, and on back to the first logic block that is being combined. Block b1 00000 00001

00002 00003 10002

00004 00202

Block b2

Block a

Complicated Diagrams

Block b

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008

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

Operands 00000 00001 00002 00003 00004 00202, - 10002

When determining what logic block instructions will be required to code a diagram, it is sometimes necessary to break the diagram into large blocks and then continue breaking the large blocks down until logic blocks that can be coded without logic block instructions have been formed. These blocks are then coded, combining the small blocks first, and then combining the larger blocks. Either AND LOAD or OR LOAD is used to combine the blocks, i.e., AND LOAD or OR LOAD always combines the last two execution conditions that existed, regardless of whether the execution conditions resulted from a single condition, from logic blocks, or from previous logic block instructions. When working with complicated diagrams, blocks will ultimately be coded starting at the top left and moving down before moving across. This will generally mean that, when there might be a choice, OR LOAD will be coded before AND LOAD.

163

Page 183

Section

Basic Ladder Diagrams

4-3

The following diagram must be broken down into two blocks and each of these then broken into two blocks before it can be coded. As shown below, blocks a and b require an AND LOAD. Before AND LOAD can be used, however, OR LOAD must be used to combine the top and bottom blocks on both sides, i.e., to combine a1 and a2; b1 and b2.

Block a1

Block b1

00000 00001

00004 00005 10003

00002 00003

00006 00007

Block a2

Block b2

Block a

Block b

Address

Instruction

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

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

Operands 00000 00001 00002 00003, 00004 00005 00006 00007, - 10003

Blocks a1 and a2

Blocks b1 and b2 Blocks a and b

The following type of diagram can be coded easily if each block is coded in order: first top to bottom and then left to right. In the following diagram, blocks a and b would be combined using AND LOAD as shown above, and then block c would be coded and a second AND LOAD would be used to combined it with the execution condition from the first AND LOAD. Then block d would be coded, a third AND LOAD would be used to combine the execution condition from block d with the execution condition from the second AND LOAD, and so on through to block n.

10000

Block a

164

Block b

Block c

Block n

Page 184

Section

Basic Ladder Diagrams

4-3

The following diagram requires an OR LOAD followed by an AND LOAD to code the top of the three blocks, and then two more OR LOADs to complete the mnemonic code. 00000

00001

Address

Instruction

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

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

Operands

LR 0000 00002

00004

00005

00006

00007

00003

LR

00000 00001 00002 00003 --00004 00005 -00006 00007 -0000

Although the program will execute as written, this diagram could be drawn as shown below to eliminate the need for the first OR LOAD and the AND LOAD, simplifying the program and saving memory space. 00002

00003

00000 LR 0000

00001

00004

00005

00006

00007

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010

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

Operands

LR

00002 00003 00001 00000 00004 00005 -00006 00007 -0000

The following diagram requires five blocks, which here are coded in order before using OR LOAD and AND LOAD to combine them starting from the last two blocks and working backward. The OR LOAD at program address 00008 combines blocks blocks d and e, the following AND LOAD combines the resulting execution condition with that of block c, etc. 00000

00001

00002 LR 0000

Block b Block a Block c 00003

00004

Block d 00005

00006

00007 Blocks d and e

Block e

Block c with result of above Block b with result of above Block a with result of above

Address

Instruction

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

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

Operands

LR

00000 00001 00002 00003 00004 00005 00006 00007 ----0000

165

Page 185

Section

Basic Ladder Diagrams

4-3

Again, this diagram can be redrawn as follows to simplify program structure and coding and to save memory space. 00006

00007

00003

00004

00000 LR 0000

00005

00001

00002

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009

LD AND OR AND AND LD AND OR LD AND OUT

Operands 00006 00007 00005 00003 00004 00001 00002 -00000 0000

LR

The next and final example may at first appear very complicated but can be coded using only two logic block instructions. The diagram appears as follows: Block a 00000

00001

01000

01001

00002

00003

00004

00005 10000

00006

10000 Block b

166

Block c

Page 186

Section

Basic Ladder Diagrams

4-3

The first logic block instruction is used to combine the execution conditions resulting from blocks a and b, and the second one is to combine the execution condition of block c with the execution condition resulting from the normally closed condition assigned IR 00003. The rest of the diagram can be coded with OR, AND, and AND NOT instructions. The logical flow for this and the resulting code are shown below. Block a

Block b

00000

00001

01000

01001

LD AND

00000 00001

LD AND

01000 01001

OR LD Block c 10000

00004

00005

00004 00005

OR

10000

LD AND

00002

00003

00006

AND 00002 AND NOT 00003

OR

00006

AND LD

10000

Address

Instruction

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

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

Operands 00000 00001 01000 01001 -10000 00002 00003 00004 00005 00006 -10000

167

Page 187

Section

Basic Ladder Diagrams

4-3-7

4-3

Coding Multiple Right-hand Instructions If there is more than one right-hand instruction executed with the same execution condition, they are coded consecutively following the last condition on the instruction line. In the following example, the last instruction line contains one more condition that corresponds to an AND with IR 00004.

00000

00003 HR 0001

00001 10000 00002

00004 10006

HR 0000

4-3-8

Address

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008

LD OR OR OR AND OUT OUT AND OUT

Operands

HR HR

00000 00001 00002 0000 00003 0001 10000 00004 10006

Branching Instruction Lines When an instruction line branches into two or more lines, it is sometimes necessary to use either interlocks or TR bits to maintain the execution condition that existed at a branching point. This is because instruction lines are executed across to a right-hand instruction before returning to the branching point to execute instructions one a branch line. If a condition exists on any of the instruction lines after the branching point, the execution condition could change during this time making proper execution impossible. The following diagrams illustrate this. In both diagrams, instruction 1 is executed before returning to the branching point and moving on to the branch line leading to instruction 2.

00000

Branching point

Address

Instruction

Instruction 2

00000 00001 00002 00003

LD Instruction 1 AND Instruction 2

Instruction 1

Address

Instruction

00000 00001 00002 00003 00004

LD AND Instruction 1 AND Instruction 2

Instruction 1 00002

Diagram A: Correct Operation 00000

Branching point

Operands 00000 00002

00001

00002 Instruction 2

Diagram B: Incorrect Operation

Operands 00000 00001 00002

If, as shown in diagram A, the execution condition that existed at the branching point cannot be changed before returning to the branch line (instructions at the far right do not change the execution condition), then the branch line will be executed correctly and no special programming measure is required. If, as shown in diagram B, a condition exists between the branching point and the last instruction on the top instruction line, the execution condition at the branching point and the execution condition after completing the top instruction line will sometimes be different, making it impossible to ensure correct execution of the branch line. There are two means of programming branching programs to preserve the execution condition. One is to use TR bits; the other, to use interlocks (IL(02)/IL(03)).

168

Page 188

Section

Basic Ladder Diagrams

4-3

The TR area provides eight bits, TR 0 through TR 7, that can be used to temporarily preserve execution conditions. If a TR bit is placed at a branching point, the current execution condition will be stored at the designated TR bit. When returning to the branching point, the TR bit restores the execution status that was saved when the branching point was first reached in program execution.

TR Bits

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 00001

00000

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.

169

Page 189

Section

Basic Ladder Diagrams

4-3

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

00000

00001

00003 Instruction 1

Instruction 1

Instruction 2

TR 0 00001

00002

00004 Instruction 2

00000 Instruction 2 00001 Instruction 1

00001

00002

00003 Instruction 1

00000

00001

00004 Instruction 2

Note TR bits are must be input by the user only when programming using mnemonic code. They are not necessary when inputting ladder diagrams directly because they are processed for you automatically. 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

170

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.