Project 1: Analog to Digital Conversion and Digital Input/Output
- All components of the project are due by Tuesday, March 22nd
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,
- using a sensor model, interpret analog voltages in terms of
sensed quantities,
- 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 mega2560 with supporting hardware,
- 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
- eight-ten 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.
Project Components
All components are required to receive full credit for the project.
Part 1: Microcontroller Circuit
Create a mega2560-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 mega2560.
- Double-stick tape your mega2560 board to the solderless
breadboard. Minimize the area of the breadboard that is
covered.
- Add the gyro module to the board. Provide this module with
power (+5V) and ground inputs (note that 3 pins on the gyro
need to be grounded). The analog output should be connected
to ADC0 on the mega2560.
- Connect to the board the two analog distance sensors. Each
require power (+5V) and ground inputs. The analog outputs
should be connected to ADC1 and 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 eight-ten LEDs that will be used to display
the heading velocity (we are supplying 10-LED "bar graph"
modules). 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 read the sensors
and displays one of their values using the set of eight-ten 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 eight-ten 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_distance(uint8_t index) will read
the analog port attached to the left distance sensor (if index
== 0) or the right distance sensor (if index == 1)
and return the value in mm. Note that a low magnitude return
value should correspond to a short distance.
- void display_distance(uint16_t dist) and
will change the state of the eight-ten LEDs (and no others) to
reflect the current distance.
Part 4: Lift Fan
Holes have already been cut in your frisbees (and in some cases, a fan
is already mounted). For this project, you need to make sure that the
fan is adequately sealed over the hole.
References
What to Hand In
All components of the project are due by Tuesday, March 22nd at 5:00pm.
Grading
Group grade distribution:
- 35%: Project implementation
- 30%: Demonstration/presentation of working project (to either
of the TA or the instructor)
- 35%: 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: Sun Mar 13 01:23:51 2011