Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

MICRO PROJECT REPORT

ON
Interconnect two PCs using RS 232 Cable. Write the
step by step Procedure to transfer a file from one
computer to another through RS232 link and
implement.

FOR COURSE
Computer Networking and Data
Communication (22634)

Class-Ty-Ej
S u b m i t t e d b y K a i v a l y a Vi s h a l
Sankpal
Index

SR.NO. CONTENT PAGE NO.

1
Rationale 8

2 Course Outcomes Achieved 8

3 Literature Review 9

4 Actual Methodology Followed 18

5 Actual Resources Used 18

6 Outputs of the Micro project 18

7 Skills Developed / learning outcome/Application of this 20


Micro- Project
8 Applications of this Project 20

9 Progress Report 21
Micro - Project Report

1.0 Rationale:

A Report has to be developed to show an endeavor has been made in to bring forth a simple, easy
and novel way of implementing PC-to-PC communication via RS-232 serial port using C language.
Implementing the asynchronous serial communication this way does not require the reader to be
familiar with serial port registers and their programming, and there is no need for constructing user-
defined functions for setting the baud rate and format of data, parity and stop bits. Moreover, the
speed of data transfer is also greater and the function used for serial programming along with its
arguments makes its purpose self-explanatory.

A PC can accommodate, at most, four serial ports but usually a PC has two RS-232 serial ports,
COM1 and COM2. Any one of the serial ports can be used in each PC for linking them together. A
serial port at the back of a PC is in the form of 9-pin (or sometimes 25-pin) D-type male connector.
Table 1 shows pin configurations of 9-pin D-type male connector, which is depicted in Figure 1

In recent years, a considerable amount of effort has been devoted, both in industry and
academia, towards the development of advanced methods of data transmission theory with
focus on its practical implementation in various fields of human activity such as space control,
robotics, and control applications.
One of the oldest, yet popular communication protocols that are used in industries and
commercial products is the RS232 Communication Protocol. The term RS232 stands for
"Recommended Standard 232" and it is a type of serial communication used for transmission of
data normally in medium distances. It was introduced back in the 1960s and has found its way into
many applications like computer printers, factory automation devices etc. Today there are many
modern communication protocols like the RS485, SPI, I2C, CAN etc. you can check them out if
interested. In this article, we will understand the basics of the RS232 Protocol and how it works

1. Course outcomes achieved:

1. Maintain wired computer network topologies.


2. Maintain PLC based process control systems
3.0 Literature Review:

What is a serial communication?

Serial communication
In telecommunication, the process of sending data sequentially over a computer bus is called as
serial communication, which means the data will be transmitted bit by bit. While in parallel
communication the data is transmitted in a byte (8 bit) or character on several data lines or buses
at a time. Serial communication is slower than parallel communication but used for long data
transmission due to lower cost and practical reasons.
Data transfer within a system is generally in parallel. All the bits of the data word are transferred
in parallel at the same instant. In some cases, particularly in transferring data over long distances,
it is preferred to transfer the data in serial form. The data word from a transmitting system is
converted to stream of bits by parallel to serial conversion, and one bit at a time is transferred on
a single line to a receiving system. At the receiving end, the word is reconstructed by serial to
parallel conversion. The speed of data transfer in serial communication is specified by baud.

Serial Communication

Parallel Communication
Example to understand:
Serial communication – you are shooting a target using machine guns, where bullets reach one
by one to the target.
Parallel communication - you are shooting a target using a shotgun, where many number of the
bullets reach at the same time.

The baud unit is named after Jean Maurice Emile Baudot, who was an officer in the French
Telegraph Service. He is credited with devising the first uniform-length 5-bit code for characters
of the alphabet in the late 19th century. What baud really refers to is modulation rate or the
number of times per second that a line changes state. This is not always the same as bits per
second (bps).
If we connect two serial devices together using direct cables then baud and bps are, in fact, the
same. But when modems are in question, this isn’t the case.

Modes of Data Transfer in Serial Communication:


