Download Serial Communication Basics

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Telecommunications engineering wikipedia , lookup

Multidimensional empirical mode decomposition wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Transcript
Khaled A. Al-Utaibi
[email protected]









Introduction
Serial Communication
Serial Communication Methods
Asynchronous Transmission Method
Synchronous Transmission Method
Half and Full-Duplex Transmission
Data Transfer Rate
RS232 Standards
Arduino Uno Board Connection to RS232

Computers transfer data in two ways (See Figure 1):

In parallel data transfers, often eight or more lines
(wire conductors) are used to transfer data to an I/O
device.
−(1) parallel and
−(2) serial.
−Examples: printers and hard disks;

In serial communication, the data is sent one bit at a
time, in contrast to parallel communication, in which
the data is sent a byte or more at a time.
−Examples: mouse, monitor, dial-up modem, etc.

The Arduino Uno Board has serial communication
capability built into it, thereby making possible fast
data transfer using only a few wires.
Figure 1: Parallel versus Serial Communications.

For serial data communication to work, the byte
of data must be converted to serial bits using a
parallel-in-serial-out shift register; then it can
be transmitted over a single data line.

This also means that at the receiving end there
must be a serial-in-parallel-out shift register to
receive the serial data and pack them into a byte.

Serial data communication uses two methods:
−(1) Asynchronous and
−(2) Synchronous.


Special IC chips are used for serial data
communications.
These chips are commonly referred to as
− UART (universal asynchronous receiver-transmitter) and
−USART (universal synchronous-asynchronous receivertransmitter). The

The Arduino Uno Board chip has a built-in UART.

Asynchronous Method (See Figure 2):
−This method transfers a single byte at a time.
−It uses start and stop bits to signify the beginning and ending
of the byte to be transmitted.
−For example, "0100 0001" would become "1 0100 0001 0". The
start and stop bits are in bold
−The start bit tells the receiver that a data byte is coming.
−The stop bit tells the receiver that the data byte has ended.
−The start and stop bits must be of opposite polarity to allows
the receiver to recognize when the second byte of information
is being sent.
−Each one of the transmitter and receiver has its own internal
clock (they are not synchronized).
−Transmitter sends bits on the falling edge of the clock.
−Receiver reads bits on rising edge of the clock.
−Many asynchronous protocols send LSB first.
Figure 2: Asynchronous Transmission.

Synchronous Method (See Figure 3):
−This method transfers a block of data (characters) at a time.
−Synchronous transmission uses no start and stop bits.
−Instead it synchronizes transmission speeds at both the
sender and receiver using clock signal(s) built into each
component.
−A continual stream of data is then sent between the two
nodes.
−Transmitter sends bits on falling edge of the synchronized
clock.
−Receiver reads bits on rising edge of the synchronized clock.
−Many synchronous protocols send MSB firs.
Figure 3: Synchronous Transmission.

Based on the direction of transmission, we have 2 main
types of serial communication (See Figure 4):
−(1) Simplex Transmission: the data is transmitted in on
direction.
−(2) Duplex Transmission: the data can be transmitted and
received.

Duplex transmissions can be half- or full-duplex,
depending on whether or not the data transfer can be
simultaneous.
−If data is transmitted one way at a time, it is referred to as halfduplex.
−If the data can go both ways at the same time, it is full-duplex.

Full-duplex requires two wire conductors for the data
lines, one for transmission and one for reception in order
to transfer and receive data simultaneously.
Figure 4: Simplex, Half- and Full-Duplex Transmissions.






The rate of data transfer in serial data
communication is stated in bps (bits per second).
Another widely used terminology for bps is baud
rate.
The data transfer rate of a given computer system
depends on communication ports incorporated into
that system.
For example, the early IBM PC/XT could transfer data
at the rate of 100 to 9600 bps.
In recent years, however, Pentium-based PCs
transfer data at rates as high as 56K bps.
It must be noted that in asynchronous serial data
communication, the baud rate is generally limited to
100,000 bps.







