CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 49
Текст из файла (страница 49)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-1 Basic Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-2 Mnemonic Code . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-3 Ladder Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-4 OUTPUT and OUTPUT NOT . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-5 The END Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-6 Logic Block Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-7 Coding Multiple Right-hand Instructions . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-8 Branching Instruction Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3-9 Jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .Controlling Bit Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-4-1 SET and RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-4-2 DIFFERENTIATE UP and DIFFERENTIATE DOWN . . . . .
. . . . . . . . . . . . . . .6-4-3 KEEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-4-4 Self-maintaining Bits (Seal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Work Bits (Internal Relays) .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Programming Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Program Execution .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304304305305306307310311311319319323324324325325326326328330303SectionInstruction Terminology6-16-2Basic ProcedureThere are several basic steps involved in writing a program. Sheets that can becopied to aid in programming are provided in Appendix D I/O Assignment Sheetand Appendix E Program Coding Sheet.1, 2, 3...
1.2.3.4.5.6.7.8.9.Obtain a list of all I/O devices and the I/O points that have been assigned tothem and prepare a table that shows the I/O bit allocated to each I/O device.If you are using LR bits to link two PCs, prepare sheet showing the used ofthese bits.Determine what words are available for work bits and prepare a table inwhich you can allocate these as you use them.Also prepare tables of TC numbers and jump numbers so that you can allocate these as you use them.
Remember, the function of a TC number canbe defined only once within the program; jump numbers 01 through 99 canbe used only once each. (TC number are described in 7-15 Timer andCounter Instructions; jump numbers are described later in this section.)Draw the ladder diagram.Input the program into the CPU Unit. When using the Programming Console, this will involve converting the program to mnemonic form.Check the program for syntax errors and correct these.Execute the program to check for execution errors and correct these.After the entire Control System has been installed and is ready for use,execute the program and fine tune it if required.The basics of ladder-diagram programming and conversion to mnemonic codeare described in 6-3 Basic Ladder Diagrams.
Preparing for and inputting the program via the Programming Console are described in the CPM1 OperationManual, the CPM1A Operation Manual, the CPM2A Operation Manual, theCPM2C Operation Manual, and the SRM1 Master Control Units Manual and viathe SSS in the SSS Operation Manual: C-series PCs.The rest of Section 6 covers more advanced programming, programming precautions, and program execution. All special application instructions are covered in Section 7 Instruction Set.
Debugging is described in the CPM1 OperationManual, the CPM1A Operation Manual, the CPM2A Operation Manual, theCPM2C Operation Manual, the SRM1 Master Control Units Manual, and SSSOperation Manual: C-series PCs. Section 9 Troubleshooting also provides information required for debugging.6-2Instruction TerminologyThere are basically two types of instructions used in ladder-diagram programming: instructions that correspond to the conditions on the ladder diagram andare used in instruction form only when converting a program to mnemonic codeand instructions that are used on the right side of the ladder diagram and areexecuted according to the conditions on the instruction lines leading to them.Most instructions have at least one or more operands associated with them.
Operands indicate or provide the data on which an instruction is to be performed.These are sometimes input as the actual numeric values, but are usually the addresses of data area words or bits that contain the data to be used. For instance,a MOVE instruction that has IR 000 designated as the source operand will movethe contents of IR 000 to some other location. The other location is also designated as an operand.
A bit whose address is designated as an operand is calledan operand bit; a word whose address is designated as an operand is called anoperand word. If the actual value is entered as a constant, it is preceded by # toindicate that it is not an address.304SectionBasic Ladder Diagrams6-3Other terms used in describing instructions are introduced in Section 7 Instruction Set.6-3Basic Ladder DiagramsA ladder diagram consists of one line running down the left side with linesbranching off to the right. The line on the left is called the bus bar; the branchinglines, instruction lines or rungs.
Along the instruction lines are placed conditionsthat lead to other instructions on the right side. The logical combinations of theseconditions determine when and how the instructions at the right are executed. Aladder diagram is shown below.00000 2000025208HR 0109LR 00032000120002Instruction0000100100 000020050100003 HR 00500050200007 TIM 001 LR 051500503005040040300405Instruction000102100121002000112100521007As shown in the diagram above, instruction lines can branch apart and they canjoin back together. The vertical pairs of lines are called conditions. Conditionswithout diagonal lines through them are called normally open conditions andcorrespond to a LOAD, AND, or OR instruction. The conditions with diagonallines through them are called normally closed conditions and correspond to aLOAD NOT, AND NOT, or OR NOT instruction. The number above each condition indicates the operand bit for the instruction.
It is the status of the bitassociated with each condition that determines the execution condition for following instructions. The way the operation of each of the instructions corresponds to a condition is described below. Before we consider these, however,there are some basic terms that must be explained.Note When displaying ladder diagrams with the SSS, a second bus bar will be shownon the right side of the ladder diagram and will be connected to all instructions onthe right side. This does not change the ladder-diagram program in any functional sense. No conditions can be placed between the instructions on the right sideand the right bus bar, i.e., all instructions on the right must be connected directlyto the right bus bar. Refer to the SSS Operation Manual: C-series PCs for details.6-3-1Basic TermsNormally Open andNormally ClosedConditionsEach condition in a ladder diagram is either ON or OFF depending on the statusof the operand bit that has been assigned to it.
A normally open condition is ON ifthe operand bit is ON; OFF if the operand bit is OFF. A normally closed conditionis ON if the operand bit is OFF; OFF if the operand bit is ON. Generally speaking,you use a normally open condition when you want something to happen when a305SectionBasic Ladder Diagrams6-3bit is ON, and a normally closed condition when you want something to happenwhen a bit is OFF.00000InstructionInstruction is executedwhen IR bit 00000 is ON.InstructionInstruction is executedwhen IR bit 00000 is OFF.Normally opencondition00000Normally closedconditionExecution ConditionsIn ladder diagram programming, the logical combination of ON and OFF conditions before an instruction determines the compound condition under which theinstruction is executed.
This condition, which is either ON or OFF, is called theexecution condition for the instruction. All instructions other than LOAD instructions have execution conditions.Operand BitsThe operands designated for any of the ladder instructions can be any bit in theIR, SR, HR, AR, LR, or TC areas. This means that the conditions in a ladder diagram can be determined by I/O bits, flags, work bits, timers/counters, etc.
LOADand OUTPUT instructions can also use TR area bits, but they do so only in special applications. Refer to 6-3-8 Branching Instruction Lines for details.Logic BlocksThe way that conditions correspond to what instructions is determined by therelationship between the conditions within the instruction lines that connectthem. Any group of conditions that go together to create a logic result is called alogic block. Although ladder diagrams can be written without actually analyzingindividual logic blocks, understanding logic blocks is necessary for efficient programming and is essential when programs are to be input in mnemonic code.Instruction BlockAn instruction block consists of all the instructions that are interconnectedacross the ladder diagram.