living with the lab Acquiring Data from an
living with the lab Acquiring Data from an ADXL 335 Accelerometer DIGIKEY DKSB 1002 A Evaluation Board 3 -axis accelerometer Arduino Uno microcontroller board
living with the lab DKSB 1002 A Evaluation Board and ADXL 335 Accelerometer • • DKSB 1002 A is a prototyping board purchased for $20 from Digikey Screw holes for mounting board onto “object of interest” Board is ~ 20 mm square ADXL 335 3 -axis accelerometer chip • 3 -axis this small chip is the ADXL 335 accelerometer (this is an older model. . . they are even smaller now) • ± 3 g • • • z x y COM - ground VSS - power (we will provide 5 V) X - acceleration in x-direction Y - acceleration in y-direction Z - acceleration in z-direction the DKSB 1002 A is a board used to evaluate the accelerometer; if you were putting an accelerometer in a device like a cell phone, you would only use the ADXL 335 chip (and maybe some capacitors) 2
living with the lab Implementing a 3 -axis Accelerometer: Wiring to Arduino COM - ground VSS - power (we will provide 5 V) X - acceleration in x-direction Y - acceleration in y-direction Z - acceleration in z-direction 3
living with the lab Programming void setup() { Serial. begin(9600); } void loop() { int xaccel = analog. Read(0); int yaccel = analog. Read(1); int zaccel = analog. Read(2); unsigned long timevar = millis(); Serial. print(timevar); Serial. print(" "); Serial. print(xaccel); Serial. print(" "); Serial. print(yaccel); Serial. print(" "); Serial. println(zaccel); associates a time with each set of accelerations } 4
living with the lab Calibration z x y 5
living with the lab +x qx Angle Measurement ax z x y θx = asin(ax/g) qx 1 g (perceived vertical acceleration) 6
living with the lab Example Application The piezospeaker below outputs a frequency that varies with the acceleration in the xdirection. The equation for computing the frequency is chosen so that the device makes an audible noise that varies when rotating or shaking the device. void setup(){Serial. begin(9600); } void loop() { int xaccel = analog. Read(0); int freq = 1500+xaccel*2; tone(7, freq); Serial. print(xaccel); Serial. print(" "); Serial. println(freq); } 7
- Slides: 7