To allow compatibility among data communication equipment
made by various manufacturers, an interfacing standard called
RS232 was set by the Electronics Industries Association (EIA) in
1960.
Today, RS232 is the most widely used serial I/O interfacing
standard.
This standard is used in PCs and numerous types of equipment.
However, since the standard was set long before the advent of
the TTL logic family, its input and output voltage levels are not
TTL-compatible.
In RS232, a 1 is represented by −3 to −25 V, while a 0 bit is +3 to
+25 V, making −3 to +3 undefined.
For this reason, to connect any RS232 to a microcontroller
system we must use voltage converters such as MAX232 to
convert the TTL logic levels to the RS232 voltage levels, and vice
versa.
MAX232 IC chips are commonly referred to as line drivers.



The original RS232 cable, commonly referred to as the DB25 connector, contains 25 pins.
Since not all the pins are used in PC cables, IBM
introduced the DB-9 version of the serial I/O standard,
which uses 9 pins only, as shown in Table 1.
The DB-9 pins are shown in Figure 5.
Table 1: IBM PC DB-9 Signals
12345
6789
Figure 5: DB-9 9-Pin Connector

Current terminology classifies data
communication equipment into two types (See
Figure 6):
−(1) DTE (data terminal equipment): refers to terminals
and computers that send and receive data.
−(2) DCE (data communication equipment): refers to
communication equipment, such as modems, that are
responsible for transferring the data.
Figure 6: DTE and DCE Equipments
Figure 6: DTE and DCE Equipments


The simplest connection between a PC and
microcontroller requires a minimum of three pins,
TxD, RxD, and ground, as shown in Figure 7.
Notice in the figure that the RxD and TxD pins are
interchanged.
PC (DTE)
Microcontroller (DTE)
Figure 7: Connection between PC and microcontroller






The x86 PCs (based on x86 microprocessors) used to
have two COM ports.
Both COM ports were RS232-type connectors.
The COM ports were designated as COM 1 and COM 2.
In recent years, one of these has been replaced with
the USB port, and COM 1 is the only serial port
available, if any.
We can connect Arduino Uno Board serial port to the
COM 1 port of a PC for serial communication
experiments.
In the absence of a COM port, we can use COM-to-USB
converter module.



In this part, the details of the physical
connections of the Arduino to RS232 connectors
are given.
As stated in previous slides, the RS232 standard
is not TTL-compatible.
Therefore, it requires a line driver such as the
MAX232 chip to convert RS232 voltage levels to
TTL levels, and vice versa.


The 8051 has two pins that are used specifically
for transferring and receiving data serially.
These two pins are called TxD and RxD and are
part of the port 3 group (P3.0 and P3.1).
−Pin 11 (P3.1) is assigned to TxD and
−Pin 10 (P3.0) is designated as RxD.


These pins are TTL-compatible; therefore, they
require a line driver to make them RS232
compatible.
One such line driver is the MAX232 chip.





The RS232 is not compatible with today’s
microprocessors and microcontrollers.
Therefore, we need a line driver (voltage converter) to
convert the RS232’s signals to TTL voltage levels that will
be acceptable to the 8051’s TxD and RxD pins.
One example of such a converter is MAX232 from Maxim
Corp
The MAX232 converts from RS232 voltage levels to TTL
voltage levels, and vice versa.
The MAX232 has two sets of line drivers for transferring
and receiving data, as shown in Figure 8.
−The line drivers used for TxD are called T1 and T2, while
−The line drivers for RxD are designated as R1 and R2.

In many applications, only one of each is used.
Figure 8: MAX232 Chip and its interface to 8051 and RS232.

Notice in MAX232 that the T1 line driver has a designation of
T1in and T1out on pin numbers 11 and 14, respectively.
− The T1in pin is the TTL side and is connected to TxD of the
microcontroller,
− The T1out is the RS232 side that is connected to the RxD pin of the
RS232 DB connector.

The R1 line driver has a designation of R1in and R1out on pin
numbers 13 and 12, respectively.
− The R1in is the RS232 side that is connected to the TxD pin of the
RS232 DB connector, and
− The R1out is the TTL side that is connected to the RxD pin of the
microcontroller.



Notice the null modem connection where RxD for one is TxD
for the other.
MAX232 requires four capacitors ranging from 1 to 22 μF.
The most widely used value for these capacitors is 22 μF.