PC Interfacing Fourth Level Lecture Three: Serial (RS232) Port Interface
PC Interfacing Fourth Level Lecture Three: Serial (RS232) Port Interface
PC Interfacing Fourth Level Lecture Three: Serial (RS232) Port Interface
Fourth Level
Lecture Three
Goals:
Up-on completing this lecture, the student should be able to:
Fig. 1.6: the format of a serial data transmission produced by the UARTs
The beginning of a data transmission is indicated by pulling the line to the logic
low state for 1 bit time. This bit is the start bit. The data bits are then sent out one after
another. The number of the data bits can be 6, 7 or 8. Following the data bits comes
the parity bit which is used to check transmission errors occurred during the data
transmission. The parity check can be ODD, EVEN or NONE. The odd and even
parities indicate that the total number of ones ('1') in the transmitted serial data is an
odd number or an even number. It is only reliable to detect single-bit errors. Errors
occurred to several bits cannot be detected. The last bits are the stop bits, which pull
the data line to the high state for at least 1 bit time to indicate the end of the data
transmission. The number of the stop bits can be 1, 1.5 and 2 bits.
The rate at which the data bits are sent is measured by the baud rate. The
standard baud rates for an RS232 serial port are 110, 150, 300, 600, 1200, 2400, 4800,
9600 and 19200. Knowing the baud rate, the number of bytes to be transmitted per
second can be calculated. For example, if a serial data has 8 data bits, no parity check
and 1 stop bit, the total length of serial data bits is 10. The transfer rate for characters
is the baud rate divided by 10. A baud rate of 9600 will transfer 960 characters per
second. What is the effects baud-rate on error rate? (H.W.)
A specially designed electronic device which generates and receives the
asynchronous serial data is called the Universal Asynchronous Receiver/Transmitter
(UART). The serial data transmission format is generated by the transmitting UART.
The UARTS have a TTL voltage level. In order to achieve a long distance
communication, the TTL voltage level is converted to higher voltage level (logic 0 = -
12 to - 3V, logic 1 = +3V to +12V). This is achieved by using dedicated RS232
drivers/receivers. All drivers/receivers have an inverting action.
UART is responsible for sending and receiving a sequence of bits.
At the output of a UART these bits are usually represented by logic
level voltages. These bits can become RS232.
RS232 specifies voltage levels. Notice that some of these voltage
levels are negative, and they can also reach ±15V.
A microcontroller UART cannot generate such voltages levels by
itself. This is done with help of an additional component: RS232 line
driver. A classic example of an RS232 line driver is MAX232. This IC has
a charge pump, which generates ±10V from +5V.
3. RS232 port connector and connections:-
A standard RS232 interface is a 25-pin interface housed in a 25-pin or a 9-pin
D-type male connector. Figure 1.7 gives the pin-out and functions of connectors.
Fig. 1.7: pin-out and function of the RS232 connectors and computers
Two types of RS232 link between a computer and an external device are shown
in Figure 1.8. The arrows show the direction of data flow. Figure 1.8(a) is known as
the null modem. Figure 1.8(b) shows a connection using only three lines. One line is
for transmitting data and the other for receiving data. The connection is arranged so
that the transmitting line of the first device is connected to the receiving line of the
second device.
A computer can have up to four RS232 interfaces installed. They are labeled
COM1 to COM4. Each COM port is associated with a UART inside the computer.
RS232 driver/receivers
The RS232 output control signals (-RTS and -DTR) and input status signals (-
CTS,-DSR) are processed by the UART in an inverted form. The serial data signal SIN
and SOUT are in a non-inverting form. The UART produces the TT'L/CMOS voltage
levels only. RS232 line drivers/receivers are connected between the UART and the
RS232 connector. The drivers convert the TTL voltage to the RS232 voltage level and
the receivers convert the RS232 level to the TTL level. All the drivers/receivers have
inverting action. The logic structure of the RS232 port is shown in Figure 1.10.
Software control
a-How to obtain the base address of COM port
-QBASIC
-TP6
-WINDOWS
b-How to transmit and receive serial data
-Printer commands &BIOS interrupt calls
As the bit-rate increases, the duration of the frame decreases. Hence the total energy
of the bit goes down. While its probability of being hit by interference goes up.
Choosing the right settings can counter-combat that.
For example, Parity bit and 5 data bits with 110 symbols/second provide the best error-
tolerance that the UART can provide.
While, no carry bit with 8 data bits and 19200 symbols/second provides the fastest
rate possible.
Summary:
1- The serial interface uses a different concept of cascading the data to
be sent.
2- There are many settings which can be manipulated to counter-act the
noise levels vs the required transmission rate
3- The null modem is a simple, yet effective configuration for data
inferface.
4- There is a difference between UART and RS232 although both
support the same frame format, however they differ in the used voltage.
ed.
Quesions:
1- What is the principle of operation of the serial port?
2- What is the difference between RS232 and UART?
3- What setting(s) give the best immunity against jamming?
4- What setting(s) give the highest througput?
5- What is the null modem?
6- Design a circuit to send the data of a 10 bit A/D using the serial port,
write the supporting code as well.