CSEP567 PreLab 6: "Accelerometer PWM"

Task

Create programs to read the X and Y axes of the accelerometer.

Suggested Reading

Suggested Steps

PART 1:

  1. Implement a program that uses timer 1 input capture mode, (accelerometer y-axis output to ICP1 pin 20), to determine the positive duty cycle of the y-axis accelerometer. To do this, time the length of the positive pulse of your accelerometer (rising edge to falling edge) and the length of the period (rising edge to next rising edge). Use the 7-segment LED to display a "1" when the accelerometer has a duty cycle less than 50% and a "2" when the accelerometer has a duty cycle greater than or equal to 50%.
    NOTES:

PART 2:

  1. New program: Define the x-axis of the accelerometer as an input on INT0 (pin 16).
  2. Use INT0 and Timer2 to create a manual interupt capture routine to determine the positive duty cycle of the x-axis.
  3. Implement a program that measures the x-axis and drives the 7-segment LED as in part 1.   

Question

Question 1: What would you change to accurately read a signal period of 1 msec?

Question 2: What are the accuracy differences between the input capture of the x-axis and the y-axis? (Please list more than one difference in your answer)

Turn-In

Please complete the prelab individually. Please turn-in your commented C code for both parts along with the answer to the question at the beginning of next week's lab.