The text of a manual · part 9 of 23
Bulletin 1771 Communication Controller Module (Cat. Nos. 1771-KE, -KF) User's Manual, pages 81 to 90
Pages 81 to 90 of 228
The original document is the PDF (9.6 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-KE
Page 81
Page 4-19 RS-232-C Link Protocols
4.3.1 Multidrop Topology
Half-duplex protocol requires the following communication characteristics:
® 8 bits per character e Even parity 1 stop bit
Pass-all mode (the terminal driver does not translate or respond to control characters)
Single character buffer (the teriminal driver immediately returns each character to the caller)
The intended environment for half-duplex protocol is a multipdrop link with all stations interfaced through half-duplex modems. The actual nature of the link does not matter much, as long as the modems support request-to-send, clear-to-send, and data-carrier-detect. If dial-up modems are used they must also support data-set-ready and data-terminal-ready, otherwise DSR should be jumpered to DTR.
There may be from 2 to 256 stations simultaneously connected to a single link. Each station has a receiver permanently connected to the circuit, and a transmitter that may be enabled or disabled by RTS.
One station is designated as master and controls which station has access to the link. Since Allen-Bradley currently does not supply the master station, this function must be performed by your own programmed intelligent device. All other stations are called slaves, and must wait for permission from the master before transmitting. Each slave station has a unique station number from 0 to 254.
The master can send and receive messages to and from each station on the multidrop. The master can send and receive messages to and from every station on highways that are connected to the multidrop via a KE/KF module. If the master is programmed to relay messages, then stations on the multidrop can engage in peer-to-peer communications. The multidrop will not easily provide flexible peer-to-peer communication between the multidrop and connected highways, or between different highways.
Either a two-circuit system (master sends and slaves receive on one circuit, slaves send and master receives on the other), or a one-circuit system (master and slaves send and receive on the same circuit) may be used.
Half-duplex dialup modems can be used as long as a carrier is detected before the carrier timeout (about 8 seconds). If a carrier is not sensed before the timeout the module will hang up the phone. Carrier must be sensed at least every 8 seconds to maintain the connection.
Page 82
Page 4-20 RS-232-C Link Protocol
Multiple masters are not allowed, except when one acts as a backup to the other, and does not communicate unless the primary is shut down.
4.3.2 Half-duplex protocol is a character oriented protocol that uses Transmission Codes _ the following ASCII control characters extended to 8 bits by adding a zero for bit 7. See ANSI X3.4, CCITT V.3, or ISO 646 for the standard definition of these characters.
Abbreviation Hexadecimal Code SOH 01 STX 02 ETX 03 EOT 04 ENQ 05 ACK 06 DLE 10 NAK 15
The term “code” means (in the following paragraphs) an indivisible sequence of one or more bytes having a specific meaning to the link protocol. “Indivisible’” means that the component characters of a code must be sent one after another with no other characters inserted between them. It does not refer to the timing of the characters. (This definition has less significance than for full-duplex protocol, since there is no multiplexing of transmission codes in half-duplex protocol).
These codes are used in half-duplex protocol:
Control Codes: DLE SOH DLE STX DLE EXT BCC/CRC DLE ACK DLE NAK DLE ENQ DLE EOT
Data Codes: DATA (single characters having values 00-0F ad 11-FF) DLE DLE (to represent the data 10)
DLE SOH indicates the start of a message.
DLE STX separates the link level header from the data field of a message.
DLE ETX BCC/CRC terminates a message.
DATA 00-0F and 11-FF encode the corresponding values in the message itself. DLE DLE encodes the occurrance of the value 10 (hex) in the message.
Page 83
Page 4-21 RS-232-C Link Protocol
4.3.3 Link-Layer Packets
4.3.3.1 Block Check
DLE ACK signals that a message has been successfully received.
DLE NAK is used as a global link reset command. This causes all slaves to cancel all messages that are ready to be transmitted to the master. Typically the slave will return the messages to the command originator with an error code.
DLE ENQ starts a poll command.
DLE EOT is used by slaves as a response to a poll when they have no messages to send.
Half-duplex protocol uses three types of transmissions: e Polling packet e Master message packet e Slave message packet
The master station transmits both polling packets and master message packets, while slave stations transmit slave message packets.
Figure 4.14 illustrates the formats of these packets. Note that the slave message packet has the same format as the full-duplex message packet (section 4.2.2). The master message packet is the same as the slave message packet except that it is prefixed with DLE SOH and an address code to specify a slave station number.
At the end of each polling packet, there is a BCC byte. At the end of each message packet, there is either a one-byte BCC field, or a two byte CRC field. With a series A-G module, you must use BCC. With a series H module, you can select BCC or CRC through switch settings.
The block check character (BCC) is a means of checking the accuracy of each packet transmission. It is the 2’s complement of the 8-bit sum (modulo-256 arithmetic sum) of the slave station number (STN) and all the data bytes in the packet. For polling packets, the BCC is simply the 2’s complement of STN. The BCC does not include any other message packets codes or response codes.
Page 84
Page 4-22
RS-232-C Link Protocols
DLE {| ENQ | STN BCC a) Polling Packet b) Slave Message Link Packet
DLE
SOH c) Master Message Link Packet
From Application Layer
From Network Layer
From Application Layer
From Network Layer
11327
Figure 4.14, Formats for Half-Duplex Protocol
Page 85
Page 4-23 RS-232-C Link Protocol
4.3.3.2 Cyclic Redundancy Check
For example, if the master station wanted to send the data codes 8, 9, 6, 0, 2, 4, and 3 to slave station 20 hex (40 octal), the master message codes would be (in hex):
10 01 20 10 02 08090600020403 10 03 CO DLE SOH STN DLE STX Data DLE ETX BCC
The sum of the STN and data bytes in this message packet is 40 hex. The BCC is the 2’s complement of this sum, or CO hex. This is shown in the following binary calculation:
0100 0000 hex 10111111 1s complement xtl
1100 0000 2s complement (EO hex) To transmit the STN or data value 10 hex, you must use the data code DLE DLE. However, only one of these DLE text characters is included in the BCC sum. For example, to transmit the values 8, 9, 6, 0, 10, 4, and 3 hex, a slave station would use the following message codes:
Represents single text value of 10 10 02 08 09 06 00 10 10 04 03 10 08 D2
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 by bytes during transmission of a packet. It also cannot detect the insertion or deletion of data values of zero within a packet.
Calculate the CRC value on the value of the data bytes and the ETX byte (using the polynomial x'* + x'° + x’ + x°). To transmit the data value of 10 hex, you must use the data code DLE DLE. However, only one of these DLE data bytes is included in the CRC value. Embedded responses are not included in the CRC value.
At the start of a message packet, the transmitter clears a 16-bit register for the CRC value. As a byte is transmitted, it is exclusive-OR’d (with bit 0 to the right) to the right eight bits of the register. The register is then shifted right eight times with Os inserted on the left. Each time a 1 is shifted out on the right, the following binary number is exclusive-OR’d with the 16-bit register value:
1010 0000 0000 0001
Page 86
Page 4-24 RS-232-C Link Protocol
As each additional byte is transmitted, it is included in the value in the register the same way. After the ETX value is included in the value in the register and is transmitted, the value in the register is transmitted (right bit first) as the CRC field.
The receiver also calculates the CRC value and compares it to the received CRC value to verify the accuracy of the data received.
NOTE: In half duplex mode there is a BCC on the polling packet regardless of whether BCC or CRC error checking is used on messages.
4.3.4 In each station there is a program connected to the link Protocol Environment hardware that is called the transceiver. The master station has Definition amore complex transceiver than the slaves, since it must include a polling algorithm. Only the slave’s transceiver is defined here, as illustrated in Figure 4.15.
Page 87
Page 4-25 RS-232-C Link Protocol
To fully define the environment of the protocol, the transceiver needs to know where to get the messages it sends and must have a means of disposing of messages it receives. These are implementation-dependent functions that shall respectively be called the message source and the message sink. We assume that the message source will supply one message at a time upon request from the transceiver, and will require notification of the success or failure of transfer before supplying the next message. Whenever the transceiver has received a message successfully, it will attempt to give it to the message sink. The possibility exists that the message sink will be full. The transceiver requires an indication of this.
Network Network Packet Packet > Link pet MASTER - SLAVE SOURCE |) TRANSCEIVER] ~ ™| RECEIVER SOURCE OK T OK - - - - Message, - Message, - - » SINK SINK Full Full A To Other Slaves Software, - - _____-_ Software - eat - - - Hardware, >} 11566 Figure 4.15, Slave Transceiver 4.3.4.1. Ideally, the link protocol should not be at all concerned with
Message Characteristics the content or form of the messages it is transferring. However, half-duplex protocol places the following restrictions on the messages that are submitted to it for transfer:
J. Minimum size of a valid message is 6 bytes, maximum is 250 bytes.
2. Some protocol implementations require that the first byte of a message match the station address. These receivers will ignore messages that do not contain the correct address. This filtering is not required, since the message sink can also provide the address filtering function.
Page 88
Page 4-26 RS-232-C Link Protocol
4.3.4.2 Master Polling Responsibilities
4.3.4.3 Slave Tranceiver Actions
3. As part of the duplicate message detection algorithm, the receiver checks the second, third, fifth, and sixth bytes of each message. There must be a difference in at least one of these bytes between a message and its predecessor for it to be recognized as distinct rather than a retransmission of the previous message.
The master polling algorithm may vary depending on the expected flow of traffic through the system.
A simple master that does not expect unsolicited messages continuously polls each slave once in a round-robin fashion. If a message is received it should be handled, then the next station polled. An alternative scheme would poll each station repeatedly until it was empty, and then proceed to the next. Relaying of peer-to-peer messages is best left to the network layer, which is the lowest level of the body of software that includes the message source and sink.
Figure 4.16 is a flowchart of the software logic for implementing half-duplex protocol from the master station’s point of view.
Since the transceiver receives “dirty” input from the physical world, it must be capable of responding to many adverse situations. Some of the things that could conceivably happen are listed below:
1. The message sink can be full, leaving nowhere to put a message.
. A message can contain a parity error.
. The BCC can be invalid.
. The DLE SOH, DLE STX or DLE ETX BCC may be missing. . The message can be too long or too short.
. A spurious control or data code can occur outside a message.
. A spurious control code can occur inside a message.
on Dm oO fF WB DY
. The DLE ACK response can be lost, causing the transmitter to send a duplicate copy of a message that has already been passed to the message sink.
The slave is always in a passive mode until it receives a message. While waiting for a message, anything besides the DLE SOH or DLE ENQ is ignored. Note that in a single circuit system the slaves must be able to safely ignore everything sent by other slaves.
If a DLE SOH is received the BCC and the message buffer are reset. The next code received must be a data code and must equal the station address or 255 (if the station can receive
Page 89
Page 4-27 RS-232-C Link Protocol broadcast messages). If there is no match, the station ignores the rest of the message and continues waiting for the start of the message.
If the station address matches, it is added to the BCC. The next code is received and must match DLE ST. If it doesn’t, the station ignores the rest of the message. Otherwise it starts building a message.
While building a message, all data codes are stored in the message buffer and added to the BCC. If the buffer overflows, the receiver continues summing the BCC, but the data is discarded, If an error is detected, it is recorded. If any control code other than a DLE ETX BCC is received, the error flag, the BCC, the message size, and the address (optionally) are all checked. If any of the tests fail, the message is ignored.
If the message is OK, its header is compared to the last message. If it is the same, the message is discarded and a DLE ACK is transmitted. If it is different, the new header is saved and the message is sent to the message sink. If the message can be stored, a DLE ACK is sent. If the message sink is full, the message is discarded and not acknowledged.
If while waiting for a message a DLE ENQ is received, the transceiver accepts the next two characters. The last character is read directly from the link, since it is a BCC and is not byte stuffed. If the station address does not match or there is an error, the poll is ignored. If the poll is accepted, there are three possible situations:
1. The transceiver could still be holding a message that it had transmitted previously, but had not been ACKed. There is a limit on the number of times each message can be sent. If this limit is exceeded when the poll is received, the message is returned to the message source with an error indication, and the transceiver tries to send the the next message from the message source. If the limit is not exceeded the response to the poll will be to re-send the current message.
2. If no message is currently being held the transceiver tries to get one from the message source. If one is available the transceiver will initialize its re-try counter and transmit it in response to the poll.
3. If no message is available the response to a poll will be to transmit a DLE EOT.
When a message is transmitted after receiving a poll, its format is identical to a full-duplex message packet. After sending a message, the transceiver will hold the message until a DLE ACK is received, or the number of times the message has been polled exceeds the limit.
Page 90
Page 4-28 RS-232-C Link Protocol
( XCVR )
Select Station all r
Poil Selected Station t
Start Timeout
Receive
No
DLE EOT ?
Set Active Station Flag
Network Layer has Message to send ?
Get Message From Network Layer
Send Message y
Start Timeout
Receive
Yes
Receive Message ?
Active Station
3
Timeouts No
Message OK?
Duplicate Message ?
Give Message to Network Layer y
Send DLE ACK
7 for this Poll?
Remove Station from Active List
DLE ACK
3 Timeouts for this Message?
Tell Network Layer of Failure
Figure 4.16, Implementation of Half-Duplex Protocol