➢ Asynchronous Data Transfer serial communication - The mode in which the bits of data
are not synchronized by a clock pulse. Clock pulse is a signal used for synchronization of
operation in an electronic system. Asynchronous data transfer is used for low speed
communication, typically at standard rates such as number (4) of 1s, the parity is made 0 for the
even parity system and 1 for the odd parity system.
➢Synchronous Data Transfer serial communication - The mode in which the bits of data are
synchronized by a clock pulse.

Characteristics of Serial Communication:

Baud rate is used to measure the speed of transmission. It is described as the number of bits passing
in one second. For example, if the baud rate is 200 then 200 bits per Sec passed. In telephone lines,
the baud rates will be 14400, 28800 and 33600.

Stop Bits are used for a single packet to stop the transmission which is denoted as “T”. Some
typical values are 1, 1.5 & 2 bits.

Parity Bit is the simplest form of checking the errors. There are of four kinds, i.e., even odd, marked
and spaced. For example, If 011 is a number the parity bit=0, i.e., even parity and the parity=1, i.e.,
odd parity.
Error Detection in asynchronous communication is detected in three ways, by checking parity error,
framing error and overrun error. The parity error informs that the received data has wrong parity,
indicating that the noise was encountered during reception. The framing error informs that the
received data does not have the start and stop bits at their proper places. The overrun error indicates
that a new data has been received before the previous data could be taken away

What is RS232?
RS232C “Recommended Standard 232C” is the recent version of Standard 25 pin whereas, RS232D
which is of 22 pins. In new PC’s male D-type which is of 9 pins.
RS232 is a standard protocol used for serial communication, it is used for connecting computer and
its peripheral devices to allow serial data exchange between them. As it obtains the voltage for the
path used for the data exchange between the devices. It is used in serial communication up to 50
feet with the rate of 1.492kbps. As EIA defines, the RS232 is used for connecting Data
Transmission Equipment (DTE) and Data Communication Equipment (DCE).

RS323 Protocol

Universal Asynchronous Data Receiver &Transmitter (UART) used in connection with RS232 for
transferring data between printer and computer. The microcontrollers are not able to handle such
kind of voltage levels, connectors are connected between RS232 signals. These connectors are
known as the DB-9 Connector as a serial port and they are of two type’s Male connector (DTE) &
Female connector (DCE).

How RS232 Works?


RS232 works on the two-way communication that exchanges data to one another. There are two
devices connected to each other, (DTE) Data Transmission Equipment& (DCE) Data
Communication Equipment which has the pins like TXD, RXD, and RTS& CTS. Now, from DTE
source, the RTS generates the request to send the data. Then from the other side DCE, the CTS,
clears the path for receiving the data. After clearing a path, it will give a signal to RTS of the DTE
source to send the signal. Then the bits are transmitted from DTE to DCE. Now again from DCE
source, the request can be generated by RTS and CTS of DTE sources clears the path for receiving
the data and gives a signal to send the data. This is the whole process through which data
transmission takes place.
RS/EIA-232
Short for Recommended Standard-232, a standard interface approved by EIA (Electronic Industries
Association) for connecting serial devices, specifies signal voltages, signal timing, signal function, a
protocol for information exchange and mechanical connectors. To ensure reliable communication
and to enable the interconnection of equipment produced by different manufacturers, the interfacing
standard RS-232 was set by EIA in 1960. Since then it has gone through a number of modifications,
including a change in its name. RS-232A, RS-232B, RS-232C, EIA-232D and EIA-232E are the
subsequent versions of this standard. The standard has been referred to as RS-232 (instead of EIA-
232) throughout this article due to its popularity

Electrical Specifications
Let us discuss the electrical specifications of RS232 given below:

