Project 2: Heli Control Basics
- All components of the project are due by Tuesday, April 7th
at 5:00pm. Please start early (this is not a single-session project).
- Groups will be composed of 3-4 students.
- Discussion within groups is fine.
- Discussion across groups may not be about the specifics of the solution.
Project Goals
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,
- Convey information about sensors using a set of LEDs
Hardware Overview
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 have a total of three complete heli systems available for this
project. In addition, there are two "test systems" that consist of
the on-board microcontroller only. These latter units allow you to
test your own system's ability to request a compass reading and to
read the response over the serial interface.
Project Overview
By the end of the semester, you will write control code that
commands the robotic heli through a sequence of heading and height
goals. In this project, we take the first step by implementing the
interface between the heli, your own microcontroller-based circuit,
and a human "operator."
In brief, your circuit/microcontroller must be able to:
- Read compass headings from the helicopter.
- Given a goal heading, compute the "error"
between current heading and the goal. The goal heading should
be selected to be equal to the heading of the craft when your
program first starts.
- Given a 1-bit input from a switch, display either the compass
heading or the error using a set of 4 LEDs.
- Estimate the rotation velocity of the craft.
- Display the rotation velocity using another set of 5 LEDs.
Project Components
All components are required to receive full credit for the project.
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/red serial line; connect pin 3 (the "serial transmit pin")
to the purple serial line.
- A set of 4 LEDs that will be used to display the current heading
of the craft.
- Another set of 5 LEDs that will be used to display the heading velocity.
- One input pin that is "pulled up" to +5V using a 10 K-Ohm
resistor. A switch will optionally connect this pin directly to
ground. Connecting to ground will result in a logic "0" on the
pin; disconnecting will result in a logic "1".
Part 2: Serial Interface
Create a software interface to the craft. Implement the following
function.
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
integer in 1/10 of a degree (so "100" means 10 degrees).
Return values must range between -1799 and 1800 (use a
left-handed coordinate system to be consistent with the compass).
Part 3: Sensor Processing and Display
Implement the following helper functions:
- int16_t compute_error(int16_t goal, int16_t heading)
returns the error between the current heading and the goal.
Specifically, we are asking what the orientation of the craft
is relative to a coordinate frame that is defined by the goal.
Return values must range between -1799 and 1800. Negative
values correspond to the current heading being
counter-clockwise from the
goal.
- int16_t compute_derivative(int16_t heading_last, int16_t
heading_current). Return an estimate of the
derivative of the compass value in units of 1/10 degree per
second. This can range between -32767 and 32767 (the limit of
int16_t). Assume that the two heading readings were taken 100ms apart.
- void display_orient(int16_t theta) changes the state
of the orientation LEDs to reflect theta (which is in a range
of -1799 and 1800).
- void display_derivative(int16_t velocity) changes
the state of the velocity LEDs to reflect "velocity". Note
that you will have to play with the mapping from velocity to
LED state to make it display interesting things (you might have
to cut things off at some moderate velocity).
Part 4: Main Controller
- void main_loop(void) will implement the main
sensory-motor control loop. It should have the following form:
void main_loop(void) {
#APPROPRIATE VARIABLE DECLARATIONS HERE#
heading_current = #HOW SHOULD THIS BE INITIALIZED?#
heading_goal = #HOW SHOULD THIS BE INITIALIZED?#
while(1) {
heading_last = heading_current;
heading_current = get_heading();
heading_error = compute_error(heading_goal, heading_current);
heading_derivative = compute_derivative(heading_last, heading_current);
if(#COMMAND INPUT LINE#) {
display_orient(heading_current);
}else{
display_orient(heading_error);
}
display_derivative(heading_derivative);
delay_ms(100);
}
}
References
What to Hand In
All components of the project are due by Tuesday, April 7th at 5:00pm.
- Demonstration/Presentation: All group members must be
present.
- 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).
- DO NOT include low-level code
- Code: Turn in your documented code to the
project 2 digital dropbox on D2L (hand in the ".c" file). Only hand in
one copy of the code per group.
- Group report: No additional group report is required
beyond the ppt presentation.
- 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!). This distribution will be used to compute the individual grades.
Grading
Group grade distribution:
- 40%: Project implementation
- 30%: Demonstration/presentation of working project (to either
of the TA 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]] cs.ou.edu
Last modified: Mon Apr 6 23:14:28 2009