serial communication lab 12 module m21.1. asynchronous serial i/o ascii code 54h = 1010100 (“t”)...

17
Serial Communication Lab 12 Module M21.1

Upload: melanie-fisher

Post on 15-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Serial CommunicationLab 12

Module M21.1

Page 2: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Asynchronous Serial I/O

MARK

SPACESTART

STOP

PARITY

D0 D1 D2 D3 D4 D5 D6 D7

ASCII code 54H = 1010100 (“T”) sent with odd parity

Page 3: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

110 9.09 2 100 10300 3.33 1 33.33 30600 1.67 1 16.67 601200 0.833 1 8.33 1202400 0.417 1 4.17 2404800 0.208 1 2.08 4809600 0.104 1 1.04 96014400 0.069 1 0.69 144019200 0.052 1 0.52 192028800 0.035 1 0.35 288038400 0.026 1 0.26 3840

Baud rate Bit time (ms)

No. ofstop bits

Char. time (ms) Chars./sec.

Page 4: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

D7 D6 D5 D4 D3 D2 D1 D0

D7 D6 D5 D4 D3 D2 D1 D0

Receive Holding Register (RHR)

Transmit Holding Register (THR)

Line Status Register

Modem Status Register

Control Register

Transmit Shift Register

Receive Shift Register

SERIAL DATA OUT

SERIAL DATA IN

TxD

RxD

DTR RTS CTS DCD DSR RI

To Modem

Functional Diagram of a UART

Page 5: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Serial Port Connector

Page 6: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

EXPERIMENT 39 – Communicating Between Two Computers

Pin 2 Pin 2

Pin 3Pin 3Null Modem

1. Connect two PCs together using a null modem between the two COM1 serial ports. A null modem is a serial cable in which pins 2 and 3 are crossed. That is, the transmit pin 2 of one computer is connected to the receive pin 3 of the other computer.

Page 7: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

EXPERIMENT 39 – Communicating Between Two Computers

2. You will execute the same program on both computers. Modify the program given in Listing 17.2 so that when you press function key F1 it switches to a double screen mode. In this mode whatever you type on the first computer should be displayed on the lower half of the second computer and on the upper half of the first computer (after making a round trip to the second computer). Similarly, anything typed on the second computer should be displayed on the lower half of the first computer and on the upper half of the second computer (after making a round trip to the first computer). Both halves of the screen should scroll independently when they are full.

Page 8: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

EXPERIMENT 39 – Communicating Between Two Computers

You need to be able to tell when a received character is one that originated at the other computer or is one that has made a round trip from your computer. To do this use the following algorithm: 

Send your own character with bit 7 = 0

If you receive a character with bit 7 = 0

Then display it on the bottom of the screen,

make bit 7 = 1 and send it backElse display it on the top of the

screenand do not send it back

 

Page 9: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Write this algorithm using Visual Basic

Page 10: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Follow 171Lab12_Tutorial.doc (available on the web site)

Page 11: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity
Page 12: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity
Page 13: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity
Page 14: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

You type in here

Your message gets displayed here after makinga round trip to the other compter.

Messages from the other computer will getdisplayed here.

Page 15: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

CSE 171 Lab 12. Week of November 26, 2001.

 

EXPERIMENT: Serial Communication – The CSE 171 Chat Room

PRE-LAB 1.      Read text Sec. 17.1, Serial I/O, pages 490-491. Read Experiment 39: Communicating between Two Computers on page 510.2.      Download the file, 171Lab12_Tutorial.doc, from the web site. 

Page 16: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

 LAB In this lab, two groups, working on adjacent computers, will run the same Visual Basic program that will allow them to chat with each other over the serial I/O line. The Visual Basic program will run the algorithm given in Experiment 39 on page 510 in the textbook. 1.         Write the Visual Basic program by going through the Tutorial given in the file 171Lab12_Tutorial.doc. 2.         Run this same program on both computers at the same time. Make sure that the null modem cable is connected between the serial ports of both computers. 3.         Each student in each group should type their name on a separate line in the box on the form. Copy the form (using Alt Print Screen) and paste it in a Word .doc file. 4.         Chat back and forth telling the other group which of the 12 labs in this class you liked the best and which you liked the least. Copy the form (using Alt Print Screen) and paste it to the same Word .doc file used in Part 3. 5.         Print out the .doc file containing your two chat screens and hand them in to your lab instructor. 

Page 17: Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = 1010100 (“T”) sent with odd parity

Note: No lab report is required for this lab.