Presentation is loading. Please wait.

Presentation is loading. Please wait.

Acquiring Data from an ADXL335 Accelerometer

Similar presentations


Presentation on theme: "Acquiring Data from an ADXL335 Accelerometer"β€” Presentation transcript:

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); }


Download ppt "Acquiring Data from an ADXL335 Accelerometer"

Similar presentations


Ads by Google