"PC-to-PC Communication Using Infrared/Laser Beam": Bachelor of Engineering

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 27

A

Minor Project Report


on

“PC-to-PC Communication using


Infrared/Laser Beam”
Submitted in partial fulfillment of the requirement
for the award of the degree of

Bachelor of Engineering
in
Electronics & Communication Engineering
(University of Rajasthan, Jaipur)

2006-07
Under the Supervision of Submitted by
Prof. / Mr. / Ms. Ms. Divya Guglani
Ms. Kirti Singh
Ms. Pratibha Bansal

Faculty of Engineering & Technology


Mody Institute of Technology & Science
(Deemed University)
Lakshmangarh – 332 311, Sikar (Rajasthan)
India
Certificate

This is to certify that Ms. Divya Guglani(E&CE), Ms.Kirti Singh (E&CE), and
Ms. Pratibha Bansal(E&CE) Students of B.E. Final Year (VII Semester) have
submitted their project entitled “PC-to-PC Communication using
Infrared/Laser Beam” under my guidance.

(Prof. / Mr./ Ms. …. )

Project Guide
Examiner’s Certificate

This is to certify that the B.E. Final Year (VII Semester) Project Examination
of Ms.Divya Guglani , Ms. Kirti Singh and Ms. Pratibha Bansal for the partial
fulfillment of the award of the degree of Bachelor of Engineering in Electronics
& Communication Engineering is held on.…………………..

Minor-Project Title:
“PC-to-PC Communication using Infrared/Laser Beam”

(Internal Examiner/s) (External Examiner/s)

(N.K.Shukla)
Project Coordinator
Department of E&CE

(Prof. S. Sarkar)
Head, Deptt. of E&CE
Acknowledgement
It is our pleasure to take this opportunity to thank all those who helped us
directly or indirectly in preparation of this project. Our special thanks goes to
Prof. S. Sarkar , H.O.D of electronics division, Faculty of Engineering and
Technology. We would also like to our esteemed guide Mr. Vikas Gupta , for
his helpful suggestions. It is because of his able and mature guidance and
cooperation without which it would not have been possible for us to complete
our project. We convey our sincere thanks to him for his constant
encouragement, guidance and suggestions throughout the tenure of our project.

Ms. Divya Guglani

Ms. Kirti Singh

Ms. Pratibha Bansal

Date: ……………
Place: MITS, Laksmangarh
Abstract
Serial communication is done via the RS-232 serial port. RS232 is the most
known serial port used in transmitting the data in communication and
interface. Even though serial port is harder to program than the parallel port,
this is the most effective method in which the data transmission requires less
wires that yields to the less cost. The RS232 is the communication line which
enables the data transmission by only using three wire links. The three links
provides ‘transmit’, ‘receive’ and common ground.

Why use a laser? A line-of-sight laser beam is useful where wires cannot be
physically connected to a remote location. A laser beam, unlike wires, also
does not require special shielding over longer distances. Lasers offer at least
an order of magnitude longer distances compared to infrared LEDs.

The UART (Universal Asynchronous Receiver Transmitter) is a large scale


integrated circuit which contains all the software programming necessary to
fully control the asynchronous communication between serial devices.
1. Introduction
There are two basic types of serial communication, synchronous and
asynchronous. With synchronous communications, the two devices initially
synchronize themselves to each other, and then continuously send characters
to stay in sync. Even when data is not really being sent, a constant flow of bits
allows each device to know where the other is at any given time. That is, each
character that is sent is either actual data or an idle character. Synchronous
communications allow faster data transfer rates than asynchronous methods,
because additional bits to mark the beginning and end of each data are not
required. The serial ports on most PC’s are asynchronous and it therefore only
supports serial communication.

>>diagram
2. Serial Communication

2.1 Need of Serial Communication

