Project 1: Analog to Digital Conversion and Digital Input/Output
- All components of the project are due by Thursday, February 25th
at 5:00pm. Please start early (this is not a single-session project).
- Groups are composed of 3-4 students.
- 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:
- create simple microcontroller-based circuits,
- read analog information through the Atmel Analog-to-Digital
converter,
- read digital information from a switch, and
- convey information about sensors using a set of LEDs
Circuit Overview
By the end of the semester, you will have a circuit on a single
breadboard that includes the following components:
- one atmel microcontroller with supporting hardware (including
crystal and programming interface),
- one motor driver board for control of the fans,
- one analog gyroscope sensor,
- two switches,
- four LEDs arranged in a circle (for indicating heading and
heading error), and
- five LEDs arranged in a line (for indicating rotation rate or
sensed distances).
Not on the breadboard, but connected to it will be:
- three ducted fans,
- a compass module,
- two analog distance sensors, and
- a power system.
Project 1 Requirements
For project 1, your circuit with associated software must be able to:
- read rate gyro and distance information from the corresponding
sensors,
- read the state of a connected switch, and
- display the sensor states depending on the state of the switch.
As you are laying out the circuit on your breadboard, keep in mind the
space requirements of the components that you will be installing
later in the semester. If you have questions about these constraints,
see Di's example circuit. (Note: if you need temporary use of an extra
breadboard, please ask).
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.
- Add the gyro module to the board. Provide this module with
power (+5V) and ground inputs. The analog output should be connected
to pin 23 (ADC0).
- Connect to the board the two analog distance sensors. Each
require power (+5V) and ground inputs. The analog outputs
should be connected to pins 24 (ADC1) and 25 (ADC2).
- Add a set of 4 LEDs that will be used to display the current heading
of the craft (organized in a circle). Each of these LEDs
should be driven by a digital output pin.
- Add another set of 5 LEDs that will be used to display the heading
velocity (organized in a line). Each of these LEDs
should be driven by a digital output pin.
- Add a switch. One end of the switch will be connected to
ground, the other to a digital input pin. This pin should also
be "pulled up" to +5V using a 10 K-Ohm resistor.
The toggle switch will connect the pin directly to
ground when first pressed, which will result in
a logic "0" on the pin. Pressing the switch again will
disconnect the connection to ground and will result in a logic "1".
Part 2: Rate Gyro
Note: this part will count for one personal programming credit
Create a main program that:
- Properly initializes the I/O ports.
- In a while(1) loop, continuously reads the sensors
and displays one of their values using the set of 5 LEDs.
- If the switch is in a logic 0 state, then the gyro state should
be displayed.
- If the switch is in a logic 1 state, then one of the distance
sensor states should be displayed.
Implement the following functions to support your main() function
(these are requirements):
- int16_t get_rotation_rate(void) will read
the analog port attached to the gyro sensor and return the
value in 10ths of a degree per second. Note that a return
value of zero should correspond to
no rotation, positive values should correspond to counter
clock-wise rotations, and negative values should correspond to
clock-wise rotations.
- void display_rotation_rate(int16_t rate) will change
the state of the 5 LEDs (and no others) to reflect the current
rotation rate.
Part 3: Distance Sensor
Note: this part will count for one personal programming credit
Implement the following functions:
- uint16_t get_left_sensor(void) will read
the analog port attached to the left distance sensor and return the
value in mm. Note that a low magnitude return value should
correspond to a short distance.
- uint16_t get_right_sensor(void) will read
the analog port attached to the right distance sensor and return the
value in mm.
- void display_left_sensor(uint16_t dist) and
void display_right_sensor(uint16_t dist) will change
the state of the 5 LEDs (and no others) to reflect the current
distance.
Part 4: Lift Fan
Cut a hole in the frisbee and mount the lift fan over the hole.
References
What to Hand In
All components of the project are due by Thursday, February 25th 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: Thu Feb 25 00:51:49 2010