CS/ECE 5785/6785: Lab 4


(back to: main 5785 page, 5785 lab page)

Your ColdFire board contains a solid-state 3-axis accelerometer very similar to the one used in the Nintendo Wii controller. This lab is about acquiring and exploiting data from this device.

Accelerometer Driver

For this part of the lab refer to your existing pot driver, the ADC chapter of the MCF5223x reference manual, the documentation for the M52233DEMO board, and the documentation for the MMA7260Q accelerometer.

Write these two functions:
void init_accelerometer_and_pot (int mode);
void sample_accelerometer_and_pot (int which, struct accel_data * datap);
Where the structure for storing data is defined as:
struct accel_data {
  int x, y, z, pot;
};
The initialization function must: The sampling function must: You should test your driver, ensuring that it returns sensible readings for the accelerometer and potentiometer.

Accelerometer Calibration

Calibrate your accelerometer. Your goal is to determine, for each of the three axes, the sensor reading at -1g, 0g, and 1g. These values completely calibrate the device since you may assume that the volatage response in linear in the acceleration sensed by the device.

You should pick the accelerometer sensitivity setting that gives the widest response curve (and hence best precision) for all three axes in the -1g to 1g range. For whatever reason, the most sensitive (1.5g) setting did not work for me (the readings for one axis were squashed against 0v). It may work for you, but you need to determine this experimentally. The setting and calibration values that you use here should be used for all subsequent portions of the lab.

If you run into calibration problems for one or more of the three axes, let an instructor know. An example of a calibration problem would be where there is no sensitivity setting for the accelerometer that permits the full -1g to 1g range to be sensed.

Accelerometer Tennis

This part of the lab will use only the X axis of the accelerometer, which is in line with your board's 4 user LEDs. The board and a human holding the board play a game.

Position Estimation

The output of an accelerometer, integrated twice, gives position information. Your assignment is to implement a ColdFire application which determines the position of your demo board in the X and Y dimensions.

Lab report




This page is maintained by John Regehr, mail me if you find a mistake or if any content is unclear.