CS222 Lecture: Serial IO Last Revised 4/13/96
Materials: Transparencies from Tanenbaum pp. 16, 22
I. Introduction
- ------------
A. Thus far in our discussion of input-output, we have dealt with
parallel IO techniques, in which an entire data byte/word is
transmitted in a single operation by using as many wires as there are
bits to send, plus some additional wires for control. Because of the
number of wires involved, parallel IO techniques are only practical over
relatively short distances - usually within the same room.
B. For longer-distance transmission, serial IO is generally used. When
data is sent serially, a single data line is used, with the individual
data bits being sent out one after another in time sequence. As a further
economy on wiring, the single data line is generally made to serve both
as a data line and for control functions, thus also eliminating the
control lines required by parallel IO. This may require the sending of
some additional control bits down the line in addition to the data bits.
C. Contrast the two approaches:
1. To send an n-bit word via parallel techniques, we need n data lines
(plus control lines), but 1 unit of time.
2. To send an n-bit word via serial techniques, we need 1 data line,
but n units of time (plus possible additional time for control bits.)
D. Serial data transmission techniques have considerable history.
1. The first techniques for sending characters over serial lines were
developed long before the computer era - e.g. the telegraph and
later the teletype. Many features of modern serial transmission of
data trace their origin to the teletype protocol.
2. The first use of serial transmission with computers was for the
transmission of data between a host computer and devices such as
terminals which might be located a significant distance from the
computer itself. (Note that, in the context of computer wiring,
several feet can be a significant distance!) Time-shared systems
that were developed in the 1960's and blossomed in the 1970's relied
on serial links to tie dozens or even hundreds of terminals to a
central CPU.
3. Later, researchers began to use serial lines to connect computers to
one another, and computer networks were born. Today, virtually all
computer networks use some sort of serial link to tie sites together -
e.g. telephone lines, fiber optics, coaxial cable, radio, etc.
II. Protocols and Protocol Hierarchies
-- --------- --- -------- -----------
A. As with parallel IO, serial transmission of data requires the use of
some PROTOCOL, or agreement, between the sender and receiver as to
how the data is sent.
1. In the simplest case - where two devices are "hard-wired" together
and are always in communication - the protocols are primarily
concerned with the physical representation of the data.
2. With networks, many other issues come in - e.g.
a. In the absence of a dedicated link between two computers, how does
the sender specify the specific computer the data is addressed to,
and how is it routed over an appropriate series of links between
source and destination?
b. How do we deal with HETEROGENEITY - the fact that communicating
computers may be built by different manufacturers, may be running
different operating systems and application software, etc?
B. In the case of computer networks, a HIERARCHY OF PROTOCOLS is used.
These protocols operate as a layered structure with several levels:
1. Low-level protocols deal with the physical representation of data -
e.g. via voltages on a wire, or tones on a telephone line, or light
signals over a fiber optic cable.
2. Intermediate-level protocols deal with routing of data
a. There may exist in the network several different possible paths
between two sites. Some path must be chosen for actual use in
each case.
b. Data arriving at a node for multiple users must be parcelled out
correctly to the individual users.
3. Higher-level protocols deal with issues specific to various
applications - e.g. email has protocols regarding addressing of mail;
a file server application has protocols regarding how requests for
data are formulated and satisfied etc.
4. A critical concept is that of LAYERING. The various protocols are
arranged in layers such that
a. There is a well-defined interface for each layer, independent of
the specific protocol in use at that layer.
b. The software at each layer depends only on the interface to the
software at the next lower layer.
c. The software at each layer provides the standard interface to the
software at the next layer up.
d. The purpose of this is so that a protocol at one level can be
changed without impacting protocols at other levels.
Example: If the physical connection between a computer and the
network it is part of is changed from a dialup phone
line to an ethernet connection, the physical layer
protocol will change, and this will require changing the
software for this layer. However, this change should
have no impact on how the email application functions -
except, perhaps, to improve performance.
5. The exact form of the hierarchy (the specific set of layers and their
interfaces) is different for different products - e.g. Digital's
DECNET has a different layer structure than IBM's SNA, and both differ
from the ARPANET structure (which is the basis for the Internet).
C. In 1980, the ISO published a reference model for describing the hierarchy
of protocols in a particular network architecture. This is commonly
called the ISO/OSI (open systems interconnect) model.
1. TRANSPARENCY - Tanenbaum p. 16
2. Most actual systems have a slightly different structure, but can be
described using the ISO model.
TRANSPARENCY - Tanenbaum p. 22
3. The ISO/OSI hierarchy constitutes a series of VIRTUAL CHANNELS.
a. The software implementing the protocol at each level on one machine
communicates with peer software at the same level on the other
machine.
b. The protocol software is written as if it had a direct link to its
peer - i.e. horizontally across the diagram.
c. In fact, except for the lowest level, the software at each level
communicates with its peer through the protocol at the next layer
down on its own machine - i.e. instead of going straight across the
diagram, the communication goes down to the bottom, then across,
and then up.
Example: Two lovers who are temporarily apart from each other
decide to keep in touch via ordinary postal mail. They
may well write their letters as if they were talking
face to face - but in fact they communicate by dropping
a properly addressed and stamped envelope in a mailbox,
relying on the services of the postal system to deliver
the letter to the other's mailbox in due time. On one
occassion, the letter may travel by truck and on another
by airplane, but this has no direct impact on their
communication (apart from perhaps affecting the delay).
D. Overview of the ISO/OSI hierarchy layers
1. Physical layer: Representation of raw bits
This layer attempts to transmit individual bits, one or more at a time,
as reliably as possible (but with no guarantees).
Note: We are discussing this in the context of a discussion of serial
transmission of data, which is most common at this layer. But
there is nothing in principle to prevent the physical layer from
being implemented in some case using a parallel link.
2. Data link layer: provides error free transmission of "physical layer
service units"
This layer deals with issues like:
a. Framing - grouping bits into larger logical groups called frames
b. Error detection and correction.
c. Acknowledgement of the receipt of a frame.
d. Resending of information when necessary - e.g. when a frame is
reported to have been received corrupted or is not acknowledged'
at all.
3. Network layer: deals with the routing of frames over the network.
This layer - and the ones below it - has to deal not only with the
sender and destination nodes, but often also with intermediate nodes
along the way. This abstraction created by this layer allows the
higher level layer software to ignore the existence of these
intermediate nodes.
4. Transport layer: breaks a lengthy message into smaller units commonly
called "packets", sends them over the network, and makes sure that
all the pieces arrive at the other end and are correctly reassembled.
5. Session layer: establishes communication with a peer on the other
machine and deals with issues like user authentication.
6. Presentation layer: deals with data format issues - e.g. different
character codes (ASCII, EBCDIC), compression and decompression of
data, encryption and decryption of data, etc.
7. Application layer: the final goal. Each kind of application has its
own protocol.
Examples (from the internet)
a. SMTP (Simple mail transfer protocol)
b. FTP (File transfer protocol)
c. HTTP (Hyper-text transfer protocol)
E. A detailed study of this hierarchy and of the various protocols used at
the different layers is obviously beyond the scope of this course. In
keeping with our hardware orientation, we will spend some time, though,
on low level protocol issues.
III. Transmission of Data over a Serial Link
--- ------------ -- ---- ---- - ------ ----
A. For the remainder of this lecture, we will look at issues related to
establishing a serial data link between two devices - e.g. a terminal
and a computer, or a peripheral such as a printer or scanner and a
computer. The material we will discuss corresponds to the physical
and data link layers of the ISO hierarchy; however, we won't rigidly
distinguish the layers, since what we will discuss is not limited to
network links.
B. At the lowest level, in the case of serial IO, timing plays a key
role in the protocols.
1. The sender places one bit at a time on the data line, and holds it
there for an agreed on period of time. This period is called the
BIT TIME.
2. The receiver samples the line at some point to extract the value of
the bit. Ideally, the receiver should sample the line as near as
possible to the middle of the bit time, to avoid errors due to
settling of the data, echoes etc:
| bit time |
_________
______/ \__________
\_________/
^
| receiver samples data here
3. This means that both sender and receiver need some sort of internal
clock. The sender's clock governs when it puts the data on the line,
and the receiver's clock governs when it samples the line. The two
clocks should obey the following relationship:
a. They both should run at the same frequency.
b. The receiver's clock should be 180 degrees out of phase vis-a-vis
the sender's.
4. The importance of having both clocks running at the same frequency
cannot be overstressed. Consider what would happen if the receiver's
clock were 1% slower than the sender's.
a. After 10 bits, the accumulated error would be 10% of the bit time.
This would cause the receiver to sample the data 1/10 bit time after
the mid-point of the bit, but should not cause any serious problems.
b. After 50 bits, the accumulated error would be 50% of the bit time.
This would cause the receiver to sample the data just as the sender
is taking it off the line, which would likely result in error.
c. After 100 bits, the accumulated error would be 1 full bit time.
As a result, the receiver would have lost one bit of data, and all
of the incoming bits would now be seen 1 bit out of their proper
place in the data item.
5. In the above example, we assumed a clock discrepancy of 1%. Obviously,
greater accuracy than this can be achieved. But any degree of
discrepancy between the two clock frequencies - no matter how small -
will eventually result in error after enough bits. For example,
a 0.01% error would lose one bit in 10,000. If textual data were
being transmitted, this would be an error after 1250 characters -
or after about 4 pages of text had been sent.
6. Because it is not practical to expect that two clocks in two devices
will run at exactly the same frequency, all serial protocols include
some provision for synchronization.
a. One approach would be to include an extra line carrying the sender's
clock. Under such an approach, the receiver would not need its
own clock, and so errors could be avoided. (The receiver could
simply invert the sender's clock to get the necessary 180 degree
phase shift.)
b. The problem with the extra line is that it doubles the cost of
connecting the two stations, which is generally unacceptable.
Therefore, most serial protocols rely on including some sort of
synchronization information on the data line along with the data
itself, as we shall see.
7. We have noted so far the importance of keeping the sender and receiver
clocks running at the same frequency. Another important problem is
initial synchronization - getting the edges of the two clocks to
coincide when a connection is first made, or when it is restored after
a disruption. We will consider ways of doing this as we consider clock
synchronization mechanisms.
8. Actually, some physical layer protocols send more than one bit at a
time by using more than two physical representations or symbols.
(E.g with 4 symbols 2 bits can be sent at a time; with 8, 3 bits etc.)
C. Another issue in serial protocols is FRAMING.
1. Serial data is sent bit-by-bit, but the data is intended to represent
larger units such as characters. The sender must have some way of
communicating to the receiver where the boundaries between characters
lie.
2. Generally, the protocol specifies a certain number of bits per
character, plus possible additional bits for parity checking and/or
synchronization. Thus, the framing problem reduces down to the
receiver recognizing one inter-character boundary; thereafter, it can
find boundaries by counting bits.
D. Another issue in serial protocols is SIMPLEX versus HALF-DUPLEX versus
FULL-DUPLEX operation.
1. In a SIMPLEX system, data can flow only one way; one end of the line
is always the sender and the other is always the receiver.
2. In a DUPLEX system, data can flow in either direction. Duplex systems
are further characterized as half duplex and full duplex.
a. In a HALF DUPLEX system, there is only a single data line, which
means that only one direction of data transmission is possible at
any given time. The protocol includes provision for line turnaround
whereby both ends agree to change the direction of data flow.
b. In a FULL DUPLEX system, two separate data lines are provided, so
data can flow both ways at the same time. No turnaround is needed.
i. The two data lines may be two separate wires (actually pairs of
wires: data and ground.) For example, this is how our terminals
are connected to the computers here, using a 4-wire cable.
ii. The two data "lines" may not be separate physical wires, but
modulation at two separate frequencies on the same wire. This is
what a modem does to allow data to flow both ways over a single
telephone circuit. (The price tag is that the data rate has
to be lower than what could be achieved over the same circuit
with simplex or half duplex operation.)
IV. Synchronous and Asynchronous Serial Protocols
-- ----------- --- ------------ ------ ---------
A. Serial protocols are of two basic types
1. SYNCHRONOUS protocols call for the sender to transmit a constant,
uninterrupted stream of data. (If it has no valid data to send, it
sends a special character called the synchronization character.)
a. This data stream is encoded in such a way as to guarantee that the
receiver's clock always runs in synchronization with the sender's.
b. Sychronization between sender and receiver is established
independently of, and prior to, the actual transmission of data.
2. ASYNCHRONOUS protocols call for the sender to transmit one character
at a time, with some idle space between characters. The receiver's
clock is started up afresh each time it senses a new character
beginning. (The start of the character serves to synchronize the
receiver's clock to the sender's.)
a. Synchronization of clocks is done character by character.
b. Since a character is on the order of 10 bits long (including
synchronization and parity bits), no data corruption occurs as long
as the receiver clock frequency is accurate to the sender's
frequency to within 1-2% or so - which is readily achievable.
3. Contrast:
a. Synchronous protocols are generally used for high-volume connections
between CPU's as in computer networks. For a given quality of line,
they can achieve a higher data rate because no synchronization bits
are used, and because the sending and receiving clocks are more
tightly coupled. However, synchronous protocols can only be used on
simplex or full duplex lines that are permanently connected, since
they require a continuous, uninterrupted transmission of data.
b. Asynchronous protocols are generally used for low-volume connections
between computer systems and peripherals such as terminals, printers
etc., where there may be long intervals of time between data items.
B. There are a number of different synchronous protocols in use, each with
various options. We consider just one example.
1. The first problem we must deal with in any synchronous protocol is
the matter of keeping the two clocks in sychronization.
a. One way to do this is by means of BINARY PHASE MODULATION.
b. The key idea is to use edges in the data (changes in voltage level)
as a way of keeping the two clocks in synchronization, since such
edges occur at a known point in the transmission of a bit.
2. At first glance, it might appear that the obvious way to transmit
bits is to adopt some convention that assigns one voltage level to
a "1" and a different voltage level to a "0", with voltage level
changes only between bits. However, such a convention does not
provide any way for the two clocks to synchronize if the data contains
a long string of 1's or 0's, since there would be no edges for the
receiver to use to synchronize its clock.
3. Binary phase modulation uses a 50% duty cycle clock (square wave) in
the transmitter. The bit time is one complete cycle of the clock;
thus, there are edges in the clock both at mid-bit and between bits.
The data that is sent is the exclusive or of the clock and the data
bit.
____
Data ------\\ \
)) )----- to line
Clock -----//____/
Thus, the data 10011100 would be sent like this (assuming the least
significant bit is sent first):
_ _ _ _ _ _ _ _
Clock |_| |_| |_| |_| |_| |_| |_| |_| |
___________ ___
Data bit ________| |_______|
0 0 1 1 1 0 0 1
_ ___ _ _ _ ___
Data sent |_| |_| |_| |_| |___| |_| |_
a. There is always a level transition in mid-bit, but there is
only a level transition between bits if the two bits are the
same; otherwise the change in the bit value exclusive ors with
the change in clock level to produce no change in the data sent.
b. A bit's value is encoded by the nature of the mid-bit transition.
A 0 has a low to high transition at mid-bit, and a 1 has a high
to low transition at mid-bit.
c. A simple circuit can now be built to convert level change to a
pulse:
____
Line ----+---------------------\\ \
| _______ )) )------- pulse
+----| Delay |--------//____/
-------
Ordinarily, the output of the exclusive or is a "0", since both
of its inputs come from the same source. However, at the point of
a level change, the delay in one input to the exclusive or
guarantees that there will be a brief period in which the two
inputs are opposites, yielding a "1" at the output of the
gate. (The width of this pulse will be equal to the length of
the delay.)
Often, an adequate delay can be achieved by simply putting 4 gates
or so in series. If each gate has a delay of 10 ns, a 40 ns
pulse will be produced whenever the line changes value.
d. It is now possible to recover both the original data and the
clock from the single data stream sent, as follows:
____
+------------------------------------------------|D |---Data
| ____ ____________ | |
Line ----+------------------\\ \ | 3/4 bit | | |
| _______ )) )----| time |-+--|> |
+----| Delay |-----//____/ | monostable | | | |
------- ------------ | | |
| ----
|___________Clock
i. The 3/4 bit time monostable turns each short pulse generated by
the edge detector into a much longer pulse. Once it has started
forming an output pulse, it is unresponsive to further input
pulses until the output pulse is complete.
ii. Of course, the edge detector responds to two kinds of edges:
the mid-bit edge occurring in every bit, and the inter-bit edge
occurring between two bits of the same value.
- Suppose the edge detector responds to a mid-bit edge,
triggering the monostable. Since the monostable pulse lasts
3/4 of a bit time, the next edge that will be accepted will
be the mid-bit pulse of the next bit. (An inter-bit edge, if
any, will occur during the time that the monostable is still
responding to the previous mid-bit edge.) Thus, once the
monostable is triggered by one mid-bit edge, it will trigger
on all subsequent mid-bit edges and ONLY on mid-bit edges.
Therefore, the leading edge of the monostable pulse will
always occur at mid-bit, as desired.
- But what if the monostable is first triggered by an inter-bit
edge? Then it will miss the following mid-bit edge, which
occurs 1/2 bit time later (too early.) However, it will
accept another inter-bit edge, if one occurs, and could do
this repeatedly. It would appear, then, that this circuit
could get locked into a pattern 1/2 bit out of phase when it
first starts receiving data - not a good pattern!
- However, if mis-synchronization occurs, it will not last long.
Inter-bit edges occur only if two adjacent bits have the same
value. As soon as a situation arises in which two adjacent
bits differ (normally within less than one byte), there will
be no inter-bit edge between them. Thus, the monostable
will not trigger until the following mid-bit edge; and once
it locks onto a mid-bit edge it will always trigger on mid-bit
edges since these occur for all bits.
iii. To recover the data, we arrange for the D flip-flop to trigger
on the falling edge of the monostable's output. This occurs
1/4 way into the next bit - when the data line contains the
bit's correct value - and mid-way between inter-bit and mid-bit
changes in the data line (the desired sampling time.)
4. Note that binary phase modulation solves the problem of keeping two
clocks running at the same frequency by using only one clock. The
only timing critical circuit in the receiver is the monostable; and
a fairly large error in its timing is possible without loss of
synchronization.
a. If it were too short by 33% (i.e. actually 1/2 bit time), then
false triggering on an inter-bit pulse would be possible.
b. If it were too long by 33% (i.e. actually 1 full bit time), then
if could miss triggering on a mid-bit edge.
c. As long as it is accurate to within a few percent, no problems at
all will occur, except that the data line will be sampled a bit
early or late. This is usually acceptable.
5. We now consider the matter of character framing. Any viable protocol
must provide for a receiver to come on line and begin receiving data
after an initial synchronization period. Even if we intend that
sender and receiver be constantly connected, disruptions in the
communication circuit may make this necessary at times.
6. We have seen that a scheme like binary phase modulation allows
synchronization at the bit level to occur fairly quickly. However,
once bit level synchronization has occurred, the receiver still has
the problem of determining where the byte boundaries occur between
bits.
7. To handle this, the protocol includes a special synchronization
character that the sender transmits between messages. (If there are
no messages to send, then the sender transmits sync characters
constantly.)
a. One commonly-used synch character is 01111110. Note that a series
of sych characters consists of the pattern two 0's, six 1's, two
zero's.
b. When the receiver first starts up, it goes into a hunt mode in
which it looks for the synch character. Every time it sees a
zero, it looks for six consecutive one's following. If it sees
them, then another zero, then another whole synch character
(01111110) it knows it has probably locked onto the correct
framing. This is confirmed when a correctly-formatted message
appears immediately after the last synch character seen.
8. Another feature of synchronous protocols is the grouping of characters
into larger packets, with headers, checksums etc. We will not explore
this; this is a topic for a course in data communications.
C. Asynchronous protocols.
1. We have already noted that the distinctive feature of an asynchronous
serial protocol is that synchronizaton between the sender and receiver
is established on a character-by-character basis, rather than being
maintained continuously.
a. We consider the most common way of doing this: the teletype
protocol (that predates the computer era by decades.
b. This is the protocol used by all standard asynchronous terminals,
modems etc.
2. The sender and receiver agree on a basic bit rate, and contain
internal clocks of the appropriate frequency.
a. Bit rate is normally measured in bits per second - abbeviated bps.
b. The bit TIME is the reciprocal of the bit rate - e.g. at 9600 bps,
each bit is about 1/9600 = 104 microseconds.
3. The bit rate is often called the "baud rate" in honor of Baudot, who
invented the first teletype code. However, the terms "baud rate" and
"bit rate" do not necessarily mean the same thing.
a. One baud = one signal/second; 2400 baud = 2400 signals/second etc.
b. When serial data is being sent digitally, each bit is normally
represented by a single signal - so the terms baud rate and bit
rate are equivalent.
c. As we shall see, high speed modems achieve their performance by
packing several bits into one signal - hence to speak of a
typical high speed modem as a 28,800 baud modem is not correct -
though it is a 28,800 bits per second (bps) modem.
4. For digital serial lines, two possible states are defined for the data
line: the space state (which corresponds to the binary value 0) and the
mark state (which corresponds to 1). (This nomenclature reflects the
fact that the asynchronous protocol was developed for data
communication in the teletype era, before computers. At that time
paper tape was commonly used for storing transmitted data: a "space"
would correspond to unpunched tape and a "mark" to punched tape.)
4. When the sender is not transmitting data, it holds the data line in
the mark state (1).
5. Synchronization is accomplished by preceeding each character with a
synchronization bit called the start bit, and following it with one
or more synchronization bits called stop bits. The start bit is
always a space (0), and the stop bit(s) is/are always mark(s) (1).
a. The receiver knows that the sender is starting a new character
when it sees the line go from its quiescent mark state to the
space state. This mark to space edge is used to establish
synchronization.
b. Once synchronization is established by the leading edge of the
start bit, the receiver uses its own internal clock to partition
the data stream into bits. Of course, this clock may not be
running at exactly the same frequency as the sender's; but this is
not a problem since each character is only 9-12 bits long, so
even with 2% clock rate difference the accumulated error at the
end of the character will be less than 1/4 of a bit time - not
enough to cause garbling of the data.
c. The stop bit(s) at the end guarantee that there will always be a
mark to space transition at the start of the next character.
i. If the sender was transmitting a series of characters one after
another, and if one character's data ended with a space, then
without the stop bit there would be no edge for the receiver to
use to establish synchronization for the next character.
ii. This guaranteed mark to space transition at the start of a
character means that each character starts off with both clocks
in perfect synchronization.
iii. Sender and receiver must agree on the number of stop bits to
include with each character. Typically, this is one, but most
serial interfaces allow 1-1/2 or 2 stop bits as options.
d. Sender and receiver must also agree on the number of bits between
the start bits and the stop bits. This number will include:
i. Some number of data bits - typically seven or eight.
- Data bits are sent least significant bit first.
- The widely-used Ascii code is basically a seven bit code,
hence the use of seven data bits on Ascii equipment is common.
- However, eight data bits may be used for convenience on
byte-oriented machines (perhaps with the eighth bit always
being zero.)
- Also, some devices handle non-Ascii special characters with
codes 80H .. FFH, necessitating eight data bits. For example,
many recent DEC devices have an international character set
with vowels with umlauts etc. in this range of codes.
- Some interfaces can also handle 5 or 6 bits of data. Six bit
codes were used on upper-case only hardware (though this kind
of device is rare today.) A five bit code is possible by
encoding the shift key as a separate character, to be sent
whenever the shift status changes.
ii. An optional parity bit. Sender and receiver may agree to:
- Include no parity bit at all. The character ends with the
last data bit.
- Include a parity bit that makes the total number of marks
(1's) in the character proper even.
- Include a parity bit that makes the total number of marks
(1's) in the character proper odd.
- Include a parity bit that is always a space (0) or mark (1).
[This is not truly a parity bit, of course, but occupies the
parity bit position in the character.]
- If a genuine parity bit is included in the protocol, the
sender is obligated to send it with the proper value, and the
receiver is obligated to receive it, but the receiver is not
obligated to actually use it to check the data - it may simply
ignore the parity bit.
Example: Show parity options in VT1xx setup menu: N(one), O(dd),
E(ven), S(pace) and M(ark).
Example: the character "B" (Ascii code 42H) is sent on a previously
quiescent line, using seven data bits, odd parity, and
one stop bit:
{ quiescent line }{ actual character }{ quiescent line or more characters }
Mark _______ _ _____________________
| | | |
Space |___| |_______|
^ 0 1 0 0 0 0 1 ^ ^
| | |
| | Stop bit
Start bit Parity bit
e. The maximum data rate for a given set of parameters can be
calculated as follows:
Data rate = Bit-rate / Total-bits-per-character
Where total-bits-per-character includes the start bit, data bits,
parity bit (if any) and stop bit(s).
Example: For the above parameters at 9600 bits/sec, the maximum data
rate is:
9600 / (1 + 7 + 1 + 1) = 960 characters/second
f. The receiver may execute the following algorithm - generally in
hardware:
Begin: Sample the line
If it is a mark, go to Begin
Wait 1/2 bit time, then sample the line again.
If it is a mark, then go to Begin. [The edge that was
seen was presumably noise, not the beginning of a
genuine start bit.
For i := 1 to number-of-bits-per-character do
Wait one bit time
Sample the line and record the value [Note: due to the
initial 1/2 bit wait, this will always occur at
mid-bit.]
If parity checking is in use, then check the received
character's parity and report a parity error if it is
improper. [This must be done in parallel with, or after,
the next steps.]
Wait as many bit times as there are stop bits [Typically
one]
Sample the line. If it is not a mark, then report a
framing error. [The character read was not properly
framed by a start bit and the prescribed number of
stop bits, and so cannot be trusted.]
6. As can be seen, to communicate properly, two devices must agree on
a number of parameters:
a. Bit rate
b. Number of data bits
c. Parity convention
d. Number of stop bits
e. Sophisticated interface devices are generally programmable,
allowing the user to select different parameter values as necessary
to communicate with various other devices.
V. Physical Representation of Serial Data
- -------- -------------- -- ------ ----
A. In addition to the protocol elements we have considered so far, we also
need to adopt some PHYSICAL REPRESENTATION for the logic values 1 and 0,
B. For hard-wired connections between devices, the most commonly used
protocol is Electronics Industry Association (EIA) standard RS-232,
RS-422, or RS-423.
1. As an example, RS232 signals represent space (0) and mark (1) by
the following voltage levels:
a. A space (0) is represented by a voltage more positive than +3V
(typically +10V.)
b. A mark (1) is represented by a voltage more negative than -3V
(typically -10V.)
c. Voltages between -3V and +3V are illegal and represent an undefined
value.
2. Note the differences between TTL logic levels and RS232 levels:
a. TTL Levels lie between 0 and 5V; RS232 levels are both negative
and positive, and the positive levels can be greater than 5V.
b. The RS232 levels are inverted compared to TTL: a TTL 1 is more
positive than a TTL 0, but an RS232 0 is more positive than an
RS232 1.
c. Conversion between TTL and RS232 levels is typically handled by
special purpose line-driver/receiver chips.
C. For sending data over telephone lines (or any long distance communication)
some additional considerations are necessary.
1. One cannot impose a DC voltage such as RS232 uses for marking on the
telephone network; even if it didn't foul up the exchange it would
certainly not be propagated through the network.
2. Line capacitance would destroy the sharp edges on which RS232 relies.
3. Therefore, a different representation is typically used. The most
common representation is based on frequency-shift-keying (FSK):
a. Zero and one are represented by different frequency tones. The
sender is always sending one of the two tones.
b. For example, in early 300 baud modems, the following frequencies
were used:
i. The originating modem (the one initiating the connection) sent
a space (0) as a 1070 Hz tone, and a mark (1) as 1270 Hz.
ii. The answer modem sends a space as 2025 Hz and a mark as 2225 Hz.
iii. Both modems transmit one or the other tone at all times (mark
when idle.) If a modem fails to detect a signal from the other
end, it assumes the connection has been broken and also stops
sending.
c. The current telephone network is inherently limited to a rate of
about 2400 signals per second (2400 baud). If each signal
represents a bit (as in the simple modem protocol), then this
translates into 2400 bits per second, maximum. To achieve higher
speeds, modern modems transmit more than one bit per signal -
which means utilizing more than two distinct tones. For example,
28,800 bps modems manage to transmit about 9 bits per signal -
equivalent to using 512 different tones.
Copyright ©1999 - Russell C. Bjork