|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
ADXL 202 AccelerometerReport by Grace Kim, 1 November, 2005 I chose the ADXL202E, a 2-axis accelerometer from Analog Devices that can measure between -2g and 2g. Since I don't know how to surface mount a chip, I got the accelerometer on a breakout board from Sparkfun. (They sell it as the "ADXL E8" for $34.95). ![]() Accelerometers are simple MEMS (Microelectromechanical System) devices and are used to measure position, motion, tilt, shock, vibration, and acceleration (the rate of change of velocity). They are available with one, two, or three axes. ApplicationsAccelerometers are used everywhere. In transportation, they are used in aircraft stability and control systems, missile guidance systems, and testing the smoothness of paved roads. Domestically, they are being added to washing machines that can balance loads, leading to faster drying times. Accelerometers are also being included in car alarms to detect if the car is being towed away. They are also used in user interface devices, most notably in cell phones and video game controllers, where the user rotates the device to control the screen instead of pushing buttons. For fun, here is a project by a MediaLab student, measuring the roughness of Cambridge roads on his bike ride home. DatasheetsSparkfun gave a spare schematic of how they hooked up the pins of the ADXL202E to their breakout board. Paired with the thoroughly detailed Analog Devices datasheet, I had all the information I needed to hook up the board and spit out data. Electrical Characteristics and Pin Descriptions![]() The Sparkfun breakout board for the ADXL202 has two analog outputs (volts) and two digital outputs (digital pulses), two for the x axis and two for the y axis. On the Sparkfun breakout board, the analog output pins are labeled as "XA" and "YA" (X and Y Analog on the sheet) and the digital output pins are labeled "XP" and "YP" (X and Y PWM on the sheet). If you used the accelerometer with a 3.3 power source, as I did, the analog pins output a minimum of 1.2V and a maximum of 1.8V and the digital output pins send a minimum of 31% and a maximum of 69% duty cycle. At rest, the analog output pins send 1.5V and the digital pulse out pins send out 50% duty cycle. I tried using both types of output to my pic and they both gave out steady values. Other than the 4 output pins, there are 3 additional pins on the ADXL202: VCC, GND, and ST. ST stood out right away when I first started reading the datasheet and after a bit of research, I found out that the "self test" pin is activated when sent a logical 1. This causes the chip to apply a deflection voltage to the inner structure of the accelerometer. It will send out -5g of force. By measuring this output, the user can verify that the accelerometer is working. In practice, this means that if you connect the "ST" pin to power, and you notice that the output values drastically decrease, your accelerometer is okay. A Bit More About the ADXL202On a micro level, The ADXL202 uses moveable polysilicon masses to detect various movements. Any movement drives the mass out of phase with the plates that surround it, inciting the differential capacitor formed between them to produce a square wave whose amplitude is proportional to acceleration. ![]() ![]() Images from Microchip.com --What is a duty cycle? A duty cycle describes an output pulse, measured in percentage. The percentage indicates what percent of the output cycle is high. When it detects forward acceleration (above 0g), it outputs a duty cycle above 50%. When it detects backwards acceleration (below 0g), it outputs a duty cycle below 50%. Microcontroller ConnectionsI connected the ADXL202 with a PIC 18F252 and powered it with a 3.3 voltage regulator. Here is how I did it: ![]() Code SampleI'm planning on using the accelerometer in a wearables project. In brief, the accelerometer (sewn into the hem of a skirt) will detect when its wearer sping. As the wearer spins faster, more lights on the skirt will illuminate. To visualize this, I made a processing application. Note that in this version of the code, I used the PWM pins on the accelerometer instead of the analog pins. It is very important that you don't have both sets of pins hooked to the microcontroller at the same time, or else you won't get any output. Also, note in the Processing code that there is a delay set in the function "processByte" before the code sends an A out to the pic to let it know that it's ready for more data. Otherwise, Processing will not receive any data. My theory is that the pic is a bit slow in spitting out data from the accelerometer, so if Processing sends an A out right away, the pic won't be ready. I could be wrong, though. Application NotesI was able to get steady, consistent values out of the accelerometer. It can easily be used to detect tilt or acceleration. My project, however, might need to detect BOTH tilt and acceleration at the same time. If I wanted to restrict the reaction of the lights to a spinning motion, I would need to make sure that the hem was tilting AND accelerating in a negative or positive direction. Therefore, in addition to sensing tilt along the Y-axis (which I have already done in my code samples), I will also need to sense acceleration along the X-axis. Testing this will be a bit tricky. Right now, I'm envisioning taping a breadboard attached to a REALLY LONG serial cable to my skirt and spinning around in the pcomp lab. Recommendations for alternative procedures are welcome. |