eBook: Integration and Automation of Manufacturing Systems
   



TOC PREV NEXT

9.1 SERIAL COMMUNICATIONS


Serial communications send a single bit at a time between computers. This only requires a single communication channel, as opposed to 8 channels to send a byte. With only one channel the costs are lower, but the communication rates are slower. The communication channels are often wire based, but they may also be optical and radio. Figure 22.2 shows some of the standard electrical connections. RS-232c is the most common standard that is based on a voltage level change. At the sending computer an input will either be true or false. The 'line driver' will convert a false value 'in' to a 'Txd' voltage between +3V to +15V, true will be between -3V to -15V. A cable connects the 'Txd' and 'com' on the sending computer to the 'Rxd' and 'com' inputs on the receiving computer. The receiver converts the positive and negative voltages back to logic voltage levels in the receiving computer. The cable length is limited to 50 feet to reduce the effects of electrical noise. When RS-232 is used on the factory floor, care is required to reduce the effects of electrical noise - careful grounding and shielded cables are often used.



Figure 22.2 - Serial Data Standards

The RS-422a cable uses a 20 mA current loop instead of voltage levels. This makes the systems more immune to electrical noise, so the cable can be up to 3000 feet long. The RS-423a standard uses a differential voltage level across two lines, also making the system more immune to electrical noise, thus allowing longer cables. To provide serial communication in two directions these circuits must be connected in both directions.

To transmit data, the sequence of bits follows a pattern, like that shown in Figure 22.3. The transmission starts at the left hand side. Each bit will be true or false for a fixed period of time, determined by the transmission speed.

A typical data byte looks like the one below. The voltage/current on the line is made true or false. The width of the bits determines the possible bits per second (bps). The value shown before is used to transmit a single byte. Between bytes, and when the line is idle, the 'Txd' is kept true, this helps the receiver detect when a sender is present. A single start bit is sent by making the 'Txd' false. In this example the next eight bits are the transmitted data, a byte with the value 18. The data is followed by a parity bit that can be used to check the byte. In this example there are two data bits set, and even parity is being used, so the parity bit is set. The parity bit is followed by two stop bits to help separate this byte from the next one.



Figure 22.3 - A Serial Data Byte

Some of the byte settings are optional, such as the number of data bits (7 or 8), the parity bit (none, even or odd) and the number of stop bits (1 or 2). The sending and receiving computers must know what these settings are to properly receive and decode the data. Most computers send the data asynchronously, meaning that the data could be sent at any time, without warning. This makes the bit settings more important.

Another method used to detect data errors is half-duplex and full-duplex transmission. In half-duplex transmission the data is only sent in one direction. But, in full-duplex transmission a copy of any byte received is sent back to the sender to verify that it was sent and received correctly. (Note: if you type and nothing shows up on a screen, or characters show up twice you may have to change the half/full duplex setting.)

The transmission speed is the maximum number of bits that can be sent per second. The units for this is 'baud'. The baud rate includes the start, parity and stop bits. For example a 9600 baud transmission of the data in Figure 22.3 would transfer up to bytes each second. Lower baud rates are 120, 300, 1.2K, 2.4K and 9.6K. Higher speeds are 19.2K, 28.8K and 33.3K. (Note: When this is set improperly you will get many transmission errors, or 'garbage' on your screen.)

Serial lines have become one of the most common methods for transmitting data to instruments: most personal computers have two serial ports. The previous discussion of serial communications techniques also applies to devices such as modems.

9.1.1 RS-232

The RS-232c standard is based on a low/false voltage between +3 to +15V, and an high/true voltage between -3 to -15V (+/-12V is commonly used). Figure 22.4 shows some of the common connection schemes. In all methods the 'txd' and 'rxd' lines are crossed so that the sending 'txd' outputs are into the listening 'rxd' inputs when communicating between computers. When communicating with a communication device (modem), these lines are not crossed. In the 'modem' connection the 'dsr' and 'dtr' lines are used to control the flow of data. In the 'computer' the 'cts' and 'rts' lines are connected. These lines are all used for handshaking, to control the flow of data from sender to receiver. The 'null-modem' configuration simplifies the handshaking between computers. The three wire configuration is a crude way to connect to devices, and data can be lost.



Figure 22.4 - Common RS-232 Connection Schemes

Common connectors for serial communications are shown in Figure 22.5. These connectors are either male (with pins) or female (with holes), and often use the assigned pins shown. The DB-9 connector is more common now, but the DB-25 connector is still in use. In any connection the 'RXD' and 'TXD' pins must be used to transmit and receive data. The 'COM' must be connected to give a common voltage reference. All of the remaining pins are used for 'handshaking'.



Figure 22.5 - Typical RS-232 Pin Assignments and Names

The 'handshaking' lines are to be used to detect the status of the sender and receiver, and to regulate the flow of data. It would be unusual for most of these pins to be connected in any one application. The most common pins are provided on the DB-9 connector, and are also described below.

TXD/RXD - (transmit data, receive data) - data lines
DCD - (data carrier detect) - this indicates when a remote device is present
RI - (ring indicator) - this is used by modems to indicate when a connection is about to be made.
CTS/RTS - (clear to send, ready to send)
DSR/DTR - (data set ready, data terminal ready) these handshaking lines indicate when the remote machine is ready to receive data.
COM - a common ground to provide a common reference voltage for the TXD and RXD.

When a computer is ready to receive data it will set the "CTS" bit, the remote machine will notice this on the 'RTS' pin. The 'DSR' pin is similar in that it indicates the modem is ready to transmit data. 'XON' and 'XOFF' characters are used for a software only flow control scheme.

TOC PREV NEXT

Search for More:

Custom Search