Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 10 of 31

DF1 Protocol and Command Set Reference Manual: 5 - Data-link Layer Message Frames

Pages 73 to 79 of 251, from DF1 Protocol and Command Set Reference Manual

The original document is the PDF (2.1 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.

Filed in the catalog under the Allen-Bradley 5250-LP and Allen-Bradley 5250-MLP1

Page 73

Chapter

5

Data-link Layer Message Frames In the data-link layer of a message frame: • half-duplex protocol uses three types of message transmission • full-duplex protocol implements its message fields at different network layers • at the end of each polling and message frame, there is a one-byte BCC field or a two-byte CRC field Read this chapter to help learn the fields that your computer uses in the data-link layer of a message frame. It contains these sections: Section

Page

Half-duplex Protocol Message Frames

5-2

Full-duplex Protocol Message Frames

5-3

BCC and CRC Fields

5-4

Publication 1770-6.5.16 - October 1996

Page 74

5–2

Data-link Layer Message Frames

Half-duplex Protocol Message Frames

Half-duplex protocol uses three types of transmissions: • polling frame • master message frame • slave message frame The master node transmits both polling frames and master message frames, and slave nodes transmit slave message frames. The following figure illustrates the formats of these frames. The slave message frame has the same format as the full-duplex message frame. The master message frame is the same as the slave message frame except that it is prefixed with DLE SOH and an address to specify a slave station address (STN). Important:

Even if you set your module to use CRC, when you send a polling frame, it uses a single BCC byte.

Polling Frame DLE ENQ

STN

BCC

Master Message Frame From common application routines DLE

SOH STN

DLE

STX

DST

SRC CMD STS

TNS

Data (command data)

DLE

ETX

BCC/ CRC

TNS

Data (command data)

DLE

ETX

BCC/ CRC

Slave Message Frame DLE

STX

DST

SRC CMD STS

From common application routines

The BCC field contains the 2's complement of the 8-bit sum (module-256 arithmetic sum) of the slave station address (STN) and all the data bytes in the frame. For polling frames, the BCC is simply the 2's complement of STN. The BCC does not include any other message frame symbols or response symbols.

Publication 1770-6.5.16 - October 1996

Page 75

Data-link Layer Message Frames

Full-duplex Protocol Message Frames

Full-duplex protocol implements different message frames, depending on the network layer. This figure shows the format of a message frame for full-duplex protocol and the layer at which each portion is implemented:

From user application program

DST

From common application routines

DST

DLE

Data-link layer frame

5–3

CMD

STS

SRC

CMD

STS

STX data from application layers command data

TNS

DLE data (from application layer)

ETX

BCC/CRC field

The BCC/CRC field contains the 2's complement of the 8-bit sum (module-256 arithmetic sum) of all application layer data bytes between the DLE STX and the DLE ETX BCC. It does not include any response symbols. You can use the BCC/CRC field for one of the following types of error checking: • block check character (BCC) • 16-bit cyclic redundancy check (CRC-16)

Publication 1770-6.5.16 - October 1996

Page 76

5–4

Data-link Layer Message Frames

BCC and CRC Fields

At the end of each polling frame and each message frame, there is a one-byte BCC (block check character) field, or a two byte CRC (cyclic redundancy check) field. You select BCC or CRC through switch settings or software configuration. Either field allows you to verify the accuracy of each message frame transmission: • The BCC algorithm provides a medium level of data security: – it cannot detect transposition of bytes during transmission of a frame – it cannot detect the insertion or deletion of the value zero within a frame • The CRC field provides a higher level of data security than BCC but is more difficult to implement

BCC Field We’ve included both half- and full-duplex BCC examples: Half-duplex protocol example If the master node wants to send the hexadecimal data symbols 08, 09, 06, 00, 10, 04, and 03 to slave node 2016 (40 octal), the master message symbols are: 10 01 20 10 02 08 09 06 00 10 10 04 03 10 03 B2 STN DLE STX APP DATA (DLE DLE) DLE ETX BCC The sum of the STN and application layer data bytes in this message frame is 4E16. The BCC is the 2's complement of this sum, or B216. This is shown in the following binary calculation: 0100 1110 = sum (4E16) 1011 0001 = 1's complement +1 ------------------ 1011 0010 2's complement (B216 = BCC) To transmit the STN or data value 10 hex, you must use the data symbol DLE DLE. You must also use the data symbol DLE DLE if your STN value is 10. Only one of these DLE bytes, however, is included in the BCC sum. For example, to transmit the data values 08, 09, 06, 00, 10, 04, and 03 (hex), a slave node uses the following message symbols: 10 DLE

02 STX

08 09 06 00 10 10 04 03 APP DATA (DLE DLE)

10 03 DLE EXT

D2 BCC

In this case, the sum of the data bytes is 2E hex because only one DLE byte is included in the BCC. The BCC (2's complement) of 2E16 is D216.

Publication 1770-6.5.16 - October 1996

Page 77

Data-link Layer Message Frames

5–5

Full-duplex protocol example If a message frame contained the data 08. 09, 06, 00, 02,04, and 03 (decimal), the message symbols are: 10 DLE

02 STX

08 09 06 00 02 04 03 APP DATA

10 03 DLE ETX

E0 BCC

The sum of the application data bytes in this message frame is 32 decimal or 20 hex. The BCC is the 2's complement of this sum, or E0 hex. This is shown in the following binary calculation: 0010 0000 20 16 1101 1111 1's compliment +1 --------------- 1110 0000 2's compliment (E0 hex) To quickly determine a BCC value, add up the hex values of the application layer bytes. If the total is greater than 100 hex, drop the most significant digit. Then, subtract the result from 100 hex. This gives you the BCC. For example, if the sum of the application layer bytes is 20 hex, then: 10016 -2016 ____ E016 Important:

10 DLE

02 STX

To transmit the value 10 hex, you must use the data symbol DLE DLE. However, only one of these DLE data bytes is included in the BCC sum. For example, to transmit the values 08, 09, 06, 00, 10, 04, and 03 hex, use the following message symbols: 08 09 06 00 10 10 04 03 APP DATA (DLE DLE)

10 03 DLE EXT

D2 BCC

In this case, the sum of the application layer data bytes is 2E hex because only one DLE byte is included in the BCC. So the BCC is D216. This is sometimes referred to as DLEs.

Important:

If your BBC check sum is 10 hex, send it as “10” and not “10 10.” That is, a BCC is not treated like data.

Publication 1770-6.5.16 - October 1996

Page 78

5–6

Data-link Layer Message Frames

CRC Field For these protocols

You calculate the CRC value➀ full-duplex using the value of the link-layer data bytes and the ETX byte.

half-duplex

•for master messages using the value of the link-layer data bytes and the STN, STX and ETX bytes➁ •for slave messages using the value of the link-layer data bytes and the ETX byte

➀ The polynomial for a CRC value is: X16 + X15 + X2 + X0. ➁ Do not add in the associated DLE for STX and ETX values.

Important:

To transmit the data value of 1016, you must use the data symbol DLE DLE. However, only one of these DLE bytes is included in the CRC value. Embedded responses are not included in the CRC value.

The following explains the transmission of the CRC value: 1. At the start of a message frame, the transmitter clears a 16-bit register used for the CRC value. 2. As a byte is transmitted, it is exclusive-ORed (least-significant bit to the right) with the right eight bits of the CRC register. 3. The result is placed in the right eight bits of the CRC register. 4. The CRC register is then shifted right eight times by inserting 0s on the left. Each time a 1 is shifted out on the right, the CRC register is exclusive-ORed with this 16-bit constant: 1010 0000 0000 0001

5. As each additional byte is transmitted, it is included in the value in the register the same way. 6. After the ETX value is transmitted, the value in the CRC register is transmitted (right bit first). The receiver also calculates the CRC value and compares it to the received CRC value to verify the accuracy of the data received.

Publication 1770-6.5.16 - October 1996

Page 79

Data-link Layer Message Frames

5–7

The full-duplex and half-duplex slave and master protocol examples below provide you with procedures for determining the CRC-16 value. Full-duplex and half-duplex slave protocol data_byte = all link-layer data, ETX CLEAR CRC_REGISTER FOR each data_byte GET data_byte XOR (data_byte, right eight bits of CRC_REGISTER) PLACE RESULT in right eight bits of CRC_REGISTER) DO 8 times (on CRC register_ Shift bit right, shift in 0 at left IF bit shifted = 1 XOR (CONSTANT, CRC_REGISTER) PLACE RESULT in CRC_REGISTER END IF END DO END FOR TRANSMIT CRC_REGISTER as 2-byte CRC field (low byte, high byte)

Half-duplex master protocol data_byte = STN, STX, all link-layer data, ETX CLEAR CRC_REGISTER For each data_byte GET data_byte XOR (data_byte, right 8 bits of CRC_REGISTER) PLACE RESULT in right 8 bits of CRC_REGISTER DO 8 times Shift bit right, shift in 0 at left IF bit shifted = 1 XOR (CONSTANT, CRC_REGISTER) PLACE RESULT in CRC_REGISTER END IF END DO END FOR TRANSMIT CRC_REGISTER as 2 byte CRC field

Below is an actual frame that you can use to validate your CRC routine: Use this frame to validate the CRC 10

02

07

11

41

00

53

B9

00 00 00 00 00 00 00 00 00 00 00 00 10

03

6B 4C

Publication 1770-6.5.16 - October 1996