Saturday, May 22, 2010

SERIAL DATA COMMUNICATION PROTOCOLS

Why serial?

There are many different reasons to use a serial interface.

· All PCs have some sort of serial bus interface available to connect peripherals.

· A benefit of serial communications is low pin counts. Serial communications can be performed with just one I/O pin, compared to eight or more for parallel communications.

· Serial buses can also provide for inter-processor communication-a network

Terminology

Before we get into the individual interface details, we should define several terms:

  • On an asynchronous bus, data is sent without a timing clock. A synchronous bus sends data with a timing clock.
  • Full-duplex means data can be sent and received simultaneously. Half-duplex is when data can be sent or received, but not at the same time.
  • Master/slave describes a bus where one device is the master and others are slaves. Master/slave buses are usually synchronous, as the master often supplies the timing clock for data being sent along in both directions.
  • A multi-master bus is a master/slave bus that may have more than one master. These buses must have an arbitration scheme that can settle conflicts when more than one master wants to control the bus at the same time.
  • Point-to-point or peer interfaces are where two devices have a peer relation to each other; there are no masters or slaves. Peer interfaces are most often asynchronous.
  • The term multi-drop describes an interface in which there are several receivers and one transmitter.
  • Multi-point describes a bus in which there are more than two peer transceivers. This is different from a multi-drop interface as it allows bidirectional communication over the same set of wires.

RS-232

RS-232 is a common interface that can be found on almost every personal computer. A point-to-point interface, RS-232 is capable of moderate distances at speeds up to 20Kbps. speeds of greater than 115.2Kbps are possible, provided that connections are short and proper grounding is used. Cable lengths of 30 feet are common, and cables of over 200 feet can be attained with low-capacitance cable.

An RS-232 bus is an unbalanced bus capable of full-duplex communication between two receiver/transmitter pairs, named data terminal equipment (DTE) and data communication equipment (DCE). Each one has a transmit signal that is connected to the receive signal on the other end. (Your PC is a DTE, while the connected peripheral is DCE.)

Each transmitter sends data by varying the voltage on the line. A voltage higher than 3V is a binary zero, while a voltage less than --3V is a binary one. Between these voltages, the value is undefined. To convert from logic levels (0 and 5V) to these levels and back, an RS-232 conversion IC, such as the 1488, 1489, or MAX232, can be used.

Typical RS-232 communication consists of a start bit, data bits, parity bits (if any), and stop bit(s). When communicating with PCs, the typical format is eight data bits, no parity, and one stop bit (8N1). Seven data bits, even parity, and one stop bit (7E1) is also common. A start bit is often a zero and a stop bit is often a one.

http://img.cmpnet.com/embedded/gifs/2002/0206/0206feat1fig1.gif
Figure 1: RS-232

Uses of the RS-232 bus:-

· Interface with PCs or PC peripherals such as modems.

· With an RS-232 so that bus traffic can be monitored easily with an inexpensive protocol analyzer or a PC equipped with two serial ports.

RS-422 and RS-485

RS-422 and RS-485 are balanced, twisted-pair interfaces capable of speeds up to 10Mbps and distances up to 4,000 feet. Being differential buses, each uses signals from 1.5V to 6V to transmit the data. (With a differential, balanced bus, noise immunity is increased over a comparable single-ended, unbalanced bus such as RS-232.). both of these protocols are capable of half duplex communication.

The RS-422 interface is a multi-drop interface, giving unidirectional communication over a pair of wires from one transmitter to several receivers, up to 10 unit loads (UL). If the devices receiving the data wish to communicate back to the transmitter, the designer must use a separate, dedicated bus between each receiver and the transmitter.

The RS-485 interface, on the other hand, is a bidirectional communication over one pair of wires between several transceivers. The specification states that the bus can include up to 32 UL worth of transceivers.

The RS-422 and RS-485 interfaces often use the same start bit/data/stop bit format of RS-232.

I2C

The Inter-Integrated Circuit bus (I2C) is a patented interface developed by Philips Semiconductors.