A parallel port sends and receives data eight bits at a time over 8 separate
wires. This allows data to be transferred very quickly; however, the cable
required is more bulky because of the number of individual wires it must
contain. Parallel ports are typically used to connect a PC to printer. A serial
port sends and receives data one byte at time over one wire. While it takes
eight times as long to transfer each byte of data this way, only a few wires are
required. In fact, two-way (fully duplex) communication is possible with only
three separate wires- one to ‘send’, one to ‘receive’, and a common ‘signal
ground’ wire.

Signal transmission is commonly used with modems and for non-network


communication between computers, terminals and other devices. There are
two primary forms of serial transmission: Synchronous and Asynchronous.
The Universal Asynchronous Receiver Transmitter (UART) controller is the
key component of the serial communication subsystem of a computer. The
UART takes bytes of data and transmit the individual bits in a sequential
fashion. At the destination, a second UART reassembles the bits into complete
bytes.
Depending on the modes that are supported by the hardware, the name of the
communication sub-system will usually include a ‘A’ if it supports
asynchronous communication and a ‘S’ if it supports asynchronous
communication. Some common acronyms are:

UART (Universal Asynchronous Receiver/Transmitter)


USART (Universal Synchronous-Asynchronous Receiver/ Transmitter)

2.1.1 Synchronous Serial Transmission

Synchronous serial transmission requires that sender and receiver share a


clock with one another, or that the sender provide a strobe or other timing
signal so that the receiver knows to ‘read’ the next bit of the data. In most
forms of serial Synchronous communication, if there is no data available at a
given instant to transmit, a fill character must be sent instead so that data is
always being transmitted between sender and receiver, and synchronous
communication can be more costly if extra wiring and circuits are required to
share a clock signal between the sender and receiver.

A form of synchronous transmission is used with printers and fixed disc


devices in that the data is sent on set of wires, a clock of strobe is set on a
different wire. Printers and fixed disk devices are not normally serial devices
because most fixed disk interface standards send an entire word of data for
each clock or strobe signal by using a separate wire for each bit of the word.
In the PC industry, these are known as parallel devices. The standard serial
communication hardware in the PC does not support synchronous operation.
This mode is described here for comparison purpose only.

2.1.2 Asynchronous Serial Transmission

Asynchronous transmission allows data to be transmitted without the sender


having to send a clock signal to the receiver. Instead, the sender and receiver
must agree on timing parameters in advance and special bits are added to each
word which is used to synchronize the sending and receiving units.

When a word is given to the UART for Asynchronous transmissions, a bit


called the "Start Bit" is added to the beginning of each word that is to be
transmitted. The Start Bit is used to alert the receiver that a word of data is
about to be sent, and to force the clock in the receiver into synchronization
with the clock in the transmitter. These two clocks must be accurate enough to
not have the frequency drift by more than 10% during the transmission of the
remaining bits in the word. (This requirement was set in the days of
mechanical teleprinters and is easily met by modern electronic equipment.)

After the Start Bit, the individual bits of the word of data are sent, with the
Least Significant Bit (LSB) being sent first. Each bit in the transmission is
transmitted for exactly the same amount of time as all of the other bits, and the
receiver “looks” at the wire at approximately halfway through the period
assigned to each bit to determine if the bit is a 1 or a 0. For example, if it takes
two seconds to send each bit, the receiver will examine the signal to determine
if it is a 1 or a 0 after one second has passed, then it will wait two seconds and
then examine the value of the next bit, and so on.
The sender does not know when the receiver has “looked” at the value of the
bit. The sender only knows when the clock says to begin transmitting the next
bit of the word.
When the entire data word has been sent, the transmitter may add a Parity Bit
that the transmitter generates. The Parity Bit may be used by the receiver to
perform simple error checking. Then at least one Stop Bit is sent by the
transmitter.
When the receiver has received all of the bits in the data word, it may check
for the Parity Bits (both sender and receiver must agree on whether a Parity
Bit is to be used), and then the receiver looks for a Stop Bit. If the Stop Bit
does not appear when it is supposed to, the UART considers the entire word to
be garbled and will report a Framing Error to the host processor when the data
word is read. The usual cause of a Framing Error is that the sender and
receiver clocks were not running at the same speed, or that the signal was
interrupted.
Regardless of whether the data was received correctly or not, the UART
automatically discards the Start, Parity and Stop bits. If the sender and
receiver are configured identically, these bits are not passed to the host.
If another word is ready for transmission, the Start Bit for the new word can
be sent as soon as the Stop Bit for the previous word has been sent.
Because asynchronous data is “self synchronizing”, if there is no data to
transmit, the transmission line can be idle.
2.2 UART
A UART chip is an electronic circuit that transmits and receives data through
the serial port. It converts bytes into serial bits for transmission, and vice
versa. It also generates and strips the start and stop bits appended to each
character.

