Laboratory 1- Preparation

advertisement
Laboratory 2- Preparation
Asynchronous data communications
via null modem
1. Review and preparation
The format of serial asynchronous data transmission via the serial (RS232) port of a
computer consists of a sequence of 8-bit ASCII characters, where each character is
encapsulated between a Star_ bit and a Stop_bit. The 8th bit of an ASCII character may be
a parity bit (odd or even parity). The Start_bit is a 1 bit and the Stop_bit is a 0 bit.
The bits 1 and 0 in serial asynchronous transmission are encoded by a polar digital signal,
where a positive pulse encodes a 0 bit and a negative pulse encodes a 1 bit. The
amplitude of a positive pulse is between +5V and +15V, and that of a negative pulse is
between -5V and -15V.
For example, the letter “B” is encoded by 7-bit ASCII code 1000010 where the leftmost
bit is the most significant bit (MSB), and the rightmost bit is the least significant bit
(LSB). Using binary-to-decimal conversion, 1000010 = 1*26+1*21 = 66 (verify this on
ASCII table found in ref. [1]). If an even-parity bit is added before the MSB, the code
becomes 01000010 (parity bit is 0 so that the number of 1’s is even, 2 in this case).
When transmitted by the serial port, this 8-bit character is encapsulated with a Start_bit
before the LSB and a Stop_bit after the MSB, as follows 1010000100.
The serial-port signal for the string 1010000100 of letter B is shown in Fig. 1-a (the
signal is read from left to right). The real signal for the same string, which was captured
from an oscilloscope by a software Wavestar in the lab, is given in Fig. 1-b.
0
0
1
0
0
0
0
1
0
1
t
Stop_bit
Parity_bit
Start_bit
Fig. 1: a) Sketch of signal for letter “B”
Fig. 1: b) Real signal of letter “B” from scope
The bit rate of data transmission is defined by a clock. The maximum bit rate of the serial
port is 115 Kbps. Typical bit rates are 300 bps, 1200 bps, 2400 bps, 9,600 bps, and
19,200 bps. The pulse width (in second) in the digital signal of Fig. 1 is the inverse of the
bit rate.
The serial ports of a PC are usually known as COM1 and COM2.
The standard connector of RS232 serial port is DB25 with 25 pins. A smaller connector is
DB9 connector with 9 pins. The 25 pins of a D25 connector and the 9 pins of a DB9
connector have well defined functions. The most important pins are the Transmit_data
(TD), the Receive_data (RD), and the Signal_Ground (SG) pins. The other pins have
control and timing (clock) functions.
In DB25: pin2=TD; pin3=RD; pin7=ground. One should, however, test the pins of the
DB9. The basic pin configuration of the DB25 and corresponding DB9 ports are shown
in Table 1 (in DB9 here: pin3=TD; pin2=RD; and pin5=ground).
DB25 Pin No.
Pin 2
DB9 Pin No.
Pin 3
Abbreviation
TD
Full Name
Transmit Data
Pin 3
Pin 2
RD
Receive Data
Pin 4
Pin 7
RTS
Request To Send
Pin 5
Pin 8
CTS
Clear To Send
Pin 6
Pin 6
DSR
Data Set Ready
Pin 7
Pin 5
SG
Signal Ground
Pin 8
Pin 1
CD
Carrier Detect
Pin 20
Pin 4
DTR
Data Terminal
Ready
Pin 22
Pin 9
RI
Ring Indicator
Table 1 : Pins of DB25 and DB9
A null modem (NM) is a simple device that connects the 2 serial ports of 2 PC’s (DTE’s),
and allows the 2 PC’s to communicate. In its simplest form, the NM is obtained by
connecting the TD pin of one PC to the RD pin of the other PC, and vice versa, and
connecting the ground pins together. The simplest NM wiring diagram is shown in Fig. 2
.
Fig. 2 : Simplest null modem wiring
Preparation: Give your work in the lab sheet
1. Use the ASCII table found in reference [1] to find the decimal code for letter “m”.
2. Convert the decimal code for letter “m” into its 7-bit binary ASCII code
3. Add a parity bit (after the MSB bit) if:
a. Even parity
b. Odd parity
Sketch the serial-port signal for letter “m” with even parity, and including the Start and Stop bits
(see example for letter B above)
[1]. http://www.asciitable.com
Download