Project 2: Serial Communication and Control
- All components of the project are due by Thursday, March 29th
at 5:00pm. Note that between now and the due date, you have a
midterm exam in the class and Spring break. Please start early
(this is not a single-session project).
- Groups will be composed of 4-5 students
At the end of this project, you should be able to:
- Create simple microcontroller-based circuits,
- Implement in code serial communication protocols for reading
sensors and commanding actuators,
- Write a proportional-derivative controller that connects
sensing to actuation.
Our "helicopters" are 4-rotor X-UFOs that are equipped with their own,
on-board microcontroller circuit that allows you to command the
helicopter remotely and to query the state of a compass (both through
a serial interface). The helis have four dimensions of control:
throttle, roll, pitch, and yaw.
We will have a total of three complete heli systems available for this
project. In addition, there will be two "test systems" that consist
of the on-board microcontroller only. These latter units will allow
you to test your own system's ability to request a compass reading and
to read the response over the serial interface.
For this project, you will be creating a microcontroller circuit and the
associated program to maintain the orientation of helicopter at a
specified compass direction (i.e., you will be doing yaw control).
In brief, your craft must:
- Bring the throttle to a level sufficient for hovering. This is
easy to do in "open-loop" (without sensing) because of the
cables that dangle from the bottom of the craft
- Hover for one minute
- During the hover, the craft must orient to and maintain a
heading that is specified at the time time of your
demonstration (you may recompile and redownload your code to
input the desired heading).
- After the minute of hovering, the throttle must be reduced
slowly so as to bring the craft to a soft landing.
All components are required to receive full credit for the project.
Although the final demonstration will focus on part 5, you should be
prepared to show the functionality of the other components (this could
be as simple as making a quick change to your code so that a different
function is called).
Part 1: Microcontroller Circuit
Create a mega8-based circuit on a solderless breadboard.
- See the bottom of the Atmel
HOWTO for a circuit starting point. This contains
everything that you need to create a programmable mega8
- Connect pin 2 of the mega8 (the "serial receive pin") to the
orange serial line; connect pin 3 (the "serial transmit pin")
to the purple serial line.
- A set of LEDs that will be used to display the current heading
of the craft.
Part 2: Serial Interface
Create a software interface to the craft. Implement the following
See the OU-XUFO hardware
specification for details of the serial interface.
- int16_t get_heading(void) will send the necessary command to
request the current heading from the craft. This function will
then wait for the serial response and return the heading as an
- void set_throttle(uint8_t) will send the necessary
command to set the current throttle level (due to the dangling
wire, this signal is a combination of acceleration and
- void set_yaw(uint8_t) will send the necessary
command to set the current yaw level (this is essentially an
Part 3: Compass Test
- show_heading(void) will
repeatedly query the state of the compass and display the craft heading.
- show_heading_change(void) will repeatedly query the state of the
compass and display the rate of change in the heading.
- show_heading_error(void) will repeatedly query the
state of the compass and display the difference between the
current heading and a specified "desired" heading. Note that
you must handle the "wrap around" case: 5 degrees and 355
degrees are very near each other, but their numeric difference
Part 4: Throttle Test
Create a test function that will slowly ramp the throttle up to a
given level and then slowly bring it down. The craft should lift
gently into the air and (just as gently) return to the ground.
Part 5: Control
Create a proportional-derivative controller that will bring the
craft's heading to a specified orientation. In essence, you will
implement the following:
yaw_command = yaw_center + Kp * (theta_desired - theta_actual) - Kv * theta_derivative_actual
where Kp and Kv are gain parameters that you
must select (start small!), and yaw_center is the yaw
command that corresponds to "no yaw acceleration" (this latter
parameter should be 128).
Note: if you are using different data types (e.g., int and float), you
must take care to cast one in terms of the other before mixing them (see
the AVR programming book on type casting)
What to Hand In
All components of the project are due by Thursday, March 29th at 5:00pm.
- Demonstration/Presentation: All group members must be
- Demonstrate your final product.
- Present your design and implementation (5 minutes).
The group is
responsible for assembling a short presentation
consisting of 3-4 slides (on computer or in printed
form). Describe the design including: your general
approach to solving the problem, the circuit, any
key software algorithms (how the general problems are solved
in code), and the
software organization (describe how the software problem
is split into different separable sub-problems, and how
the different components interact).
- Code: Turn in your documented code to the
project 2 digital dropbox on D2L (text format). Only hand in
one copy of the code per group.
- Group report: Augment your presentation with any details
that do not fit within the allotted time. You may use your
presentation format (e.g., powerpoint) for this report.
Turn in one copy per group.
- Personal report: One submission per person to the
project 2 digital dropbox. State the
relative contribution of you and your group members (in terms of
percentage of effort) (text format only!)
Group grade distribution:
- 40%: Project implementation
- 30%: Demonstration/presentation of working project (to either
of the TAs or the instructor). This demonstration is due at
the same time as the reports
- 30%: Code documentation and group report
Grades for individuals will be based on the group grade, but weighted
by the assessed contributions of the group members.
fagg [[at]] ou.edu
Last modified: Wed Mar 7 10:55:33 2007