Project 4: Height Control
All components of the project are due by Tuesday, May 5th at 9:00pm.
Project Goals
At the end of this project, you should be able to:
- design and implement a real-time sensor control interface,
- implement an "integration" control scheme, and
- make modifications the design of a finite state machine.
Hardware Overview
The heli hardware is the same as the previous projects.
Remember that we have a total of two test stations and three heli stations.
Each test station is equipped with a Devantech
sonar sensor unit and a compass.
Each sonar 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. We will then 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.
Project Components
For this project, you will modify your microcontroller circuit to
provide an interface to the sonar unit. You will be
writing the software that is necessary to control the sonar and
to interpret the signals that you receive from it. Finally, you will be
using the estimated height to control the heli
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:
- Produces the appropriate sonar control signal.
- Measures the duration of the pulse from the sonar.
- Once the pulse is measured, places the resulting value into the
global variable:
volatile int16_t global_duration;
If there is an error, this variable should be set to a value of
-1.
Modified hint: a finite state machine can be used to tell the
ISR what control phase the sonar is currently in. Then, use a
"clock" variable in your ISR that is incremented every time the ISR is
called.
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 the ISR.
- Display the height using the "velocity" LEDs.
Part 4: Height Control
-
Given a height goal, alter the throttle command until the current
height matches the height goal.
Because your throttle command is not an acceleration (due to
the dangling wire), an appropriate implementation is to use an
integration controller.
Your main loop will have an additional component:
throttle_command += Ki * (height_goal - height_current) / 100;
#Insert code to ensure that throttle_command remains in the valid limits#
set_throttle((uint8_t) throttle_command);
Note: the divisor of 100 will essentially allow you to express
fractional integration gains (i.e., your effective gain is Ki/100)
- Modify the finite state machine implementation so that heli
performs the following sequence:
- Rise to approximately 50 cm
- After obtaining 50 cm, wait for 20 seconds
- Rise to approximately 100 cm
- After obtaining 100 cm, wait for 20 seconds
- Land
Hint: you will need a deadband around your height goal.
References
What to Hand In
All components of the project are due by Tuesday, May 5th at
9: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,
- 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
- Hand in the power point file to the project 4 digital
dropbox.
- Code: Turn in your documented code to the
project 4 digital dropbox on D2L (hand in the ".c" file). Only hand in
one copy of the code per group.
- Personal report: One submission per person to the
project 4 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 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 20 21:16:01 2009