UART stands for Universal Asynchronous Receiver/Transmitter. It is found


on the serial card which controls the modem or other connected devices.
Modem cards have the UARTs integrated into other chips which may also
control the parallel ports, game ports, and floppy or hard disk drives are
typically surface mount devices. All the UARTs pins are TTL compatible.
Therefore, RS232 level converters are used.
Type Description
8250 First UART in this series. It contains no scratch register. The 8250A
was an improved version of the 8250 which operates faster on the bus
side.
8250A This UART is faster than the 8250 on the bus side. Looks exactly the
same to software than 16450.
8250B Very similar to that of the 8250 UART.
16450 Used in AT's (Improved bus speed over 8250's). Operates comfortably
at 38.4KBPS. Still quite common today.
16550 This was the first generation of buffered UART. It has a 16 byte buffer,
however it doesn't work and is replaced with the 16550A.
16550A Is the most common UART use for high speed communications eg
14.4K & 28.8K modems. They made sure the FIFO buffers worked on
this UART.
16650 Very recent breed of UART. Contains a 32 byte FIFO, Programmable
X-On / X-Off characters and supports power management.
16750 Produced by Texas Instruments. Contains a 64 byte FIFO.

2.3. RS232
RS232 is the most known serial port used in transmitting the data in
communication and interface. Even though serial port is harder to program
than the parallel port, this is the most effective method in which the data
transmission requires less wires that yields to the less cost. The RS232 is the
communication line which enables the data transmission by only using three
wire links. The three links provides ‘transmit’, ‘receive’ and common ground.

In serial I/O data can be transmitted as voltage or current. When data is


transmitted as voltage the communication used standard is known as RS232C.
RS232 stands for Recommended Standard Number 232 and C is the latest
revision of the standard.

The electrical specifications of the serial port are contained in the EIA
(Electronics Industry Association) RS232C standard. It states many
parameters such as –

1. A "Space" (logic 0) will be between +3 and +25 Volts.


2. A "Mark" (Logic 1) will be between -3 and -25 Volts.
3. The region between +3 and -3 volts is undefined.
4. An open circuit voltage should never exceed 25 volts. (In reference to
GND)
5. A short circuit current should not exceed 500mA. The driver should be able
to handle this without damage.
2.3.1 Hardware Properties

Devices which use serial cables for their communication are split into two
categories. These are

• DCE (Data Communications Equipment)


• DTE (Data Terminal Equipment)

Data Communications Equipment are devices such as modem, TA adapter,


plotter etc .

Data Terminal Equipment is our Computer or Terminal.

Serial Ports come in two "sizes". There is the D-Type 25 pin connector and
the D-Type 9 pin connector both of which are male on the back of the PC,
thus both will require a female connector on our device.

Serial Pinouts (D25 and D9 Connectors)

D Type-9 pin no. D- Pin outs Function


