1 of 18

Unit 2 - Motion

Lab 2D: Accelerometer

UCLA Physics Department

1

University of California, Los Angeles

Department of Physics and Astronomy

​

Physics 4AL

2 of 18

Outline of Lab 2D

  • 2D In-Lab
    • Accelerometer basics.
    • Connect accelerometer to Bluetooth-ultrasonic sensor setup.
    • Accelerometer Arduino code.
    • Calibrate accelerometer.

​

​

​

UCLA Physics Department

2

3 of 18

Accelerometer Wiring

UCLA Physics Department

3

4 of 18

How the accelerometer works

  • MEMS (Micro Electro Mechanical System) accelerometer

​

  • Spring mass system when accelerated will move the capacitor plate changing the voltage

​

  • In the vertical direction - the accelerometer will measure the acceleration due to gravity (1g) when not moving since the smaller mass inside experiences g

UCLA Physics Department

4

5 of 18

Accelerometer Code

UCLA Physics Department

5

6 of 18

MPU-6050 Introduction

  • The MPU6050 is an accelerometer that can track acceleration in the x, y, and z cardinal axes
  • It can also track rotations in yaw, roll, and pitch
  • MPU 6050 comes in a Module form, with 8 pins but we will use only 4 pins for our purposes. These let us track the x, y, and z axis accelerations

UCLA Physics Department

6

7 of 18

Installing Libraries

8 of 18

Installing Libraries

9 of 18

Installing Libraries

10 of 18

Install libraries (Important)

  • Download the 2 Zip files from the google Drive
  • I2Cdev.zip
  • MPU6050.zip
  • (In the Arduino IDE) Sketch > Include Library > Add .ZIP Library > select the Zip

I2Cdev.zip > Open

  • (In the Arduino IDE) Sketch > Include Library > Add .ZIP Library > select the Zip

MPU6050.zip > Open

  • You can check your installed libraries by going to Sketch -> Include Library and scanning the list of libraries.

​

​

​

​

UCLA Physics Department

10

11 of 18

Adding the Sensor

12 of 18

Accelerometer Calibration

UCLA Physics Department

12

13 of 18

Accelerometer axes

  • The x axis and the y axis with respect to the accelerometer orientation are marked on the accelerometer.
  • For example, in the image, the +x axis is pointing down and the +y axis is to the right (in the plane of the accelerometer).
  • The z axis is perpendicular to the plane of the accelerometer with the +z pointing towards the ceiling and -z towards the ground.
  • Don’t worry if the sign of the analog values is opposite of what you expect as the orientation of the accelerometer chips may be flipped!

UCLA Physics Department

13

14 of 18

Calibration z axis

  • Place your setup as shown in the image to calibrate the accelerometer in the -z axis

UCLA Physics Department

14

  • Select the COM port associated with your bluetooth and collect >=20 data points

​

  • Save this data to a text file for z-axis calibration

​

  • Take a picture of your setup for assignment

15 of 18

Calibration z axis

  • Your serial monitor will return 5 values

​

  • The first value is elapsed time in milliseconds and the second one is the ultrasound reading in cm

​

  • The third, fourth and fifth values are the accelerations in the x, y, and z directions, respectively. These values do not have the correct units!

​

  • The z axis analog value will correspond to an acceleration of g, while the other 2 axes correspond to 0 acceleration

UCLA Physics Department

15

16 of 18

What do these values mean?

  • The analog value the accelerometer returns is assumed to be linearly proportional to the acceleration it experiences

​

  • Calibration constants vary for each accelerometer

​

  • Our task is to find the slope and intercept calibration constants corresponding to the equation mapping analog value to acceleration

​

  • acceleration = slope*analog_output + intercept

UCLA Physics Department

16

17 of 18

TA Checkpoint 2 - Accelerometer Calibration

  • Repeat this process for the x and y axes of the accelerometer, as shown in these images

​

  • Save the results to text files for the x and y axes

​

  • Take pictures of your setups for each of these directions for your post-lab

​

  • Use the lab 2D notebook and extract the calibration coefficients for each axis of the accelerometer

UCLA Physics Department

17

y-axis –>

<– x-axis

18 of 18

Post-Lab Requirements for lab 2D

  • Complete Week 4 Post-Lab Assignment found in JupyterHub
    • Physics_4AL/Assignments/Post-Labs/Post-Lab-Week-4.ipynb
    • Include the photos of your Arduino setup for calibration in the x, y, and z axes
    • Include your functions to convert from accelerometer output to true acceleration
    • Include your plots of accelerometer calibration in the x, y, and z directions, including best fits using your functions