AME 3623: Project 3: Analog Processing and Interrupts
Many embedded systems must face the problem of how to process
sensory data that is encoded using a continuous voltage. In
addition, sensory processing can include the production of control
signals that are coordinated in time with the sensor "reading."
In this project, we will sense the orientation of a "weather vane" so
that we can drive the robot toward a wind source. We will use a
sensor called an encoder to infer the current orientation of
the vane. Unlike many encoders, its state is presented as an analog
signal (most encoders use a pair of digital signals).
The learning goals for this project include:
- extracting analog data from a sensor,
- performing time-sensitive control and sensor processing,
- implementing interrupt routines, and
- designing and implementing finite state machines.
Project Due Date
- Part 1 (encoder processing): Tuesday, April 11th, 5:00pm
- Part 2 (following the wind): Tuesday, April 18th, 5:00pm
Robot Task
In the full task, the robot will orient toward and then drive into "the
wind" (provided by a fan). When a beacon is observed to the left, the
robot should stop.
Design Process
Part 1: Encoder Processing
Due: Thursday, April 11th at 5:00pm. Note that this is a soft deadline (in order to complete the project on time, you should have this done by this date, but there are not penalties for missing the deadline)
The Encoder
Your encoder has two signal lines. Connect one line to ground and one
to an analog input pin (PC0 ... PC5). Note that you may need
to re-assign one of your digital pins from project 2. For these
sensors, it does not matter which line is connected to ground (pretty
cool). Make sure that you include a pull-up resistor of 10Kohms on
your analog input pin.
Before reading the sensor state, it is necessary to charge up a
capacitor contained within the encoder (this will provide power to the
encoder for a brief amount of time while we are reading its state).
To take this first step, you must configure the pin as a digital
output pin and bring it to +5V. After a delay of at least 3ms, the
capacitor is charged. Re-configure the pin so that it is an input pin
and set its state to 0V (both steps are necessary). After a delay of
4us, you are free to read the analog value (note that you will need an
ADC prescalar of 32 in order to get the timing right).
The sensor will produce analog values of approximately 2.6V, 1.7V,
3.9V, and 4.5V (we will refer to these as integer values 0, 1, 2, and
3, respectively). When the shaft is turned in one direction, you will
observe this sequence of voltages; when the shaft is turned in the
other direction, the voltages will pass through the opposite
sequence. For each complete turn of the shaft, the encoder will pass
through this sequence of 4 steps 4 different times (so we have a resolution of
22.5 degrees per step).
Since we will be using this as an orientation sensor (for which it is
important to distinguish the 16 possible orientations), it is
necessary to keep a count of how many times you move through the
sequence of 4 voltages. In particular, you will need to increment a
counter every time the sensor passes from 4.5V to 2.6V, and decrement
the counter every time it passes from 2.6V to 4.5V.
Important notes to keep in mind as you are designing your FSM:
- Due to the design of the sensor, the 4.5V level may be very
short (and can be easily missed). It is therefore necessary to
handle the cases where there is a transition from 2.6V to 3.9V
(assume that this is "through" 4.5V), and from 3.9V to 2.6V
(again, assume that this is through 4.5V).
- When the voltage is read at 2.6V and 3.9V, it is not clear
whether the analog value is constant or is in transition to
another voltage. In these cases, it will be necessary to
verify the constant voltage using two different samples.
For more details about the sensors see (these are good sources of
information, but note that they are incorrect in their report of the
sequence of voltages):
Coding Steps
This part requires the following:
Part 2: Interrupts and Control
Due: April 18th at 5:00
You must complete the following steps:
- Embed your FSM step function into an interrupt routine
(function) and configure the timer so that it is called every
~4ms.
- Write a main program that first orients the robot toward the
wind source and then drives to it. The robot should stop when
it observes a beacon to its left.
- Demonstrate your working program
Hints
- You are responsible for designing and attaching your own vane.
Make sure that you attach it such that it does not slip on the
shaft.
- You should not need to sample your encoder value more often
than once every 4ms.
- The oscilloscopes are your friends. Use them heavily when you
are unsure about the timing of events (e.g., you can look at the raw
sensor data, or the state of your LEDs).
- See the Atmel
HOWTO for details about
circuits and programming.
- LED's on extra output pins can be used by your program to
communicate debugging information to you (for example, to
represent the current state of your code).
What to Hand In
Project Report
Your report should include the following:
- The names of the group members.
- Describe the details of your FSM design.
- A copy of your documented program (this may be handed in as a
separate file). The documentation should be such that a person
not familiar with your program (but familiar with the control
problem) can understand what you are doing.
The reports are due at 5:00 on April 13th. Please turn these in using
the D2L dropbox (one copy per group) in
either postscript or pdf format.
Personal Reports
Your personal report must include the following information:
- Your name
- An estimate of your contribution to the project in terms of
percentage of effort.
- An estimate of the contribution of each of your fellow group
members.
- A justification of your contribution assessment.
The personal reports are due at 5:00 on April 13th. These must be
turned in via D2L in raw text format.
fagg at ou.edu
Last modified: Sat Apr 8 18:39:21 2006