230 likes | 364 Views
Fall 2005 Local Serial Asynchronous Communication. Qutaibah Malluhi Computer Science and Engineering Qatar University. Bit-wise data transmission. Data transmission requires: Encoding bits as energy Transmitting energy through medium Decoding energy back into bits
E N D
Fall 2005Local Serial Asynchronous Communication Qutaibah Malluhi Computer Science and Engineering Qatar University
Bit-wise data transmission • Data transmission requires: • Encoding bits as energy • Transmitting energy through medium • Decoding energy back into bits • Energy can be electric current, radio, infrared, light • Transmitter and receiver must agree on encoding scheme and transmission timing
Using Electric Current to Send Data • Simple idea - use varying voltages to represent 1s and 0s • One common encoding use negative voltage for 1 and positive voltage for 0 • In following figure, transmitter puts positive voltage on line for 0 and negative voltage on line for 1
Encoding Details and Standards • Encoding scheme must specify the details. For example: • How long will voltage last for each bit? • How soon will next bit start? • How will the transmitter and receiver agree on timing? • All details specified by standards • Allow interoperability of devices adhering to the standard • Several organizations produce networking standards • International Telecommunications Union (ITU) • Electronic Industries Association (EIA) • Institute for Electrical and Electronics Engineers (IEEE)
Parallel versus Serial Transmission Parallel Serial
Asynchronous Communication • Asynchronous and synchronous communications • In broad sense, communication may be called asynchronous if transmitter and receiver do not explicitly coordinate before each data transmission • Sender can wait arbitrarily long between transmissions. Sends when data becomes ready • Used, for example, when sender may not always have data ready to send (E.g., keyboard, mouse) • Receiver does not know when a character will arrive. May wait forever • In more technical sense, Asynchronous may also mean no explicit information about where individual data bits begin and end
Asynchronous Vs. Synchronous Clock Data Line idle 0 1 1 0 1 0 1 • Synchronous: • May use a separate clock signal to indicate duration of bits. • Asynchronous • How do we know beginning of a bit and the ending of it? • One way to ensure meaningful exchange • Sender and receiver agree on bit duration • Start bit before character • One or more stop bits after character • 1s when idle e.g., 010100110100110101110011010111111111 Ch1 Ch2 Ch3 Idle
The RS-232C Standard • Standard specified by EIA • For transfer of characters across copper wire • Full name is RS-232-C common name is RS-232 • Defines serial, asynchronous communication • Serial - bits are encoded and transmitted one at a time (as opposed to parallel transmission) • Asynchronous - characters can be sent at any time and bits are not individually synchronized
More Details about RS-232 • Components of standard: • Data represented by voltage between +15 and –15 • Cable limited to ~50 feet • 25-pin connector, with specific signals such as data, ground and control assigned to designated pins • Specifies transmission of characters between, e.g., a terminal and a modem • Transmitter never leaves wire at 0v; when idle, transmitter puts negative voltage (a 1) on the wire
RS-232 Character Transmission • Transmitter indicates start of next character by transmitting a zero • Receiver can detect transition as start of character • Extra zero called the start bit • Transmitter must leave wire idle so receiver can detect transition marking beginning of next character • Transmitter sends a one after each character • Extra one called the stop bit • Thus, character represented by 7 data bits requires transmission of 9 bits across the wire RS-232 terminology: MARK is a negative voltage (== 1) SPACE is a positive voltage (== 0)
Duration of a Bit • Transmitter and receiver must agree on timing of each bit • Agreement accomplished by choosing transmission rate • Measured in bits per second • Detection of start bit indicates to receiver when subsequent bits will arrive • Hardware can usually be configured to select matching bit rates • Switch settings • Software • Autodetection
Bit Rate And Baud Rate • Baud rate measures number of signal changes per second • Bits per second measures number of bits transmitted per second • In RS-232, each signal change represents one bit, so baud rate and bits per second are equal • If each signal change represents more than one bit, bits per second may be greater than baud rate • Bit rate = Baud rate * the number of bits represented by each signal unit • Example: An analog signal carries 4 bits in each signal change. If 1000 signal changes are sent per second, then baud rate = 1000 bauds per second, bit rate = 1000 * 4 = 4000 bps
Character Framing • Start and stop bits represent framing of each character • If transmitter and receiver are using different speeds, stop bit will not be received at the expected time • Problem is called a framing error • RS-232 devices may send an intentional framing error called a BREAK • E.g., ASCII keyboard BREAK key • Deliberately create a framing error. Applications noticing a framing error as a request to abort
Full-Duplex Communication • Simultaneous two-way communication • Requires each side to have transmitter and receiver • Requires an electrical path in each direction • Transmitter on one side connected to receiver on other • Separate wires needed to carry current in each direction • Common ground wire
DB-25 Connection Standard • RS-232 specifies use of 25 pin connector (DB-25) • Pins are assigned for use as data, ground and control: • Pin 2 - Receive (RxD) • Pin 3 - Transmit (TxD) • Pin 4 - Ready to send (RTS) • Pin 5 - Clear to send (CTS) • Pin 7 – Ground • Commonly DB-9 is used.
2-3 Swap • Cable must cross-over wires to connect pins 2 and 3 on receiver and transmitter • RS-232 specifies that modems (DTE) transmit on pin 2 and receive on pin 3, while computers (DCE) transmit on pin 3 and receive on pin 2 • DTE: Data Terminal Equipment (modem) • DCE: Data Computer Equipment (computer) • To connect two DCEs (Computers), RS-232 cables between two computers must have 2-3 swap • Also called null modem cable • To connect DCE to DTE, use a straight through cable • Standard modem cable
Electric Transmission • In real world • Electric energy dissipates as it travels along • Wires have resistance, capacitance, and inductance which distort signals • Magnetic or electrical interference distorts signals • Distortion can result in loss or misinterpretation
Distorted Signal For A Single Bit • In practice • Distortion can be much worse than illustrated
Consequences • RS-232 hardware must handle minor distortions • Take multiple samples per bit • Tolerate less than full voltage • Can not use electrical current for long-distance transmission • Use carrier signals
Newer Standards • USB (Universal Serial Bus) • Hot pluggable • Device powered by bus • Upto 12 Mbps • Newer USB2 speed is 480 Mbps • Firewire: a high speed serial bus • 400/800 Mbps
Conclusions • Asynchronous communication - data can start at any time; individual bits not delineated • RS-232 - EIA standard for asynchronous character transmission • Bit rate and baud rate • Bandwidth limits maximum data transmission rate • Newer standards such as USB and Firewire are replacing the role of RS 232 in PCs