CP/PC364 Data Communications and Networks
Laboratory
Universal Asynchronous Receiver Transmitter (UART)
Overview
This week's laboratory investigates
RS-232
(or EIA 232) communication.
Background
The RS-232 protocol has been around since 1962. Originally designed
to basically connect a single "smart" device to a single "dumb"
device, it is now still very commonly used to connect sensors to
microprocessors or microcontrollers, and so will remain relevant for
the forseable future. It's also one of the simplest serial protocols,
and so it's easy to study.
The Arduino board has a UART built-in, so it can be used to study
RS-232 communications.
Note: The UART pins on the Arduino will be at
TTL levels, not at acceptable RS-232 levels.
Objectives
- Become familiar with the hardware layer of UART.
Equipment
- Arduino Uno board, with linksprite LCD display
Exercise
- Connect the Arduino to the oscilloscope, using one
channel for
the TxD signal. (Since the communication is only being
tested in one direction,
only one serial signal matters.)
- Use
SimpleSerialCharOut
to repeatedly send a character
out from the UART.
- Watch the signal on the scope and identify the transmission of
a single character. Sketch the signal or print
it. This will be needed for the postlab.
- On the sketch, identify the start bit(s), stop bit(s),
and the character bits to show how the character can be
decoded from the signal. If you're not sure which end of the
pattern is the beginning and which is the end, change the
character
being sent to clarify.
- On the sketch, show the time scale and explain how it relates
to the baud rate. (i.e. Identify how the time for one bit is
determined from the baud rate.)
- The built-in UART on the Arduino board is also used for USB
communication with the board, so using it for other things can
cause problems.
There is a library for software serial ports which allows you
to use other pins to create a UART.
The
SimpleSoftwareSerialCharOut example makes the changes to the
previous example so that you can now change the pins to any not
used by the shield using a software serial port.
Load the software serial sketch and change the pins to demonstrate
that ability.
- Combine this sketch with the LCD shield sketch so that pressing
different buttons on the display shield will change the character
being transmitted.
-
Show your pin assignments on the diagram.
Demonstrate and explain your results to the
lab instructor
-
Look at the postlab requirements. See what changes, if any, are
required to your signal image to meet the requirements, and make
them if time permits.
Wilfrid Laurier University
© 2019 Wilfrid Laurier University