The text of a manual · part 17 of 70
SLC 500 Instruction Set Reference Manual, pages 161 to 170
Pages 161 to 170 of 694
The original document is the PDF (7.2 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-L514
Page 161
Chapter
8
Block Transfer Instructions
This chapter contains general information about block transfer instructions and explains how they function in your application program. Each of the block transfer instructions includes information on: • what the instruction symbol looks like. • how to use the instruction.
Table 8.1 Block Transfer Instructions Instruction Mnemonic
Instruction Name
Purpose
Page
BTR
Block Transfer Read
A BTR is used to receive data from a remote device.
8-1
BTW
Block Transfer Write
A BTW is used to send data to a remote device.
8-1
Block Transfer Instructions (BTR and BTW)
BTW Block Transfer Write Rack Group Slot Control Block Data File Buffer File Requested Word Count Transmitted Word Count
Block transfer instructions are supported by SLC 5/03 (OS302, Series C), SLC 5/04 (OS401, Series C) and SLC 5/05 (OS501, Series C) and higher processors using RSLogix 500 version 4.10 and higher. With block-transfer instructions, you can transfer up to 64 words to or from a remote device over an Allen-Bradley Remote I/O (RIO) link. A Block Transfer Read (BTR) is used to receive data from a remote device. A Block Transfer Write (BTW) is used to send data to a remote device. The RIO Series B scanner (1747-SN) modules and the back-up scanner (1747-BSN) modules perform block transfers via M0 and M1 file buffers.
EN 0 0 0 N10:10 N20:0 M0:1.100 0 0
DN ER
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
1
•
•
A false-to-true rung transition initiates a BTW or BTR instruction. The BTW instruction tells the processor to write data stored in the BTW Data File to a device at the specified RIO rack/group/slot address. The BTR instruction tells the processor to read data from a device at the specified RIO rack/group/slot address and store it in the BT Data File. The Data File may be any valid integer, floating point or binary data table file. A total of 32 block transfer buffers are available; you can execute a maximum of 32 different block transfers. Each buffer is made up of 100 consecutive words. The processor runs each block transfer request in the order it is requested. When the processor changes to Program mode, all pending block transfers are cancelled.
Publication 1747-RM001G-EN-P - November 2008
Page 162
8-2
Block Transfer Instructions
A BTR or BTW instruction writes information into its control structure address (a three-word integer Control Block) when the instruction is entered. The processor uses these values to execute the transfer. You must enter an M1 file address into BTR Instructions and an M0 file address into BTW Instructions. However, each instruction uses both the M0 and M1 file for that one hundred word buffer (1 through 32). For example, to use the first available buffer (1) for a BTR, enter M1:e.100 into the “Buffer File” field. However, M0:e.100 is also used by this BTR. So, the next BT instruction must use another M-file buffer (2 through 32).
RIO Block Transfer General Functional Overview The RIO scanner performs block transfers through control/status buffers allocated in the scanner’s M0 and M1 files. For BTW’s, the data stored in the Data File is copied into the M0 block transfer buffer, the M0 block transfer buffer is then transferred to the RIO device. The corresponding M1 block transfer buffer contains only BTW status information. For BTR’s, the M0 block transfer buffer contains only BTR control information. The actual data read from the remote device is received in the scanner’s M1 block transfer buffer. This data is then copied into the BTR Data File. A total of 32 block transfer control/status buffers exist in the M0 (output/control) and the M1 (input/status) files.
Entering Parameters for BTR and BTW The instructions have the following parameters. • Data File - The address in the SLC processor’s data file containing the BTW or BTR data. Valid file types are B, N and F. • BTR/BTW Buffer File - Block transfer buffer file address; i.e. M0: e.x00, where “e” is the slot number of the scanner and “x” is the buffer number. The range of the buffer number is from 1 to 32. Each BTR and BTW instruction uses both the M1 and M0 files for a specific buffer number. M0 is used for BTR control and for BTW data. M1 is used for BTW status and BTR data.
TIP
Publication 1747-RM001G-EN-P - November 2008
Since buffer number 32 is utilized by the SLC processor for Remote I/O passthru, you should not assign buffer number 32 to a block transfer instruction unless you do not intend to ever use Remote I/O passthru.
Page 163
Block Transfer Instructions
8-3
• Control - The control block is an integer data file address that stores all the block transfer control and status information. The control block is three words in length. Note that these integer file addresses should not be used for any other instructions. You should provide the following information for the control structure. – Rack - The I/O rack number (0 to 3) of the I/O chassis in which you placed the target I/O module. – Group - The I/O group number (0 to 7) which specifies the position of the target I/O module in the I/O chassis. When using 1/2-slot addressing, only even group numbers are valid. – Slot - The slot number (0 or 1) within the group. When using 2-slot addressing, the 0 slot is the low (right) slot and the 1 slot is the high (left) slot within the group. When using 1-slot or 1/2-slot addressing, always select slot 0. – Requested Word Count - The number of words to transfer. If you set the length to 0, the processor reserves 64 words for block transfer data. The block transfer module transfers the maximum words the adapter can handle. If you set the length from 1 to 64, the processor transfers the number of words specified.
The three-word control block has the following structure. Before executing a block transfer, the BTR and BTW instructions clear all status bits and initialize word 2 to 0. See Table 8.2, “Control Block Structure,” for more information.
TIP
Table 8.2 Control Block Structure 15
14
13
12
11
Word 0
EN
ST
DN
ER
Word 1
Requested word count
Word 2
Transmitted word count/Error code
10 EW
9
8
7
6
TO
RW
Rack
5
4
3 Group
2
1
0 Slot
Control Status Bits To use the BTR and BTW instructions correctly, examine the instruction’s control and status bits stored in the control structure. These bits are mapped to bits in word 0 of the control block structure.
Publication 1747-RM001G-EN-P - November 2008
Page 164
8-4
Block Transfer Instructions
Figure 8.1 Successful Block Transfer Control Information Control Bits EN TO
Status Information Status Bits EW ST ER
DN
122
3
4
5
Successful Block Transfer Read/Write Figure 8.1 illustrates a successful BT operation. 1. The SLC control program copies new data to the data file (BTW only) and solves the BT rung true, which sets the enable (EN) bit. 2. The scanner detects that the EN bit is set, validates the control block information, puts the BT request on the RIO link successfully, and since no other BTs are pending for the same logical rack, sets the enable waiting (EW) and start (ST) bits. 3. The scanner receives a BT reply (with no errors) from the RIO link device, copies the received data to the data file (BTR only) and sets the done (DN) bit. 4. The SLC control program detects the DN bit, processes the BTR data and solves the BT rung false, which clears the enable (EN) bit. 5. The scanner detects that the SLC control program has completed processing (because the EN bit is clear) and clears the EW, ST and DN bits. At this point, the SLC control program could re-initiate the same BT operation by solving the BT rung true again.
Publication 1747-RM001G-EN-P - November 2008
Page 165
Block Transfer Instructions
TIP
IMPORTANT
TIP
8-5
Except for the time-out bit, TO (bit 08), do not modify any controller status bits while the block transfer is in progress.
The BTR/BTW instruction must be scanned (true or false) in order to update the control and status bits.
In order to conserve scan time, place each block transfer instruction in its own subroutine and only call the subroutine while the block transfer instruction is enabled.
Table 8.3 Control and Status Bit Descriptions Control/Status Bit
Description
Enable EN (bit 15)
Block Transfer Enabled - (EN = Enabled). The processor sets/resets this bit depending on the rung state (true/false). The processor sends the enable bit to the RIO scanner when the BTR/BTW instruction is scanned. If the BT is not waiting (EW set) and is not started (ST set), and the EN bit sees a false-to-true transition, the RIO scan triggers a BT.
Start ST (bit 14)
Block Transfer Started - (ST = Started). When the instruction is scanned (true or false), the processor reads this bit from the RIO scanner. The scanner sets this bit when the BT starts. The scanner resets this bit when the ladder logic (processor) clears the EN bit indicating the BT is finished.
Done DN (bit 13)
Block Transfer Successful - (DN = Done). When this bit is set, it indicates the successful completion of a block transfer operation. When the instruction is scanned (true or false), the processor reads the DN bit from the RIO scanner. The scanner clears the DN bit when the ladder logic (processor) clears the EN bit.
Error ER (bit 12)
Block Transfer Error - (ER = Error). When this bit is set, it indicates that the process detected a failed block transfer. When the instruction is scanned (true or false), the processor reads the ER bit from the RIO scanner. The scanner clears the ER bit when the ladder logic (processor) clears the EN bit.
Enable-waiting EW (bit 10)
Block Transfer Enabled and waiting for block transfer to start - (EW = Enable Waiting). When the EW bit is set and the ST bit is clear, this indicates that a block transfer operation is pending. When the instruction is scanned (true or false), the processor reads the EW bit from the scanner. The scanner clears the EW bit after the ladder logic (processor) clears the EN bit.
Time Out TO (bit 08)
Block Transfer Time-out (TO = Time-out). You can set this bit to cancel block transfer operation by forcing the BT to time out once the Enabled Waiting (EW) bit sets and before the RIO scanner’s internal four-second block transfer timer times out or the block transfer completes. Cancelling a block transfer causes an error (ER) bit to set and an error code of -9 to display in the control structure. Note that the Time-out (TO) bit must be cleared before initiating a new block transfer. The RIO scanner ignores a block transfer request if both TO and EN bits are set at the same time.
Read-Write RW (bit 07)
Block Transfer Type. This bit is controlled by the instruction type. A “0” indicates a write operation (BTW); a “1” indicates a read operation (BTR).
Publication 1747-RM001G-EN-P - November 2008
Page 166
8-6
Block Transfer Instructions
In addition to the control and status bits, the control block contains two other parameters the processor uses to execute the block transfer instructions.
Requested Word Count, Word 1 (RLEN) This is used to configure BTR/BTW length information (0 to 64). Length is the number of BTR/BTW words read from or written to the RIO device. If RLEN = 0 for a BTW instruction, 64 words are sent. If RLEN = 0 for a BTR instruction, the actual length is determined by the RIO device responding to the block transfer read request.
Transmitted Word Count/Error Code, Word 2 (DLEN) Transmitted Word Count is the status of the actual number of BTW words sent or the number of BTR words received. The processor uses this number to verify the transfer. This number should match the requested word count (unless the transmitted word count is zero). If these numbers do not match, the processor sets the ER bit (bit 12). If there is an error, the processor gives the error code in Word 2 of the control structure in the form of a negative number. See Table 8.4, “BTR/BTW Error Codes,” for a list of error codes. Only one error code is stored at a time (a new error code overwrites the previous error code).
Table 8.4 BTR/BTW Error Codes
Publication 1747-RM001G-EN-P - November 2008
Error Code
Description
0
The block transfer completed successfully.
-6
Illegal block transfer length requested.
-7
Block transfer communication error occurred when block transfer request was initiated.
-8
Error in block transfer protocol.
-9
Block Transfer Time-out - Either the SLC user program cancelled the block transfer or the scanner’s block transfer timer timed out. Note that a time-out error occurs if a block transfer is attempted at a location that is not configured for block transfer operation (for example, requesting a block transfer for a location that is an output module).
-10
No RIO channel configured.
-11
Attempted a block transfer either to a non-configured block transfer device (i.e., an invalid logical rack, group, or slot), or at a complementary device location where there is no corresponding primary image space allocated.
-12
Attempted a block transfer to an inhibited device.
Page 167
Block Transfer Instructions
8-7
Instruction Operation 1. The scanner processes the BTR/BTW when it detects that the SLC control program rung, which contains the BTR/BTW, goes true. If the RIO scanner detects any problem at this point (such as invalid block transfer control field, or unconfigured device), the control structure word 2 fills with the error code and the ER bit (bit 12) is set. If no problems occur, the EW bit (bit 10) and ST bit (bit 14) are set in the control block.
TIP
The ST bit is not set if the scanner is already in the process of block transferring data to a location within the same logical RIO rack. The ST bit is set only after any previous pending block transfers to the same logical rack are completed and the block transfer request is scheduled on the RIO link.
The SLC control program can monitor the block transfer by examining bits in word 0 of the control block. They indicate when the scanner has started processing (EW and ST) the block transfer and whether the block transfer operation completed successfully (DN) or failed (ER). The SLC control program can take different actions based on these status bits. 2. When a block transfer completes successfully, the DN bit is set. This indicates that the block transfer control block has been updated with the actual transmitted word count. This is important for BTR instructions, because this indicates the number of valid data words received from the remote device. This data is stored in the BTR data file. 3. If the block transfer fails, the length field and the data file are not updated. The ER bit is set and the error code field indicates the problem. 4. The SLC control program must indicate to the scanner when it is done processing the status word in the control structure (because DN or ER was set) so the corresponding control bits can be reused for another block transfer operation. The SLC control program indicates that it is done processing the block transfer when it solves the BT rung false, which clears the EN bit in the control block. 5. When the RIO scanner detects that the EN bit cleared, it then clears the EW, ST and DN or ER bits, as well as the Transmitted Word Count/Error Code. This ensures that the status bits in the control block are not reflecting the results of the previous block transfer operation. Publication 1747-RM001G-EN-P - November 2008
Page 168
8-8
Block Transfer Instructions
IMPORTANT
To prevent configuration conflicts, it is highly recommended that each M-file buffer (My:e.x00) should be used by only one block transfer instruction.
Programming Examples
Table 8.5 Block Transfer Programming Examples Figure 8.2, "Directional" on page 8-8 Figure 8.3, "Directional Repeating" on page 8-9 Figure 8.4, "Directional Continuous" on page 8-9 Figure 8.5, "Bi-directional Continuous" on page 8-9 Figure 8.6, "Bi-directional Alternating" on page 8-10 Figure 8.7, "Bi-directional Alternating Repeating" on page 8-10 Figure 8.2 Directional
Publication 1747-RM001G-EN-P - November 2008
Page 169
Block Transfer Instructions
8-9
Figure 8.3 Directional Repeating
Figure 8.4 Directional Continuous
Figure 8.5 Bi-directional Continuous
Publication 1747-RM001G-EN-P - November 2008
Page 170
8-10
Block Transfer Instructions
Figure 8.6 Bi-directional Alternating
Figure 8.7 Bi-directional Alternating Repeating
Publication 1747-RM001G-EN-P - November 2008