The text of a manual · part 17 of 19
PLC-5 DeviceNet Scanner Module 1771-SDN User Manual: E - Programming the PLC-5 Processor
Pages 133 to 140 of 149, from PLC-5 DeviceNet Scanner Module 1771-SDN User Manual
The original document is the PDF (3.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 1771-SDN
Page 133
Appendix
E
Programming the PLC-5 Processor
Program the PLC-5 Processor
You must program your PLC-5 processor so it communicates with the 1771-SDN Scanner Module. Communication is possible when you program your processor through multiple block transfer instructions. The scanner uses the size of the block transfer to map the block transfer data words into the scanner’s internal data table. The scanner module accepts blocks of different sizes and knows that each block has a different meaning. PLC-5 block transfer instructions use one integer file in the data table section for module location and other data to execute the instruction. This is the control block file. The block transfer data file stores data that you want to transfer to your module (when programming a block transfer write (BTW)) or from your module (when programming a block transfer read (BTR)). The address of the block transfer data file is stored in the control block file. You must select a separate data file for each of the block transfer instructions. You must also use separate 5-word block transfer control files for each of the block transfer instructions when an integer file is used. This is not necessary when a control block file is a BT data type.
1
Publication 1771-UM118C-EN-P - June 2003
Page 134
E-2
Programming the PLC-5 Processor
To make sure the instruction is reset after the block transfer completes and recycles, you must use enable bits as the conditions on each rung with the PLC-5. The following figure shows a PLC-5 sample program. IMPORTANT
The module does not support continuous mode block transfer. Set Continuous to NO for each BTW or BTR.
BTR Precondition
BT10:0 EN BTR enable bit
Precondition
BT10:5.EN EN BTW enable bit
BTW enable bit
BTR enable bit
BT10:5.EN
BT10:0
EN
EN
Block-transfer rungs must be scanned for the transfers to occur. The preconditions allow time-driven or event-driven transfers.
Note: Precondition is optional
Publication 1771-UM118C-EN-P - June 2003
BLOCK TRANSFER READ Rack Group Module Control Block Data file Length Continuous
EN 3 2 0 BT10:0 N11:0 62 NO
DN ER
BTW BLOCK TRANSFER WRITE Rack Group Module Control Block Data file Length Continuous
EN 3 2 0 BT10:5 N11:62 62 NO
DN ER
Page 135
Programming the PLC-5 Processor
E-3
When using rungs like those in the preceding figure, the processor alternates between the BTR and the BTW, waiting to request the next block transfer until the previous block transfer is completed. When only one block transfer is active at a time, it is considered a single-threaded block transfer. Single-threaded block transfers operate in an orderly sequence of read and write, however, they tend to be slower than the asynchronous method, shown below: BTR Precondition
BT10:0
BLOCK TRANSFER READ Rack Group Module Control Block Data file Length Continuous
EN BTR enable bit
BTW enable bit Precondition
EN 3 2 0 BT10:0 N11:0 62 NO
DN ER
BTW
BT10:5.EN EN
Block-transfer rungs must be scanned for the transfers to occur. The preconditions allow time-driven or event-driven transfers.
BLOCK TRANSFER WRITE Rack Group Module Control Block Data file Length Continuous
EN 3 2 0 BT10:5 N11:62 62 NO
DN ER
As soon as an asynchronous block transfer completes, it is requested again, independent of other block transfers going to the same module. If you have programmed many block transfers to the same logical rack (especially a remote rack), you will fill the processor’s queue. In this situation, the asynchronous method can result in irregular timing between successive executions of the same block transfer. For more information on programming and block transfers, refer to your PLC-5 Programming Software Instruction Set Reference Manual, publication 1785-6.1.
Using BTW to Send Outputs to the Scanner The PLC-5 downloads output data to the scanner using block transfer write instructions over the 1771 backplane. The scanner module can update a maximum of 357 output words by internally linking together six different sized block transfers as shown in the following table.
Publication 1771-UM118C-EN-P - June 2003
Page 136
E-4
Programming the PLC-5 Processor
Block Transfer Size
Accessed Scanner Output Block
62 words
Block 62
61 words 60 words 59 words 58 words 57 words 1-50 words
Block 61 Block 60 Block 59 Block 58 Block 57 Block 1-50
Scanner Output Data Table DeviceNet Messages
Word 0 – Module Command Register Word Words 1–61 Words 62–122 Words 123–182 Words 183–241 Words 242–299 Words 300–356 Words 0-49
Each individual block transfer is independent, but always updates the same output bytes in the scanner’s memory table. Of the scanner output words 0 through 61, the word 0 is reserved for the Module Command Register. Block transfer sizes 1 through 50 update scanner output words 0 through 49, thus reducing the required BTW time when 50 or fewer output words are needed. Sizes 51 thru 56 are illegal and size 64 is used for Explicit Message Program Control. For more details on Explicit Message Program Control, refer to page 26. If the scanner receives a BTW of 62 words, then it knows that it contains the first block of the table. A BTW of 61 words, if necessary, contains the second block of the table and so on for 60, 59, 58 and 57 words. You determine the data that is exchanged with a given node on channel 1 or 2 by creating custom configurations using RSNetworx software version 2.22 or later. Refer to your RSNetworx documentation or online help and your 1771-SDN Scanner Configuration Manual (publication number 1771-6.5.132) for more information on custom configurations.
Module Command Register The first word of the BTW downloaded from the PLC-5 to block 62 is reserved as the module command register. The register is downloaded with every 1 through 50 and 62 word block transfer write. This modifies the scanner’s operation. To execute a command, you set the appropriate bits in the module command word, then perform a block transfer write to the first block (the 62 word block) of the scanner output table. When the scanner receives the command it immediately executes it. You latch bits 0 through 5 in your program to maintain the scanner’s desired state.
Publication 1771-UM118C-EN-P - June 2003
Page 137
Programming the PLC-5 Processor
E-5
The following table outlines the module command register’s bit numbers and descriptions. Module Command Register - Word 0, Block 62 Bit Number
Bits 01 00 0 0
Operating Mode DeviceNet Channel 1 in idle mode
0
1
DeviceNet Channel 1 in run mode
1
0
DeviceNet Channel 1 in fault mode
00 – 01
05
06
07
08 – 15
Idle The scanner does not map output data to the devices, but keeps network connections to devices open so device failures can be detected. Input data is returned from devices, and mapped into the scanner input table and the discrete inputs. Outputs on the network are not under program control and will be in their configured ‘idle state.’ The scanner must be put into this mode to perform configuration of the scanner database tables. Run The scanner module maps output data from its scanner output table and discrete outputs to each device on the network. Inputs are received and mapped into the scanner input table and discrete inputs. Outputs on the network are under program control. Placing the PLC-5 into PROG or REM_PROG mode places the scanner into idle mode regardless of the state of the bits in the module command register. Placing the PLC-5 into RUN or REM_RUN mode causes the state of the bits in the module command register to determine the scanner state.
1
1
Reserved
0
0
DeviceNet Channel 2 in idle mode
0
1
DeviceNet Channel 2 in run mode
1
0
DeviceNet Channel 2 in fault mode
1
1
Reserved
Fault Network The scanner stops communicating with devices on the network. No outputs or inputs are mapped. Outputs on the network are not under program control. If the scanner was in run, devices will go to their configured ‘fault state.’
0
Enable DeviceNet Channel 1
Enable The DeviceNet channel is enabled for communication. This is the normal operating state of the channel.
1
Disable DeviceNet Channel 1
0
Enable DeviceNet Channel 2
Disable The DeviceNet channel is disabled for communication. No communication may occur over this channel. Outputs on the network are not under program control. If the scanner was in run, devices will go to their configured ‘fault state.’ Numeric error code 90 will occur when channel is disabled.
1
Disable DeviceNet Channel 2
Scanner Active This is the normal operating mode of the scanner.
0
Scanner run
1
Scanner halt
0
Scanner Active
1
Scanner reboot
0
Reserved for future use
02 - 03
04
Operating Mode Description
Scanner Halt All scanner operations stop when this command is issued. No communications occur over either DeviceNet port. No block transfer or discrete I/O mapping occurs. Outputs on the network are not under program control. If the scanner was in run, devices will go to their configured ‘fault state.’ Numeric error code 97 will occur - you must reset the scanner or cycle power to the scanner to recover from this state. Scanner Reboot This command causes the scanner to reset as though the reset button had been pressed. When this command is issued, all scanner communication stops for the duration of the scanner’s initialization sequence. Outputs on the network are no longer under program control. If the scanner was in run, devices will go to their configured ‘fault state.’
Publication 1771-UM118C-EN-P - June 2003
Page 138
E-6
Programming the PLC-5 Processor
Use BTR to Upload Input Data from the Scanner The PLC-5 uploads input data from the scanner using block transfer read instructions over the 1771 backplane. The scanner interprets BTRs of length 1 through 50 and 62 words as being from the first block of the scanner input table. The scanner module can update a maximum of 357 input words by internally linking together six different sized block transfers. See the table below.
Block Transfer Size
Accessed Scanner Input Block
62 words
Block 62
61 words 60 words 59 words 58 words 57 words 52 words 51 words 1-50 words
Block 61 Block 60 Block 59 Block 58 Block 57 Block 52 Block 51 Block 1-50
Scanner Input Data Table DeviceNet Messages
Word 0 – Module Status Register Word Words 1–61 Words 62–122 Words 123–182 Words 183–241 Words 242–299 Words 300–356 Device Failure Table Device Active Table Words 0–49
Each individual block transfer is independent, but always retrieves the same input bytes from the scanner’s input data table. The types of information that a PLC-5 program will upload from the scanner via the BTR are the: • Device Input Data Table (6 blocks, 62 through 57 words) • Device Failure Table (1 block, 52 words) • Device Active Table (1 block, 51 words) When the scanner receives a BTR, it automatically knows which block of data is desired by the size specified. You may upload portions of the scanner input table rather than the entire table, to support higher-speed operations. The scanner will interpret any BTR of length 1 through 50 with the words 0 thru 49 of block 62 of the scanner input table. BTRs of sizes 57 through 61 represent full blocks of the table. A BTR of 52 words contains the Device Failure Table. Sizes 53 through 56 are reserved. Size 64 is used for Explicit Message Program Control. For more details on Explicit Message Program Control, refer to page 26.
Publication 1771-UM118C-EN-P - June 2003
Page 139
Programming the PLC-5 Processor
E-7
To reduce block transfer time and increase system performance, use only the words you need. Use the RSNetWorx for DeviceNet software to map data from a DeviceNet node into the scanner input table. Data from a DeviceNet node can be split and put into as many as four different locations in the scanner input table.
Module Status Register In the Module Status Register (word 0, block 62), bits 0 through 5 indicate to the PLC-5 the current state of the scanner module. When a Module Command Register command is sent to the scanner module, the respective bits are set in the Module Status Register when the command executes. Depending on network load, the scanner may take several moments to detect network status changes. The bits latch on in the “on” state until the command clears. Bits 6 and 7 indicate that you should read the device failure table for more specific information about which devices failed. Bits 8 and 9 indicate that you should read the device autoverify table to determine which device has incorrect device keying or a misconfigured data size in the scanner configuration tables. Use the DeviceNetManager software to correct this error. You can use bits 6 and 7 of the Module Status Register to enable the scanner module’s Module Command Register to react to certain conditions. An example reaction to a condition is to keep the communication ports in the “idle” mode until the bits clear. When the bits clear, this indicates that all devices on the networks are operational. When the devices are operational, you can put the ports in the “run” mode, so that output data goes to the devices. If a device failure is detected, you can put the communication into the “idle” mode, so that all devices would go into their idle state. You may tie these inputs to the Module Command Register, so that you may use them to adjust the operating mode of the scanner when devices fail or go online at startup. You can also modify your control logic to run differently to compensate for the loss of communication with a certain node. An alarm message to alert an operator of the problem is also possible.
Publication 1771-UM118C-EN-P - June 2003
Page 140
E-8
Programming the PLC-5 Processor
The following table lists Module Status Register bit numbers and their descriptions. Module Status Register - Word 0, Block 62 Bit Number
00 - 01
02 - 03
04 05 06 07 08 09
10
Bits 01
00
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
11
1 0
12
1 0
13
14 15
1 0 1 0 1
Operating Mode
Operating Mode Description
DeviceNet Channel 1 in idle mode DeviceNet Channel 1 in run mode DeviceNet Channel 1 in fault mode Reserved DeviceNet Channel 2 in idle mode DeviceNet Channel 2 in run mode DeviceNet Channel 2 in fault mode Reserved Enable DeviceNet Channel 1 Disable DeviceNet Channel 1 Enable DeviceNet Channel 2 Disable DeviceNet Channel 2 No failures detected DeviceNet Channel 1 device failure detected No failures detected DeviceNet Channel 2 device failure detected No failures detected DeviceNet Channel 1 autoverify failure detected No failures detected DeviceNet Channel 2 autoverify failure detected No failures detected DeviceNet Channel 1 communications failure detected No failures detected DeviceNet Channel 2 communications failure detected No failures detected DeviceNet Channel 1 duplicate node address failure No failures detected DeviceNet Channel 2 duplicate node address failure No failures detected Scanner configuration missing or corrupted No failures detected Client/server transaction response queued
Idle The scanner does not map output data to the devices, but keeps network connections to devices open so device failures can be detected. Input data is returned from devices, and mapped into the scanner input table and the discrete inputs. Outputs on the network are not under program control and will be in their configured ‘safe state.’ The scanner must be in this mode to perform configuration of the scanner database tables.
Publication 1771-UM118C-EN-P - June 2003
Run The scanner module maps output data from its scanner output table and discrete outputs to each device on the network. Inputs are received and mapped into the scanner input table and discrete inputs. Outputs on the network are under program control. Placing the PLC-5 into the PROG or REM_PROG mode places the scanner into IDLE MODE regardless of the state of the bits in the module command register. Placing the PLC-5 into RUN or REM_RUN mode causes the state of the bits in the module command register to determine the scanner state. Fault The scanner has stopped communicating with devices on the network. No outputs or inputs are mapped. Outputs on the network are not under program control. If the scanner was in run, devices will go to their fault state. Device Failure One or more of the devices in the scanner’s scan list has failed to communicate with the scanner. Autoverify Failure One or more of the devices in the scanner’s scan list is returning an incorrect number of bytes of data in response to a strobe/poll, according to the information stored in the scanner’s scan list. Communications Failure There is no communication on the port. Duplicate Node Address Failure There is another node with the same address on the network. Scanner Configuration Missing or Corrupted Either the I/O chassis addressing mode is set to an illegal position or, the chassis addressing mode switch does not match the value stored in the scanner’s scan list. Client/server transaction response queued The client/server response is loaded and available with a 64-word Block Transfer Read.