250a Accelerometer Lab
Lab 5: Accelerometers, and Audio Filters
Due on Wednesday, November 2nd at 5PM
Set up for lab
First start up your kit Connect your Satellite CCRMA kit to your laptop and boot it.
- Use a terminal window to login to Satellite CCRMA as usual using the command
ssh -XY firstname.lastname@example.org the password
- Check that your kit has access to the internet through you laptop. You can do this by trying to ping Bing. Run the command
ping bing.com/ If it is successful, it will tell you how long it takes to send a packet from your Satellite CCRMA kit to Bing and back.
Now copy the lab files to your kit.
- At the command line in the terminal window, type
wget http://ccrma.stanford.edu/courses/250a/labs/lab5.zipto download the lab5 files to your Beagleboard.
- Unzip the file: change into your ~/ directory, and type
unzip lab5.zip. This should create a folder called lab5/ with all the files you need.
arduino &to start the Arduino IDE.
- Use the Arduino IDE to flash your Arduino with Standard Firmata. (See this link if you forget how.)
Set up your accelerometer so that the XYZ outputs are going into the Arduino analog pins A0, A1 & A2.
Graphing the accelerometer output
We will be using GEM (which stands for Graphics Environment for Multimedia) to make a nice visual display of the real-time accelerometer readings. It was originally written by Mark Danks to generate real-time computer graphics, especially for audio-visual compositions. It is possible to do some very fancy 3D graphics using GEM, but here we are just using it to make colorful bar charts.
To start PD with GEM:
- if remotely logged in from a Windows machine: type "'pd lab5/accel.pd &'" at the command prompt.
- if remotely logged in from a Mac OS X machine: type "'LIBGL_ALWAYS_INDIRECT=1pd lab5/accel.pd &'" at the command prompt. (This forces pd to transmit OpenGL commands and let your local X11 program do the real drawing--otherwise you will get errors in the pd console window and nothing will come up when you try to create gemwindow later.)
After starting the patch, you'll need to:
- set the proper serial port to communicate with the Arduino,
- adjust the volume, turn on the input messages and
- create a GEM window.
Make sure you are able to see the changing accelerometer data both in the table-graphs on the left of the patch, and in the separate GEM window.
- Note which physical axes map to X, Y, and Z inputs from your Arduino board.
Now, experiment a little with the GEM libraries:
- Locate the help link in the upper right hand corner. Open "Help->Browser->Examples->GEM->01.basic/09.teapot".
- As soon as you open the file, a teapot should appear in your GEM window.
- Experiment to rotate the teapot.
Map the accelerometer to some dimension of the teapot's rendering. Describe this in your write-up, and included a screenshot of the GEM window.
How to recognize a jerk
After taking the difference you can detect when the difference is greater than some threshold.
- Still using lab5/accel.pd.
- Have your patch make a sound when the threshold has been surpassed.
Congratulations, you have now written a jerk detector.
- Modify the jerk detector to account for the fact that our accelerometer outputs 3.3V max.
Describe what you needed to do to make this work.
Open the pd patch lab5/audio-filters/filter-demo.
- No filtering
- High pass filtering
- High pass filtering with a "cascade" of four hip~ objects
- Low pass filtering
- Low pass filtering with a cascade of four lop~ objects
- Band pass filtering
Finally, play (some of) the oud sample(s) through various filters.
Filtering Acceleration Data to Distinguish Tilt from Sudden Motion
- Open the lab5/guppy.pd patch.
- Experiment with different cutoff frequencies for the crossover
- Examine briefly the stillness detector in the lower right corner. How does this work?
Make Some (musically-expressive, gesture-controlled) Music!
Put it all together. Create an interaction in which sound is controlled by physical gesture in some way that you find interesting, and render feedback graphically. You can begin by conjoining guppy and filter-demo if you like, but you are welcome to use any method for analyzing accelerometer data or creating sound.
Think about the relationship you want to enable between music, vision and sound. Are the qualities of movement reflected in the qualities of the sound? Is this important to you?
Some possibilities you may want to explore:
- Invent a specific gesture, and then figure out how to detect it.
- Is there a way to get velocity or position from acceleration?
Please make a video and post of your results, and in your lab writeup describe how you approached this (open-ended) design problem and what techniques you used to implement it.
(This lab was written by Luke Dahl on 10/13/09, and modified by Wendy Ju on 10/26/11. Huge portions were imported from Michael Gurevich's original accelerometer lab.)