The text of a manual · part 16 of 29
1772 Mini PLC-2/05 Processor (Cat. No. 1772-LS, LSP) Programming and Operations Manual, pages 151 to 160
Pages 151 to 160 of 289
The original document is the PDF (1.4 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 Allen-Bradley 1772-LSP
Page 151
Chapter 13 Jump Instructions and Subroutines
Editing the Instruction You can edit a Jump, Jump to Subroutine or Return instruction to change an instruction type or its address by performing the following steps. 1.
Position the cursor over the Jump, Jump to Subroutine or Return instruction you are going to edit.
2.
Press -(JMP)-, -(JSR)-, or [SHIFT]-(RET)- or any other appropriate instruction type key.
Important: Do not perform step 3 for a Return instruction. 3.
Label Instruction
Enter <octal identification number>.
Purpose: The Label instruction is the target for both the Jump and Jump to Subroutine instructions. Label instructions are assigned octal identification numbers from 00-07. The label identification number must be the same as that of the Jump and/or Jump to Subroutine instruction with which it is used. A Label instruction can be defined only once, meaning that a label with a given identification number can only appear in one location. However, a Label instruction can be the target of jumps from more than one location. The Label instruction is always logically true. Programmed as the first condition instruction in the rung. If conditions precede a Label instruction, they will be ignored by the processor during a jump operation. Do not program with a program control instruction. 01 LBL
010 RET 00
Important: There are 8 labels available. Each label can only be defined once (using an octal identifier), but can be the target of multiple Jump or Jump to Subroutine instructions. Octal identifiers are labeled from 00-07.
13-3
Page 152
Chapter 13 Jump Instructions and Subroutines
ATTENTION: Do not place a Label instruction in a ZCL or MCR zone. When jumping over a start fence, the processor executes the program from the label to the end fence as if the start fence had been true, i.e. outputs controlled by the rungs. The start fence may have been false intending that all outputs within the zone be controlled by the output override instruction, i.e. off for MCR or last state for ZCL instructions. Unpredictable machine operation could occur with possible damage to equipment and/or injury to personnel. Keystrokes: You enter a Label instruction by performing the following steps. 1.
Press [SHIFT][LBL].
2.
Enter the <octal identification number>.
Removing the Label Instruction You can remove a Label instruction. You can edit it by performing the following steps. 1.
Position the cursor over the Label instruction you want to remove.
2.
Press [REMOVE][SHIFT][LBL].
Editing a Partially Completed or a Completed Rung If you are editing a completed rung, proceed to step 1. If you are editing a partially completed rung, enter the next instruction and proceed to step 1.
Subroutine Area Instruction
13-4
1.
Position the cursor over the Label instruction you are going to edit.
2.
Press [SHIFT][LBL] or any other appropriate instruction type key.
3.
Enter <octal identification number>.
Purpose: The subroutine area is located in the memory between the main program and the message store areas (Figure 13.1). This area acts as the end of program statement for the main program. It allows storage of small programs that are to be accessed periodically. Subroutines are not scanned unless you program the processor to jump into this area.
Page 153
Chapter 13 Jump Instructions and Subroutines
Figure 13.1 Subroutine Area Total Decimal Words 128 Varies Varies
Octal Word Address Factory Configure Data Table Additional AC, PR and Bit/Word Storage File or Bit/Word Storage
177 200 Varies
Data Table
Varies
Main Program
Varies
Subroutine Area
Varies
User Program
Subroutines
Varies
End
Varies
Message Storage Area (if used) 2944
3072
5577
Message Storage
10718-I
13-5
Page 154
Chapter 13 Jump Instructions and Subroutines
You can program a maximum of eight subroutines in the subroutine area. Each subroutine begins with a label instruction and (when you want to exit to your main program) ends with a return instruction. The subroutine area serves as the end of the main program and defines the beginning of the subroutine program (Figure 13.2). Figure 13.2 Subroutine Programming Example 01 JSR
012 00 012
013 10 012 U OFF 11
02 114 06 116
200 U OFF 17
11 116 02 116 13 01 LBL
014
06 116 116 116 11
12
13
012 File To File Move 200 Counter Addr: 001 Position: 007 File Length: 400- 406 File A: 500- 506 File R: Rate Per Scan 007
11 200 EN 17 200 DN 15 01 JSR
Here general programming facts for the subroutine instruction: Uses one word in the data table Processor does not scan the instruction until you program a Jump to Subroutine instruction. Up to eight subroutines can be programmed if you do not program any jump instructions. You cannot nest subroutine programs by inserting a Jump to Subroutine instruction in the Subroutine area. It is possible to jump from one subroutine to another using a Jump instruction.
13-6
Page 155
Chapter 13 Jump Instructions and Subroutines
Keystrokes: You establish a subroutine area by performing the following steps. 1.
Cursor down to the end of the main program.
2.
Press [SHIFT][SBR].
Important: The boundary marker SUBROUTINE AREA appears. A subroutine area instruction can only be programmed as the last instruction in the main program. It cannot be inserted between rungs. It requires one memory word, can be programmed only once, and cannot be removed except by clearing the entire subroutine area or the entire memory.
Chapter Summary
We showed you how to reduce scan time by selectively jumping over portions of the program. The next chapter shows you how to transfer a block of data in a single scan.
13-7
Page 156
Chapter
14
Block Transfer
Chapter Objectives
This chapter describes three types of block transfer: read write bidirectional Block transfer is a combination of an instruction and support rungs used to transfer up to 64 16-bit words of data in one scan from I/O modules to/from the data table. This transfer method is used by intelligent I/O modules such as the analog, PID, servo positioning, stepper positioning, ASCII, thermocouple, or encoder/counter modules. Block transfer can be performed as a read, write, or bidirectional operation, depending on the I/O module you are using. An input module uses the read operation, an output module uses the write operations. During a read operation, data is read into the data table from the module. During a write operation, data is written to the output module from the data table.
Basic Operation
The processor uses two I/O image table bytes to communicate with block transfer modules. The byte corresponding to the module’s address in the output image table (control byte) contains the read or write bit for initiating the transfer of data. The byte corresponding to the module’s address in the input image table (status byte) is used to signal the completion of the transfer. Important: Do not use word 127 for data storage. Whether the upper or lower byte of the I/O image table word is used depends on the position of the module in the module group. When in the lower slot, the lower byte is used and vice versa (Figure 14.1).
14-1
Page 157
Chapter 14 Block Transfer
Figure 14.1 Image Table Byte Relationship vs Module Position Data Table
17
Bit Numbers 10 07
ÉÉÉÉÉÉ ÉÉÉÉÉÉ
Output Image Table Control Byte
00
010 012
Output Image Table Word, Lower Byte
Block Transfer Module
017
ÉÉÉÉÉÉ ÉÉÉÉÉÉ
Input Image Table Status Byte
110
112
ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ ÉÉÉÉÉ
Input Image Table Word, Lower Byte
117
Left Slot
Right Slot
The lower byte of the I/O image table words is used when the module is in the left slot and the upper byte when the module is in the right slot.
The block transfer read or write operation (Figure 14.2) is initiated in the program scan and completed in the I/O scan as follows:
14-2
10222
Page 158
Chapter 14 Block Transfer
Figure 14.2 Block Transfer Diagram Transfer is made in I/O Scan Output Scan
Input Scan
Request is made in Program Scan
10377-I
Program scan - When the rung goes true, the instruction is enabled. The number of words to be transferred and the read or write bit that controls the direction of transfer are set by a bit pattern in the output image table byte. I/O scan - The processor requests a transfer by sending the output image table byte data to the block transfer module during the scan of the output image table. The module signals that it is ready to transfer. The processor then interrupts the I/O scan and scans the timer/counter accumulated area of the data table, looking for the address of the module that is ready to transfer. The module address is stored in BCD at a word address in the same manner as an accumulated value of a timer is stored. The module address was entered by the programmer when entering the block instruction parameters. The word address at which the module address is stored is called the data address of the instruction. Once the module address is found, the processor locates the address of the file to which (or from which) the data is transferred. The file address is stored in BCD at an address 100 above the address containing the module address. This is done in the same manner that the processor locates the preset value of a timer in a word address 100 above the accumulated value address. The analogy between block transfer and timer/counter data and addresses is shown in Table 14.A.
14-3
Page 159
Chapter 14 Block Transfer
Table 14.A Timer/Counter Transfer Analogy Address of Accumulated Value
Data Address of Instruction
Accumulated Value in BCD
Module Address in BCD (R,G,S)
Address of Preset Value
1008 Above Data Address
Preset Value in BCD
File Address in BCD
After locating the file address in the timer/counter area of the data table, the processor then duplicates and transfers the file data consecutively one word at a time until complete, starting at the selected file address. At the completion of the transfer, a done bit for the read or write operation is set in the input image table byte as a signal that a valid transfer has completed.
Block Transfer Format
The format of a block transfer read and a block transfer write instruction with default values is shown in Figure 14.3. Figure 14.3 Block Transfer Format Block Xfer Read Data Addr: 030 Module Addr: 100 Block Length: 01 110- 110 File: Block Xfer Write Data Addr: 030 Module Addr: 100 Block Length: 01 110- 110 File:
Note: Numbers shown are default values. Numbers in shaded areas must be replaced by user-entered values. The number of default address digits initially displayed (3 or 4) will depend on the size of the data table.
14-4
010 EN 07 110 DN 07 010 EN 06 110 DN 06
Page 160
Chapter 14 Block Transfer
Here is an explanation of each value: This Value:
Stores the:
Data Address
First possible address in the timer/counter accumulated value area of the data table
Module Address
RGS for R = rack, G = module, S = slot number
Block Length
Number of words to be transferred (enter 00 for default value or for 64 words)
File
Address of the first word of the file
Enable bit -(EN)-
Automatically entered from the module address Set on when the rung containing the instruction is true
Done bit -(DN)-
Automatically entered from the module address Remains on for 1 program scan following successful transfer
Data Address The data address stores the module address of the block transfer module. The data address must be assigned the first available address in the timer/counter accumulated area of the data table. This depends on the number of I/O racks being used (Table 14.B). When more than one block transfer module is used, consecutive data addresses must be assigned ahead of address for timer and counter instructions. Table 14.B The First Available Address in Timer/Counter Area of Data Table # I/O Racks
First Available Address in Timer/ Counter Area
1
020
2
030
3
040
4
050
5
060
6
070
7
200
The last consecutive word in the accumulated area following the words reserved for block transfer data addresses should be loaded with zeroes. When the processor sees this boundary word, it does not search further for block transfer data. In addition, the processor is prevented from finding other BCD values that could, by chance, be in the same configuration as the rack, group and slot numbers found in block transfer data addresses. 14-5