CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 51
Текст из файла (страница 51)
Although an END instruction can be placed at any point ina program, which is sometimes done when debugging, no instructions past thefirst END instruction will be executed until it is removed. The number followingthe END instruction in the mnemonic code is its function code, which is usedwhen inputted most instruction into the PC. These are described later.
The ENDinstruction requires no operands and no conditions can be placed on the sameinstruction line with it.0000000001InstructionEND(01)Address00500005010050200503InstructionProgram executionends here.OperandsLDAND NOTInstructionEND(01)0000000001---If there is no END instruction anywhere in the program, the program will not beexecuted at all.Now you have all of the instructions required to write simple input-output programs. Before we finish with ladder diagram basic and go onto inputting the program into the PC, let’s look at logic block instruction (AND LOAD and OR LOAD),which are sometimes necessary even with simple diagrams.6-3-6Logic Block InstructionsLogic block instructions do not correspond to specific conditions on the ladderdiagram; rather, they describe relationships between logic blocks.
The ANDLOAD instruction logically ANDs the execution conditions produced by two logicblocks. The OR LOAD instruction logically ORs the execution conditions produced by two logic blocks.AND LOADAlthough simple in appearance, the diagram below requires an AND LOADinstruction.00000000020000100003InstructionAddressInstruction0000000001000020000300004LDORLDOR NOTAND LDOperands00000000010000200003---311SectionBasic Ladder Diagrams6-3The two logic blocks are indicated by dotted lines.
Studying this example showsthat an ON execution condition will be produced when: either of the conditions inthe left logic block is ON (i.e., when either IR 00000 or IR 00001 is ON), andwhen either of the conditions in the right logic block is ON (i.e., when either IR00002 is ON or IR 00003 is OFF).The above ladder diagram cannot, however, be converted to mnemonic codeusing AND and OR instructions alone. If an AND between IR 00002 and the results of an OR between IR 00000 and IR 00001 is attempted, the OR NOT between IR 00002 and IR 00003 is lost and the OR NOT ends up being an OR NOTbetween just IR 00003 and the result of an AND between IR 00002 and the firstOR.
What we need is a way to do the OR (NOT)’s independently and then combine the results.To do this, we can use the LOAD or LOAD NOT instruction in the middle of aninstruction line. When LOAD or LOAD NOT is executed in this way, the currentexecution condition is saved in special buffers and the logic process is begunover. To combine the results of the current execution condition with that of a previous “unused” execution condition, an AND LOAD or an OR LOAD instruction isused.
Here “LOAD” refers to loading the last unused execution condition. An unused execution condition is produced by using the LOAD or LOAD NOT instruction for any but the first condition on an instruction line.Analyzing the above ladder diagram in terms of mnemonic instructions, thecondition for IR 00000 is a LOAD instruction and the condition below it is an ORinstruction between the status of IR 00000 and that of IR 00001. The condition atIR 00002 is another LOAD instruction and the condition below is an OR NOTinstruction, i.e., an OR between the status of IR 00002 and the inverse of thestatus of IR 00003. To arrive at the execution condition for the instruction at theright, the logical AND of the execution conditions resulting from these two blockswould have to be taken. AND LOAD does this.
The mnemonic code for the ladder diagram is shown below. The AND LOAD instruction requires no operands ofits own, because it operates on previously determined execution conditions.Here too, dashes are used to indicate that no operands needs designated or input.OR LOADThe following diagram requires an OR LOAD instruction between the top logicblock and the bottom logic block. An ON execution condition would be producedfor the instruction at the right either when IR 00000 is ON and IR 00001 is OFF orwhen IR 00002 and IR 00003 are both ON. The operation of and mnemonic codefor the OR LOAD instruction is exactly the same as those for a AND LOADinstruction except that the current execution condition is ORed with the last unused execution condition.0000000001Instruction00002Address000000000100002000030000400003InstructionLDAND NOTLDANDOR LDOperands00000000010000200003---Naturally, some diagrams will require both AND LOAD and OR LOAD instructions.312SectionBasic Ladder DiagramsLogic Block Instructions inSeries6-3To code diagrams with logic block instructions in series, the diagram must bedivided into logic blocks.
Each block is coded using a LOAD instruction to codethe first condition, and then AND LOAD or OR LOAD is used to logically combinethe blocks. With both AND LOAD and OR LOAD there are two ways to achievethis. One is to code the logic block instruction after the first two blocks and thenafter 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 blockinstructions which combine them. In this case, the instructions for the last pair ofblocks should be combined first, and then each preceding block should be combined, working progressively back to the first block.
Although either of thesemethods will produce exactly the same result, the second method, that of codingall logic block instructions together, can be used only if eight or fewer blocks arebeing combined, i.e., if seven or fewer logic block instructions are required.The following diagram requires AND LOAD to be converted to mnemonic codebecause three pairs of parallel conditions lie in series. The two means of codingthe programs are also shown.0000000002000042000000001Address000000000100002000030000400005000060000700008InstructionLDOR NOTLD NOTORAND LDLDORAND LDOUT00003Operands00000000010000200003—0000400005—2000000005Address000000000100002000030000400005000060000700008InstructionLDOR NOTLD NOTORLDORAND LDAND LDOUTOperands000000000100002000030000400005——20000Again, 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 thefirst 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 000012000100002 0000300004 00005313SectionBasic Ladder Diagrams6-3The first of each pair of conditions is converted to LOAD with the assigned bitoperand and then ANDed with the other condition. The first two blocks can becoded first, followed by OR LOAD, the last block, and another OR LOAD, or thethree blocks can be coded first followed by two OR LOADs.
The mnemonic codefor both methods is shown below.AddressInstruction000000000100002000030000400005000060000700008LDAND NOTLD NOTAND NOTOR LDLDANDOR LDOUTOperands00000000010000200003—0000400005—20001AddressInstruction000000000100002000030000400005000060000700008LDAND NOTLD NOTAND NOTLDANDOR LDOR LDOUTOperands000000000100002000030000400005——20001Again, 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 thefirst method.Combining AND LOAD andOR LOADBoth of the coding methods described above can also be used when using ANDLOAD and OR LOAD, as long as the number of blocks being combined does notexceed 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 usingonly AND and OR.00000 0000100002 00003200010020100004BlockaBlockbAddressInstruction0000000001000020000300004000050000600007LDAND NOTLDANDORORAND LDOUTOperands000000000100002000030020100004—20001Although the following diagram is similar to the one above, block b in the diagrambelow cannot be coded without separating it into two blocks combined with ORLOAD. In this example, the three blocks have been coded first and then ORLOAD has been used to combine the last two blocks followed by AND LOAD tocombine the execution condition produced by the OR LOAD with the executioncondition of block a.314SectionBasic Ladder Diagrams6-3When coding the logic block instructions together at the end of the logic blocksthey 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 theone to combine the execution condition resulting from the first logic blockinstruction and the execution condition of the logic block third from the end, andon back to the first logic block that is being combined.Blockb100000 0000100002 000032000200004 00202Blockb2BlockaComplicated DiagramsBlockbAddressInstruction000000000100002000030000400005000060000700008LD NOTANDLDAND NOTLD NOTANDOR LDAND LDOUTOperands000000000100002000030000400202——20002When determining what logic block instructions will be required to code a diagram, it is sometimes necessary to break the diagram into large blocks and thencontinue breaking the large blocks down until logic blocks that can be codedwithout logic block instructions have been formed.
These blocks are then coded,combining the small blocks first, and then combining the larger blocks. EitherAND LOAD or OR LOAD is used to combine the blocks, i.e., AND LOAD or ORLOAD always combines the last two execution conditions that existed, regardless of whether the execution conditions resulted from a single condition, fromlogic 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.