Advantages
Serial ports can exchange just about any type of information. Applications suited for serial ports often involve reading sensors, switches, or other inputs or controlling motors, relays, displays, or other outputs. The hardware is inexpensive and readily available. PCs that dont have built-in serial ports can use USB/serial converters. Just about every microcontroller family includes variants with built-in serial ports. Other than the Start, Stop, and optional parity bits added to each transmitted byte, serial interfaces assume nothing about the content of the data being transmitted. In contrast, USB and Ethernet use sophisticated protocols that define the format of transmitted data. Hardware or firmware must implement these protocols, adding complexity that some applications dont need.
Advantages
Cables can be very long. An RS-232 interface can use cables of 130 ft or more. An RS-485 cable can be over 4000 ft. In contrast, the maximum distance between a USB device and its host is 16 ft, or 98 ft with five hubs. Ethernet cables have a maximum length of 328 ft. The cables are inexpensive. Many links can use unshielded cables with 39 wires. For devices that connect to PCs, Windows and other operating systems provide drivers for accessing COM ports. Programming languages provide classes, libraries, or other tools for COM-port communications. A USB device accessed as a COM port doesnt have to have an asynchronous serial interface. The device can have a parallel or other interface as needed to suit the application. Wireless technologies enable transmitting serial data without cables.
Limits-asynchronous serial
interfaces
The computers at each end must convert between the transmitted serial data and the CPUs parallel data bus. The conversion is usually handled automatically by hardware, however. The specified maximum bit rate for RS-232 is 20 kbps. But many interface chips can exceed this rate, and RS-485 supports speeds of up to 10 Mbps. Communications between a PC and a USB Virtual COM ports arent limited by RS-232s maximum bit rate. Windows doesnt promise real-time performance for serial communications.Sending or receiving data may need to wait as the operating system attends to other tasks. But the delays are normally short and are common to other interfaces on Windows systems. Embedded systems typically can control the scheduling of serial communications more precisely.
System Components
Communicating via serial ports requires three things:
Computers with serial ports:
Devices with asynchronous serial ports typically contain a hardware component called a Universal Asynchronous Transmitter/Receiver (UART). Examples: Microcontroller serial ports, External UART chips that interface to microcontrollers or other CPUs, The RS-232 serial ports that were standard on PCs and other devices before USB became common, RS-232 ports on PC Cards (also called PCMCIA cards), etc.
A cable or wireless interface that provides a physical link between the ports (RS-232 links can use just about any cable type and require one line per signal plus a common ground line.) And programming to manage the communications.
Asynchronous communications
In an asynchronous protocol, the interface doesnt include a clock line. Instead, each computer provides its own clock to use as a timing reference. The computers must agree on a clock frequency, and the actual frequencies at each computer must match within a few percent. A transmitted Start bit synchronizes the transmitters and receivers clocks.
Synchronous communications
In In contrast, in a synchronous protocol, the interface includes a clock line typically controlled by one of the computers, and all transmitted bits synchronize to that clock.
Each transmitted bit is valid at a defined time after a clocks rising or falling edge, depending on the protocol.
Word Formats
A UART transmits data in chunks often called words. Each word contains a Start bit, data bits, an optional parity bit, and one or more Stop bits. Most UARTs support multiple word formats: 8-N-1. Where the transmitter sends each word as one Start bit, followed by eight data bits and one Stop bit. The data bits transmit beginning with bit 0 (the least significant bit, or LSb). 7-E-1 6-O-1
Word Formats
The parity bit can provide a basic form of error detecting. With even parity, the data bits and parity bit in each word contain an even number of 1s. With odd parity, the data bits and parity bit in each word contain an odd number of 1s. 0000001b 0000011b parity bit ???? parity bit ????
If the communications are using 7-E-1 format: right or wrong ????. Hint: assume parity bit=1. Mark and space parity are forms of stick parity. With mark parity, the parity bit is always 1, and with space parity, the parity bit is always zero. One use for these parities is in 9-bit networks that use mark and space bits to indicate whether the data bits contain an address or data.
Hands-on
7-E-1 format 00101011 00101010 11010101 7-O-1 format 10001001 01101110 11011111 5-E-1 format 100010 101010 111101 8-N-1 format 00101000 00100110 11111111
Sending bits
Figure 2-1B shows how a byte transmits in 8-N-1 format. When idle, the transmitters output is a logic 1. To indicate the beginning of a transmission, the transmitter sends a logic 0 for one bit width. This is the Start bit. At 9600 bps, a bit is 104 s. The receiver attempts to read the logic state of each bit near the middle of the bits time period. RS-232 uses inverted polarities from those shown in Figure 2-1B. An RS-232 Stop bit is a negative voltage and an RS-232 Start bit is a positive voltage.
To read all of the bits in a 10-bit word correctly, the transmit and receive clocks should vary no more than about three percent. !!!
Class dismissed