Type-
25 pin
no.
3 2 RD Receive Data (Serial data
input)
2 3 TD Transmit Data (Serial data
output)
7 4 RTS Request to send
(acknowledge to modem that
UART is ready to exchange
data
8 5 CTS Clear to send (i.e.; modem is
ready to exchange data)
6 6 DSR Data ready state (UART
establishes a link)
5 7 SG Signal ground
1 8 DCD Data Carrier detect (This line
is active when modem
detects a carrier
4 20 DTR Data Terminal Ready.
9 22 RI Ring Indicator (Becomes
active when modem detects
ringing signal from PSTN

Null Modems
A Null Modem is used to connect two DTEs together. This is commonly used
as a cheap way to network games or to transfer files between computers using
Zmodem Protocol, Xmodem Protocol etc.

Figure 1: Null Modem Wiring Diagram


Above is the preferred method of wiring a Null Modem. It only requires 3
wires (TD, RD & SG) to be wired straight through thus is more cost effective
to use with long cable runs. The theory of operation is reasonably easy. The
aim is to make to computer think it is talking to a modem rather than another
computer. Any data transmitted from the first computer must be received by
the second thus TD is connected to RD. The second computer must have the
same set-up thus RD is connected to TD. Signal Ground (SG) must also be
connected so both grounds are common to each computer.

The Data Terminal Ready is looped back to Data Set Ready and Carrier
Detect on both computers. When the Data Terminal Ready is asserted active,
then the Data Set Ready and Carrier Detect immediately become active. At
this point the computer thinks the Virtual Modem to which it is connected is
ready and has detected the carrier of the other modem.

All left to worry about now is the Request to Send and Clear To Send. As both
computers communicate together at the same speed, flow control is not
needed thus these two lines are also linked together on each computer. When
the computer wishes to send data, it asserts the Request to Send high and as
it's hooked together with the Clear to Send, It immediately gets a reply that it
is ok to send and does so.
Notice that the ring indicator is not connected to anything of each end. This
line is only used to tell the computer that there is a ringing signal on the phone
line. As we don't have a modem connected to the phone line this is left
disconnected.

3. Circuit Description
3.1 General Description of the Transceiver Module

Serial communication between two PC’s was earlier done using two separate
IC’s (for TTL to RS-232C and vice versa level conversion) using wireless
radio wave technology. This level conversion required use of three different
voltages, i.e. +12V,-12V and +5V.

Nowadays, circuits use MAXIM Corporation’s IC MAX232, which needs


only a single power supply of 5V for level conversion. Figure1 below shows
the internal functional diagram of MAX232 IC. The communication over the
short distance of 2 to 3 meters is established using infrared diodes as shown in
Figure2. The range could be increased upto 100 meters, using a laser diode
module in place of infrared LEDs.

The laser module used is easily available as laser pointer(having about 5mW
power output). It is to be used with its three battery cells removed and positive
supply terminal soldered to the casing and 0V to the contact inside the laser
module.

We need to assemble the two prototypes on PCBs or breadboards and connect


them to COM-1(or COM-2) port of each PC. Point the laser beam of one
module to fall on the photodiode of the module connected to the other PC, and
vice versa.

TABLE 1
MAX232 Conversion Levels
TTL +5V to -9V RS232
TTL 0V to +9V RS232
RS 232 +9V to 0V TTL
RS 232 -9V to 5V TTL

>>DIAGRAM

3.2 Transmitter:
Data signals transmitted through Pin 3 of 9-pin(or Pin 2 of 25-Pin) ‘D’
connector of RS232 COM port are sent to pin 8 of MAX232 and it converts
these EIA(Electronic Industry Association) RS232C compatible levels of ±9V
to 0/5V TTL levels as given in Table1. The output pin 9 of MAX232 IC
drives the pnp transistor SK100 and powers the IR LEDs. Output pin 9 also
drives an LED indicator (LED2) during the positive output at its pin 9. At
logic ‘0’ output at pin 9, LED 2 goes ‘off’, but drives the pnp transistor
through a bias resistor of 1Kilo-ohm(R5) , to switch ‘on’ IR LED1 and IR
LED2 and also a visible LED3.Since very low drive current is used, use of
high efficiency visible LEDs, which light up at 1mA, is needed. The electrical
pulses sent by the COM port are now converted into corresponding modulated
pulses of IR light.

3.3 Receiver
The IR signals are detected by a photodiode (D1). (A photodiode is reverse
biased and breaks down when IR light falls on its junction).The detected TTL
level (0/5V) signals are coupled to pin 10 of MAX232 IC. These TTL levels
are converted to ±9V levels internally (as per Table1) and output at pin 7.

TABLE 2

DB 9 DB25 Signal Description


Pin Pin direction
1 8 In DCD(data carrier
detect)
2 3 In RX(receiver
data)
3 2 Out TX(transmit
data)
4 20 Out DTR(data
terminal ready)
5 7 - GND(signal
ground)
6 6 In DSR(data set
ready)
7 4 Out RTS(request to
send)
8 5 In CTS(clear to
send)
9 22 In RI(ring
indicator)
A visible LED1 at pin 7 of MAX232 IC indicates that the signals are being
received. Pin 7 is also connected to pin 2 (receiver pin) of 9-pin (or pin 3 of
25-pin) ‘D’ connector used for the serial port in the PC,so that the data may be
read. The optical signals received by the photo-diode are in fact converted to
electrical pulses and both PCs ‘think’ that there is a null modem cable
connected between them.Table 2 shows the correspondence between the
various pins of a 9-pin (or 25-pin) ‘D’ connector of serial port of PC. In some
PCs,the serial port is terminated into a 9-pin ‘D’ connector and in some others
into a 25-pin ‘D’ connector.

3.4 Testing

Assemble two transceiver modules and connect each of them, using 3-core
cables, to COM-1 ports of the two PCs. Place them 15 to 20 cms apart so that
the IRLEDs of each module face the photodiode detector of the other.
Power ‘on’ both the circuits to operate at stabilized 5V DC. We may
alternately use a 7805 regulator IC with a 9V DC source to obtain regulated
5V supply. Check if the MAX232 IC is working properly by testing pin 2 for
9 to 10V positive supply and pin 6 for -9V supply.MAX232 (refer figure 1)
uses 1µF, 25V capacitors C1-C5 as a charged pump to internally generate
±9V from 5V supply. Generally defective MAX232 ICs will not show a
voltage generation of +9V and -9V at pins 2 and 6, respectively. Replace ICs,
if required. Although 1µF, 25V capacitors are recommended in the data sheet,
the circuit works well even with 10µF, 25V capacitors, which are easily
available. With both the PCs and supply to the transceiver modules ‘on’,
throw some light with the torch on the photodiode. LED 1 should flicker at the
burst frequency rate of the transmitter. This proves that the IR signals are
being detected by photodiodes and converted intoRS232-compatible levels by
the MAX232 and output at pin 7 of MAX232 ICs is available for the PC to
read the pulses.
To test the transmitter side, disconnect the module from COM-1(or COM-2)
port of the PC,and with the device powered ‘on’,use a short jumper wire from
+5V and touch it at pin 8 of MAX232 IC to simulate a positive pulse. LED 2
should turn ‘off’ and IRLEDs and LED 3 should turn ‘on’ if the wiring is
correct.IRLEDs would also be glowing, although one cannot see them
glowing.
Remove the link wire from +5V to pin 8 of MAX232 IC and connect back
the ‘D’ connector to PC’s COM-1 (or COM-2) port.
Run simple communication software like PROCOM or TELIX. Set the baud
rate, parity, bits per character and stop bits to 9600,n, 8, 1 respectively, and
send a few characters from the keyboard through COM-1(or COM-2) port.
We should be able to see LED3 flickering for a few seconds, indicating data
transmission. Connect both PCs to the circuits and set the software to chat
mode. We should be able to transfer data between the PCs, as if a cable was
connected.
Depending on the sensitivity setting and power/angle of IR LEDs, increase the
distance to about 35cms (12 inches) and try again for better distance. For more
power, use metal-can type IRLEDs and reduce the value of register R7 for
more drive current. If we use a laser beam as explained earlier, remove the
IRLEDs and the device will track upto 10mtrs without any data loss.
NOTE:

1. Aligning the laser beam is a problem, but once it is aligned carefully and
fixed, the data transmission and reception would be error free. Transmitter and
receiver alignment routines have been included in this software program to aid
in the alignment process.
2. Ordinary clear photodiodes should be used for detector. If we use dark-red
plastic-encapsulated diodes, we may have problems, as these react only to
very bright natural light or infrared light.

Some problems are faced with red-encapsulated diodes as well as Darlington


detectors (when used) due to the various light sources in the room causing
corruption of the data. This can be avoided by certain modifications in the
circuit as shown in figure 3. By doing so, we can flawlessly transfer files,
from about 5-meters distance, between two PC’s. We included a 38kHz
modulator in the transmitter section and used IR receiver module, which
includes a band pass filter and demodulator for 38kHz carrier.

>>DIAGRAM

The base addresses for the serial communication ports in a PC are shown in
Table 3.
Table 3
DB 9 Pin DB25 Pin Signal direction Description
1 8 In DCD(data carrier detect)
2 3 In RX(receiver data)
3 2 Out TX(transmit data)
4 20 Out DTR(data terminal ready)
5 7 - GND(signal ground)
6 6 In DSR(data set ready)
7 4 Out RTS(request to send)
8 5 In CTS(clear to send)
9 22 In RI(ring indicator)

The offset addresses of the registers used in serial communication are given in
Table 4.

Table 4
8250 registers: Offset from base address
Offset LCR Bit 7 Meaning Read/Write
0 0 Transmitter holding Write
register(THR)
[when written to port]
0 0 Receiver data register(RDR) Read
[when read from port]
0 1 Baud rate divisor-low Read/Write
byte(BRDL)
1 0 Interrupt enable register(IER) Read/Write
1 1 Baud rate divisor-high Read/Write
byte(BRDL)
2 × Interrupt identification Read only
Register(IIR)
3 × Line control register(LCR) Read/Write
4 × Modem control register(MCR) Read only
5 × Line status register(LSR) Read only
6 × Modem status register(MSR) Read only
For serial port initialization, the program makes use of BIOS interrupt 14H
service 00H. It initializes the serial port pointed to by the contents of dx
register (0 for COM-1 and 1 for COM-2 port). The contents of ‘al’ register
initialize the specific communication port for baud rate, parity, stop-bit code,
and character-size code as per table 5 (and expanded in table 6 through 9
respectively).
Table 5
AL Register Bits

Bit
7 6 5 4 3 2 1 0 Use
× × × . . . . . Baud rate code
. . . × × . . . Parity code
. . . . . × . . Stop-bit code
. . . . . . × × Character-size code

Table 6
Baud rate

Bit Valu Bits per second


7 6 e
5
0 0 0 0 110
0 0 1 1 150
0 1 0 2 300
0 1 1 3 600
1 0 0 4 1200
1 0 1 5 2400
1 1 0 6 4800
1 1 1 7 9600

Table 7
Parity
Bit Valu Meaning
4 e
3
Table 8 0 0 0 None
Stop bits 0 1 1 Odd parity
1 0 2 None
1Bit1 Valu
3 Meaning
Even Parity
2 e
0 0 One
0 1 Two

Table 9
Character Size

Bit Valu Meaning


1 0 e
0 0 0 Not used
0 1 1 Not used
1 0 2 7-bit
The transmitter
1 1 3 8-bit
holding register (THR) and receiver data register (RDR) both at address
Base+0 (the former being write (only) and latter being read (only)) act as
buffers during transmission and reception, respectively, of a character. The
other most important register which used frequently is the line status register
(LSR) at Base+5 (i.e. 03FDH for COM-1 port or 02FDH for COM-2 port).
Meaning of each of the bits of line status register is given in table 10. Its bit 0
is set when a byte is logged in the receiver buffer register and cleared when
the byte when the byte is read by the CPU. Its bit 6 is set when both the
transmitter holding register and the transmitter shift register are empty.

The software program can be used for COM-1 port initialization for
600, or 1200, or 2400, or 4800 bauds, etc. by changing the contents
of ‘al’ register in the initialization function to 63H, or 83H, or A3H,
or C3H.

You might also like