The I2C bus is a half-duplex, synchronous, multi-master bus requiring only two signal wires: data (SDA) and clock (SCL). These lines are pulled high via pull-up resistors and controlled by the hardware via open-drain drivers, giving a wired-AND interface.

I2C uses an addressable communications protocol that allows the master to communicate with individual slaves using a 7-bit or 10-bit address. Each device has an address that is assigned by Philips to the manufacturer of the device. In addition, several special addresses exist, including a "general call" address (which addresses every device on the bus) and a high-speed initiation address.

During communication with slave devices, the master generates all clock signals for both communication to and from the slave. Each communication begins with the master generating a start condition, an 8-bit data word, an acknowledge bit, followed by a stop condition or a repeated start. http://img.cmpnet.com/embedded/gifs/2002/0206/0206feat1fig2.gif
Figure 2: I2C

I2C has a rather interesting feature called clock stretching, which is done when the slave device is unable to process the bit and wishes for more time.

The I2C bus has three speeds: slow (under 100Kbps), fast (400Kbps), and high-speed (3.4Mbps), each downward compatible. Philips has specified a recommended wiring arrangement should the signals need to leave the circuit board.

I2C bus distances are often limited to on-board communications,

SPI

The Serial Peripheral Interface (SPI) is a synchronous serial bus developed by Motorola.

The SPI bus consists of four signals: master out slave in (MOSI), master in slave out (MISO), serial clock (SCK), and active-low slave select (/SS). As a multi-master/slave protocol, communications between the master and selected slave use the unidirectional MISO and MOSI lines, to achieve data rates over 1Mbps in full duplex mode.

In addition to the 1Mbps data rate, another advantage to SPI is if only one slave device is used, the /SS line can be pulled low and the /SS signal does not have to be generated by the master.

A disadvantage to SPI is the requirement to have separate /SS lines for each slave. Provided that extra I/O pins are available, or extra board space for a demultiplexer IC.

Microwire

Microwire is a three-wire synchronous interface developed by National Semiconductor. Similar to SPI, Microwire is a master/slave bus, with serial data out of the master (SO), and serial data in to the master (SI), and signal clock (SK). These correspond to SPI's MOSI, MISO, and SCK, respectively. There is also a chip select signal, which acts similarly to SPI's /SS. A full-duplex bus, Microwire is capable of speeds of 625Kbps and faster (capacitance permitting).

Unlike SPI, which is based on an 8-bit byte, Microwire permits variable length data, and also specifies a "continuous" bitstream mode.

Microwire has the same advantages and disadvantages as SPI with respect to multiple slaves, which require multiple chip select lines. In some instances, an SPI device will work on a Microwire bus, as will a Microwire device work on an SPI bus, although this must be reviewed on a per-device basis. Microwire is generally limited to on-board communications and traces of no longer than 6 inches can be achieved.

1-Wire

Dallas Semiconductor's 1-Wire bus is an asynchronous, master/slave bus with no protocol for multi-master. Like the I2C bus, 1-Wire is half-duplex, using an open-drain topology on a single wire for bidirectional data transfer. However, the 1-Wire bus also allows the data wire to transfer power to the slave devices, although this is somewhat limited. Though limited to a maximum speed of 16Kbps, bus length can be upwards of 1,000 feet, given the proper pull-up resistor.

Table 1 Protocol comparison






Name

Sync
/Async

Type

Duplex

Max
devices

Max
speed
(Kbps)

Max
distance
(Feet)

Pin
count(1)

RS-232

async

peer

full

2

20(2)

30(3)

2(4)

RS-422

async

multi-drop

half

10(5)

10,000

4,000

1(6)

RS-485

async

multi-point

half

32(5)

10,000

4,000

2

I2C

sync

multi-master

half

-7

3,400

<10

2

SPI

sync

multi-master

full

-7

>1,000

<10

3+1(8)

Microwire

sync

master/slave

full

-7

>625

<10

3+1(8)

1-Wire

async

master/slave

half

-7

16

1,000

1s

from wikipidea

Examples of serial communication architectures