Download presentation
Presentation is loading. Please wait.
1
Acquiring Data from an ADXL335 Accelerometer
DIGIKEY DKSB1002A Evaluation Board 3-axis accelerometer Arduino Uno microcontroller board
2
DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms
3
Implementing a 3-axis Accelerometer: Wiring to Arduino
COM Ground VSS Power (5V) X Acceleration in x-direction Y Acceleration in y-direction Z Acceleration in z-direction
4
Programming associates a time with each set of accelerations
void setup() { Serial.begin(9600); } void loop() int xaccel = analogRead(0); int yaccel = analogRead(1); int zaccel = analogRead(2); unsigned long timevar = millis(); Serial.print(timevar); Serial.print(" "); Serial.print(xaccel); Serial.print(" "); Serial.print(yaccel); Serial.println(zaccel); associates a time with each set of accelerations
5
Calibration Output when +x points upward: xaccel=627
Output when +x points downward: xaccel=401 Difference = 627 β 401 = 226 Change in acceleration = 2g Change in accelerometer per g: π = 113 π Output when accelerometer is flat: 627 β 113 = 514 x y z
6
Angle Measurement z x y ΞΈx = asin(ax/g)
1g (perceived vertical acceleration) ax qx +x ΞΈx = asin(ax/g) Angle Measurement x y z The Arduino will output 514 when the accelerometer is flat; the output changes by 113 per βgβ Expected output of Arduino when accelerometer is at 45 degrees? π π₯ = sin 45 βπ=0.707π ππ’π‘ππ’π‘= πβ 113 π =594 If the Arduino output is 450, then what is the angle? π π₯ = 450β π =β0.57π πππ π π₯ = asin β0.57π π = β34.5 Β° Donβt forget that the accelerometer can also measure actual acceleration (not just angles)
7
Example Application The piezospeaker below outputs a frequency that varies with the acceleration in the x-direction. 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 = analogRead(0); int freq = 1500+xaccel*2; tone(7,freq); Serial.print(xaccel); Serial.print(" "); Serial.println(freq); }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.