Project 3: Sensor Control and Distance Sensing
All components of the project are due by Wednesday, April 18th
at 5:00pm.
Project Goals
At the end of this project, you should be able to:
- produce a control signal for a sensor,
- capture the width of a digital signal pulse and interpret
this in terms of distance to an object,
- write an interrupt service routine.
Hardware Overview
Each test station is equipped with a Devantech
sonar sensor unit. Each unit is equipped with a sonic transmitter
which will emit a small burst of clicks. The receiver will sense the
signal that has reflected off of some surface. By measuring the
return time of the signal, we can infer the distance to the surface.
For the heli stations, the sensors will be
placed underneath the helicopter (facing upwards). This way, we can
measure the height of the heli at a given time. In project 4, we will use this information to
hover the heli at some specified height.
The interface to the sonar unit is as follows:
- White wire: sonar command.
-
Bring this line high for at least
10 usec.
- Once it is returned to a low state, the sonar will
produce a brief sonic burst.
- Green wire: signal return.
- Once the sonic burst is complete,
this line will be brought high by the sonar itself.
- When the
reflected signal is sensed, this line will be brought low
(between 100 usec and 18 msec later).
- If no reflected signal
is observed, the sonar will timeout and bring this line low at
about 36 msec.
Note: After the reflected signal has been detected, you must
wait for at least 10 msec to command the next sonic pulse.
Hint: consider using a counter that tells the ISR "what time it is"
(e.g., when to emit the burst, when it is measuring the pulse, and
when it is waiting before it emits the next pulse).
Project Overview
For this project, you will modify your microcontroller circuit to
provide an interface to the sonar unit. In addition, you will be
writing the software that is necessary to control the sonar and
interpret the signals that you receive from it.
Note: in the next project, you will be integrating the current work
into the helicopter control problem (and doing height and yaw control
simultaneously). So: do not completely dismantle
your project 2 implementation.
In brief, your code must:
- Continuously sense the distance to an object
- Indicate the distance using a set of LEDs (you may reuse your
existing LEDs if you wish).
- Indicate an error state (specifically, if the sonar has timed out).
Project Components
All components are required to receive full credit for the project.
Part 1: Microcontroller Circuit
Designate one additional input pin and one output pin. Wire these
into the sonar connector.
Part 2: Sensing Distance
Implement an interrupt service routine (e.g., one that is attached to
the timer0 overflow interrupt) that does the following:
Part 3: Height Display
- Implement a function:
int16_t get_height(void)
That will safely read the value from global_duration
and return the height of the craft (i.e., measured distance) in
millimeters.
By safely, we mean that this variable should be accessed
without being interrupted by some ISR (we will discuss this
further in class).
- Display the height using a set of LEDs. For example, you could
use four LEDs to encode a value between 0 and 15 (of course,
you would need to scale 0 to 3000 mm to this range)
References
What to Hand In
All components of the project are due by Wednesday, April 18th 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).
- Code: Turn in your documented code to the
project 3 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 3 digital dropbox. State the
relative contribution of you and your group members (in terms of
percentage of effort) (text format only!)
Grading
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 Apr 4 22:08:42 2007