Project 2: Serial Communication and Compass Interface
- All components of the project are due by Friday, March 12th
at 5:00pm. Note: your 48 hours grace period (with penalty)
accumulates over the weekend.
- Discussion within groups is fine.
- Discussion across groups may not be about the specifics of the
solution (general programming/circuit issues are fine to
discuss).
Project Goals
At the end of this project, you should be able to:
- implement in code serial communication protocols for
interacting with sensors,
- compute errors between desired and actual state variables, and
- convey information about sensors using a set of LEDs.
Project Components
All components are required to receive full credit for the project.
Part 1: Microcontroller Circuit
Add the compass to your circuit:
- Connect power and ground directly to the battery (not to
the +5V power supply)
- Connect the compass transmit line to your Mega8 receive line
(PD0, pin 2)
- Connect the compass receive line (green wire with a knot) to
your Mega8 transmit line (PD1, pin 3)
- Mount the motor amplifier board to your breadboard. Do not
wire it in at this time.
- When mounting the compass to your hovercraft, mount it as far
away as possible from the motors and from other wires (we
mounted ours on the front of the hovercraft).
- Note: you have already mounted a set of 4 LEDs to your circuit
(these form a circle). We will use these to display the craft
orientation or orientation error (depending on the state of the
switch).
Part 2: Serial Interface
Note: this part will count for one personal programming credit
Create a software interface to the craft. Implement the following
functionality:
- int16_t get_orientation(void) will send the necessary
command to request the current heading from the compass device.
This function will then wait for the serial response and return
the heading as an integer in 1/10's of a degree (so "100" means
10 degrees). Return values must range between -1799 and
1800, with 0 degrees corresponding to North. Use a
left-handed coordinate system to be consistent with the
compass.
In order to query the compass, your Mega8 must transmit on the
serial line:
c
The compass responds with:
cXXX\n\r
Where XXX is the ASCII representation of a 3-digit
hexadecimal number that gives the orientation of the craft in
tenths of a degree. Note that "\n" is the newline character '\n', not the characters '\' and 'n'. "\r"
is the carriage return character, not the characters '\' and 'r'.
- Modify the while(1) loop in your main function to:
- read the current orientation (calling the above function)
- compute an error (using the function described below)
- display either the current orientation (Switch state ==
0) or the orientation error (Switch state == 1) using
the function described below
Part 3: Sensor Processing and Display
Note: this part will count for one personal programming credit
Implement the following functions:
Part 4: Hovercraft Layout
Mount the following to your Frisbee:
- Batteries
- Forward thrust fans
- Breadboard
- Compass
- Distance sensors
Let us know if you need any additional components for mounting.
References
What to Hand In
All components of the project are due by Friday, March 12th at 5:00pm.
Grading
Group grade distribution:
- 40%: Project implementation
- 30%: Demonstration/presentation of working project (to either
of the TA or the instructor)
- 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: Tue Mar 2 00:01:19 2010