Data Highway or Data Highway Plus Asynchronous (RS-232-C or RS-422-A) Interface Module Cat. No.
Important User Information Because of the variety of uses for the products described in this publication, those responsible for the application and use of this control equipment must satisfy themselves that all necessary steps have been taken to assure that each application and use meets all performance and safety requirements, including any applicable laws, regulations, codes and standards.
Table of Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Module Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Highway Applications . . . . . . . .
ii Table of Contents Error Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ERROR WORD in User Programming (1771 KG, 1771 KA, 1771 KA2, 1774 KA Modules) . . . . . . . . . Error Codes for 1775 KA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Internal Error Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1 7 2 7 8 7 19 Switch Settings . . .
Chapter 1 Introduction General A 1770-KF2 Series B module is a communication interface that links intelligent RS-232-C or RS-422-A (asynchronous) devices to an Allen-Bradley local area network. By setting switches on the KF2, and changing cables, you can direct communications over a Data Highway or a Peer Communication Link (PCL). With a 1770-KF2 module, a computer on a PCL can communicate with any PLC-5 node on the network.
Chapter 1 Introduction Table 1.A Related Documentation Publication Number Old Publication Number Title 1770-6.2.1 1770-810 Data Highway Cable Assembly and Installation Manual 1771-6.5.1 1771-801 Communication Adapter Module (Cat. No. 1771-KA2) User’s Manual 1771-6.5.15 1771-822 Communication Controller Module (Cat. Nos. 1771-KE, -KF) User’s Manual 1771-6.5.8 1771-811 PLC-2 Family/RS-232-C Interface Module (Cat. No. 1771-KG) User’s Manual 1775-6.5.
Chapter 1 Introduction Module Description Figure 1.1 shows the 1770-KF2 module’s hardware features: Diagnostic Indicators Connectors for Data Highway and RS-232-C Devices Communication Option Switches On/Off Switch, Power Plug, Fuse, and Voltage Select Switch Figure 1.1 1770-KF2 Communication Interface Module ALLEN–BRADLEY PWR XMTG RCVG RDY ACTV CPU DATA HIGHWAY COMMUNICATION INTERFACE A KF2 also features extensive self-diagnostics.
Chapter 1 Introduction Specifications Table 1.B lists KF2 module specifications. Table 1.B KF2 Module Specifications Specification Communication Rates Requirements • • • Functions • • Interface a programmable RS-232-C or RS-422-A compatible device with an Allen-Bradley Data Highway. Serve as a replacement for a 1771-KD Communication Controller Module. Location • • Tabletop (or other horizontal surface) Controlled environment, e.g.
Chapter 1 Introduction Data Highway Applications A KF2 module provides either a point-to-point link or a multi-drop link between an Allen-Bradley Data Highway and an intelligent asynchronous device. By “intelligent asynchronous device” we mean any device that complies with RS-232-C or RS-422-A electrical standards and that can be programmed to handle the communication protocol described in Chapters 4 through 6 of this manual.
Chapter 1 Introduction In a multi-drop configuration, one intelligent asynchronous device connects to several Data Highways through sets of modems and KF2 modules. Figure 1.3 illustrates this type of configuration. If the multi-drop link consists of broadband modems, you can select either peer-to-peer (full-duplex) or master-slave (half-duplex) communication.
Chapter 1 Introduction In either type of configuration, there are three possible ways you can connect a KF2 module: Direct connection to an intelligent asynchronous device if the KF2 module is mounted within 50 cable-feet of an RS-232-C, or within 4,000 cable-feet of an RS-422-A device. Direct connection to an Allen-Bradley 1775-KA, 1773-KA, or 1771-KG interface module if the KF2 module is within 50 cable-feet of the other module.
Chapter 1 Introduction Figure 1.4 A PCL Network Connected to a Data Highway Advisor 2+ TM PLC-3 1770-KF2 1775-KA Data Highway 1785-KA PCL PLC-5 PLC-5 1770-KF2 Computer 14690 Important: A 1770-KF2 module on a PCL link cannot access a station on the Data Highway through a 1785-KA module. A KF2 module on the Data Highway, however, can access a station on a PCL link through a 1785-KA.
Chapter 2 Communication Concepts General This chapter presents some of the concepts of communication with the KF2 module. It describes the physical communication links to the module and the various levels of software necessary to make those links work. A KF2 module connects a computer or programmable controller to an Allen-Bradley local area network (LAN), either Data Highway or Peer Communication Link (PCL).
Chapter 2 Communication Concepts the application and network layers, refer to Chapters 5 and 6. For more on the data link layer of the asynchronous link, refer to Chapter 4 and Appendix D. Physical Link Layer The physical link layer is a set of cables and interface modules that work together to provide a channel for communication between the various points, called stations, on the physical link. A station consists of an intelligent programmable device (e.g.
Chapter 2 Communication Concepts Figure 2.1 Data Highway Network PLC-3 Processor Computer TM 1775-KA Module Advisor 2+ MODEM RS-232-C Link 50 Cable-Ft. Max. MODEM Link MODEM 1770-KF2 Module 1770-KF2 Module Data Highway Link 1770-KF2 Module RS-232-C Link 50 Cable-Ft. Max.
Chapter 2 Communication Concepts One station consists of an Advisor 2+TM Color Graphic System connected to a KF2 module through an RS-232-C link limited to 50 cable-feet. Another station consists of a computer interfacing with a KF2 module through a modem link that is limited only by the nature of the modems themselves. The third such station consists of a 1771-KG module interfacing a PLC-2/30 processor with a KF2 module through an RS-232-C link limited to 50 cable-feet.
Chapter 2 Communication Concepts Stations A station consists of a computer, or PC processor, and the module or modules that interface it with the PCL. Within a station that contains a KF2 module, an asynchronous link is required as an auxiliary link to the network. PCL networks currently use PLC-5 processors, which interface directly to the PCL; and no station interface module is required. You can, however, connect other PCs, as shown in Figure 2.2. Figure 2.
Chapter 2 Communication Concepts Computer Programming The communication protocol for the PCL is transparent to a computer on the network. However, for a computer to send or receive messages through the PCL, it must be programmed to communicate with its KF2 module over an asynchronous link. Chapters 4, 5, and 6 describe the protocol that you must program your computer to use on this link. Configuration Selection Figure 2.1 and Figure 2.
Chapter 2 Communication Concepts Configuration Considerations Allen-Bradley manufactures a variety of communication interface modules for different applications: Communication Interface Module Cat. No.
Chapter 2 Communication Concepts Software Layers Each of the physical links just described requires three layers of software to enable communication to take place. The layers are defined as follows: Application Layer — Controls and executes the actual tasks, or commands, specified in the communication between stations. To program this layer, use the commands described in Chapter 5. Network Management Layer — Handles queueing, sequencing, routing, and error status reporting for communication.
Chapter 2 Communication Concepts automatically fills the protocol bytes. If the transaction originates from a computer station, your computer software must supply the necessary protocol. In both cases, the data bytes contain information supplied by application programs. Command/Reply Cycle Any network transaction consists of two messages: a command and a reply. The two parts provide extra data integrity by ensuring that a required action always returns some sort of status, whether an error code or data.
Chapter 2 Communication Concepts required. Using an excessive number of high priority commands defeats the purpose of this feature and could delay or inhibit the transmission of normal priority messages. Command Structures There are four basis types of command on a Data Highway network or a standalone link: Read Write Diagnostic Mode Select Reads There are two types of read: Physical Unprotected A physical read allows you to read any area of PC memory at a remote station.
Chapter 2 Communication Concepts As with reads, writes also are classified by the level of access to PC memory. Non-physical writes can access only the data table at a remote PC; physical writes can access all of user memory, including PC program memory. Non-physical writes can be further subdivided into protected and unprotected. Protected writes can access only specified areas of the remote PC’s data table memory.
Chapter 2 Communication Concepts Generally, you need not be concerned with the interaction of station interface modules on the network. This means that your application programs at the PCs and computers along the network need not involve themselves with interstation protocol, handshaking, or control of the network link. This is all carried out automatically by the station interface modules. However, an understanding of station interaction is useful both to computer programmers and PC programmers.
Chapter 3 Installation General This chapter explains how to install the 1770-KF2 module. There are four parts to installation: Setting Communication Option Switches Situating the Module for Operation Connecting the Module to the Network and Asynchronous Links Observing the Diagnostic Indicators Please read the first three chapters of this manual carefully before attempting any of the installation steps. Communication Option Switches The KF2 module has 8 switch assemblies (Figure 3.
Chapter 3 Installation Figure 3.
Chapter 3 Installation Switch 3 determines whether the asynchronous port of the KF2 module can detect duplicate messages transmitted to it. If You Want Your Module to: Set Switch 3: Detect and Ignore Duplicate Messages ON Accept All Messages Regardless of Duplication OFF Switch 4 determines whether the module uses and recognizes the following handshaking signals: data set ready, request to send, clear to send, data carrier detect, and data terminal ready.
Chapter 3 Installation Figure 3.2 Station Number Switch Groups SW-2 O 1 N 2 O F F SW-3 O 1 N 2 ON SW-4 O 1 N 3 O F F 2 OFF 3 O F F First Digit ON ON OFF OFF Second and Third Digits Set Switches If You Want to Set This Digit: No. 1 No. 2 0 1 2 3 OFF OFF ON ON OFF ON OFF ON Set Switches If You Want to Set This Digit: No. 1 No. 2 No. 3 0 1 2 3 4 5 6 7 OFF OFF OFF OFF ON ON ON ON OFF OFF ON ON OFF OFF ON ON OFF ON OFF ON OFF ON OFF ON Switch Setting Example: Station No.
Chapter 3 Installation Figure 3.3 Switch Settings for Network Link SW–5 O 1 N 2 Both switches ON for 57,600 bits per second O F F 13514 Asynchronous Communication Rate and Diagnostic Commands Switch Assembly SW-6 lets you select the communication rate and diagnostic commands for the KF2 module’s asynchronous port.
Chapter 3 Installation Switch 4 relates only to diagnostic commands sent to the KF2 module from a remote Data Highway station. Since only computers can transmit diagnostic commands, the remote station must be a computer connected to the Data Highway by means of another KF2 module. At the computer station, the setting of Switch 4 does not affect any diagnostic commands that the computer sends to its local KF2 module.
Chapter 3 Installation Selecting the Network Link You use Switch Assembly SW-7, a spare assembly in all Series A modules, to select whether the KF2 treats the network link as a Data Highway or as a PCL.
Chapter 3 Installation Important: The asynchronous port of the KF2 module can communicate at a maximum rate of 9,600 bits per second. If your 1771-KD module was set to communicate at a higher rate, then you might have to make some modifications to your RS-232-C link before installing the replacement KF2 module. Mounting (Placing) A KF2 module is not actually mounted in the sense that other Allen-Bradley communication modules are.
Chapter 3 Installation Interface Connections The KF2 module has 3 connectors on its rear panel (Figure 3.5). The center connector, labeled DATA HIGHWAY, connects to the Data Highway dropline cable. Plug the 15-pin connector of the dropline into the DATA HIGHWAY socket. For connection to the PCL, plug the 15-pin PCL dropline into the Data Highway socket. (For details on how to construct the dropline, refer to Publications 1770-6.2.1 or 1770-2.13.
Chapter 3 Installation Mechanical Characteristics The COMPUTER ASYNCHRONOUS connector on a KF2 module is a male 25-pin D-shell. This connector conforms to the RS-232-C standard and will accommodate any RS-232-C standard cable (see “Cabling”). Electrical Characteristics Selection of either RS-232-C or RS-422-A determines the input and output levels of the transmit data and receive data circuits on the asynchronous interface.
Chapter 3 Installation The definitions of the above signals are: TXD carries serialized data. It is an RS-232-C standard output from the module. RXD is RS-232-C standard serialized data input to the module. RTS is a request from the module to the modem to prepare to transmit. With full-duplex protocol, RTS is always asserted. With half-duplex protocol, it is turned on when the module has permission to transmit; otherwise it is off. It conforms to RS-232-C specifications.
Chapter 3 Installation must be connected to the GND of the modem or computer. Note that this type of connection does not provide electrical isolation between the module and the connected device. If a connection is made between the KF2 and an RS-422-A compatible device, you can mount the device and the module up to 4,000 cable-feet apart. Direct Connection to a Computer To connect the module directly to a computer, you can construct your own cable according to the wiring diagram in Figure 3.6.A.
Chapter 3 Installation This type of connection includes the DTR signal to allow each end to detect the loss of the other end’s ability to communicate. If your computer does not provide the DTR signal, jump Pins 6 and 8 at the KF2 module to Pin 20. Connection to a Modem To connect the module to a modem, you can construct your own cable according to the wiring diagram in Figure 3.7.
Chapter 3 Installation The module can be connected to standard American dial-up modems and some European modems. Other European standards specify that the DTR signal will make the modem answer the phone whether it is ringing or not, causing the phone always to be “busy.” Do not use the module with any type of modem that answers the phone when DTR is asserted, even while waiting for a call. The types of dial-up network modems that you can use are: Manual: These are typically acoustically coupled modems.
Chapter 3 Installation Figure 3.8 Connection to 1771-KG Module A. Connection Diagram 25-Pin Female Connector Asynchronous Port Connector of 1770-KF2 Module (RS-232-C) User-Supplied Cable, Belden 8723, or Equivalent (50 Feet Maximum) 15-Pin Male Connector RS-232-C Port Connector of 1771-KE/KF or 1771-KG Module (Cat. No. 1778-CR) User-Supplied Connectors B.
Chapter 3 Installation Figure 3.9 Connection to 1773-KA or 1775-KA Module A. Connection Diagram 25-Pin Female Connector Asynchronous Port Connector of 1770-KF2 Module (RS-232-C) User-Supplied Cable, Belden 8723, or Equivalent (50 Feet Maximum) 25-Pin Male Connector RS-232-C Port Connector of 1773-KA or 1775-KA Module (Cat. No. 1778-CR) User-Supplied Connectors B.
Chapter 3 Installation After detecting DCD, the module continues to monitor the DCD line. If DCD goes off, the module restarts the timeout. If DCD is not restored within the timeout, the module initiates the hang-up sequence. This feature allows the remote station to redial in the event that the connection is lost through a fault in the phone network. This handshaking is necessary to guarantee access to the phone line.
Chapter 3 Installation Diagnostic Indicators There are 6 LED indicators on the front of a KF2 module (Figure 3.10). These indicators can help you in diagnosing problems with the module’s installation and operation. The indicators are: PWR - Power On XMTG - Transmitting RCVG - Receiving RDY - Ready to Transmit ACTV - Active CPU - Module Fault, or DLE NAK Indicator Figure 3.
Chapter 3 Installation The ACTV light remains on as long as the cable between the COMPUTER ASYNCHRONOUS socket and the interfacing asynchronous device is properly connected. This light will appear to flicker whenever characters are being transmitted across the asynchronous link. If this light goes off, check the cable and connectors for possible problems. The CPU light comes on for about half a second every time the module transmits or receives a DLE NAK protocol sequence (Chapter 4).
Chapter 4 Asynchronous Link Protocols General This chapter describes the communication protocol used on the asynchronous link to the KF2 module. If you are connecting a KF2 module to another Allen-Bradley communication interface module (such as a 1771-KG, 1773-KA, or 1775-KA module), you need not be concerned with protocol because the modules automatically take care of it.
Chapter 4 Asynchronous Link Protocols Important: Some Allen-Bradley documentation might refer to full-duplex and half-duplex protocols as DF1 and polled-mode protocols, respectively. Full-Duplex Protocol Full-duplex protocol conforms closely to ANSI X3.28-1976, combining features of Subcategories D1 (data transparency) and F1 (two-way simultaneous transmission with embedded responses). Full-duplex protocol is used over a point-to-point link that allows two-way simultaneous transmission.
Chapter 4 Asynchronous Link Protocols Data Codes: - Data (single characters having values 00-0F and 11-FF hex) - DLE DLE (to represent the value 10 hex) Codes are grouped into two classes: message codes, sent from transmitter to receiver; and response codes, sent from receiver to transmitter. DLE STX is a message code used to indicate the start of a message. DLE ETX BCC/CRC is a message code used to terminate a message.
Chapter 4 Asynchronous Link Protocols Figure 4.1 Packet Format for Full-Duplex Protocol DST SRC DLE STX CMD STS CMD STS From Application Layer Command/Response Block From Network Layer Data (From Application Layer) TNS Data (From Network Layer) DLE ETX BCC Data Link Layer Packet 11321A Block Check The block check character (BCC) is a means of checking the accuracy of each message packet transmission.
Chapter 4 Asynchronous Link Protocols The sum of the data bytes in this message packet is 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 1101 1111 +1 1110 0000 20 hex 1’s complement 2’s complement (E0 hex) Example 2: 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.
Chapter 4 Asynchronous Link Protocols 1010 0000 0000 0001 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.
Chapter 4 Asynchronous Link Protocols To implement all of these data paths with only two physical circuits, a software multiplexer combines the message codes with the response codes going in the same direction. At the other end of the link a software separator divides the message codes from the response codes. The message codes are sent to the receiver, and the response codes are sent to the transmitter via internal software.
Chapter 4 Asynchronous Link Protocols Figure 4.4 shows Path 1 with unrelated parts of Figure 4.3 removed. Paths 2, 3, and 4 could be similarly shown. Figure 4.4 Path 1, Unrelated Parts of Figure 4.3 Removed Transmitter A Receiver B Path 1 Path 1 M S 11558 The full-duplex protocol is symmetrical; that is, anything that can be said about Transmitter A, Receiver B, and Paths 1 and 2 applies equally to Transmitter B, Receiver A, and Paths 3 and 4.
Chapter 4 Asynchronous Link Protocols Although the protocols on each subsystem operate independently of each other, there will be a slight interaction as transmission of a message is delayed when a two-character response code is inserted in a stream of message codes. Also, any hardware problem that affects message codes traveling over a hardware circuit will also likely affect response codes on the same circuit.
Chapter 4 Asynchronous Link Protocols Message Characteristics Ideally the link protocol should not be at all concerned with the content or form of the message it is transferring. However, full-duplex protocol places the following restrictions on the messages that are submitted to it for transfer: 1. Minimum size of a valid message is 6 bytes, maximum is 250 bytes. 2.
Chapter 4 Asynchronous Link Protocols If the timeout expires before a response is received, the transmitter sends a DLE ENQ on Path 1 to request a retransmission of the last response sent on Path 2. It restarts the timeout and waits for a response. This too can be repeated several times, and there is a user-defined limit on the number of timeouts that are allowed per message.
Chapter 4 Asynchronous Link Protocols Table 4.A Transmitter for Full-Duplex Protocol TRANSMITTER is defined as loop Message = GET-MESSAGE-TO-SEND Status = TRANSFER (Message) SIGNAL-RESULTS (Status) end loop TRANSFER (Message) is defined as initialize NAK-limit and ENQ-limit SEND (Message) start timeout loop WAIT for response on Path 2 or timeout.
Chapter 4 Asynchronous Link Protocols Receiver Actions Since the receiver gets “dirty” input 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: 1. The message sink can be full, leaving the receiver with nowhere to put a message. 2. A message can contain a parity error. 3. The BCC can be invalid. 4. The DLE STX or DLE ETX BCC may be missing. 5.
Chapter 4 Asynchronous Link Protocols If a DLE STX is received, the BCC and the message buffer are reset; and the receiver 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 a parity, overrun, framing, or modem handshaking error is detected, it is recorded.
Chapter 4 Asynchronous Link Protocols Table 4.
Chapter 4 Asynchronous Link Protocols Figure 4.
Chapter 4 Asynchronous Link Protocols Full-Duplex Protocol Diagrams The following figures show some events that can occur on the various interfaces. Time is represented as increasing from the top of the figure to the bottom. Data bytes are represented by “xxxx”; corrupted data by “???”. Figure 4.9 Normal Message Transfer SOURCE XMTR LINK RCVR SINK xxxx DLE STX xxxx DLE ETX BCC Not Full xxxx DLE ACK OK 11561 Figure 4.
Chapter 4 Asynchronous Link Protocols Figure 4.11 Message Transfer with Timeout and ENQ SOURCE XMTR LINK RCVR SINK xxxx DLE STX xxxx DLE EXT BCC Not Full xxxx DL ??? CK (Timeout) DLE ENQ DLE ACK OK 11563 Figure 4.12 Message Transfer with Retransmission SOURCE XMTR LINK RCVR SINK xxxx DLE STX xxxx DLE EXT BCC Not Full xxxx DL ??? CK ??? (Timeout) DLE ENQ DLE NAK DLE STX xxxx DLE EXT BCC (Message Discarded)1 DLE ACK OK 1 4-18 Note that this is detected as a duplicate message.
Chapter 4 Asynchronous Link Protocols Figure 4.13 Message Transfer with Message Sink Full SOURCE XMTR LINK RCVR SINK xxxx DLE STX xxxx DLE EXT BCC Full DLE NAK DLE STX xxxx DLE ETX BCC Full DLE NAK DLE STX xxxx DLE EXT BCC Not Full xxxx DLE ACK OK 11565 Retransmission occurs when noise hits both sides of the line. This type of noise destroys the DLE ACK while also producing invalid characters at the receiver.
Chapter 4 Asynchronous Link Protocols Examples If a line monitor were connected to the wires between Stations A and B, and only the A to B subsystem were active, the following would be observed: Normal Message Path 1: Path 2: DLE STX ... DLE ETX BCC DLE STX .... DLE ETX BCC DLE ACK DLE ACK Message with Parity or BCC Error and Recovery Path 1: Path 2: DLE STX ...xxx.. DLE ETX BCC DLE STX .... DLE ETX BCC DLE ACK DLE NAK Message with ETX Destroyed Path 1: Path 2: DLE STX .... DLE ETX BCC DLE STX ..
Chapter 4 Asynchronous Link Protocols Half-Duplex Protocol Half-duplex protocol is the alternative to full-duplex protocol. You can select half-duplex protocol by setting communication option Switches 1, 2, and 5 of SW-1. Half-duplex protocol is based on full-duplex but extends or redefines several features. Half-duplex protocol is a multi-drop protocol for one master and one or more slaves. Modems must be used (unless there is only one slave).
Chapter 4 Asynchronous Link Protocols One station is designated as master, and it controls which station has access to the link. You can use a 1771-KGM PLC-2 Family module as the master, or this function can 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.
Chapter 4 Asynchronous Link Protocols 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.
Chapter 4 Asynchronous Link Protocols Link-Layer Packets Half-duplex protocol uses three types of transmissions: Polling Packet Master Message Packet 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 (see “Link-Layer Message Packets”).
Chapter 4 Asynchronous Link Protocols 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. You can select BCC or CRC through switch settings (see Chapter 3, “Asynchronous Link Features”). Block Check The block check character (BCC) is a means of checking the accuracy of each packet transmission.
Chapter 4 Asynchronous Link Protocols 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.
Chapter 4 Asynchronous Link Protocols transceiver is illustrated in Figure 4.15, and the master transceiver is illustrated in Figure 4.16. 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.
Chapter 4 Asynchronous Link Protocols 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. 3. As part of the duplicate message detection algorithm, the receiver checks the second, third, fifth, and sixth bytes of each message.
Chapter 4 Asynchronous Link Protocols Figure 4.
Chapter 4 Asynchronous Link Protocols Slave Transceiver Actions 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. 2. A message can contain a parity error. 3. The BCC can be invalid. 4. The DLE SOH, DLE STX, or DLE ETX BCC may be missing. 5. The message can be too long or too short. 6.
Chapter 4 Asynchronous Link Protocols 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.
Chapter 4 Asynchronous Link Protocols When a DLE NAK is received, the transceiver takes messages from the source until it is empty. Each message will be discarded with an error code sent back to the message source. This can be used by the master to clear up the message source buffers of all slaves after the master has been down. Half-Duplex Protocol Diagrams The following figures show some of the events that occur on various interfaces.
Chapter 4 Asynchronous Link Protocols Figure 4.19 Message Transfer with ACK Destroyed SOURCE/ SINK MASTER LINK SLAVE SOURCE/ SINK xxxx DLE SOH STN DLE STX xxxx DLE ETX BCC Not Full xxxx DL ??? CK (Timeout) DLE SOH STN DLE STX xxxx DLE ETX BCC DLE ACK OK 11569 Figure 4.20 Poll with No Message Available SOURCE/ SINK MASTER LINK SLAVE SOURCE/ SINK Not Full DLE ENQ STN BCC No Message DLE EOT 11570 Figure 4.
Chapter 4 Asynchronous Link Protocols Figure 4.22 Duplicate Message Transmission SOURCE/ SINK MASTER LINK SOURCE/ SINK SLAVE Not Full DLE ENQ STN BCC xxxx DLE STX xxxx DLE ETX BCC xxxx DL ??? CK Sometime Later ... Not Full DLE ENQ STN BCC DLE STX xxxx DLE ETX BCC DLE ACK (Discard Retransmission) OK 11572 Figure 4.
Chapter 4 Asynchronous Link Protocols Figure 4.24 Message Sink Full, Case 2 SOURCE/ SINK MASTER LINK SLAVE SOURCE/ SINK xxxx DLE SOH STN DLE STX xxxx DLE ETX BCC Full (Timeout) Not Full DLE ENQ STN BCC xxxx DLE STX xxxx DLE ETX BCC xxxx DLE ACK DLE SOH STN DLE STX xxxx DLE ETX BCC Not Full xxxx DLE ACK OK 11575 The message sent for the second poll is the same as the first, since the first transmission was not ACKed.
Chapter 4 Asynchronous Link Protocols station alone may not work, since it could be that the only way to free up space is to send a message to the master. Line Monitoring When monitoring half-duplex protocol in two-wire mode, you need to monitor only one line. The example below shows a message sent by the master and a reply sent by the slave in answer to a poll. Slave responses are in boldface.
Chapter 5 Message Packet Formats General This chapter describes how your computer application programs should format command and reply messages for transmission over the asynchronous link. It covers both application level and network level functions. Basically, the application layer specifies the contents of messages and initiates their transmissions. The network layer takes the information from the application layer and formats it in a way that is acceptable to the data link layer (Chapter 4).
Chapter 5 Message Packet Formats Figure 5.1 Network Model Command Initiator Command Executor Q Q Replies Commands Replies Commands R R Network R = Routing Subroutine Entry Q = Incoming Message Queue 11576 Messages do not necessarily arrive at their destination in the same order that they were sent. It is impossible for the network layer to guarantee delivery, and in some cases it may not be possible to provide notification of non-delivery.
Chapter 5 Message Packet Formats Message Packets The message bytes contain unsigned binary data from both the application layer and the network layer. Figure 5.2 shows the general format of a command message. Figure 5.
Chapter 5 Message Packet Formats The meanings of the bytes are: DST — Destination Station for the Message SRC — Source Station of the Message CMD — Command Code STS — Status Code TNS — Transaction Number (2 Bytes) FNC — Function Code EXT STS — Extended Status Code ADDR — Address of Memory Location (2 Bytes Minimum) SIZE — Number of Bytes to Be Transferred DATA — Data Values Being Transferred by the Message These bytes are described in more detail below.
Chapter 5 Message Packet Formats Figure 5.4 shows the format for the CMD byte itself. Bits 0 through 3 contain the command code. Bits 4 and 7 should always be set to 0. Bit 5 is the priority indicator; set to 0 for normal priority messages and 1 for high priority messages (Chapter 2). Bit 6 is the command/reply indicator; set it to 0 in a command message and 1 in a reply message. Figure 5.4 CMD Byte Format Bit 7 6 5 4 3 2 1 0 0 r p 0 command 11702 Reply messages also contain a CMD byte.
Chapter 5 Message Packet Formats TNS A complete transaction consists of a command message transmitted by a PC station. The TNS (transaction) bytes contain a a unique 16-bit transaction identifier. The first byte, RNG, contains the number of the PC program rung that generated the command; and the second, SQN, contains the transmission sequence number.
Chapter 5 Message Packet Formats ADDR The ADDR (address) field contains the address of a memory location in the command executor. ADDR specifies the address where the command is to begin executing. For example, if the command is to read data from the command executor, ADDR specifies the address of the first byte of data to be read. Note that the ADDR field specifies a byte address, not a word address as in PC programming. Chapter 6 explains how to convert PC word addresses to byte addresses.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Basic Command Set Basic commands include those that can generally be executed by any PC station on the communication link, regardless of the type of PC controller at that station. In some cases, switch settings on the station interface module can disable execution of a particular type of command at that station. For more details, refer to the user’s manual for the station interface module.
Chapter 5 Message Packet Formats Diagnostic Loop You can use this command to check the integrity of transmissions over the communication link. The command message transmits up to 243 bytes of data to a station interface module. The receiving module should reply to this command by transmitting the same data back to the originating station. Command Format: DST SRC CMD 06 STS TNS FNC 00 DATA — Max. 243 Bytes CMD 46 STS TNS DATA — Max.
Chapter 5 Message Packet Formats Diagnostic Status This command reads a block of status information from the station interface module. The reply to this command contains the status information in its DATA field. Command Format: DST SRC CMD 06 STS TNS FNC 03 CMD 46 STS TNS DATA — Max. of 244 Bytes Reply Format: DST SRC The status information varies with the type of station interface module. Table 5.
Chapter 5 Message Packet Formats Table 5.B Contents of Status DATA for 1771-KA2, -KC/KD, -KE/KF; 1770-KF2; 1771-KG, 1774-KA; and 1785-KA Modules Byte Bit 1 Operating Status of PC Processor — For the 1770-KF2, this byte is always 0.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Protected Bit Write This command sets or resets individual bits within limited areas of the PC data table memory. Its access is limited by memory access rungs in the communication zone of the PC’s ladder diagram program. The data field in this packet consists of 4-byte blocks, each of which contains a 16-bit address field, a set mask, and a reset mask. Use the ADDR field to specify the address of the byte to be modified in the PC data table memory.
Chapter 5 Message Packet Formats Protected Write This command writes words of data into limited areas of the PC data table memory. Its access is limited by memory access rungs in the communication zone of the PC’s ladder diagram program. Command Format: DST SRC CMD 00 STS TNS CMD 40 STS TNS ADDR DATA — Max. of 243 Bytes Reply Format: DST SRC Set ENQS This command sets the maximum number of ENQs that the station interface module will issue per message transmission.
Chapter 5 Message Packet Formats Set NAKS This command sets the maximum number of NAKs that the station interface module will accept per message transmission. Put the number in the DATA field. The default setting for the KF2 module is 3 NAKs per transmission. Command Format: DST SRC CMD 06 STS TNS CMD 46 STS TNS FNC 05 DATA Reply Format: DST SRC Set Timeout This command sets the maximum amount of time that the station interface module will wait for an acknowledgment to its message transmission.
Chapter 5 Message Packet Formats Set Variables This command is a combination of the above three commands. It sets the maximum ENQs, NAKs, and timeouts all at once. Put the timeout setting in the first byte of the DATA field, the NAKs setting in the second byte, and the ENQs in the third byte.
Chapter 5 Message Packet Formats Note that the interface module at the receiving PC station executes this command by first making a copy of the addressed PC byte. It then sets or resets the appropriate bits and writes the byte back into PC memory. At the same time, the PC processor can be changing the states of the original bits in memory. Because of this, some data bits may unintentionally be overwritten.
Chapter 5 Message Packet Formats Unprotected Write This command writes words of data into ay area of PC data table memory. Use the SIZE field to specify the number of bytes to be read. To specify a number of PC words, SIZE should be an even value because PC words are two bytes long.
Chapter 5 Message Packet Formats Disable Outputs This command turns off all outputs of the PLC controller. Use this command to disable the PLC’s outputs before doing a physical write operation. Command Format: DST SRC CMD 07 STS TNS CMD 47 STS TNS FNC 00 Reply Format: DST SRC Enable Program This command returns control of outputs to the PLC ladder diagram program. Use this command to cancel the effect of the disable outputs command.
Chapter 5 Message Packet Formats Enable Scan This command restarts the PLC processor’s program scanner after a physical write operation has been performed. Note that you must always use the enable scan command to restart the PLC processor after a physical write command. Command Format: DST SRC CMD 07 STS TNS CMD 47 STS TNS FNC 03 Reply Format: DST SRC Physical Read This command reads bytes of data from the PC data table or program memory.
Chapter 5 Message Packet Formats Physical Write This command writes bytes of data into the PC data table or program memory. Use this command to download a computer file into PLC memory. Use the SIZE field to specify the number of bytes to be written. To specify a number of PC words, SIZE should be an even value because PC words are two bytes long. Command Format: DST SRC CMD 03 STS TNS CMD 43 STS TNS ADDR DATA — Max.
Chapter 5 Message Packet Formats Enter Download Mode This command puts the PLC-2 processor into the Download mode. Use this command on a PLC-2 station before attempting to send any physical write commands to the station. Command Format: DST SRC CMD 07 STS TNS CMD 47 STS TNS FNC 04 Reply Format: DST SRC When you send an Enter Download/Upload mode command, the Industrial Terminal port is disabled until you send an Exit Download/Upload mode command.
Chapter 5 Message Packet Formats Enter Upload Mode This command puts the PLC-2 processor into the Upload mode. Use this command on a PLC-2 station before attempting to send any physical read commands to the station. Command Format: DST SRC CMD 07 STS TNS CMD 47 STS TNS FNC 06 Reply Format: DST SRC When you send an Enter Download/Upload mode command, the Industrial Terminal port is disabled until you send an Exit Download/Upload mode command.
Chapter 5 Message Packet Formats Physical Read This command reads bytes of data from the PC data table or program memory. Use this command to upload the contents of PLC-2 memory to your computer. Use the SIZE field to specify the number of bytes to be read. To specify a number of PC words, SIZE should be an even value because PC words are two bytes long. Command Format: DST SRC CMD 04 STS TNS ADDR SIZE CMD 44 STS TNS DATA — Max.
Chapter 5 Message Packet Formats Set Data Table Size This command sets the data table size for the PLC-2 processor. Use this command immediately before performing any physical writes on the PLC-2 processor. For the DATA field in this command, enter the number of bytes of memory that you want to allocate to the PLC-2 data table. Since PC words are two bytes long, the DATA value is double the number of words in the PLC-2 data table.
Chapter 5 Message Packet Formats Only a computer can initiate privileged commands. Their primary use is for uploading and downloading PLC-3 memory. Only a computer or another PLC-3 station can initiate the non-privileged PLC-3 commands listed above. Their primary use is for transferring data between two PLC-3 files. Those files may be located in the same PLC-3 processor in two different PLC-3s.
Chapter 5 Message Packet Formats 7. WORD OFFSET — Contains the word offset between the desired word and the beginning of the addressed file. The offset is zero for the first word of a file. In word-range read and write commands, this field can be combined with a symbolic file address to specify a word address. Bit Writes This is a bit write command to modify the bits at the address specified by either a word symbol, a file symbol plus a word offset, or a logical address.
Chapter 5 Message Packet Formats Download Request A computer can use this command to inform the 1775-KA module that it wants to do a download. If the 1775-KA module grants the download privilege, the computer may begin issuing physical reads or writes. If a different station already has the download privilege, the second station is denied the privilege. Command Format: DST SRC Reply Format: A. STS TNS FNC 05 (EXT STS Byte Optional) Format When Successful Execution DST B.
Chapter 5 Message Packet Formats File Write This is a write command, starting address of which is either a file symbol or a block address. This starting address must point to a file of words. Command Packet: DST SRC CMD 0F STS Reply Format: A. DST B. DST TNS FNC 03 PACKET OFFSET TOTAL TRANS PLC-3 LOGICAL ADDRESS (2-51 Bytes) DATA — Max. length is 239 bytes minus the length of the PLC-3 logical address. (Must be an even number of bytes.
Chapter 5 Message Packet Formats Physical Write This is a write command where the starting address is a PLC-3 physical address. It is used to download to a PLC-3 from a computer. The destination 1775-KA module will accept this command only after the source station has successfully transmitted a shutdown request. Function code for this command is 8. Command Packet: DST SRC CMD 0F STS Reply Format: A. DST B. DST TNS FNC 08 PLC-3 PHYSICAL ADDRESS DATA — Max.
Chapter 5 Message Packet Formats Shutdown Request This command is used by the computer to ask the 1775-KA module to initiate either a PLC-3 shutdown (if the computer has download privileges) or a freeze on file allocations (if the computer has upload privileges). The computer cannot issue this command until it has successfully transmitted an upload or download request to the 1775-KA module. Command Format: DST SRC CMD 0F STS TNS FNC 07 Reply Format: (EXT STS Byte Optional) A.
Chapter 5 Message Packet Formats Word Range Read This is a read command whose starting address is either a word symbol, a file symbol plus a word offset, or a block address. This starting address must point to a word in a file. The function code is 1. A special case of this command is the single-word read, where the number of bytes to read is only two bytes (one word). Command Format: A. Word Symbol Address DST SRC B. DST SRC CMD 0F STS DST B.
Chapter 5 Message Packet Formats Word Range Write This is a write command whose starting address is either a word symbol, a file symbol plus a word offset, or a logical address. This starting address must point to a word in a file. The function code is 0. A special case of this command is the single-word write, where the number of bytes to read is only one word long. Command Format: A. DST SRC B. DST SRC Word Symbol Address CMD 0F STS DST B.
Chapter 5 Message Packet Formats The above are privileged commands. This means that only a computer can execute them. Their primary purpose is for uploading and downloading PLC-4 memory. PLC-4 stations cannot initiate any type of command message. In addition to the message packet fields already described for the basic command set (see “Message Packets”), PLC-4 messages may also contain a byte called PLC-4 SEL.
Chapter 5 Message Packet Formats Deallocate This command deallocates access privileges to the selected PLC-4 controller. Command Format: DST SRC CMD 0E STS TNS FNC 06 PLC-4 SEL Reply Format: (EXT STS Byte Optional) A. Format When Successful Execution DST B. DST SRC CMD 4E STS TNS Format When Reporting an Error SRC CMD 4E STS TNS EXT STS Initialize Processor This command initializes, or clears, memory in the selected PLC-4 controller.
Chapter 5 Message Packet Formats Physical Read This command reads the specified number of bytes from the memory of the selected PLC-4 controller. Use this command to upload the contents of PLC-4 memory to your computer. The SIZE field contains the number of bytes to be read, and it may have a value from 1 to 242 decimal. Command Format: DST SRC CMD 0E STS TNS FNC 0D PLC-4 SEL ADDR SIZE Reply Format: (EXT STS Byte Optional) A. Format When Successful Execution DST B.
Chapter 5 Message Packet Formats Physical Write with Mask This command sets or resets bits in a memory word of the selected controller. The ADDRESS field contains the physical PLC-4 address of the memory word to be modified. Refer to Chapter 6 for a description of physical addresses. The BIT MASK field specifies which bits in the PLC-4 word are to be modified, and the DATA field specifies whether those bits are to be set or reset.
Chapter 5 Message Packet Formats Set to Program Load Mode This command sets the selected controller to the Program Load mode. Command Format: DST SRC CMD 0E STS TNS FNC 01 PLC-4 SEL Reply Format: (EXT STS Byte Optional) A. Format When Successful Execution DST B. DST SRC CMD 4E STS TNS Format When Reporting an Error SRC CMD 4E STS TNS EXT STS Set to Run Mode This command sets the selected controller to the Run mode.
Chapter 5 Message Packet Formats Set to Single-Scan Test Mode This command sets the selected controller to the Single-Scan Test mode. Command Format: DST SRC CMD 0E STS TNS FNC 04 PLC-4 SEL Reply Format: (EXT STS Byte Optional) A. Format When Successful Execution DST B. DST SRC CMD 4E STS TNS Format When Reporting an Error SRC CMD 4E STS TNS EXT STS Set to Test Mode This command sets the selected controller to the Test mode.
Chapter 5 Message Packet Formats PLC-5 Commands PLC-5 stations can execute the basic command set with the following exceptions: Set ENQs Set NAKs Set Timeouts Set Variables This section presents the message formats of the PLC-5 command and reply messages.
Chapter 5 Message Packet Formats 2. PLC-5 LOGICAL BINARY ADDRESS — Contains the logical address of a PLC-5 file, element, and subelement. Chapter 6 gives more details about the contents of this address field. 3. PLC-5 LOGICAL ASCII ADDRESS — Contains the logical address of a PLC-5 file, element, or subelement expressed as a string of ASCII characters. Chapter 6 gives more details about the contents of this address field. 4. PLC-5 PHYSICAL ADDRESS — Contains the physical address of a PLC-5 word.
Chapter 5 Message Packet Formats The STS and EXT STS bytes contain status and error code information. For more information on these bytes, see the “Error Codes” section in this document. Download Completed Use this command after downloading a complete system to place the processor back in the mode that it was in prior to executing the Download All Request command.
Chapter 5 Message Packet Formats The link ID (presently not used, set it to zero) and the station address are one byte while the file number is two bytes. The format for this message is as follows: Command Format: DST SRC CMD 0F STS TNS CMD 4F STS TNS FNC 5E LINK ID STATION FILE ADDRESS NUMBER Reply Format: DST SRC EXT STS The STS and EXT STS bytes contain status and error code information. For more information on these bytes, see the “Error Codes” section in this document.
Chapter 5 Message Packet Formats The STS and EXT STS bytes contain status and error code information. For more information on these bytes, see the “Error Codes” section in this document. Read-Modify-Write Use this command to take the contents of each location specified: AND them with the appropriate AND mask. OR them with the appropriate OR mask. Restore them to their location, one word at a time. The command parameters that follow the FNC byte in the example can be repeated up to a length of 243 bytes.
Chapter 5 Message Packet Formats have the privilege of placing the host in a Download mode. This error occurs when: the processor is in Program or Run mode (must be in Remote Program or Remote Run mode), the processor is being edited, or some other station is already downloading to the processor.
Chapter 5 Message Packet Formats For example, if you wanted to set the processor to Run mode, your flag byte would look like this: Bit 76543210 00000010 Typed Read and Typed Write Use these commands to: read data from the processor starting at the PLC-5 system address plus the packet offset or write data to the processor starting at the PLC-5 system address plus the packet offset. The type of data sent with the Typed Write command must match the file type being written.
Chapter 5 Message Packet Formats The format for the Typed Write message is as follows: Command Format: DST 1 2 SRC CMD 0F STS TNS FNC 67 PACKET OFFSET TOTAL TRANS PLC-5 SYSTEM ADDRESS 1 2 Type/Data Parameter Data Bytes — This can be up to 240 bytes long (including the size of the PLC-5 system address and data type information). Reply Format: DST SRC CMD 4F STS TNS EXT STS The packet offset, total transaction (in elements), and size (in elements) are all two bytes.
Chapter 5 Message Packet Formats Table 5.
Chapter 5 Message Packet Formats Data Type Size If Bit 3 is a zero (0), the data type defined in the ID Value Field uses 7 or less bytes for each piece of data. The actual number of bytes the data type uses for each piece of data is then contained in the Size Value Field (Bits 0, 1, 2). If Bit 3 is a one (1), the data type defined in the ID Value Field uses more than 7 bytes for each piece of data.
Chapter 5 Message Packet Formats The following example shows a type “A” (array) type/data parameter. The array data type includes one descriptor as part of its data field.
Chapter 5 Message Packet Formats The message format is as follows: Command Format: DST SRC CMD 0F STS TNS FNC 53 CMD 4F STS TNS EXT STS Reply Format: DST SRC The STS and EXT STS bytes contain status and error code information. For more information on these bytes, see the “Error Codes” section in this document. Upload Completed Use this command after uploading a complete system to place the processor back to the mode that it was in prior to executing the Upload All Request command.
Chapter 5 Message Packet Formats Write Bytes Physical Use this command to perform a Download Only after a Download (or Upload) All Request has been successfully performed. Command Format: DST 1 2 SRC CMD 0F STS TNS The Physical Address is a 4-byte field that contains the address you are writing to: FNC 18 1 Byte Physical Address Bit(s) 1 2 3 4 A00 - A07 A08 - A15 A16 - A23 A24 - A31 2 Up to 119 data words can be written with a single command (low byte of the word first).
Chapter 5 Message Packet Formats The packet offset and total transaction are two bytes each, while the size is only one byte. The format is as follows: Command Format: DST SRC CMD 0F STS TNS CMD 4F STS TNS FNC 01 PACKET OFFSET TOTAL TRANS PLC-5 SYSTEM ADDRESS SIZE Reply Format: DST 1 SRC DATA (Up to 244 Bytes) 1 This byte will be the Extended Status byte if there is an error; otherwise it will be data at “address + packet offset,” first word, low byte.
Chapter 5 Message Packet Formats Error Codes Each command has a status (STS) byte in its reply format to indicate: if the command was successfully completed (STS equals 00) or if there was an error in the completion of the command (STS not equal to 00). The reply may also use an extended status byte (EXT STS) to define an error if necessary.
Chapter 6 Data Encoding and Addressing General This chapter explains two areas of special concern when you are transmitting messages between computers and PCs: Data Encoding Addressing Formats The information contained in this chapter gives some application details that relate to the data and address fields of the message formats in Chapter 5. Data Encoding In general, PCs store binary data (1s and 0s) in 16-bit groups called words.
Chapter 6 Data Encoding and Addressing Binary The binary number system is probably the simplest to use for computer and PC applications because it is the most natural way to represent data bits. However, since the binary system uses only the digits 0 and 1, it is cumbersome to show values in binary format. Each digit in a binary number has a certain place value expressed as a power of 2.
Chapter 6 Data Encoding and Addressing Binary Coded Decimal PC data is often represented in binary coded decimal (BCD) form. In this system, each group of four bits in a PC word represents one decimal number between 0 and 9. In this way, each 16-bit word can represent a BCD value between 0 and 9,999. Figure 6.2 shows the BCD representation of the decimal number 239. Figure 6.
Chapter 6 Data Encoding and Addressing Decimal The decimal number system is probably the easiest for us to use because it is the most familiar to us. It uses the common digits 0 through 9, and each digit has a place value that is a power of 10 (Figure 6.3). However, despite the convenience of decimal numbers, it is often easier to convert binary data to a number system other than decimal. Figure 6.
Chapter 6 Data Encoding and Addressing Figure 6.4 Hexadecimal Numbers 0 x 23 = 0 0 x 22 = 0 016 0 x 21 = 0 0 x 20 = 0 0 x 23 = 0 0 x 22 = 0 116 0 x 21 = 0 1 x 20 = 1 1 x 23 = 8 0 x 22 = 0 A16 1 x 21 = 2 0 x 20 = 0 0 x 23 = 0 1 x 22 = 4 1 x 21 = 2 716 1 x 20 = 1 0 0 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 x 163 = 0 1 x 162 = 256 10 x 161 = 160 7 x 160 = 7 01A716 = 42310 11335 Octal The octal number system is also a relatively easy way to represent binary data.
Chapter 6 Data Encoding and Addressing corresponding place value and add the results of the multiplications. Figure 6.5 shows the octal representation of the decimal number 239. Figure 6.5 Octal Numbers 1 x 21 = 2 38 1 x 20 = 1 1 x 22 = 4 0 x 21 = 0 58 1 x 20 = 1 1 x 22 = 4 1 x 21 = 2 78 1 x 20 = 1 1 1 1 0 1 1 1 1 3 x 82 = 192 5 x 81 = 40 7 x 80 = 7 3578 = 23910 11336 Order of Transmission PCs store data in 16-bit (2-byte) words.
Chapter 6 Data Encoding and Addressing This does not present a problem at PC stations on the link because PCs store and retrieve their data in this same order of low byte first. It can, however, require you to do some extra computer application programming to maintain the proper byte and word order in PC data stored in the computer.
Chapter 6 Data Encoding and Addressing Figure 6.6 Results of Transmitting Low Byte First A. PC Word Value A576 Hex 17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 1 0 1 0 0 1 0 1 0 1 1 1 0 1 1 0 Odd, High Byte Bit Number (Octal) Even, Low Byte B. 16-Bit Computer Word with Right-to-Left Byte and Bit Order Value A576 Hex 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 1 0 1 0 0 1 0 1 0 1 1 1 0 1 1 0 Odd, High Byte Bit Number (Decimal) Even, Low Byte C.
Chapter 6 Data Encoding and Addressing addressing in a PLC’s ladder diagram program to allow it to access its own data table memory. Due to the differences in PLC memory organization, the logical addressing scheme varies for each controller type. PLC/PLC-2 PLC and PLC-2 Family controllers access their data tables by using an octal word address. In PLC/PLC-2 command messages, this type of logical word address must be represented as an equivalent byte address.
Chapter 6 Data Encoding and Addressing PLC-3 and PLC-5 PLC-3 and PLC-5 controllers use a form of logical addressing known as “extended addressing.” With extended addressing, you specify the address for each level (or subdivision) of PLC-3 or PLC-5 memory, down to the smallest subdivision you want to access. With a PLC-3, you can use this method to specify up to 6 levels of extended addressing, which is enough to address any particular word in PLC-3 memory.
Chapter 6 Data Encoding and Addressing In Figure 6.7, the Level 5 address is 260 (decimal), which is too large to fit in one byte. Therefore, a byte of all 1’s is used to delimit the 2-byte address value for this level. The value 260 is then coded low byte first. Note that the last level (Level 6 in this example) must be specified in the address field even though it is equal to the default value of zero. Figure 6.7 Example of PLC-3 Logical Binary Addressing Format PLC-3 Extended Address E3 . X . 8 . 260 .
Chapter 6 Data Encoding and Addressing To send a command message to a PLC-5 station, you put the extended address of the station in the field labeled “PLC-5 SYSTEM ADDRESS” in the message block formats of your program. There are two types of logical addressing: Logical Binary Addressing Logical ASCII Addressing Figure 6.8 shows the logical binary address you use to access the 360th element in Integer File 10. Figure 6.9 shows the logical ASCII address to access the 360th element in Integer File 10.
Chapter 6 Data Encoding and Addressing Figure 6.9 PLC-5 Logical ASCII Addressing $ N 10 : 360 Displayed Logical Address Symbol File-Type Identifier File Number Delimiter Element Number ASCII Hex Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte 9 Byte 10 NUL $ N 1 0 : 3 6 0 NUL 0 2 4 3 3 3 3 3 3 0 Byte 1 Byte 2 Bytes3-9 Byte 10 Is the null character that tells the PLC that an ASCII address is to follow. Is an ASCII “$.” Are the ASCII address in the PLC-5.
Chapter 6 Data Encoding and Addressing PLC-4 Microtrol PLC-4 Microtrol controllers use a form of logical addressing that specifies the identification number of the controller in the loop, the section of memory, and the bit address. To specify a PLC-4 logical address in a command message, you would use an appropriate binary code. Note that these binary codes let you address only PLC-4 words, not bits. PLC-4 controllers can accept only PLC/PLC-2 type non-privileged commands.
Chapter 6 Data Encoding and Addressing PLC PLC controllers use physical addresses that are exactly the same values as the corresponding logical addresses. Remember that the logical address is a byte address, so the physical address will also be a byte address. For example, the logical byte address of the 17th word in PLC memory is 32 decimal, and the physical address of that word is also 32 decimal.
Chapter 6 Data Encoding and Addressing PLC-3 and PLC-5 PLC-3 and PLC-5 controllers use physical addresses that are related to logical addresses by means of pointers. Since no two PLC-3/PLC-5 systems are configured identically, the pointers are not fixed. Therefore, there is no algorithm for converting logical to physical PLC-3 or PLC-5 addresses. The PLC-3/PLC-5 physical address is a word address.
Chapter 6 Data Encoding and Addressing PLC-4 Microtrol PLC-4 Microtrol controllers use physical addresses that begin at 00 for the first word of memory and continue to 5FF hex for the last word of memory. Figure 6.11 is a map of PLC-4 physical memory. Figure 6.
Chapter 6 Data Encoding and Addressing The symbolic address field can be from 1 to 8 bytes long. The first byte contains the ASCII code for the first character in the symbol name, the second byte contains the ASCII code for the second character, and so on. If the symbol name is more than 8 characters long, encode only the first 8 characters. To use a symbolic address in a command message, encode the symbol in the field labeled “ASCII symbol” in the command message formats (Chapter 5).
Chapter 7 Error Reporting General This chapter contains a list of error codes associated with network start-up and run-time situations. The error information is available in three places: 1. the PC application program, 2. the internal error counters in each module, and 3. the STS byte in the header of a message packet. The first section deals with the PC application program’s error word and is the most accessible to you.
Chapter 7 Error Reporting ERROR WORD in User Programming (1771 KG, 1771 KA, 1771 KA2, 1774 KA Modules) An error code word specified in the header rung is the primary source of explanation for programming problems and run-time problems. Error codes are stored in this word for most events that can be observed by a Data Highway user. The display of an error code at a given location does not necessarily mean a faulted condition exists on the highway.
Chapter 7 Error Reporting Prescan errors always cause the module to turn on the PROG light and enter an error state. When the keylock is turned to PROGRAM, the error state is exited; and the PROG light turned off. For all prescan errors the upper two digits act as a pointer to the rung containing the error. Rungs are numbered from 1 to 99, then wrap around back to 0 through 99, and so on. The first rung after the header rung is number 1.
Chapter 7 Error Reporting 03 The KA or KG does not have enough internal memory to store the start bit index. This should only occur if the communication rung is very large. To correct this, the communication zone can be shortened, perhaps by combining commands or windows. It may also occur if a RAM hardware error corrupts the internal memory organization. 04 The first element of a memory access branch is not a GET.
Chapter 7 Error Reporting 30 A command rung syntax error has been detected in RUN mode after the prescan. This means that either the communication zone has been altered by on line editing, hardware problems, or a highway download operation, or that it has been moved by a gap or ungap of a rung before the zone, or by changing the data table size. 31 This will not be generated by Revision F (1771 KA).
Chapter 7 Error Reporting 53 A reply message has been received for which the start bit is off. This could mean that the user program turned off the start bit before the done bit came on or that the automatic timeout is too short. This error often follows a 36 or 37 error. This error will not cause the setting of an error bit or done bit. 54 Run time command rung syntax check failed. This is probably the result of on line editing. This error will cause the module to enter the error state. See Error 30.
Chapter 7 Error Reporting 88 Execution of protected commands at the remote station is inhibited because its PROG light is on. This error results in setting the remote error bit for the associated rung. This error code corresponds with STS Code 80. 89 The remote station has no memory to store messages. This error will only be signaled after 5 retries at half second intervals.
Chapter 7 Error Reporting Local and Remote Error Bits As a diagnostic tool, these bits are useful to identify the rung that caused an 80- or 90-series error. The remote error code corresponds with STS Code 03. The remote error bit indicates that a message was received from the remote station that some condition there prevented successful execution of the message. When a remote error is indicated, there is probably nothing wrong with the local station or with the highway cable.
Chapter 7 Error Reporting Local Error Codes The 1775-KA module stores local error codes under the user symbol ERROR. Possible local errors are listed below: Code (If Applies) EXT STS STS Error Code Meaning 32 The size of the local file involved in a file assignment command is greater than 65,535 bytes. 34 A station number greater than 376 (octal) was specified for the remote address in an assignment command. 35 Attempt to send unprotected command is invalid.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code 124 Meaning Illegal destination in an assignment command. This does not necessarily mean that an assignment command was desired because any command line that doesn't look like anything else is assumed to be an assignment command. Lines that will generate this error include: 5=4+1 6ASDFGHJ whereas the line: WERTYUI will generate an Error 140 (unrecognized command). 7 10 125 Illegal modifier for the CREATE command.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code 159 Meaning Bad level specified in extended address. 1. More than 9 levels were specified in an extended address. 2. Something other than a (" or a number followed a ." in an extended address. 160 $" unrecognized section specifier. An illegal character followed the $" in an address. 161 Bad timer or counter specification. 1.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code 194 Expression is too complex. 199 Attempt to divide by zero. 200 Bad port specifier. That is, the character following the #" is other than H", h", M", or m". 201 User symbol used as part of remote address specification. 202 Undefined data following assignment command. This error would occur, for instance, if the modifier UNRPOT were used instead of UNPROT. 203 Error in remote specification. 1.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code 215 Meaning The value resulting from operations specified on the left side of an assignment statement will not fit into the destination specified on the right side. 1. The source is in the H section, and the destination is in the N section; but the number is too large (i.e., outside the range 32,768 to +32,767). 2. A word is transferred from a binary section (I, O, or B section) to the N or C section and the high order bit is a 1. 3.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code Meaning DIAGNOSTIC READ COMMAND 10 50 81 85 1. A 2 byte ADDR field and a 1 byte SIZE field are missing after the FNC byte in the command message. 2. The number of bytes of data requested in the SIZE field is greater than the maximum number allowed per reply packet (244), or SIZE is 0 (zero). The command is an illegal request to read from the 1775 KA module's backplane window.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code Meaning PLC/PLC 2 READ COMMANDS 10 81 1. The required 2 byte ADDR field and 1 byte SIZE field are missing in the command message. 2. The ADDR value is odd (that is, it does not specify a word address). 3. The value of SIZE is 0 (zero). 4. The value of SIZE is greater than 244. 5. The SIZE value specifies an odd number of bytes. 30 83 Same as for PLC/PLC 2 write commands above.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code Meaning PLC 3 WRITE COMMANDS 10 1. There are not at least 2 bytes of data after the end of the block address. 2. There is an odd number of data bytes after the end of the block address. 3. Sum of packet offset and size values specifies more than 65,535 words. 4. Sum of packet offset and size is greater than total transaction size. 30 83 The local 1775 KA module has executed a shutdown request.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code A F0 240 Sum of total transaction size and the word level of PLC 3 addressing is greater than 65,535 bytes. B F0 241 Source station does not have access to the destination file. Meaning PLC 3 READ COMMANDS 81 1. There is more than one byte of data after the byte address. 2. Number of bytes to read is odd. 3. Number of bytes to read is zero. 4.
Chapter 7 Error Reporting Code (If Applies) EXT STS STS Error Code 8 F0 238 The file size decreased between packets of a multi packet transaction and became too small for the total transaction. 9 F0 239 File is larger than 65,535 words. A F0 240 Sum of total transaction size and PLC 3 address is greater than 65,535 bytes. Meaning PLC 3 BIT WRITE COMMANDS 10 81 More than 4 bytes of data exist after the PLC 3 address in the command message.
Chapter 7 Error Reporting The meaning of a particular remote error code will vary, depending on the type of communication interface module at the remote station. For example, if the remote station is a PLC-3 processor with a 1775-KA interface module, the remote error codes will have the meanings listed above. For the meanings of other remote error codes, refer to “ERROR WORD in User Programming (1771-KG, 1771-KA, 1771-KA2, 1774-KA Modules),” Errors 80-89.
Chapter 7 Error Reporting They apply to activity on their respective links. Obviously, the 1771-KA will have only Data Highway counters. Most modules (including the KF2) will have both. A KF2 can operate on either the Data Highway or the PCL; it has a block of counters for each network. 1771 KA, 1771 KA2, and 1774 KA Data Highway Counters 7 20 0. CRC error on ACK. 1. ACK Timeout: Counts the number of times that the sender timed out waiting for an acknowledgment.
Chapter 7 Error Reporting 7. False Poll: Counts the number of times that this station has tried to relinquish mastership and the station that was expected to take over failed to respond. This happens often on a noisy highway because the noise is mistaken for a poll response, and the wrong station is selected as the next master. When this occurs, the old master resumes polling. It can happen also on a long highway if the poll response is very attenuated and is not picked up by the carrier detect circuit.
Chapter 7 Error Reporting 15. Retransmits: Counts the number of duplicate frames received. A duplicate frame is sent by a transmitter when it fails to receive an ACK. If the reason it failed to receive an ACK was that the ACK was lost, rather than because the original message was lost, the duplicate is redundant and should be discarded. Any two successive messages between polls that have the same sequence number fields and the same command/reply bit are assumed to be duplicates. 16.
Chapter 7 Error Reporting 25. Replies Received: A 16-bit counter that records the number of reply messages that were received that resulted in the setting of a done bit or a remote error bit. 26. Not used. 27. Breaks: Counts the number of breaks sent to the IT. 28. Resynchs: Counts the number of times the PC driver has to resynchronize with the PC. This counter will always count at least one resynch (because of power-up). 29. IT Errors: Counts down modulo 5 the number of errors on the KA-to-IT cable.
Chapter 7 Error Reporting 7 24 3. Bad ACK Status: Counts the number of times the ACK was successfully received but contained a non-zero status code other than memory full. 4. Returned Messages: Counts the number of times the highway driver returns a message to sender with a non-zero status code because a reply was not received from a remote station. Each count corresponds to one local error bit set or one reply message lost. 5.
Chapter 7 Error Reporting 10. Wrong Destination Address: Counts the number of frames that were rejected because the destination address was incorrect. This can have the same cause as #8. This counter also detects frames that have the same source and destination address. 11. Receiver/Memory Full: Counts the number of times that the receiver sent an ACK without first being able to allocate a receive buffer. This will result in a memory overflow error when the next message is received. 12.
Chapter 7 Error Reporting 19. Received Messages: A 16-bit counter that records the number of messages successfully received. 20. Not used. 21. Number of ACKs received. 22. Not used. 23. Number of ACKs sent. 24. Not used. 25. Number of NAKs received. 26. Not used. 27. Number of NAKs sent. 28. Not used. 29. Undeliverable Replies: Counts the number of replies that were lost because they could not be delivered over the highway.
Chapter 7 Error Reporting 0. Bad CRC or I/O error on ACK. Same causes as bad CRC on messages. 1. ACK Timeout: Counts the number of times that the sender timed out waiting for an acknowledgment. This is a common error and will be one of the first to respond to reflections or low-level noise on the highway. It seems to be especially sensitive to problems on longer cables. It will also appear often if the receiver or transmitter circuitry on a module is marginal or if the cable connections are loose. 2.
Chapter 7 Error Reporting hear it, the old master will record a false poll and continue polling; and the new master will start polling also. This usually leads to the second station detecting contention and relinquishing. 8. Receiver Heard Status: Counts the number of times that the receiver received a status frame instead of a message frame. (This counter will never be incremented because the message size is checked first, and all status messages are too small to be accepted.) 9.
Chapter 7 Error Reporting 16. Aborts: Counts the number of aborts received. The HDLC abort signal is not used on the Data Highway but can be detected by the SIO in certain circumstances. Some stations whose addresses match the ringing pattern after a transmitter shutoff can be particularly susceptible to this error (Stations 36, 76, and 176 for example). These numbers will depend on highway configurations. 17.
Chapter 7 Error Reporting 31. Number of ENQs sent. 32. Number of messages that could not be successfully sent. 33. Number of reply messages that could not be forwarded and which were destroyed. 34. 16-bit count of messages received. 35. Not used. 36. 16-bit count of ACKs sent. 37. Not used. 38. Number of NAKs sent. 39. Number of ENQs received. 40. Number of retransmissions received and ACKed. A retransmission is a message that has a transparent word, command, and source that match the previous message. 41.
Chapter 7 Error Reporting 47. Number of broadcast messages received. 48. Number of broadcast messages that were successfully received. 49. Number of messages seen that were not for this station. 50. Number of DLE EOTs sent. 51. Number of calls received. 52. Number of times that phone was hung up by the module. 53. Number of times that DCD was lost. 54. Number of times that the phone was hung up because of a DCD timeout. 1771 KG Error Counters MODEM CHANNEL COUNTERS 0.
Chapter 7 Error Reporting 8. Number of NAKs passed from the separator to the transmitter. 9. Number of timeouts waiting for a response. 10. Number of ENQs sent. 11. Number of messages that could not be successfully sent. 12. Number of reply messages that could not be forwarded and which were destroyed. 13. 16-bit count of messages received. 14. Not used. 15. 16-bit count of ACKs sent. 16. Not used. 17. Number of NAKs sent. 18. Number of ENQs received. 19. Number of retransmissions received and ACKed.
Chapter 7 Error Reporting 24. Number of times the DLE ACK response was delayed because of a lack of buffer space for the next message. 25. Number of times reply was changed from ACK to NAK because unexpected characters (any besides DLE ENQ) were received while waiting for memory to free up. 26. Number of broadcast messages received. 27. Number of broadcast messages that were successfully received. 28. Number of messages seen that were not for this station. 29.
Chapter 7 Error Reporting 41. Number of messages with incorrect network address. 42. 16-bit count of messages sent by command initiator. 43. Not used. 44. 16-bit count of commands received by command executor. 45. Not used. 46. 16-bit count of replies sent by command executor. 47. Not used. 48. 16-bit count of replies received by command initiator. 49. Not used. 50. Number of breaks sent to IT. 51. Number of resynchs sent to PC. 1775 KA Diagnostic Counters DATA HIGHWAY PORT 7 34 0.
Chapter 7 Error Reporting 7. False polls (failure to transfer). 8. Received acknowledgment when not master. 9. Message size too small (less than 5 bytes). 10. Incorrect DST, or SRC = DST. 11. Memory not available for receive buffer. 12. Received message has bad CRC value. 13. Message too long. 14. Message arrived when no buffer space left. 15. Retransmissions of previously received message. 16. Aborts (result of line nose). 17. Message successfully transmitted. 18. Not used. 19.
Chapter 7 Error Reporting 27. Reply messages sent. 28. Not used. MODEM CHANNEL COUNTERS 29. Command messages sent. 30. Not used. 31. Reply messages received. 32. Not used. 33. Command messages received. 34. Not used. 35. Reply messages sent. 36. Not used. 37. ACKs received. 38. Not used. 39. ACKs sent. 40. Not used. 41. NAKs received. 42. Not used. 43. NAKs sent. 44. Not used. 45. Undeliverable reply messages.
Chapter 7 Error Reporting 46. Computer link timeout (preset to 500 msec). 47. Not used. 48. Maximum number of NAKs accepted per message (preset to 10). 49. Maximum number of ENQs sent per message (preset to 10). 50. Current NAK count. 51. Current ENQ count. 1785 KA Data Highway Diagnostic Counters Byte No. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17, 18 19, 20 21, 22 23, 24 25, 26 27, 28 29 Received ACK with bad CRC. Timeout expired with no ACK received. Mastership contention. Error in received ACK.
Chapter 7 Error Reporting 1770 KF2 and 1785 KA PCL Link Error Counters For the KF2, the block of counters in this section are followed by a block of modem (asynchronous link) counters. They are exactly the same as those in “1771-KE/KF, 1770-KF2 (Data Highway Mode) Error Counters,” although in this case, they are numbered starting at 35 rather than at 21. PCL Diagnostic Counters Byte No.
Chapter 7 Error Reporting PLC 5 Diagnostic Counters Byte No.
Chapter 7 Error Reporting The remote station then formatted a reply with the STS byte containing some error code. Local errors mean that the network controller was unable to transmit the message to the remote station. The local station then turns the command around, stuffs the STS byte with the appropriate error code, and returns it to the sender (computer).
Chapter 7 Error Reporting Here is a list of relevant PLC-3 status codes for the STS byte and the EXT STS byte. Bits 04 07 Hex Value STS Byte 0 1 2 3 4 5 6 7 8 Meaning Success, no error. Illegal command or format. Host has a problem and will not communicate. Remote station host is not there, disconnected, or shut down. Host could not complete function due to hardware fault. Addressing problems or memory protect rungs. Function disallowed due to command protection selection. Processor is in Program mode.
Appendix A Switch Settings General Here is a reference for switch settings for a 1770-KF2 communication interface module. Table A.
Appendix A Switch Settings Table A.B Station Number (SW 2, SW 3, SW 4) A. First Digit (SW 2) Switch Digit 1 2 0 1 2 3 OFF OFF ON ON OFF ON OFF ON For a PLC network link, both of these switches must be OFF. B. Second and Third Digits (SW 3 and SW 4) Digit 1 Switch 2 3 0 1 2 3 4 5 6 7 OFF OFF OFF OFF ON ON ON ON OFF OFF ON ON OFF OFF ON ON OFF ON OFF ON OFF ON OFF ON Table A.
Appendix A Switch Settings Table A.E Network Link Selection (SW 7) Local Area Network Switch 1 Switch 2 Data Highway OFF OFF Peer Communication Link ON OFF Switch 1 Switch 2 RS 232 C OFF ON RS 422 A ON OFF Table A.F RS 232 C/RS 422 A (SW 8) Communication Standard Figure A.
Appendix B Message Formats Table B.
Appendix C General Asynchronous Link Error Codes (STS, EXT STS) Where to Find Asynchronous Link Error Codes Asynchronous link (RS-232-C) error codes are passed in the link message packets.
Appendix C General Asynchronous Link Error Codes (STS, EXT STS) Remote STS Error Codes The remote STS error code nibble contains errors found by the remote station receiving the command. The following table contains error codes (in hex) that you may find in the remote error code nibble of the STS byte.
Appendix C General Asynchronous Link Error Codes (STS, EXT STS) The EXT STS Byte You will have an EXT STS code if your STS code is F0 (hex). The EXT STS has different definitions depending on the command code (type of command).
Appendix C General Asynchronous Link Error Codes (STS, EXT STS) EXT STS Codes for Command Code 0F (Hex) The following table contains EXT STS codes (in hex) that you may find if the command code is 0F (hex): This Code 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 to FF C 4 Means Not Used Error in Converting Block Address Less Levels Specified in Address Than Minimum for Any Address More Levels Specified in Address Than System Supports Symbol Not Found Symbol Is of Improper Format Address Doesn't Point to
Appendix D Detailed Flowcharts General This appendix presents flowcharts that give detailed views of an example of software logic for implementing full-duplex protocol. The flowcharts in Chapter 4 gave you a simplified view of this software logic. We have not shown any error checking or recovery relating to interaction with the modem handshake driver, a third process. To do this would overly complicate the flowcharts and, in many cases, such error checking and recovery are not needed.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.5 STARTTIME Subroutine STARTTIME An Implementation-Dependent Routine that Schedules TIMEOUT to Be Executed at the Expiration of an Interval of Time (Typically 12 Character Times) RETURN 11658 Figure D.
Appendix D Detailed Flowcharts Figure D.7 TIMEOUT Subroutine Scheduled By TIMEOUT • STARTTIME Aborted By • STOPTIME WAKEUP Wake Up the Process Sleeping at WTRESP (If Any) RETURN 11660 Figure D.8 GETMSG Subroutine GETMSG SLEEP Is Queue Empty ? Yes Go to Sleep at WTMSG No UNLINK Remove a Message from Queue Common • WTMSG • Output Queue Output • A Message RETURN Boxed area above must be executed indivisibly, i.e., with the scheduler or interrupts disabled, depending on implementation.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.10 Sharing the Transmit Side of the UART XMIT RCVE TXALLOC UART Usage Not-in-Use Signal TXFREE XMIT RCVE 11664 Since the transmit side of the UART is shared by the transmit and receive processes, a mutual exclusion mechanism is used to gain sole access during transmission of each indivisible code sequence. The UART is like a small bridge; and the mutual exclusion mechanism is like two flagmen, one at each end of a one lane bridge.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.13 SEND Subroutine Input • Link Data Byte SEND Common • TXWAIT: A Sleep Variable Disable Processor Interrupts Enable UART Transmit Interrupt SLEEP UART Transmitter Empty ? No Suspend at TXWAIT Yes Disable UART Transmit Interrupt Output Byte to UART Enable Processor Interrupts Indivisible Zone NOTE: This figure assumes the use of a Z80 S10.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.15 TXALLOC Subroutine TXALLOC SLEEP UART in Use ? Yes Wait at TXALWT Until UART Is Free No Set IN-USE Flag Indivisible Zone Common RETURN • • IN-USE Flag TXALWT: A Sleep Variable 11667 Figure D.
Appendix D Detailed Flowcharts Figure D.17 TRANSMIT INTERRUPT Subroutine TRANSMIT INTERRUPT WAKEUP Resume Process Sleeping at TXWAIT NOTE: This figure assumes the use of a Z80 S10. NOTE: UART transmit interrupt must be enabled and disabled without affecting the current state of the receive and status interrupt enable flags. INTERRUPT RETURN 11670 Figure D.
Appendix D Detailed Flowcharts Figure D.19 SLEEP and WAKEUP Interaction PROCESS A PROCESS B PROCESS C 1 A Previous Wakeup SLEEP 2 3 4 7 8 Sequence of processor execution is indicated by circled numbers. NOTE 1: SLEEP and WAKEUP are always used in connection with some type of indivisible interprocess interlock. Indivisibility is achieved on many processors (e.g., -Z-80) by disabling processor interrupts. For this reason, SLEEP and WAKEUP assure that interrupts are OFF when they are called.
Appendix D Detailed Flowcharts Figure D.20 POWERUP Subroutine POWERUP POWERUP At power-up the Z-80 starts executing code at Location 0. The POWERUP routine starts the XMIT and RCVE processes by executing a SPAWN. A SPAWN is very similar to a WAKEUP, except the corresponding SLEEP is imaginary and is located ahead of the first instruction of the SPAWNed process. SPAWN RCVE SPAWN XMIT Continue Initialization 11673 Figure D.21 Message Queue ROOT The address of a queue is the address of its root.
Appendix D Detailed Flowcharts Figure D.22 UNLINK Subroutine UNLINK Input • Address of Queue Output • An ImplementationDependent Routine that Removes a Message from a Queue Message Control Block RETURN 11675 Figure D.
Appendix D Detailed Flowcharts Figure D.
Appendix D Detailed Flowcharts Figure D.25 XMSG Subroutine A XMSG Output Flag GETBUF • ACK if Message Is OK Check Availability of Receive Buffer • NAK if Message Is in Error • 0 if Message Is to be Ignored Clear CRC Accumulator DLE ETX ? No Yes Was Buffer Available ? No Yes GETCODE Did Buffer Overflow ? Get a Code Yes No No Link Data ? Message Too Small Yes Yes No Code = Station No.
Appendix D Detailed Flowcharts Figure D.26 GETCODE Subroutine GETCODE GETRAW Get Byte from UART BCC DLE ? No Add Data Bytes to BCC Yes GETRAW Return Byte and Data Flag Get Byte from UART Save ACK or NAK in RESP DLE ? WAKEUP Resume XMIT if Sleeping at WTRESP Yes Output • BYTE: What was received? No • Control/Data: Set if BYTE is Yes a control character which was preceded by a DLE. ACK or NAK ? NOTE: BCC should now equal zero.
Appendix D Detailed Flowcharts Figure D.27 GETRAW Subroutine GETRAW Disable Processor Interrupts Enable UART Receive Interrupt SLEEP Byte in UART ? No Wait for RXD Interrupt at RXDWAIT Yes Disable UART Received Interrupt Check Parity, Framing, and Receiver Overrun Set Receiver Error Flag Discard Bad Data Reset UART Error Flag Yes NOTE: This figure assumes the use of a Z80 S10.
Appendix D Detailed Flowcharts Figure D.28 SENDNET Subroutine Input SENDNET • Message Buffer An ImplementationDependent Routine to Put a Message on the INPUT Queue Reset the BUFFER Flag RETURN 11682 Figure D.
Appendix E Data Link Layer Data Link Layer Operation on Data Highway The data link layer controls the flow of communication on the physical link by acquiring and releasing access to the communication channel for each station. This layer differs for each type of physical link. Chapter 4 explains how to program the data link layer for an asynchronous link. The rest of this section describes the data link layer of the Data Highway link.
Appendix E Data Link Layer When a station gains control of the Data Highway to transmit messages, it has become a master station. All other station interface modules assume a slave mode. This enables these stations to receive and acknowledge messages sent to them.
Appendix E Data Link Layer Message Transmission A station must have mastership of the Data Highway before it can transmit any messages or polling sequences. As part of the data integrity of the highway, all commands must receive a reply before a transaction is considered complete. Since the highway treats commands and replies as the same type of message, it takes at least one change of mastership to complete a single transaction.
Appendix E Data Link Layer Figure E.2 Polling Scheme 012 011 010 376 375 374 373 013 • • • 074 075 • • • • • • 303 302 301 300 277 276 275 076 077 110 111 112 113 174 175 176 177 200 201 274 • • • 203 202 11537 The mechanics of the polling algorithm are essentially transparent to you. This is because the communication modules handle this automatically.
Appendix E Data Link Layer A block check is used to detect errors at the link level. You can select a CRC instead of this block check. Any device connected to the asynchronous link must be capable of generating a BCC or a CRC, if used. A BCC is added to the end of every message block to help detect errors of transmission between station interface modules. The command station generates a BCC by first summing every byte of the text (excluding control characters), then taking the 2’s complement of that sum.
Index A D ADDR, 5 7 DATA Field, 5 7 Addressing, 6 8 Logical, 6 8 Logical ASCII, 6 18 PLC, 6 15 PLC/PLC-2, 6 9 PLC-2, 6 15 PLC-3 and PLC-5, 6 10, 6 16 PLC-3 Logical Binary, 6 10 PLC-4 Microtrol, 6 14, 6 17 PLC-5 Logical ASCII, 6 13 PLC-5 Logical Binary, 6 12 Symbolic, 6 17 Data Highway Applications, 1 5 Advisor 2+TM Color Graphics, 1 5 Diagnostic Status, 5 11 Application Layer, 2 8, 5 1 Asynchronous Link, 1 1, 1 5, 2 1, 2 3, 2 5, 2 6, 2 8, 3 1, 3 2, 3 19, 4 1, 6 6, A 1 B Data Highway LAN, 2 2 Data
I–2 Index Full-Duplex Receiver Routine, D 19 PLC-2 Commands, 5 25 PLC-3 Commands, 5 29 H Half-Duplex Protocol, 1 1, 4 1, 4 21, 4 22 Half-Duplex Protocol, Diagrams, 4 32 Half-Duplex Protocol, Implementation, 4 24 Hexadecimal Numbers, 6 1, 6 4 Highway Counters, 7 20 PLC-4 Commands, 5 37 PLC-5 Commands, 5 44 Point-to-Point Configuration, 1 5 Polling, 2 4, 2 9, 4 24, 4 25, 4 26, 4 28, 4 35 Power Supply, KF2, 3 8 Processor/Asynchronous Interface, 2 7 Processor/Data Highway Interface, 2 7 Protected Write, 5
Allen Bradley, a Rockwell Automation Business, has been helping its customers improve pro ductivity and quality for more than 90 years. We design, manufacture and support a broad range of automation products worldwide. They include logic processors, power and motion control devices, operator interfaces, sensors and a variety of software. Rockwell is one of the worlds leading technology companies. Worldwide representation.