• Voltage Levels: RS232 also used as ground & 5V level. Binary 0 works with voltages up to +5V
to +15Vdc. It is called as ‘ON’ or spacing (high voltage level) whereas Binary 1 works with
voltages up to -5V to -15Vdc. It is called as ‘OFF’ or marking (low voltage level).
• Received signal voltage level: Binary 0 works on the received signal voltages up to +3V to +13
Vdc & Binary 1 works with voltages up to -3V to -13 Vdc.
• Line Impedances: The impedance of wires is up to 3 ohms to 7 ohms & the maximum cable
length are 15 meters, but new maximum length in terms of capacitance per unit length.
• Operation Voltage: The operation voltage will be 250v AC max.
• Current Rating: The current rating will be 3 Amps max.
• Dielectric withstanding voltage: 1000 VAC min.
• Slew Rate: The rate of change of signal levels is termed as Slew Rate. With its slew rate is up to
30 V/microsecond and the maximum bitrate will be 20 kbps.

The ratings and specification changes with the change in equipment model.

The RS-232 standard supports two types of connectors – a 25-pin D-type connector (DB-25) and a
9-pin D-type connector (DB-9). The type of serial communications used by PCs requires only nine
pins, so either type of connector will work equally well. Since modern PCs employ only 9-pin D-
type connectors, only this configuration has been discussed in this article, including connections
and programming.

In RS-232 parlance, the device that connects to the interface is called Data Communications
Equipment (DCE) and the device to which it connects is called Data Terminal Equipment (DTE).
This standard was mainly designed to connect DTE that is sending and receiving serial data (such as
a computer) and DCE that is used to send data over long distances (such as a modem).
Table 1: Pin functions of a 9-pin
connector of RS-232
serial port
Pin number Description
1 DCD (data carrier detect)
2 RxD (receive data)
3 TxD (transmit data)
4 DTR (data terminal ready)
5 GND (signal ground)
6 DSR (data set ready)
7 RTS (request to send)
8 CTS (clear to send)
9 RI (ring indicator)

For example: The signals set to logic 1, i.e., -12V. The data transmission starts from next bit and to
inform this, DTE sends start bit to DCE. The start bit is always ‘0’, i.e., +12 V & next 5 to 9
characters is data bits. If we use parity bit, then 8 bits data can be transmitted whereas if parity
doesn’t use, then 9 bits are being transmitted. The stop bits are sent by the transmitter whose values
are 1, 1.5 or 2 bits after the data transmission.

Mechanical Specification
For mechanical specifications, we have to study about two types of connectors that is DB-25 and
DB-9. In DB-25, there are 25 pins available which are used for many of the applications, but some
of the applications didn’t use the whole 25 pins. So, the 9 pin connector is made for the convenience
of the devices and equipments.
Now, here we are discussing the DB-9 pin connector which is used for connection between
microcontrollers and connector. These are of two types: Male Connector (DTE) & Female
Connector (DCE). There are 5 pins on the top row and 4 pins in the bottom row. It is often called
DE-9 or D-type connector.

Pin Structure of DB-9 Connector:

RS232 or DB9 male connector


RS232 or DB9 female connector

Pin Description DB-9 Connector:

PIN No. Pin Name Pin Description

1 CD (Carrier Detect) Incoming signal from DCE

2 RD (Receive Data) Receives incoming data from DTE

3 TD (Transmit Data) Send outgoing data to DCE

4 DTR (Data Terminal Ready) Outgoing handshaking signal

5 GND (Signal ground) Common reference voltage

6 DSR (Data Set Ready) Incoming handshaking signal

7 RTS (Request to Send) Outgoing signal for controlling flow

8 CTS (Clear to Send) Incoming signal for controlling flow

9 RI (Ring Indicator) Incoming signal from DCE


To distinguish between DTE and DCE:
• Measure the DC voltages between (DB-9) pins 3 and 5 and between pins 2 and 5. Be sure that
the black lead is connected to pin 5 (GND) and the red lead to whichever pin you are measuring.
• If the voltage on pin 3 (TxD) is more negative than -3V, then it is a DTE, otherwise it should be
near zero volts.
• If the voltage on pin 2 (RxD) is more negative than -3V, then it is a DCE.
• If both pins 3 and 2 have a voltage of at least 3V then either you are measuring incorrectly, or
your device is not a standard RS-232 device. Call tech- nical support
• In general, a DTE provides a voltage on TxD, RTS & DTR, whereas a DCE provides voltage on
RxD, CTS, DSR & DCD.

