* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Lecture #8: Communication Protocols and Interface
Survey
Document related concepts
Transcript
Lecture #8: Communication Protocols and Interface Communication Protocols (1) PARALLEL DATA TRANSMISSION IEEE-488 Parallel (HPIB or GPIB ) Centronics Parallel Protocol (Printer ) SCSI IDE ISA (Industrial Standard Architecture, 16 bit) PCI (Referral Component Interconnect, 32 bit) AGP (2) SERIAL DATA TRANSMISSION RS 232 RS 422 RS 485 UART (Universal Asynchronous receiver-transmitter) USART (Universal Synchronous- Asynchronous receiver-transmitter) MIDI IEEE1394, also called "FireWire" CAN (Controller Area Network) USB (Universal Serial Bus) I2C (Inter Integrated Circuit) -- Philips SPI (Serial Peripheral Interface bus) Micro-wire Ethernet Fiber optics Bluetooth WiFi SUB SECTIONS TO PARALLEL AND SERIAL PROTOCOLS Wired connections Wireless connections Radio Frequency (RF) Infrared (IR) HOW TO SELECTION A PROTOCOL OR TO DEVELOP YOUR OWN Amount of data Speed of processor Hardware or software implementation Number of available pins Number of sensor Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] Introduction to Communication Interface Data Transmission Parallel Communication Interface (PCI) Serial Communication Interface (SCI) Synchronous Asynchronous 1. Parallel Data Transmission Parallel ports were originally developed by IBM as a way to connect a printer to a PC. When IBM was in the process of designing the PC, the company wanted the computer to work with printers offered by Centronics, a top printer manufacturer at the time. IBM decided not to use the same port interface on the computer that Centronics used on the printer. Instead, IBM engineers coupled a 25-pin connector, DB-25, with a 36-pin Centronics connector to create a special cable to connect the printer to the computer. Other printer manufacturers ended up adopting the Centronics interface, making this strange hybrid cable an unlikely de facto standard. When a PC sends data to a printer or other device using a parallel port, it sends 8 bits of data (1 byte) at a time. These 8 bits are transmitted parallel to each other. The standard parallel port is capable of sending 50 to 100 kilobytes of data per second. Advantages of Parallel Data Transmission: ¾ Fastest form of transmission -- able to send multiple bits simultaneously ¾ doesn’t require high frequency of operation Disadvantages of Parallel Data Transmission: ¾ Requires separate lines for each bit of a word ¾ Costly to run long distances due to multiple wires ¾ Suffers from electromagnetic interference ¾ Cable lengths more limited than a serial cable Applications: Parallel ports can be used to connect a host of popular computer peripherals: such as prints, scanners, CD burners, external hard drives, Iomega zip, network adapters, and tape backup drives. Types of parallel port At the present time it is known four types of parallel port: o Standard parallel port (SPP) o Parallel port PS/2 (bidirectional) o Enhanced Parallel Port (EPP) o Extend Capability Port (ECP) SPP/EPP/ECP The original specification for parallel ports was unidirectional, meaning that data only traveled in one direction for each pin. With the introduction of the PS/2 in 1987, IBM offered a new bidirectional parallel port design. This mode is commonly known as Standard Parallel Port (SPP) and has completely replaced the original design. Bidirectional communication allows each device to receive data as well as transmit it. Many devices use the eight pins (2 through 9) originally designated for data. Using the same Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] eight pins limits communication to half-duplex, meaning that information can only travel in one direction at a time. But pins 18 through 25, originally just used as grounds, can be used as data pins also. This allows for full-duplex (both directions at the same time) communication. Enhanced Parallel Port (EPP) was created by Intel, Xircom, and Zenith in 1991. EPP allows for much more data, 500 kilobytes (KB) to 2 megabytes (MB), to be transferred each second. It was targeted specifically for non-printer devices that would attach to the parallel port, particularly storage devices that needed the highest possible transfer rate. Close on the heels of the introduction of EPP, Microsoft and Hewlett Packard jointly announced a specification called Extended Capabilities Port (ECP) in 1992. While EPP was geared toward other devices, ECP was designed to provide improved speed and functionality for printers. In 1994, the IEEE 1284 standard was released. It included the two specifications for parallel port devices, EPP and ECP. In order for them to work, both the operating system and the device must support the required specification. This is seldom a problem today since most computers support SPP, ECP and EPP and will detect which mode needs to be used, depending on the attached device. If you need to manually select a mode, you can do so through the BIOS (Basic Input/Output System) on most computers. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] Description of Pins and their Functions • Pin 1 carries the strobe signal. It maintains a level of between 2.8 and 5 volts, but drops below 0.5 volts whenever the computer sends a byte of data. This drop in voltage tells the printer that data is being sent. • Pins 2 through 9 are used to carry data. To indicate that a bit has a value of 1, a charge of 5 volts is sent through the correct pin. No charge on a pin indicates a value of 0. This is a simple but highly effective way to transmit digital information over an analog cable in real-time. • Pin 10 sends the acknowledge signal from the printer to the computer. Like Pin 1, it maintains a charge and drops the voltage below 0.5 volts to let the computer know that the data was received. • If the printer is busy, it will charge Pin 11. Then, it will drop the voltage below 0.5 volts to let the computer know it is ready to receive more data. • The printer lets the computer know if it is out of paper by sending a charge on Pin 12. • As long as the computer is receiving a charge on Pin 13, it knows that the device is online. • The computer sends an auto feed signal to the printer through Pin 14 using a 5-volt charge. • If the printer has any problems, it drops the voltage to less than 0.5 volts on Pin 15 to let the computer know that there is an error. • Whenever a new print job is ready, the computer drops the charge on Pin 16 to initialize the printer. • Pin 17 is used by the computer to remotely take the printer offline. This is accomplished by sending a charge to the printer and maintaining it as long as you want the printer offline. • Pins 18-25 are grounds and are used as a reference signal for the low (below 0.5 volts) charge. Notice how the first 25 pins on the Centronics end match up with the pins of the first connector. With each byte the parallel port sends out, a handshaking signal is also sent so that the printer can latch the byte. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] 2. Serial Data Transmission: 1. Synchronous Data Transmission: Data is transmitted one bit at a time, using a clock to maintain integrity between words. Advantages: ¾ Only one (half duplex) or two (full duplex) wires are required to send/receive data. ¾ Low cost due to low number of wires. Disadvantages: ¾ Lower speeds than parallel transmissions. ¾ Difficult to maintain data integrity due to problems with synchronizing clocks. 2. Asynchronous Data Transmission: Data is transmitted on bit at a time using start bits and strop bits to maintain integrity between words. Disadvantages: ¾ Lower speeds than parallel transmissions. Key words for SCI Baud Rate: The measure of the number of signal elements transmitted or received per second. Baud rates and data bit rates (bps-bit per second) are not equal in asynchronous transmission due to the start and stop bits. Start Bit: The bit preceding every word that signals the receiver a data word is coming. In some microcontroller (e.g., HC11) the start bit is logic low (0), while in others the start bit is logic high (1). Parity Bit: A bit sometimes added to the end of the data word. There are three possible settings for the parity: none, even, and odd. The setting represents the sum of the 1’s transmitted. Stop Bit: The bit or bits following every word that signals the end of a data word. In some microcontroller (e.g., HC11) the stop bit is logic high (1), while in others the start bit is logic low (0). Half Duplex: Two-way serial communication using only one line. With half duplex, the device can not transmit and received at the same time. Full Duplex: Two-way serial communication using two lines. With full duplex, data can be simultaneously transmitted and received. Applications of SCI ¾ The SCI can be used to transmit/receive data through a modem. ¾ The SCI can be used to transmit/receive data with any device that uses RS-232-C protocol. RS-232 RS-232C is the oldest and most popular serial communication standard. It is the standard used on PC COM port hardware. It is designed to connect two systems only and is "single ended", meaning that it uses one wire for data and one for ground. It is a robust interface with speeds to 115,200 baud and will withstand a short circuit between any 2 pins. Maximum signal voltages are ±15 volts. Cable length depends on baud rate but is typically 50 feet maximum. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] Examples Ex 1: A synchronous data transmission system is operating at 9600 baud. How long is each bit? Solution: Since in a synchronous data transmission system, the baud rate is same as bps (bit per second) , thus at 9600 bps, each bit takes 1/9600 seconds or about 104 μs. Ex 2: Suppose the number “45” in hex is to be transmitted in an 8-bit asynchronous format with odd parity. Sketch the output. Solution: the number “45 in hex” is “0”1000101 in binary. Keep in mind that the data is sent least significant bit (LSB) first, the result is displayed below. Since there are already three 1’s in the data word, the parity bit would be set to zero to mean the parity odd. (Usually in the PC environment you will find 7 or 8 bit words, the first is to accommodate all upper and lower case text characters in ASCII codes (the 127 characters), the latter one is used to exactly correspond to one byte. By convention, the least significant bit of the word is sent first and the most significant bit is sent last. When communicating the sender encodes the each word by adding a start bit in front and 1 or 2 stop bits at the end. Sometimes it will add a parity bit between the last bit of the word and the first stop bit, this used as a data integrity check. This is often referred to as a data frame. Five different parity bits can be used, the mark parity bit is always set at a logical 1, the space parity bit is always set at a logical 0, the even parity bit is set to logical 1 by counting the number of bits in the word and determining if the result is even, in the odd parity bit, the parity bit is set to logical 1 if the result is odd. The later two methods offer a means of detecting bit level transmission errors. Note that you don't have to use parity bits, thus eliminating 1 bit in each frame, this is often referred to as non parity bit frame). Most equipment using RS-232 serial ports use a DB-25 type connector, while many PCs today use DB-9 connectors since all you need in asynchronous mode is 9 signals, as shown in Figure 2. Normally the male connector is on the DTE side and the female connector is on the DCE side even if this is not always the case. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] DESCRIPTION OF PINS AND THEIR FUNCTIONS CIRCUIT V.24 CIRCUIT # DB-25 Pin # DB-9 Pin # SIGNAL NAME AA 101 1 - Protective Ground AB 102 7 5 Signal Ground BA 103 2 3 Transmitted Data BB 104 3 2 Received Data CA 105 4 7 Request to send CB 106 5 8 Clear to send CC 107 6 6 Data set ready CD 108 20 4 Data terminal ready CE 125 22 9 Ring detector CF 109 8 1 Carrier detect CG 110 21 - Signal quality detect CH / CI 111 / 112 23 - Data signal rate selector DA 113 24 - Transmitter signal timing (DTE) DB 114 15 - Transmitter signal timing (DCE) DD 115 17 - Receiver signal timing SBA 118 14 - Secondary TX SBB 119 16 - Secondary RX SCA 120 19 - Secondary RTS SCB 121 13 - Secondary CTS SCF 122 12 - Secondary CD 9 - Reserved Positive test 10 - Reserved Negative test 11 - N/C 18 - N/C 25 - N/C AA: Protective ground This line is connected to the power ground of the serial adapter. It should not be used as signal ground. AB: Signal ground This is the logical ground which is used as a point of reference for all signals received or transmitted. This signal is very important and must be present for all communications. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] BA: Transmitted data This line is used to transmit data from the DTE to the DCE. It is maintained at a logical 1 state when nothing is transmitted. The terminal will start to transmit when a logical 1 is present on all of the following lines: Clear To Send, Data Terminal Ready, Data Set Ready, Data Carrier Detect. BB: Received data This pin is used to receive data from the DCE to the DTE.The terminal will start to transmit when a logical 1 is present on all of the following lines: Request To Send, Data Terminal Ready, Data Set Ready, Data Carrier Detect. CA: Request To Send On this line, the DTE will send a signal when it wants to receive data from the DCE. CB: Clear To Send Here the DCE will send a signal when it's ready to receive data from the DTE. CC: Data Set Ready At a logical level of 1, this line indicates to the DTE that the DCE is ready to send data. (ex. When a modem has established a connection with a remote modem and is in transmission mode). CD: Data Terminal Ready When a logical level 1 is sent from the DTE the DCE can start to send and receive data. When this line passes to logical level 0 the DCE will stop all communications. (ex. A modem would stop all communications and would disconnect from the line, you will often see "DROP DTR" in communication programs). CF: Data Carrier Detect On this line the DCE indicates to the DTE that it has established a carrier with a remote device. CE: Ring Indicator This line is used mostly by communications software when the modem is not in "auto answer" mode and will indicate to the the software that a remote device is calling. This is signal is optional when not using software that will answer a phone call automatically. CG: Signal quality This line although rarely used serves to indicate to the DTE that the quality of the signal is poor or just not good enough to keep a good connection. CH: Data signal rate selector In the case where a modem able of multiple connection rates, the DTE could choose the speed at which it is connected. Usually this line is kept a logical level 0 which selects the highest speed. CI: Data signal rate selector This signal is the same as CH but in this case the modem selects the speed at which the DTE communicates. Timing circuits: In synchronous mode, it is necessary to have some way to exchange clock signals, here are three timing circuits used in the RS-232 protocol. DA & DB: Transmitter signal timing: DA: DTE towards DCE (clock part of the DTE). DB: DCE towards DTE (clock part of the DCE). These two circuits are used to synchronize the flow of data. Timing is given by the DTE or DCE but never from both at the same time. Usually data is transmitted to the modem or it's own clock control on the DB circuit. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] DD: Receiver signal timing DCE DD: DCE towards DTE (clock part of the DCE). This circuit is used to synchronize data received from the DTE. The clock signal received on this this line indicates to the DTE at which instant to sample the received data on the the BB line. NOTE: the following materials between two “+++” lines are for reference only, not included in the exam ++++++++++++++++++++++++++++Start Here +++++++++++++++++++++++++++++++++++ RS-232, RS-423, RS-422 and RS-485 Serial Interface Standard Summary All four of these standards were written by the EIA (Electronics Industry Association) to allow peripherals and computers to communicate with each other regardless of manufacturer. There are identical government (MIL spec) and international (CCITT) standards. These standards are for asynchronous serial communication. This means that data is transferred one bit at a time using a start bit, 7 or 8 data bits, stop bit(s) and an optional parity bit. The data is "self clocking" so that once the sender and receiver agree on the baud rate, the timing of the individual bits is based only on the start and stop bits. Alternatives to these standards are synchronous communication and parallel communication. Synchronous communication requires an additional clock line between the sender and receiver. Parallel communication requires a clock line, usually some control signals and several data lines. Both parallel and synchronous communication systems can transfer data faster than asynchronous serial systems but require more wires in the interconnect cables. PC parallel ports are examples of parallel communication. IBM's SDLC and HDLC are synchronous serial communication protocols and have been typically used in mainframe communications. RS-232, 423, 422 and 485 specify the communication system characteristics of the hardware such as voltage levels, terminating resistances, cable lengths, etc. The standards say nothing about the software protocol or how data is framed, addressed, checked for errors or interpreted. RS-485 RS-485 is an improved RS-422 with the capability to connect up to 16 devices (transceivers) on one serial bus to form a network. Such a network can have a "daisy chain" topology where each device is connected to two other devices except for the devices on the ends. Only one device may drive data onto the bus at a time. The standard does not specify the rules for deciding who transmits and when on such a network. That's up to the system designer to define. RS-423 RS-423 is similar to RS-232C except that it allows for higher baud rates and longer cable lengths because it tolerates ground voltage differences between sender and receiver. The maximum signal voltage levels are ±6 volts. Ground voltage differences can occur in electrically noisy environments where heavy electrical machinery is operating. RS-422 RS-422, like RS-232, is used to connect only two systems. It uses differential, or "double ended" data transmission, which means that data is transmitted simultaneously on two wires between two stations independent of the ground wire. Each signal requires 2 wires with a ground present in the system. The advantage of this method over RS-232 is higher speeds and longer cable lengths - 4000 feet at a 100K baud rate, for example. Introduction RS-232 was created for one purpose, to interface between Data Terminal Equipment (DTE) and Data Communication Equipment (DCE) employing serial binary data interchange. RS-232 was originally Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected] adopted in 1960 by the Electronic Industries Association (EIA). The DTE is the terminal or computer and the DCE is the modem or other communication devices. History RS-232 was originally adopted in 1960 by the Electronic Industries Association (EIA). The standard evolved over the years and in 1969 the third revision (RS-232C) was to be the standard of choice of PC makers. In 1987 a fourth revision was adopted (RS-232D also known as EIA-232D). In most part of this new revision, they added 3 additional test lines. In this lecture note you will see several parts of the original RS-232C standard and mostly the ones used in the PC world. Dr. Winncy Du, E310F, MAE Dept., SJSU, Tel.:408-924-3866,E-mail: [email protected]