The text of a manual · part 10 of 55
Hand-Held Terminal (Catalog Number 1747-PT1) User Manual: 4 - Data File Organization and Addressing, pages 67 to 76
Pages 67 to 76 of 486, from Hand-Held Terminal (Catalog Number 1747-PT1) User Manual
The original document is the PDF (1.5 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 1747-PT1
Page 67
Chapter 4 Data File Organization and Addressing
Data File 6 – Control These are 3-word elements, used with Bit Shift, FIFO, LIFO, and Sequencer instructions. Word 0 is the status word, word 1 indicates the length of stored data, and word 2 indicates position. This is shown below: Control Element
Addressable Bits
15 14 13 12 11 10 9
8 7
6 5
4
3 2
1
EN EU DN EM ER UL
FD
Internal Use
0 Word 0
Length of Bit array or File
1
Position
2
Addressable Words
EN = Enable LEN = Length EU = Unload Enable (FFU,LFU) POS = Position DN = Done EM = Stack Empty (stacks only) ER = Error UL = Unload (Bit shift only) FD = Found (SQC only)
Bits labeled “Internal Use” are not addressable. Assign control addresses as follows: Format
Rf:e
Example:
Explanation R
Control file f
File number. Number 6 is the default file. A file number between 10 – 255 can be used if additional storage is required.
:
Element delimiter e
Element number
R6:2
Ranges from 0 to 255. These are 3-word elements. See figure above.
Element 2, control file 6.
Address bits and words by using the format Rf:e.s/b where Rf:e is explained above, and: . is the word delimiter s indicates subelement / is the bit delimiter b indicates bit R6:2/15 R6:2/14 R6:2/13 R6:2/12 R6:2/11 R6:2/10 R6:2/8 R6:2.1 R6:2.2 R6:2.1/0 R6:2.2/0
Enable bit Unload Enable bit Done bit Stack Empty bit Error bit Unload bit Found bit or or
R6:2.LEN Length value R6:2.POS Position value Bit 0 of length value. Bit 0 of position value.
4–11
Page 68
Chapter 4 Data File Organization and Addressing
Data File 7 – Integer These are 1-word elements, addressable at the element and bit level. Address
Data
N7:0 N7:1 N7:2 N7:3
Element 1 has a decimal value of 495.
0 495 0 66
Element 3 has a decimal value of 66.
Assign integer addresses as follows: Format
Nf:e/b
Explanation N
Integer file f
File number. Number 7 is the default file. A file number between 10 – 255 can be used if additional storage is required.
:
Element delimiter e
Element number
/
Bit delimiter b
Bit number
Ranges from 0 to 255. These are 1-word elements. 16 bits per element.
Bit location within the element. 0 to 15
Examples: N7:2 N7:2/8 N10:36
4–12
Element 2, integer file 7 Bit 8 in element 2, integer file 7 Element 36, integer file 10 (you designate file 10 as an integer file)
Page 69
Chapter 4 Data File Organization and Addressing
Indexed Addressing SLC 5/02 Processors Only
An indexed address is offset from its indicated address in the data table. Indexing of addresses applies to word addresses in bit and integer data files, preset and accumulator words of timers and counters, and to the length and position words of control elements. You can also index I/O addresses. The indexed address symbol is #. When programming, place it immediately before the file type identifier in the word address. Examples: • #N7:2 • #B3:6 • #T4:0.PRE • #C5:1.ACC • #R6:0.LEN
Offset Value (S:24 Index Register ) An indexed address in a bit or integer data file is offset from its indicated address by the number of words you specify in word 24 of the status file. Operation takes place at the address plus the offset number of words. If the indexed address is word 1 or 2 of a timer, counter, or control element, the offset value in S:24 is the offset in elements. For example, an offset value of 2 will offset #T4:0.ACC to T4:2.ACC, which is 2 elements (6 words). The number in S:24 can be a positive or negative integer, resulting in a positive or negative offset. You can use more than one indexed address in your ladder program. All indexed addresses will have the same offset, stored in word S:24. You can manipulate the offset value in your program before each indexed address is operated on. Note that file instructions (SQO, COP, LFL for example) overwrite S:24 when they execute. For this reason, you must insure that the index register is loaded with the intended value prior to the execution of an indexed instruction that follows a file instruction. Example Suppose that during the operation of the ADD instruction, an offset value of 10 is stored in word S:24. The processor will take the value at N7:12 (N7:2+10) and add it to the value at N10:0. The result is placed at N11:15 (N11:5+10). ADD ADD Source A
#N7:2
Source B
N10:0
Dest
#N11:5
4–13
Page 70
Chapter 4 Data File Organization and Addressing
Creating Data for Indexed Addresses Data tables are not expanded automatically to accommodate indexed addresses. You must create this data with the memory map function as described in chapter 6. In the example on the previous page, data words N7:3 through N7:12 and N11:6 through N11:15 must be allocated. Important: Failure to allocate these data file elements will result in an unintended overwrite condition or a major fault.
Crossing File Boundaries An offset value may extend operation to an address outside the data file boundary. You can either allow or disallow crossing file boundaries. If you choose to disallow crossing file boundaries, a runtime error occurs if you use an offset value which would result in crossing a file boundary. You are allowed to select crossing file boundaries only if no indexed addresses exist in the O: (output), I: (input), or S: (status) files. This selection is made at the time you save your program. The file order from start to finish is: • B3:, T4:, C5:, R6:, N7:, x9:, x10: . . . • x9: and x10: . . . are application-specific files where x can be of types B, T, C, R, N. Example The figure below indicates the maximum offset for word address #T4:3.ACC when allowing and disallowing crossing file boundaries. B3:0 Maximum negative of –3
T4:0.ACC
#T4:3.ACC
#T4:3.ACC T4:9.ACC
Maximum. positive of 6
Crossing file boundaries is disallowed.
End of Highest File Created Crossing file boundaries is allowed.
Crossing file boundaries disallowed: In the example above, the highest numbered element in the timer data file is T4:9. This means that #T4:3.ACC can have a maximum negative offset of –3 and a maximum positive offset of 6. Crossing file boundaries allowed: The maximum negative offset extends to the beginning of data file 3. The maximum positive offset extends to the end of the highest numbered file created.
4–14
Page 71
Chapter 4 Data File Organization and Addressing
Monitoring Indexed Addresses The offset address value is not displayed when you monitor an indexed address. For example, the value at N7:2 appears when you monitor indexed address #N7:2. Example If your application requires you to monitor indexed data, we recommend that you use a MOV instruction to store the value. MOV
B3 ] [ 1
MOVE Source
#N7:2
Dest
N10:2
ADD ADD Source A
#N7:2
Source B
T4:0.ACC
Dest
T4:1.PRE
N10:2 will contain the data value that was added to T4:0.ACC.
Effects of File Instructions on Indexed Addressing The # symbol is also required for addresses in file instructions. The indexed addresses used in these file instructions also make use of word S:24 to store an offset value upon file instruction completion. Refer to the next page for a list of file instructions that use the # symbol for addressing.
!
ATTENTION: File instructions manipulate the offset value stored in word S:24. Make sure that you load the correct offset value in S:24 prior to using an indexed address that follows a file instruction. Otherwise, unpredictable operation could occur, resulting in possible personal injury and/or damage to equipment.
Effects of Program Interrupts on Index Register S:24 When normal program operation is interrupted by the user error handler, an STI (selectable timed interrupt), or an I/O interrupt, the content of index register S:24 is saved; then, when normal program operation is resumed, the content of index register S:24 is restored. This means that if you alter the value in S:24 in these interrupt subroutines, the system will overwrite your alteration with the original value contained on subroutine entry.
4–15
Page 72
Chapter 4 Data File Organization and Addressing
File Instructions – Using the File Indicator #
File instructions employ user-created files. These files are addressed with the # sign. They store an offset value in word S:24, just as with indexed addressing discussed in the last section. COP FLL BSL BSR FFL FFU
LFL LFU SQO SQC SQL
Copy File File Fill Bit Shift Left Bit Shift Right (FIFO Load)* (FIFO Unload)*
(LIFO Load)* (LIFO Unload)* Sequencer Output Sequencer Compare Sequencer Load*
* Available in the SLC 5/02 processor only.
!
ATTENTION: SLC 5/02 processor users If you are using file instructions and also indexed addressing, make sure that you monitor and/or load the correct offset value prior to using an indexed address. Otherwise, unpredictable operation could occur, resulting in possible personal injury and/or damage to equipment.
The following paragraphs explain user-created files as they apply to Bit Shift instructions, Sequencer instructions, and File Copy and File Fill instructions.
Bit Shift Instructions The figure below shows a user-defined file within bit data file 3. For this particular user-defined file, enter the following parameters when programming the instruction: • #B3:2 The address of the bit array. This defines the starting bit as bit 0 in element 2, data file 3. • 58 This is the length of the bit array, 58 bits. Note that the bits “left over” in element 5 are unusable. You can program as many bit arrays as you like in a bit file. Be careful that they do not overlap. Bit Data File 3
15 Address of the bit array is #B3:2 Length of the bit array is 58, entered as a separate parameter in the Bit Shift instruction. INVALID
4–16
0 0 1 2 3 #B3:2 4 5 6
Page 73
Chapter 4 Data File Organization and Addressing
Sequencer Instructions The figure below shows a user-defined file within bit data file 3. For this particular user-defined file, enter the following parameters when programming the instruction:
• #B3:4 The address of the file. This defines the starting element as element 4, bit file 3. • 6 This is the specified length of the file, 6 elements beyond the starting address (totals 7 elements). You can use user-defined integer files or bit files with sequencer instructions, depending on the application. You can program as many files as you like within another file. However, be careful that the files do not overlap. 15
Bit Data File 3
0 0 1 2 3 4 5 6 7 #B3:4 8 9 10 11
0 1 2 3 4 5 6
Address of the user-defined file is #B3:4. Length of the file is 6 elements beyond the starting address (elements labeled 0-6 in the diagram).
4–17
Page 74
Chapter 4 Data File Organization and Addressing
File Copy and File Fill Instructions These instructions manipulate user-defined files. The files are used as source or destination parameters in File Copy or File Fill instructions. Files can be Output, Input, Status, Bit, Timer, Counter, Control, or Integer files. Two examples are shown below. Note that the file length is the specified number of elements of the destination file; this differs from the file length specification for sequencer instructions. Refer to the previous page. The first example is a user-defined file within Data File 7 – Integer. The file is #N7:14, specified as 6 elements long. The second example is a user-defined file within Data File 0 – Output Image. We used this particular data file configuration in regard to I/O addressing on page 4-6. Here, we are defining a file 5 elements long. Note that for the output file (and the input file as well), an element is always one word, referenced as the slot and word taken together. For example, element O:3.0 refers to output file, slot 3, word 0. This defaults to O:3, where word 0 is implied.
Address
Data
N7:14 N7:15 N7:16 N7:17 N7:18 N7:19
0 0 0 0 0 0
File #N7:14 This file is 6 elements long: Elements 14, 15, 16, 17, 18, 19.
Data File 0 – Output Image 15
0 INVALID INVALID
O:1 O:3 O:4 O:5 O:5.1 O:9 O:10
#O:3
File #O:3 shown above is 5 elements long: Elements 3, 4, 5, 5.1, 9.
4–18
Page 75
Chapter 4 Data File Organization and Addressing
Creating Data
The SLC 500 controller provides the flexibility of a user-configured memory. Data is created, in the Offline mode, in two ways: • Assign addresses to instructions in your program – When you assign an address to an instruction in your ladder program, you are allocating memory space in a data file. Data files are expanded for instructions that use File Addresses. As more and more addresses are assigned, the various data files increase in size, according to the needs of your program. Memory space is allocated in element blocks, beginning with element 0. For example, suppose the first address you assign in your program is B3/16. This allocates two elements to your program: B3:0, which consists of bits B3/0 through B3/15; and B3:1, which consists of bits B3/16 through B3/31. Since B3/16 is the first bit of element B3:1, all 16 bits of that element are created, therefore, the highest bit address now available to you is B3/31. If the first timer element you assign in your program is T4:99, you allocate timers T4:0 through T4:99. As described on page 4–9, timers are 3–word elements. By assigning timer T4:100 you allocate 100 elements using 300 words of memory. So whether you use timers T4:0 through T4:98 later in the program, they are allocated in memory. Obviously, you can keep the size of your data files to a minimum by assigning addresses beginning at element 0 of each data file, and trying to avoid creating blocks of addresses that are allocated but unused.
• Create files with the memory map function – The memory map function of the programming device allows you to create data files by entering addresses directly, rather than assigning addresses to instructions in your program. You can create data files to store recipes and lookup tables if needed. You create a data file by entering the highest numbered element you want to be included in the file. For example, entering address N7:20 creates 21 integer elements, N7:0 through N7:20.
Creating Data for Indexed Addresses Data tables are not expanded automatically to accommodate indexed addresses as described on page 4–14. However, the data tables are expanded for file addresses. You must create this data with the memory map function as described in chapter 6.
4–19
Page 76
Chapter 4 Data File Organization and Addressing
Deleting Data
Deleting data is accomplished only in the Offline mode. There are two ways to delete the contents of data files: • Clear memory – This deletes your entire program, including all files except the system program file (0) and the status data file (2). • Use the memory map function – The memory map function allows you to delete data in individual files or portions of files. For example, you can delete blocks of addresses that have been allocated but are not being used.
Allocated Space
Not Used
You cannot delete these files.
Not Used
You can delete these files.
You cannot delete an element if it is used in your program. Neither can you delete an unused element if a higher numbered element in the file is used in your program. (For example, if you are using element B3:5, you cannot delete B3:0 through B3:4, even if you aren’t using them in your program.) Important: Make certain that you do not inadvertently delete data originally reserved for indexed addressing. Unexpected operation will result.
Program Constants
You can enter integer constants directly into many of the instructions you program. The range of values for most instructions is –32,768 through +32,767. Instructions such as SQO, SQC, MEQ, and MVM allow you to enter a hex mask, which is also a program constant. The hex mask is represented in hexadecimal, range 0-FFFF. Program constants are used in place of data file elements. They cannot be manipulated by the user program. You must enter the offline program editor to change the value of a constant. See appendix B in this manual for more information on number systems.
4–20