What is Handshaking?
How can a transmitter, transmits and the receiver receives data successfully. So, the Handshaking
defines, for this reason.
Handshaking is the process which is used to transfer the signal from DTE to DCE to make the
connection before the actual transfer of data. The messaging between transmitter & receiver can be
done by handshaking.

There are 3 types of handshaking processes named as:-


No Handshaking:
If there is no handshaking, then DCE reads the already received data while DTE transmits the next
data. All the received data stored in a memory location known as receiver’s buffer. This buffer can
only store one bit so receiver must read the memory buffer before the next bit arrives. If the receiver
is not able to read the stored bit in the buffer and next bit arrives then the stored bit will be lost.
As shown in below diagram, a receiver was unable to read the 4th bit till the 5th bit arrival and this
result overriding of 4th bit by 5th bit and 4th bit is lost.

NO handshaking example
Hardware Handshaking:
• It uses specific serial ports, i.e., RTS & CTS to control data flow.
• In this process, transmitter asks the receiver that it is ready to receive data then receiver checks the
buffer that it is empty, if it is empty then it will give signal to the transmitter that I am ready to
receive data.
• The receiver gives the signal to transmitter not to send any data while already received data cannot
be read.
• Its working process is same as above described in handshaking.

Software Handshaking:
• In this process, there are two forms, i.e., X-ON & X-OFF. Here, ‘X’ is the transmitter.
• X-ON is the part in which it resumes the data transmission.
• X-OFF is the part in which it pauses the data transmission.
• It is used to control the data flow and prevent loss during transmission.

Description steps
1. Objective – To implement PC-to-PC communication by inputting the data through one port and
receiving the same through another and vice-versa (Turbo C++ version 3.0).
2. Connection diagram – The connection diagram (Figure 3) shows the wiring of the null-modem
that is intended for RS232 asynchronous communications (most PC-based systems). This
configuration is called so because each PC terminal detects as if some modem is connected to it
rather than the other PC
The two PC terminals are connected through TxD, RxD and GND pins. The Data Terminal
Ready (DTR, pin 4) is looped back to Data Set Ready (DSR, pin 6) and Data Carrier Detect
(DCD, pin 1) on both PCs. When DTR is asserted active, then the DSR and DCD immediately
become active. At this moment, the computer thinks the virtual modem to which it is connected
is ready and has detected the carrier of the other modem. The lines Request to Send (RTS, pin 7)
and Clear to Send (CTS, pin 8) have been linked together. When the computer wishes to send
data, it asserts RTS high, which in turn asserts CTS high, meaning thereby that the virtual
modem has the room for storing the data and the computer can send it.
3. Testing – It is usually difficult to work on both PCs when a programmer wishes to check his/her
source code for PC-to-PC communication. The best possible way to overcome this problem is to
use a loopback connector (shown in Figure 4), which enables the programmer to write source-
code for programming serial port with single PC.

A loopback connector usually consists of a connector without a cable and includes internal
wiring to re-route signals back to the sender. When the computer receives data, it will not know
whether the signals it receives come from a remote DCE device set to echo characters, or from a
loopback connector. Using loopback connector, proper operation of the computer’s serial port
can be checked
4. Data transfer procedure
• Connect the two PCs together using the 3-wire link.
• Run the program given in the source code on both PCs.
• Before sending the data, set both the sending and receiving PC terminals to the same baud rate,
and same format of data bits, parity bits and stop bits using the macro (pre-processor directive)
‘SETTINGS’ in the source code.
• When the source code is compiled and run on both PCs, the characters typed in one computer
should appear on the other computer’s screen and vice-versa.
5. Limitations – Here, we are using RS-232 serial asynchronous communication, so the
communication speed is less than that of parallel data transfer, where 8-bit data is sent at a time
rather than bit by bit.
1. Actual methodology followed:
1. The first step was that we finalized our topic with our respective guide.
2. We divided the project work equally between all the members of our group.
3. Then we researched on our topic via google as well as in books
4. Then we collect information related to topic
5. We edited all the information with given respected format
6.And finally we made our report.
7.
5.0 Actual resources used:

