The text of a manual · part 43 of 47
Bulletin 2803 VIM Vision Input Module User Manual: E - DF1 Protocol Description
Pages 365 to 374 of 404, from Bulletin 2803 VIM Vision Input Module User Manual
The original document is the PDF (26 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 2803-VIM2
Page 365
Appendix
Objectives
What is DFI Protocol?
Protocol E Dfl Description This appendix describes the Allen-Bradley DFl communication protocol, and the programming you need to do at the host end to communicate with the VIM2 module.
DFl protocol is an Allen-Bradley developed software convention used for serial communications. DFl protocol provides some handshaking and data-packing formats which allow for fast communications with integrity of the data. DFl protocol combines some features of subcategories Dl and Fl as described in the ANSI X3.28-1976 specification. The DFl for the VIM2 module is half-duplex, point-to-point communications between the VIM2 module and a computer host.
Transmission
Codes
DFl protocol is a character-oriented protocol that uses the following ASCII control characters extended to eight bits by adding a zero for bit 7 (see ANSI X3.4, CCITT V-3, or IS0 646 for the standard definition of these characters). Control Character STX (Start of Text) ETX (End of Text) ENQ (Enquiry) ACK (Acknowledge) DLE (Data Link Escape) NAK (Negative Acknowledge)
Hexadecimal
Code
02 03 05 06 10 15
Additionally, a block check character (BCC) field is used at the end of each packet for error checking. These bytes can be any value from 00 to FF hex. As used in the following paragraphs, a code is an indivisible sequence of one or more bytes having a specific meaning to the protocol. Indivisible means that the component bytes of a code must be sent one after another with no other bytes between them. It does not refer to the timing of the bytes.
Page 366
Appendix E-2
Tfaw71ission Codes
DFl Protocol Description
E
The protocol uses these codes:
(continued) l l
Control codes: )
DLE STX
)
DLE ETX BCC
)
DLEACK
)
DLENAK
)
DLEENQ
Data codes: )
Data (single bytes having values 00-OF and ll-FF hex)
)
DLE DLE (or 10 10, to represent the value 10 hex)
Using two DLEs in sequence to represent the value 10 hex is called “DLE stufing.” The system reads a single 10 hex as a Date Link Escape, and expects the next byte to be a control code. A valid 10 hex intended to be data would be misinterpreted as a DLE. To send 10 hex as a data value, send it twice in sequence. We can also group codes into two classes according to their use - codes issued from a station transmitting a message, and response codes issued from a station receiving a message. By this classification, the codes are: l l
Codes from station transmitting a message:
)
DLE STX - indicates the start of a message.
)
Data (00-OF and ll-FF command.
)
DLE DLE (or 10 10) - encodes the value 10 hex in the text code.
)
DLE ETX BCC - terminates a message.
)
DLE ENQ - requests the retransmission received ACK or NAK.
hex) - encodes the bytes of the of the last
Response code from station receiving a message: )
DLE ACK - signals that the receiver has successfully received the last message sent.
)
DLE NAK - signals that the receiver did not successfully receive the last message sent.
Page 367
Appendix
MesslagePackets
E
DFl Protocol Description E-3
A message packet starts with a DLE STX, ends with a DLE ETX BCC, and includes all data codes in between. Data codes can occur only inside a message packet. Figure A.1 shows the format of a message packet. At the end - of each message is a one byte BCC. Figure A.1 Message Packet Format
Data ...
Block Check Character
DLE
ETX
BCC
The block check character (BCC) is a means of checking the accuracy of each message packet transmission. It is the 2’s complement of the 8-bit sum (module-256 arithmetic sum) of all data bytes between the DLE STX and the DLE ETX BCC. It does not include any other message packet codes or response codes. For example, if a message packet contained the data codes 8, 9,6,0,2,4, and 3, the message packet codes would be (in hex): 10
02
DLE
STX
Data
DLE
03
EO
ETX
BCC
The sum of the data bytes in this message packet is 20 hex. The BCC is the 2’s complement of this sum, or EO hex. This is shown in the following binary calculation: 0010 0000 1101 1111 cl
20 hex l'scomplement
1110 0000
2'scomplement
(EO hex)
Page 368
DFl Protocol Descri,ption
Appendix E
E-4
BIock Check Character (continued)
To transmit the data value 10 hex, you must use the data code DLE DLE. However, only one of these DLE data bytes is included in the BCC sum. For example, to transmit the values 8,9,6,0,10,4, and 3 hex, you would use the following message codes: Represents single data byte value of 10 10
02
DLE
STX
03
Data
DLE
D2
ETX BCC
In this case, the sum of the data bytes is 2E hex because only one DLE text code is included in the BCC. So the BCC is D2 hex. The BCC algorithm provides a medium level of data security. It cannot detect transposition of bytes during transmission of a packet. It also cannot detect the insertion or deletion of data values of zero within a packet.
Message Size
The maximum size of a message packet is 250 bytes. This does not include the “DLE STX,” “DLE ETX BCC,” or the first “DLE” of data “DLE DLE.”
Page 369
Appendix
Transmitter Actions
E
DFl Protocol Description E-5
Whenever the message source can supply a packet and the transmitter is not busy, transmitter A sends a message packet (see Figure A-2). It then starts a timeout, and waits for a response. When transmitter A gets a DLE ACK, the message transfer is complete. After signaling the message source that the message has been sent successfully, transmitter A proceeds with the next message. If transmitter A gets a DLE NAK, it retransmits the same message. The transmitter restarts the timeout and waits again for a response. The default retry setting is 3. Once the number of retransmissions exceeds this limit, the transmitter should notify the message source that the transmission has failed. The transmitter can then proceed with the next message. If the timeout expires before transmitter A gets a response, it sends a DLE ENQ to request a retransmission of the last response sent. Transmitter A restarts the timeout and waits for a response. The default retry setting is 3 for the VIM2 module. If this ENQ limit is exceeded, the transmitter should notify the message source that the transmission has failed. The transmitter can then proceed with the next message. DLE ACK and DLE NAK are the only response codes defined. If the receiver gets an invalid response code, it should ignore it. Note that the transmitter must encode a text value of 10 hex as two consecutive (indivisible) bytes, each of value 10 hex. This is necessary to distinguish the text value of 10 hex from the DLE control code of 10 hex. This technique is known as DLE stuffing. The receiver must be able to reverse this process and extract the original text value of 10 hex.
Page 370
DFl Protocol Description
Appendix E
E-6
Tmwnitter
Figure A.2 is a flowchart which gives a simplified view of an example of software logic for implementing the transmitter.
Actions (con timed)
Figure A.2 Transmitter for DFl Protocol
Retransmit
Same Message
Message Packet DLE
Data
Timeout
ETX
BCC
Loop
No TV No
DLE
ENQ
Legend
0 0
P
T
I
= Recovery Procedure w = Ready to Transmit
“Default
Values
Next Message
Page 371
Appendix
Receiver Actions
E
DFl Protocol Description E-7
Since the receiver gets input structured in a variety of formats from the physical world, it is more complex and must be capable of responding to many adverse situations. Some of the things that can conceivably happen are listed here: Receiver is busy and cannot process the message. A message can contain a parity error. The BCC can be invalid. The DLE STX or DLE ETX BCC may be missing. The message can be too long. A spurious control or text code can occur outside a message. A spurious control code can occur inside a message. Any combination of the above can occur.
The DLE ACK response can be lost, causing the transmitter to send a duplicate copy of a message that has already passed to the message sink. The receiver must keep a record of the last response code (DLE ACK or DLE NAK) sent. If it receives a DLE ENQ, the receiver sends this recorded response code again. Until it receives a DLE STX or a DLE ENQ, the receiver ignores all input. On initialization, receipt of spurious control or text code outside a message, or receipt of DLE STX, the last response code is set to NAK. Receipt of ACK from last message sent will set the response to ACK. The receiver responds to a DLE ENQ input by sending its last response (ACK or NAK) and continues waiting for input. If the receiver gets a DLE STX, it resets its BCC accumulator and data buffer to zero and starts storing the data in the data buffer.
Page 372
Appendix f-8
Receiver Actions (continued)
E
DFl Protocol Description
While the receiver stores all link-level data codes in the data buffer, it adds the link-level data code values to the BCC. If the data buffer overflows, or there is no buffer available, the receiver continues summing the BCC, but it discards the data. The receiver also sets an error flag to indicate the occurrence of a parity, buffer overrun, message framing, or modem handshaking error. When the receiver gets a DLE ETX BCC, it checks the error flag, the BCC, and the message size. If any of the tests fail, the receiver sends a DLE NAK. Figure A.3 is a flowchart which gives a simplified view of an example of software logic for implementing the receiver.
Page 373
Appendix
E
DFl Protocol Description E-9
Receiver Actions (continued) Figure A.3 Receiver
DFl
Protocol
1
No
-
No
No LAST = NAK
1
LAST=ACK
]
,
Page 374
DFI Protocol Description
Appendix E
E-IO
Example
If you were to connect a line monitor to the wires between stations you could observe the activates shown in Figure A.4: Figure A.4 Message Error Recovery
Normal message Path 1:
DLE STX (Data) DLE ETX BCC+
DLE STX (Data) DLE ETX BCC+ tDLE
Path 2:
tDLE
ACK
ACK
Message with parity or BCC error and recovery Path 1:
DLE STX (Data) DLE ETX BCC+
DLE STX (Noise) DLE ETX BCC+ tDLE
Path 2:
tDLE
NAK
ACK
Message with ETX destroyed Path 1:
DLE ST.K (Data) (Noise) [timeout] tDLE
Path 2:
DLE STX (Data) DLE ETX BCC+
DLE ENQ-, NAK tDLE
ACK
Good message but ACK destroyed Path 1: Path 2:
DLE STK (Data) DLE ETX BCCtDL
[timeout]
(Noise) CK
DLE ENQ-, tDLE
ACK
Note: A simple way to test the RS-485 link is to send the VIM2 module a DLE ENQ (enquiry). If you have the port properly connected and the VIM2 module is configured for DFl protocol, the VIM2 module should send a DLE ACK or DLE NAK in response. If no response is provided, check your connections and VIM2 module configuration.