Sr. No Name of resource/Material Specifications Qty


1 Personal computer With Internet Connection 1
2 www.google.com 1
3 Microsoft office word Latest Version 1

6.0 Output of the micro project:

Source code

#include<stdio.h>
#include<conio.h>
#include<bios.h>

#define SETTINGS (_COM_9600 | _COM_CHR8 | _COM_NOPARITY |


_COM_STOP1)
/* baud rate = 9600, 8 data bits, no parity bit, 1 stop bit */

void main(void)
{
unsigned in,out,status; int port;

clrscr();
printf(“Select Port(Enter ‘0’ for COM1 and ‘1’ for COM2):”);
scanf(“%d”,&port);
printf(“Press ESC to exit”);
textcolor(YELLOW);
cprintf(“\n\rData Received:”);
_bios_serialcom(_COM_INIT,port,SETTINGS);
for(;;)
{
status=_bios_serialcom(_COM_STATUS,port,0);
if (status & 512);
printf(“\n\t\a Overrun Error”);
if (status & 1024) printf(“\n\t\a Parity Error”);
if (status & 2048) printf(“\n\t\a Framing Error”);
if(status & (512|1024|2048)) /* if any error */ break;
if(status & 256) /* if data ready */
{
if((out=_bios_serialcom(_COM_RECEIVE,port,0) & 255)!=0) putch(out);
}
if(kbhit()) /* if a keystroke is currently available */
{
in=getch(); /* get a character without echoing onto the screen */ if(in==27) /* if ESC */
break;
_bios_serialcom(_COM_SEND,port,in);
}
}
}

Transmission and Receiver Status

Output of Transmission and Receiver Status

Data Transmission Process


1. Skills developed/Learning outcome:
The following skills were developed while performing and developing this micro-project-
✓ Teamwork: Learned to work in a team and boost individual confidence.
✓ Good research skills: Because of this micro project we are able to search in a good way.
✓ Time Management: Timely completion of micro project as scheduled.
✓ Problem-solving: Develop good problem-solving habits.
✓ Technical writing: Preparing a report of the proposed plan and final report.

1. Application of this Micro-Project:

The applications of RS232 Serial Communication include the following

• DNC for CNC


• Automation
• Receipt Printer, POS
• PLC control
• Sensor Data Com.
• Robot, etc.
• RS232 serial communication is used in old generation PCs for connecting the peripheral
devices like mouse, printers, modem etc.
• Nowadays, RS232 is replaced by advanced USB.
• It is also used in PLC machines, CNC machines, and servo controllers because it is far
cheaper.
• It is still used by some microcontroller boards, receipt printers, point of sale system (PoS), etc.

The standard feature of a PC is RS232 because; it is used to connect the printers, modems, data
storage, etc. Though, there are several new growths but RS232 still find its application. The main
reason is the simplicity of the standard. It lets user to communicate straight with serial ports.
There are fields such as automation, laboratory, surveying who have continued the demand for
RS232 due to use of very exclusive but aging equipment's.

It is far cheaper to use RS232 than change the modern automation devices like CNC
equipment's, servo drivers, etc. are programmable by RS232. Serial ports by RS232 are used to
communicate to headless system like a server where no keyboard is mounted during boot. Some
embedded systems employ RS232 serial port to communicate as an another network mode
monitoring.

Useful functions such as file transfer, chatting etc can be implemented. By using hardware
circuitry employing infrared/laser diodes, even wireless PC-to- PC communication can be easily
implemented.

Thus, this is all about tutorial on RS232 Serial Communication and serial interface. We hope that
you have got a better understanding of this concept. Furthermore, any queries regarding this
concept or to implement any communication projects please give your feedback by commenting
in the comment section below.

You might also like