Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

4/11/13

Main Site Blog Playground Forum Labs Store Help | Sign in or Register

Arduino Playground - MPU-6050

search

The play ground is a publicly -editable wiki about Arduino.

MPU-6050 Accelerometer + Gyro


Manuals and Curriculum Installing Arduino on Linux Board Setup and Configuration Development Tools Arduino on other Atmel Chips Interfacing With Hardware Output Input User Interface Storage Communication Power supplies General Interfacing with Software User Code Library Snippets and Sketches Libraries Tutorials Suggestions & Bugs Electronics Technique Sources for Electronic Parts Related Hardware and Initiatives Arduino People/Groups & Sites Exhibition Project Ideas Languages PARTICIPATE Suggestions Formatting guidelines All recent changes PmWiki WikiSandBox training Basic Editing Cookbook (addons) Documentation index Drone with Arduino Thermostat with Arduino
edit SideBar

Navigation
Introduction It can be easy, or not Information and Programs Breakout boards Measurements Sketch

Introduction
The InvenSense MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, since it contains 16-bits analog to digital conversion hardware for each channel. Therefor it captures the x, y, and z channel at the same time. The MPU-6050 is not expensive, since it combines both an accelerometer and a gyro.

Photo: GY-521 breakout board

playground.arduino.cc/Main/MPU-6050

1/13

4/11/13

Arduino Playground - MPU-6050

It can be easy, or not.


Reading the raw values for the accelerometer and gyro is easy. The sleep mode has to be disabled, and then the registers for the accelerometer and gyro can be read. But the sensor also contains a 1024 byte FIFO buffer. The sensor values can be programmed to be placed in the FIFO buffer. And the buffer can be read by the Arduino. The FIFO buffer is used together with the interrupt signal. If the MPU6050 places data in the FIFO buffer, it signals the Arduino with the interrupt signal so the Arduino knows that there is data in the FIFO buffer waiting to be read. A little more complicated is the ability to control a second I2C-device. The MPU-6050 always acts as a slave to the Arduino with the SDA and SCL pins connected to the I2C-bus. But beside the normal I2C-bus, it has it's own I2C controller to be a master on a second (sub)-I2C-bus. It uses the pins AUX_DA and AUX_CL for that second (sub)-I2C-bus. It can control, for example, a magnetometer. The values of the magnetometer can be passed on to the Arduino. Things get really complex with the "DMP". The sensor has a "Digital Motion Processor" (DMP), also called a "Digital Motion Processing Unit". This DMP can be programmed with firmware and is able to do complex calculations with the sensor values. For this DMP, InvenSense has a discouragement policy, by not supplying enough information how to program the DMP. However, some have used reverse engineering to capture firmware. The DMP ("Digital Motion Processor") can do fast calculations directy on the chip. This reduces the load for the microcontroller (like the Arduino). The DMP is even able to do calculations with the sensor values of another chip, for example a magnetometer connected to the second (sub)-I2C-bus.

Information and Programs.


The accelerometer and gyro values are called the "raw" values. This is just as with other accelerometer and gyro sensors. More sophisticated is using the DMP to retrieve specific computed values from the sensor. The code on this page (scroll down) is just a simple and basic sketch to read the raw values. For more serious use of the MPU-6050, Jeff Rowberg has done an excellent job. See his I2C lib: http://www.i2cdevlib.com/devices/mpu6050 Or the latest code on github: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 The FreeIMU library includes the MPU-6050 code from Jeff Rowberg. The FreeIMU library: http://www.varesano.net/projects/hardware/FreeIMU To start with the MPU-6050, see the page of InvenSense: http://www.invensense.com/mems/gyro/mpu6050.html For other programs and sensors, see the Degrees Of Freedom, 6DOF, 9DOF, 10DOF, 11DOF-section in the Playground index.

playground.arduino.cc/Main/MPU-6050

2/13

4/11/13

Arduino Playground - MPU-6050

Breakout boards.
There are a number of "breakout boards" or "sensor boards" with the MPU6050. Sparkfun SEN-11028 http://www.sparkfun.com/products/11028 With schematic and full information. This breakout board must be used with 3.3V. There is no voltage regulator and no I2C-level shifter on the board. The pull-up resistors for the I2C-bus are 10k. Pull-up resistors of 4k7 are preferred, so two extra 10k pull-up resistors could be added. Drotek IMU 10DOF - MPU6050 + HMC5883 + MS5611 http://www.drotek.fr/shop/en/62-imu-10dof-mpu6050-hmc5883ms5611.html This sensor board contains three sensors. A schematic is not provided. The interrupt ('INT') of the MPU-6050 is not made available. Therefor the FIFO and the Jeff Rowberg library can not be used. Drotek MPU-6050 Invensense http://www.drotek.fr/shop/en/42-mpu6050-gyro-accelerometer.html This breakout board contains a voltage regulator. It can be used with 3.3V and with 5V. A schematic is not provided. GY-521 This sensor board has a voltage regulator. So it can be used with 3.3V and with 5V. It has pull-up resistors of 2k2 on the I2C-bus. The value of 2k2 is rather low. If it is combined with other sensor board which have also pull-up resistors, the total pull-up impedance might be too low. This schematic is hard to find, so here is a copy: http://playground.arduino.cc/uploads/Main/MPU6050-V1-SCH.jpg GY-52 This sensor board has a voltage regulator. So it can be used with 3.3V and with 5V. The board was originally designed for the MPU-3050, therefor the text "MPU-3050" or "MPU-X050" is sometimes printed on the board. The pull-up resistors are sometimes 10k and sometimes 4k7. If they are 10k, two extra pull-up resistors of 10k to the 3.3V could be added (from the SDA and SCL to the 3.3V of the sensor board or the 3.3V of the Arduino). Flyduino MPU6050 Break Out onboard 3.3V reg http://flyduino.net/MPU6050-Break-Out-onboard-33V-reg_1 This sensor board contains a voltage regulator, so it can also be used with 5V. The pull-up resistors of the I2C-bus are 4k7. It is actually a GY52 breakout board. Flyduino 10DOF IMU GY-86 MPU6050+HMC5883l+MS5611 http://flyduino.net/10DOF-IMU-GY-86-MPU6050-HMC5883lMS5611_1 A sensor board with the MPU-6050 and a magnetometer and barometer. A schematic is not provided. The sensor board contains a voltage regulator, so it can be used with 5V. There seems to be also a level shifter on the board for the I2C-bus. The pull-up resistors for the I2C-bus seems to be 2k2, which is rather low.

playground.arduino.cc/Main/MPU-6050

3/13

4/11/13

Arduino Playground - MPU-6050


no name breakout board In august 2012 the cheapest breakout board with the MPU-6050 was a breakout board (for about 12 dollars/ 10euros) without any name or code. The header is on the right with the pins in this order: "5V", "3V3", "GND", "SCL", "SDA", "INT", "SYNC", "CLK", "ASCL", "ADSA". There are two pull-up resistors for the SCL and SDA, but the value is unknown. On the back are three solder jumpers, one of them for AD0.

Measurements.
The raw values raises questions in the forums, since the raw values might seem unstable. Below are the raw values of the sensor that I measured, so you can compare them with your own raw values. The raw values changes a lot due to a number of reasons. The default sensitivity is high, and the sensor returnes 16 bits, but the actual valid number of bits is less than 16 bits. Since they are 16 bits, a variation of 50 is just a very small variation. The next measurement were done in these conditions: The sensor was placed as horizontal as possible. It was placed on concreet, not a wooden table. During the measurements, there was no traffic in the street. An battery of 12V was used, not the less stable voltage from the USB bus. I used a battery instead of an adapter to avoid any mains noise. The circuit was on for 15 minutes, to stabalize any temperature influence. The room temperature was 25 degrees Celcius.
M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :1 8 4 ,4 8 4 ,1 4 9 9 2 t e m p e r a t u r e :2 9 . 6 3 5d e g r e e sC e l s i u s g y r ox , y , z:3 6 7 ,2 2 0 ,8 1 2 , M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :1 1 6 ,3 6 4 ,1 5 0 5 6 t e m p e r a t u r e :2 9 . 6 3 5d e g r e e sC e l s i u s g y r ox , y , z:3 7 3 ,2 2 6 ,7 6 6 , M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :2 3 2 ,4 3 2 ,1 5 1 0 0 t e m p e r a t u r e :2 9 . 6 8 2d e g r e e sC e l s i u s g y r ox , y , z:3 8 2 ,2 3 2 ,7 9 0 , M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :2 8 0 ,4 6 8 ,1 5 1 3 6 t e m p e r a t u r e :2 9 . 6 3 5d e g r e e sC e l s i u s g y r ox , y , z:3 6 8 ,2 1 1 ,8 2 0 , M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :1 4 0 ,4 3 2 ,1 5 1 0 8 t e m p e r a t u r e :2 9 . 5 8 8d e g r e e sC e l s i u s g y r ox , y , z:3 8 8 ,2 0 3 ,8 0 6 , M P U 6 0 5 0 R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :2 2 0 ,4 6 4 ,1 4 9 2 0 t e m p e r a t u r e :2 9 . 5 4 1d e g r e e sC e l s i u s g y r ox , y , z:3 7 4 ,1 9 6 ,7 7 4 ,

playground.arduino.cc/Main/MPU-6050

4/13

4/11/13
M P U 6 0 5 0

Arduino Playground - MPU-6050

R e a da c c e l ,t e m pa n dg y r o ,e r r o r=0 a c c e lx , y , z :1 7 2 ,4 4 0 ,1 5 1 0 0 t e m p e r a t u r e :2 9 . 5 8 8d e g r e e sC e l s i u s g y r ox , y , z:3 6 3 ,2 0 0 ,7 6 9 ,

Sketch.
The sketch below is the code made with Arduino 1.0.1 and it uses I2C-bus communication. The code uses the Arduino functions as much as possible. It is just a simple and basic sketch to get the MPU-6050 working. The I2C-address depends on the AD0 pin of the sensor. If it is connected to ground, the address is 0x68. If it is connected to VLOGIC (+3.3V) it is 0x69. There are a few sensor boards with the MPU-6050 sensor already soldered on it. Some of those boards have a pull-down resistor at AD0 (address = 0x68), others have a pull-up resistor (address = 0x69). Search in the sketch for "MPU6050_I2C_ADDRESS" and set that to your own I2C address. A i2c_scanner can be used to check if the device is connected to the i2c bus. The acceleration and gyro values of the sketch are raw values, which are not yet compensated for offset. The very first acceleration and gyro values after power up are sometimes not valid. The sketch is about 7kbyte, and will fit in a ATmega8.
/ /M P U 6 0 5 0A c c e l e r o m e t e r+G y r o / // / / /B ya r d u i n o . c cu s e r" K r o d a l " . / /J u n e2 0 1 2 / /O p e nS o u r c e/P u b l i cD o m a i n / / / /U s i n gA r d u i n o1 . 0 . 1 / /I tw i l ln o tw o r kw i t ha no l d e rv e r s i o n , / /s i n c eW i r e . e n d T r a n s m i s s i o n ( )u s e sap a r a m e t e r / /t oh o l do rr e l e a s et h eI 2 Cb u s . / / / /D o c u m e n t a t i o n : / /-T h eI n v e n S e n s ed o c u m e n t s : / / -" M P U 6 0 0 0a n dM P U 6 0 5 0P r o d u c tS p e c i f i c a t i o n " , / / P S M P U 6 0 0 0 A . p d f / / -" M P U 6 0 0 0a n dM P U 6 0 5 0R e g i s t e rM a pa n dD e s c r i p t i o n s " , / / R M M P U 6 0 0 0 A . p d fo rR S M P U 6 0 0 0 A . p d f / / -" M P U 6 0 0 0 / M P U 6 0 5 09 A x i sE v a l u a t i o nB o a r dU s e rG u i d e " / / A N M P U 6 0 0 0 E V B . p d f / / / /T h ea c c u r a c yi s1 6 b i t s . / / / /T e m p e r a t u r es e n s o rf r o m4 0t o+ 8 5d e g r e e sC e l s i u s / / 3 4 0p e rd e g r e e s ,5 1 2a t3 5d e g r e e s . / / / /A tp o w e r u p ,a l lr e g i s t e r sa r ez e r o ,e x c e p tt h e s et w o : / / R e g i s t e r0 x 6 B( P W R _ M G M T _ 2 )=0 x 4 0 ( Ir e a dz e r o ) . / / R e g i s t e r0 x 7 5( W H O _ A M _ I ) =0 x 6 8 . / / # i n c l u d e< W i r e . h > / /T h en a m eo ft h es e n s o ri s" M P U 6 0 5 0 " . / /F o rp r o g r a mc o d e ,Io m i tt h e' ' , / /t h e r e f o rIu s et h en a m e" M P U 6 0 5 0 . . . . " . / /R e g i s t e rn a m e sa c c o r d i n gt ot h ed a t a s h e e t . / /A c c o r d i n gt ot h eI n v e n S e n s ed o c u m e n t / /" M P U 6 0 0 0a n dM P U 6 0 5 0R e g i s t e rM a p / /a n dD e s c r i p t i o n sR e v i s i o n3 . 2 " ,t h e r ea r en or e g i s t e r s / /a t0 x 0 2. . .0 x 1 8 ,b u ta c c o r d i n go t h e ri n f o r m a t i o n / /t h er e g i s t e r si nt h a tu n k n o w na r e aa r ef o rg a i n / /a n do f f s e t s . / / # d e f i n eM P U 6 0 5 0 _ A U X _ V D D I O 0 x 0 1 / /R / W # d e f i n eM P U 6 0 5 0 _ S M P L R T _ D I V 0 x 1 9 / /R / W # d e f i n eM P U 6 0 5 0 _ C O N F I G 0 x 1 A / /R / W # d e f i n eM P U 6 0 5 0 _ G Y R O _ C O N F I G 0 x 1 B / /R / W # d e f i n eM P U 6 0 5 0 _ A C C E L _ C O N F I G 0 x 1 C / /R / W # d e f i n eM P U 6 0 5 0 _ F F _ T H R 0 x 1 D / /R / W # d e f i n eM P U 6 0 5 0 _ F F _ D U R 0 x 1 E / /R / W # d e f i n eM P U 6 0 5 0 _ M O T _ T H R 0 x 1 F / /R / W

playground.arduino.cc/Main/MPU-6050

5/13

4/11/13

Arduino Playground - MPU-6050


# d e f i n eM P U 6 0 5 0 _ M O T _ D U R 0 x 2 0 # d e f i n eM P U 6 0 5 0 _ Z R M O T _ T H R 0 x 2 1 # d e f i n eM P U 6 0 5 0 _ Z R M O T _ D U R 0 x 2 2 # d e f i n eM P U 6 0 5 0 _ F I F O _ E N 0 x 2 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C T R L 0 x 2 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ A D D R 0 x 2 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ R E G 0 x 2 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ C T R L 0 x 2 7 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ A D D R 0 x 2 8 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ R E G 0 x 2 9 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ C T R L 0 x 2 A # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ A D D R 0 x 2 B # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ R E G 0 x 2 C # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ C T R L 0 x 2 D # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ A D D R 0 x 2 E # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ R E G 0 x 2 F # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ C T R L 0 x 3 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ A D D R 0 x 3 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ R E G 0 x 3 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ D O 0 x 3 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ C T R L 0 x 3 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ D I 0 x 3 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ S T A T U S 0 x 3 6 # d e f i n eM P U 6 0 5 0 _ I N T _ P I N _ C F G 0 x 3 7 # d e f i n eM P U 6 0 5 0 _ I N T _ E N A B L E 0 x 3 8 # d e f i n eM P U 6 0 5 0 _ I N T _ S T A T U S 0 x 3 A # d e f i n eM P U 6 0 5 0 _ A C C E L _ X O U T _ H 0 x 3 B # d e f i n eM P U 6 0 5 0 _ A C C E L _ X O U T _ L 0 x 3 C # d e f i n eM P U 6 0 5 0 _ A C C E L _ Y O U T _ H 0 x 3 D # d e f i n eM P U 6 0 5 0 _ A C C E L _ Y O U T _ L 0 x 3 E # d e f i n eM P U 6 0 5 0 _ A C C E L _ Z O U T _ H 0 x 3 F # d e f i n eM P U 6 0 5 0 _ A C C E L _ Z O U T _ L 0 x 4 0 # d e f i n eM P U 6 0 5 0 _ T E M P _ O U T _ H 0 x 4 1 # d e f i n eM P U 6 0 5 0 _ T E M P _ O U T _ L 0 x 4 2 # d e f i n eM P U 6 0 5 0 _ G Y R O _ X O U T _ H 0 x 4 3 # d e f i n eM P U 6 0 5 0 _ G Y R O _ X O U T _ L 0 x 4 4 # d e f i n eM P U 6 0 5 0 _ G Y R O _ Y O U T _ H 0 x 4 5 # d e f i n eM P U 6 0 5 0 _ G Y R O _ Y O U T _ L 0 x 4 6 # d e f i n eM P U 6 0 5 0 _ G Y R O _ Z O U T _ H 0 x 4 7 # d e f i n eM P U 6 0 5 0 _ G Y R O _ Z O U T _ L 0 x 4 8 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 0 0 x 4 9 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 1 0 x 4 A # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 2 0 x 4 B # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 3 0 x 4 C # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 4 0 x 4 D # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 5 0 x 4 E # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 6 0 x 4 F # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 7 0 x 5 0 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 8 0 x 5 1 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 0 9 0 x 5 2 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 0 0 x 5 3 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 1 0 x 5 4 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 2 0 x 5 5 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 3 0 x 5 6 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 4 0 x 5 7 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 5 0 x 5 8 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 6 0 x 5 9 # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 7 0 x 5 A # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 8 0 x 5 B # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 1 9 0 x 5 C # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 2 0 0 x 5 D # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 2 1 0 x 5 E # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 2 2 0 x 5 F # d e f i n eM P U 6 0 5 0 _ E X T _ S E N S _ D A T A _ 2 3 0 x 6 0 # d e f i n eM P U 6 0 5 0 _ M O T _ D E T E C T _ S T A T U S 0 x 6 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ D O 0 x 6 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ D O 0 x 6 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ D O 0 x 6 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ D O 0 x 6 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D E L A Y _ C T R L0 x 6 7 # d e f i n eM P U 6 0 5 0 _ S I G N A L _ P A T H _ R E S E T 0 x 6 8 # d e f i n eM P U 6 0 5 0 _ M O T _ D E T E C T _ C T R L 0 x 6 9 # d e f i n eM P U 6 0 5 0 _ U S E R _ C T R L 0 x 6 A # d e f i n eM P U 6 0 5 0 _ P W R _ M G M T _ 1 0 x 6 B # d e f i n eM P U 6 0 5 0 _ P W R _ M G M T _ 2 0 x 6 C # d e f i n eM P U 6 0 5 0 _ F I F O _ C O U N T H 0 x 7 2 # d e f i n eM P U 6 0 5 0 _ F I F O _ C O U N T L 0 x 7 3 # d e f i n eM P U 6 0 5 0 _ F I F O _ R _ W 0 x 7 4 # d e f i n eM P U 6 0 5 0 _ W H O _ A M _ I 0 x 7 5 / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / /R / /R / W / /R / W / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R / W / /R

/ /D e f i n e sf o rt h eb i t s ,t ob ea b l et oc h a n g e / /b e t w e e nb i tn u m b e ra n db i n a r yd e f i n i t i o n . / /B yu s i n gt h eb i tn u m b e r ,p r o g r a m m i n gt h es e n s o r / /i sl i k ep r o g r a m m i n gt h eA V Rm i c r o c o n t r o l l e r . / /B u ti n s t e a do fu s i n g" ( 1 < < X ) " ,o r" _ B V ( X ) " , / /t h eA r d u i n o" b i t ( X ) "i su s e d . # d e f i n eM P U 6 0 5 0 _ D 00 # d e f i n eM P U 6 0 5 0 _ D 11 # d e f i n eM P U 6 0 5 0 _ D 22 # d e f i n eM P U 6 0 5 0 _ D 33 # d e f i n eM P U 6 0 5 0 _ D 44 # d e f i n eM P U 6 0 5 0 _ D 55 # d e f i n eM P U 6 0 5 0 _ D 66 # d e f i n eM P U 6 0 5 0 _ D 77 / /A U X _ V D D I OR e g i s t e r # d e f i n eM P U 6 0 5 0 _ A U X _ V D D I OM P U 6 0 5 0 _ D 7 / /I 2 Ch i g h :1 = V D D ,0 = V L O G I C / /C O N F I GR e g i s t e r / /D L P Fi sD i g i t a lL o wP a s sF i l t e rf o rb o t hg y r oa n d a c c e l e r o m e t e r s . / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T 0M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T 1M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T 2M P U 6 0 5 0 _ D 5 / /C o m b i n e dd e f i n i t i o n sf o rt h eE X T _ S Y N C _ S E Tv a l u e s # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 1( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 0 ) ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 2( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 1 ) )

playground.arduino.cc/Main/MPU-6050

6/13

4/11/13

Arduino Playground - MPU-6050


# d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 3 ( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 1 ) | b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 0 ) ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 4( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 2 ) ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 5 ( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 2 ) | b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 0 ) ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 6 ( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 2 ) | b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 1 ) ) # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 7 ( b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 2 ) | b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 1 ) | b i t ( M P U 6 0 5 0 _ E X T _ S Y N C _ S E T 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s . # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ D I S A B L E D M P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 0 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ T E M P _ O U T _ L M P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 1 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ G Y R O _ X O U T _ L M P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 2 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ G Y R O _ Y O U T _ L M P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 3 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ G Y R O _ Z O U T _ L M P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 4 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ A C C E L _ X O U T _ LM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 5 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ A C C E L _ Y O U T _ LM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 6 # d e f i n eM P U 6 0 5 0 _ E X T _ S Y N C _ A C C E L _ Z O U T _ LM P U 6 0 5 0 _ E X T _ S Y N C _ S E T _ 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eD L P F _ C F Gv a l u e s # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 1( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 0 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 2( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 1 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 3 ( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 1 ) | b i t ( M P U 6 0 5 0 _ D L P F _ C F G 0 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 4( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 2 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 5 ( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 2 ) | b i t ( M P U 6 0 5 0 _ D L P F _ C F G 0 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 6 ( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 2 ) | b i t ( M P U 6 0 5 0 _ D L P F _ C F G 1 ) ) # d e f i n eM P U 6 0 5 0 _ D L P F _ C F G _ 7 ( b i t ( M P U 6 0 5 0 _ D L P F _ C F G 2 ) | b i t ( M P U 6 0 5 0 _ D L P F _ C F G 1 ) | b i t ( M P U 6 0 5 0 _ D L P F _ C F G 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h i sn a m eu s e st h eb a n d w i d t h( H z )f o rt h ea c c e l o m e t e r , / /f o rt h eg y r ot h eb a n d w i d t hi sa l m o s tt h es a m e . # d e f i n eM P U 6 0 5 0 _ D L P F _ 2 6 0 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 0 # d e f i n eM P U 6 0 5 0 _ D L P F _ 1 8 4 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 1 # d e f i n eM P U 6 0 5 0 _ D L P F _ 9 4 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 2 # d e f i n eM P U 6 0 5 0 _ D L P F _ 4 4 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 3 # d e f i n eM P U 6 0 5 0 _ D L P F _ 2 1 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 4 # d e f i n eM P U 6 0 5 0 _ D L P F _ 1 0 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 5 # d e f i n eM P U 6 0 5 0 _ D L P F _ 5 H Z M P U 6 0 5 0 _ D L P F _ C F G _ 6 # d e f i n eM P U 6 0 5 0 _ D L P F _ R E S E R V E DM P U 6 0 5 0 _ D L P F _ C F G _ 7 / /G Y R O _ C O N F I GR e g i s t e r / /T h eX G _ S T ,Y G _ S T ,Z G _ S Ta r eb i t sf o rs e l f t e s t . / /T h eF S _ S E Ls e t st h er a n g ef o rt h eg y r o . / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ F S _ S E L 0M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ F S _ S E L 1M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ Z G _ S T M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ Y G _ S T M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ X G _ S T M P U 6 0 5 0 _ D 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eF S _ S E Lv a l u e s # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 1( b i t ( M P U 6 0 5 0 _ F S _ S E L 0 ) ) # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 2( b i t ( M P U 6 0 5 0 _ F S _ S E L 1 ) ) # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 3 ( b i t ( M P U 6 0 5 0 _ F S _ S E L 1 ) | b i t ( M P U 6 0 5 0 _ F S _ S E L 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h en a m eu s e st h er a n g ei nd e g r e e sp e rs e c o n d . # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 2 5 0 M P U 6 0 5 0 _ F S _ S E L _ 0 # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 5 0 0 M P U 6 0 5 0 _ F S _ S E L _ 1 # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 1 0 0 0M P U 6 0 5 0 _ F S _ S E L _ 2 # d e f i n eM P U 6 0 5 0 _ F S _ S E L _ 2 0 0 0M P U 6 0 5 0 _ F S _ S E L _ 3 / /A C C E L _ C O N F I GR e g i s t e r / /T h eX A _ S T ,Y A _ S T ,Z A _ S Ta r eb i t sf o rs e l f t e s t . / /T h eA F S _ S E Ls e t st h er a n g ef o rt h ea c c e l e r o m e t e r . / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F 0M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F 1M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F 2M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ A F S _ S E L 0 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ A F S _ S E L 1 M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ Z A _ S T M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ Y A _ S T M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ X A _ S T M P U 6 0 5 0 _ D 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eA C C E L _ H P Fv a l u e s # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 1( b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 0 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 2( b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 1 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 3 ( b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 1 ) | b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 0 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 4( b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 2 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 7 ( b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 2 ) | b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 1 ) | b i t ( M P U 6 0 5 0 _ A C C E L _ H P F 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h en a m eu s e st h eC u t o f ff r e q u e n c y . # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ R E S E T M P U 6 0 5 0 _ A C C E L _ H P F _ 0 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 5 H Z M P U 6 0 5 0 _ A C C E L _ H P F _ 1 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 2 _ 5 H Z M P U 6 0 5 0 _ A C C E L _ H P F _ 2 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 1 _ 2 5 H ZM P U 6 0 5 0 _ A C C E L _ H P F _ 3 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ 0 _ 6 3 H ZM P U 6 0 5 0 _ A C C E L _ H P F _ 4 # d e f i n eM P U 6 0 5 0 _ A C C E L _ H P F _ H O L D M P U 6 0 5 0 _ A C C E L _ H P F _ 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eA F S _ S E Lv a l u e s # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 1( b i t ( M P U 6 0 5 0 _ A F S _ S E L 0 ) ) # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 2( b i t ( M P U 6 0 5 0 _ A F S _ S E L 1 ) ) # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 3 ( b i t ( M P U 6 0 5 0 _ A F S _ S E L 1 ) | b i t ( M P U 6 0 5 0 _ A F S _ S E L 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h en a m eu s e st h ef u l ls c a l er a n g ef o rt h ea c c e l e r o m e t e r . # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 2 G M P U 6 0 5 0 _ A F S _ S E L _ 0 # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 4 G M P U 6 0 5 0 _ A F S _ S E L _ 1

playground.arduino.cc/Main/MPU-6050

7/13

4/11/13

Arduino Playground - MPU-6050


# d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 8 G M P U 6 0 5 0 _ A F S _ S E L _ 2 # d e f i n eM P U 6 0 5 0 _ A F S _ S E L _ 1 6 GM P U 6 0 5 0 _ A F S _ S E L _ 3 / /F I F O _ E NR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ S L V 0 _ F I F O _ E N M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ S L V 1 _ F I F O _ E N M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ S L V 2 _ F I F O _ E N M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ A C C E L _ F I F O _ E NM P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ Z G _ F I F O _ E N M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ Y G _ F I F O _ E N M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ X G _ F I F O _ E N M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ T E M P _ F I F O _ E N M P U 6 0 5 0 _ D 7 / /I 2 C _ M S T _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ P _ N S RM P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ S L V _ 3 _ F I F O _ E NM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ W A I T _ F O R _ E S M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ M U L T _ M S T _ E N M P U 6 0 5 0 _ D 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eI 2 C _ M S T _ C L K # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 5 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 6 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 7 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 8 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 9 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 0 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 1 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 2 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 3 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 4 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) ) # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 5 ( b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 3 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 2 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 1 ) | b i t ( M P U 6 0 5 0 _ I 2 C _ M S T _ C L K 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h en a m e su s e sI 2 CM a s t e rC l o c kS p e e di nk H z . # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 4 8 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 3 3 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 2 0 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 0 8 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 9 6 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 8 6 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 7 6 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 6 7 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 7 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 2 5 8 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 8 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 5 0 0 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 9 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 7 1 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 4 4 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 2 1 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 4 0 0 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 8 1 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 3 6 4 K H ZM P U 6 0 5 0 _ I 2 C _ M S T _ C L K _ 1 5 / /I 2 C _ S L V 0 _ A D D RR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ R WM P U 6 0 5 0 _ D 7 / /I 2 C _ S L V 0 _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ L E N 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ L E N 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ L E N 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ L E N 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ G R P M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ R E G _ D I SM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ B Y T E _ S WM P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ E N M P U 6 0 5 0 _ D 7 / /Am a s kf o rt h el e n g t h # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ L E N _ M A S K0 x 0 F / /I 2 C _ S L V 1 _ A D D RR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ R WM P U 6 0 5 0 _ D 7 / /I 2 C _ S L V 1 _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ L E N 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ L E N 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ L E N 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ L E N 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ G R P M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ R E G _ D I SM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ B Y T E _ S WM P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ E N M P U 6 0 5 0 _ D 7 / /Am a s kf o rt h el e n g t h # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ L E N _ M A S K0 x 0 F

playground.arduino.cc/Main/MPU-6050

8/13

4/11/13

Arduino Playground - MPU-6050


/ /I 2 C _ S L V 2 _ A D D RR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ R WM P U 6 0 5 0 _ D 7 / /I 2 C _ S L V 2 _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ L E N 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ L E N 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ L E N 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ L E N 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ G R P M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ R E G _ D I SM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ B Y T E _ S WM P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ E N M P U 6 0 5 0 _ D 7 / /Am a s kf o rt h el e n g t h # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ L E N _ M A S K0 x 0 F / /I 2 C _ S L V 3 _ A D D RR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ R WM P U 6 0 5 0 _ D 7 / /I 2 C _ S L V 3 _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ L E N 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ L E N 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ L E N 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ L E N 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ G R P M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ R E G _ D I SM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ B Y T E _ S WM P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ E N M P U 6 0 5 0 _ D 7 / /Am a s kf o rt h el e n g t h # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ L E N _ M A S K0 x 0 F / /I 2 C _ S L V 4 _ A D D RR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ R WM P U 6 0 5 0 _ D 7 / /I 2 C _ S L V 4 _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y 3 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y 4 M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ R E G _ D I SM P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ I N T _ E N M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ E N M P U 6 0 5 0 _ D 7 / /Am a s kf o rt h ed e l a y # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ D L Y _ M A S K0 x 1 F / /I 2 C _ M S T _ S T A T U SR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ N A C KM P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ N A C KM P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ N A C KM P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ N A C KM P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ N A C KM P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ I 2 C _ L O S T _ A R B M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ D O N EM P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ P A S S _ T H R O U G H M P U 6 0 5 0 _ D 7 / /I 2 C _ P I N _ C F GR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ C L K O U T _ E N M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ B Y P A S S _ E N M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ F S Y N C _ I N T _ E N M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ F S Y N C _ I N T _ L E V E LM P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I N T _ R D _ C L E A R M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ L A T C H _ I N T _ E N M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ I N T _ O P E N M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ I N T _ L E V E L M P U 6 0 5 0 _ D 7 / /I N T _ E N A B L ER e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ D A T A _ R D Y _ E N M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ I N T _ E NM P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ F I F O _ O F L O W _ E N M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ Z M O T _ E N M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ M O T _ E N M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ F F _ E N M P U 6 0 5 0 _ D 7 / /I N T _ S T A T U SR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ D A T A _ R D Y _ I N T M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ I N T M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ F I F O _ O F L O W _ I N TM P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ Z M O T _ I N T M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ M O T _ I N T M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ F F _ I N T M P U 6 0 5 0 _ D 7 / /M O T _ D E T E C T _ S T A T U SR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ M O T _ Z R M O TM P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ M O T _ Z P O S M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ M O T _ Z N E G M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ M O T _ Y P O S M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ M O T _ Y N E G M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ M O T _ X P O S M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ M O T _ X N E G M P U 6 0 5 0 _ D 7

playground.arduino.cc/Main/MPU-6050

9/13

4/11/13

Arduino Playground - MPU-6050


/ /I C 2 _ M S T _ D E L A Y _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 0 _ D L Y _ E NM P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 1 _ D L Y _ E NM P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 2 _ D L Y _ E NM P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 3 _ D L Y _ E NM P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ I 2 C _ S L V 4 _ D L Y _ E NM P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ D E L A Y _ E S _ S H A D O WM P U 6 0 5 0 _ D 7 / /S I G N A L _ P A T H _ R E S E TR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ T E M P _ R E S E T M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ A C C E L _ R E S E TM P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ G Y R O _ R E S E T M P U 6 0 5 0 _ D 2 / /M O T _ D E T E C T _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T 0 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T 1 M P U 6 0 5 0 _ D 3 # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 0M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 1M P U 6 0 5 0 _ D 5 / /C o m b i n e dd e f i n i t i o n sf o rt h eM O T _ C O U N T # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T _ 1( b i t ( M P U 6 0 5 0 _ M O T _ C O U N T 0 ) ) # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T _ 2( b i t ( M P U 6 0 5 0 _ M O T _ C O U N T 1 ) ) # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T _ 3 ( b i t ( M P U 6 0 5 0 _ M O T _ C O U N T 1 ) | b i t ( M P U 6 0 5 0 _ M O T _ C O U N T 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s # d e f i n eM P U 6 0 5 0 _ M O T _ C O U N T _ R E S E TM P U 6 0 5 0 _ M O T _ C O U N T _ 0 / /C o m b i n e dd e f i n i t i o n sf o rt h eF F _ C O U N T # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T _ 1( b i t ( M P U 6 0 5 0 _ F F _ C O U N T 0 ) ) # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T _ 2( b i t ( M P U 6 0 5 0 _ F F _ C O U N T 1 ) ) # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T _ 3 ( b i t ( M P U 6 0 5 0 _ F F _ C O U N T 1 ) | b i t ( M P U 6 0 5 0 _ F F _ C O U N T 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s # d e f i n eM P U 6 0 5 0 _ F F _ C O U N T _ R E S E TM P U 6 0 5 0 _ F F _ C O U N T _ 0 / /C o m b i n e dd e f i n i t i o n sf o rt h eA C C E L _ O N _ D E L A Y # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 1( b i t ( M P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 0 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 2( b i t ( M P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 1 ) ) # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 3 ( b i t ( M P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 1 ) | b i t ( M P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y 0 ) ) / /A l t e r n a t i v en a m e sf o rt h eA C C E L _ O N _ D E L A Y # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 0 M SM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 0 # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 1 M SM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 1 # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 2 M SM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 2 # d e f i n eM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 3 M SM P U 6 0 5 0 _ A C C E L _ O N _ D E L A Y _ 3 / /U S E R _ C T R LR e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ S I G _ C O N D _ R E S E TM P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ R E S E T M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ F I F O _ R E S E T M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ I 2 C _ I F _ D I S M P U 6 0 5 0 _ D 4 6 0 5 0 # d e f i n eM P U 6 0 5 0 _ I 2 C _ M S T _ E N M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ F I F O _ E N M P U 6 0 5 0 _ D 6 / /P W R _ M G M T _ 1R e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ C L K S E L 0 M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ C L K S E L 1 M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ C L K S E L 2 M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ T E M P _ D I S M P U 6 0 5 0 _ D 3 t e m p e r a t u r es e n s o r # d e f i n eM P U 6 0 5 0 _ C Y C L E M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ S L E E P M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ D E V I C E _ R E S E TM P U 6 0 5 0 _ D 7 v a l u e s

/ /m u s tb e0f o rM P U -

/ /1 :d i s a b l e / /1 :s a m p l ea n ds l e e p / /1 :s l e e pm o d e / /1 :r e s e tt od e f a u l t

/ /C o m b i n e dd e f i n i t i o n sf o rt h eC L K S E L # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 1( b i t ( M P U 6 0 5 0 _ C L K S E L 0 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 2( b i t ( M P U 6 0 5 0 _ C L K S E L 1 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 3 ( b i t ( M P U 6 0 5 0 _ C L K S E L 1 ) | b i t ( M P U 6 0 5 0 _ C L K S E L 0 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 4( b i t ( M P U 6 0 5 0 _ C L K S E L 2 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 5 ( b i t ( M P U 6 0 5 0 _ C L K S E L 2 ) | b i t ( M P U 6 0 5 0 _ C L K S E L 0 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 6 ( b i t ( M P U 6 0 5 0 _ C L K S E L 2 ) | b i t ( M P U 6 0 5 0 _ C L K S E L 1 ) ) # d e f i n eM P U 6 0 5 0 _ C L K S E L _ 7 ( b i t ( M P U 6 0 5 0 _ C L K S E L 2 ) | b i t ( M P U 6 0 5 0 _ C L K S E L 1 ) | b i t ( M P U 6 0 5 0 _ C L K S E L 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s # d e f i n eM P U 6 0 5 0 _ C L K S E L _ I N T E R N A L M P U 6 0 5 0 _ C L K S E L _ 0 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ X M P U 6 0 5 0 _ C L K S E L _ 1 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ Y M P U 6 0 5 0 _ C L K S E L _ 2 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ Z M P U 6 0 5 0 _ C L K S E L _ 3 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ E X T _ 3 2 K H Z M P U 6 0 5 0 _ C L K S E L _ 4 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ E X T _ 1 9 _ 2 M H ZM P U 6 0 5 0 _ C L K S E L _ 5 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ R E S E R V E D M P U 6 0 5 0 _ C L K S E L _ 6 # d e f i n eM P U 6 0 5 0 _ C L K S E L _ S T O P M P U 6 0 5 0 _ C L K S E L _ 7 / /P W R _ M G M T _ 2R e g i s t e r / /T h e s ea r et h en a m e sf o rt h eb i t s . / /U s et h e s eo n l yw i t ht h eb i t ( )m a c r o . # d e f i n eM P U 6 0 5 0 _ S T B Y _ Z G M P U 6 0 5 0 _ D 0 # d e f i n eM P U 6 0 5 0 _ S T B Y _ Y G M P U 6 0 5 0 _ D 1 # d e f i n eM P U 6 0 5 0 _ S T B Y _ X G M P U 6 0 5 0 _ D 2 # d e f i n eM P U 6 0 5 0 _ S T B Y _ Z A M P U 6 0 5 0 _ D 3

playground.arduino.cc/Main/MPU-6050

10/13

4/11/13

Arduino Playground - MPU-6050


# d e f i n eM P U 6 0 5 0 _ S T B Y _ Y A M P U 6 0 5 0 _ D 4 # d e f i n eM P U 6 0 5 0 _ S T B Y _ X A M P U 6 0 5 0 _ D 5 # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L 0M P U 6 0 5 0 _ D 6 # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L 1M P U 6 0 5 0 _ D 7 / /C o m b i n e dd e f i n i t i o n sf o rt h eL P _ W A K E _ C T R L # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 0( 0 ) # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 1( b i t ( M P U 6 0 5 0 _ L P _ W A K E _ C T R L 0 ) ) # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 2( b i t ( M P U 6 0 5 0 _ L P _ W A K E _ C T R L 1 ) ) # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 3 ( b i t ( M P U 6 0 5 0 _ L P _ W A K E _ C T R L 1 ) | b i t ( M P U 6 0 5 0 _ L P _ W A K E _ C T R L 0 ) ) / /A l t e r n a t i v en a m e sf o rt h ec o m b i n e dd e f i n i t i o n s / /T h en a m e su s e st h eW a k e u pF r e q u e n c y . # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ 1 _ 2 5 H ZM P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 0 # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ 2 _ 5 H Z M P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 1 # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ 5 H Z M P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 2 # d e f i n eM P U 6 0 5 0 _ L P _ W A K E _ 1 0 H Z M P U 6 0 5 0 _ L P _ W A K E _ C T R L _ 3 / /D e f a u l tI 2 Ca d d r e s sf o rt h eM P U 6 0 5 0i s0 x 6 8 . / /B u to n l yi ft h eA D 0p i ni sl o w . / /S o m es e n s o rb o a r d sh a v eA D 0h i g h ,a n dt h e / /I 2 Ca d d r e s st h u sb e c o m e s0 x 6 9 . # d e f i n eM P U 6 0 5 0 _ I 2 C _ A D D R E S S0 x 6 8 / /D e c l a r i n ga nu n i o nf o rt h er e g i s t e r sa n dt h ea x i sv a l u e s . / /T h eb y t eo r d e rd o e sn o tm a t c ht h eb y t eo r d e ro f / /t h ec o m p i l e ra n dA V Rc h i p . / /T h eA V Rc h i p( o nt h eA r d u i n ob o a r d )h a st h eL o wB y t e / /a tt h el o w e ra d d r e s s . / /B u tt h eM P U 6 0 5 0h a sad i f f e r e n to r d e r :H i g hB y t ea t / /l o w e ra d d r e s s ,s ot h a th a st ob ec o r r e c t e d . / /T h er e g i s t e rp a r t" r e g "i so n l yu s e di n t e r n a l l y , / /a n da r es w a p p e di nc o d e . t y p e d e fu n i o na c c e l _ t _ g y r o _ u n i o n { s t r u c t { u i n t 8 _ tx _ a c c e l _ h ; u i n t 8 _ tx _ a c c e l _ l ; u i n t 8 _ ty _ a c c e l _ h ; u i n t 8 _ ty _ a c c e l _ l ; u i n t 8 _ tz _ a c c e l _ h ; u i n t 8 _ tz _ a c c e l _ l ; u i n t 8 _ tt _ h ; u i n t 8 _ tt _ l ; u i n t 8 _ tx _ g y r o _ h ; u i n t 8 _ tx _ g y r o _ l ; u i n t 8 _ ty _ g y r o _ h ; u i n t 8 _ ty _ g y r o _ l ; u i n t 8 _ tz _ g y r o _ h ; u i n t 8 _ tz _ g y r o _ l ; }r e g ; s t r u c t { i n tx _ a c c e l ; i n ty _ a c c e l ; i n tz _ a c c e l ; i n tt e m p e r a t u r e ; i n tx _ g y r o ; i n ty _ g y r o ; i n tz _ g y r o ; }v a l u e ; } ; v o i ds e t u p ( ) { i n te r r o r ; u i n t 8 _ tc ; S e r i a l . b e g i n ( 9 6 0 0 ) ; S e r i a l . p r i n t l n ( F ( " I n v e n S e n s eM P U 6 0 5 0 " ) ) ; S e r i a l . p r i n t l n ( F ( " J u n e2 0 1 2 " ) ) ; / /I n i t i a l i z et h e' W i r e 'c l a s sf o rt h eI 2 C b u s . W i r e . b e g i n ( ) ; / /d e f a u l ta tp o w e r u p : / / G y r oa t2 5 0d e g r e e ss e c o n d / / A c c e l e r a t i o na t2 g / / C l o c ks o u r c ea ti n t e r n a l8 M H z / / T h ed e v i c ei si ns l e e pm o d e . / / e r r o r=M P U 6 0 5 0 _ r e a d( M P U 6 0 5 0 _ W H O _ A M _ I ,& c ,1 ) ; S e r i a l . p r i n t ( F ( " W H O _ A M _ I:" ) ) ; S e r i a l . p r i n t ( c , H E X ) ; S e r i a l . p r i n t ( F ( " ,e r r o r=" ) ) ; S e r i a l . p r i n t l n ( e r r o r , D E C ) ; / /A c c o r d i n gt ot h ed a t a s h e e t ,t h e' s l e e p 'b i t / /s h o u l dr e a da' 1 ' .B u tIr e a da' 0 ' . / /T h a tb i th a st ob ec l e a r e d ,s i n c et h es e n s o r / /i si ns l e e pm o d ea tp o w e r u p .E v e ni ft h e / /b i tr e a d s' 0 ' . e r r o r=M P U 6 0 5 0 _ r e a d( M P U 6 0 5 0 _ P W R _ M G M T _ 2 ,& c ,1 ) ; S e r i a l . p r i n t ( F ( " P W R _ M G M T _ 2:" ) ) ; S e r i a l . p r i n t ( c , H E X ) ; S e r i a l . p r i n t ( F ( " ,e r r o r=" ) ) ; S e r i a l . p r i n t l n ( e r r o r , D E C ) ; / /C l e a rt h e' s l e e p 'b i tt os t a r tt h es e n s o r . M P U 6 0 5 0 _ w r i t e _ r e g( M P U 6 0 5 0 _ P W R _ M G M T _ 1 ,0 ) ;

v o i dl o o p ( ) { i n te r r o r ;

playground.arduino.cc/Main/MPU-6050

11/13

4/11/13

Arduino Playground - MPU-6050


d o u b l ed T ; a c c e l _ t _ g y r o _ u n i o na c c e l _ t _ g y r o ; S e r i a l . p r i n t l n ( F ( " " ) ) ; S e r i a l . p r i n t l n ( F ( " M P U 6 0 5 0 " ) ) ; / /R e a dt h er a wv a l u e s . / /R e a d1 4b y t e sa to n c e , / /c o n t a i n i n ga c c e l e r a t i o n ,t e m p e r a t u r ea n dg y r o . / /W i t ht h ed e f a u l ts e t t i n g so ft h eM P U 6 0 5 0 , / /t h e r ei sn of i l t e re n a b l e d ,a n dt h ev a l u e s / /a r en o tv e r ys t a b l e . e r r o r=M P U 6 0 5 0 _ r e a d( M P U 6 0 5 0 _ A C C E L _ X O U T _ H ,( u i n t 8 _ t* ) & a c c e l _ t _ g y r o ,s i z e o f ( a c c e l _ t _ g y r o ) ) ; S e r i a l . p r i n t ( F ( " R e a da c c e l ,t e m pa n dg y r o ,e r r o r=" ) ) ; S e r i a l . p r i n t l n ( e r r o r , D E C ) ; / /S w a pa l lh i g ha n dl o wb y t e s . / /A f t e rt h i s ,t h er e g i s t e r sv a l u e sa r es w a p p e d , / /s ot h es t r u c t u r en a m el i k ex _ a c c e l _ ld o e sn o / /l o n g e rc o n t a i nt h el o w e rb y t e . u i n t 8 _ ts w a p ; # d e f i n eS W A P ( x , y )s w a p=x ;x=y ;y=s w a p S W A P( a c c e l _ t _ g y r o . r e g . x _ a c c e l _ h ,a c c e l _ t _ g y r o . r e g . x _ a c c e l _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . y _ a c c e l _ h ,a c c e l _ t _ g y r o . r e g . y _ a c c e l _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . z _ a c c e l _ h ,a c c e l _ t _ g y r o . r e g . z _ a c c e l _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . t _ h ,a c c e l _ t _ g y r o . r e g . t _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . x _ g y r o _ h ,a c c e l _ t _ g y r o . r e g . x _ g y r o _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . y _ g y r o _ h ,a c c e l _ t _ g y r o . r e g . y _ g y r o _ l ) ; S W A P( a c c e l _ t _ g y r o . r e g . z _ g y r o _ h ,a c c e l _ t _ g y r o . r e g . z _ g y r o _ l ) ; / /P r i n tt h er a wa c c e l e r a t i o nv a l u e s S e r i a l . p r i n t ( F ( " a c c e lx , y , z :" ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . x _ a c c e l ,D E C ) ; S e r i a l . p r i n t ( F ( " ," ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . y _ a c c e l ,D E C ) ; S e r i a l . p r i n t ( F ( " ," ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . z _ a c c e l ,D E C ) ; S e r i a l . p r i n t l n ( F ( " " ) ) ; / /T h et e m p e r a t u r es e n s o ri s4 0t o+ 8 5d e g r e e sC e l s i u s . / /I ti sas i g n e di n t e g e r . / /A c c o r d i n gt ot h ed a t a s h e e t : / / 3 4 0p e rd e g r e e sC e l s i u s ,5 1 2a t3 5d e g r e e s . / /A t0d e g r e e s :5 1 2-( 3 4 0*3 5 )=1 2 4 1 2 S e r i a l . p r i n t ( F ( " t e m p e r a t u r e :" ) ) ; d T=(( d o u b l e )a c c e l _ t _ g y r o . v a l u e . t e m p e r a t u r e+1 2 4 1 2 . 0 )/ 3 4 0 . 0 ; S e r i a l . p r i n t ( d T ,3 ) ; S e r i a l . p r i n t ( F ( "d e g r e e sC e l s i u s " ) ) ; S e r i a l . p r i n t l n ( F ( " " ) ) ; / /P r i n tt h er a wg y r ov a l u e s . S e r i a l . p r i n t ( F ( " g y r ox , y , z:" ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . x _ g y r o ,D E C ) ; S e r i a l . p r i n t ( F ( " ," ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . y _ g y r o ,D E C ) ; S e r i a l . p r i n t ( F ( " ," ) ) ; S e r i a l . p r i n t ( a c c e l _ t _ g y r o . v a l u e . z _ g y r o ,D E C ) ; S e r i a l . p r i n t ( F ( " ," ) ) ; S e r i a l . p r i n t l n ( F ( " " ) ) ; } d e l a y ( 1 0 0 0 ) ;

/ // /M P U 6 0 5 0 _ r e a d / / / /T h i si sac o m m o nf u n c t i o nt or e a dm u l t i p l eb y t e s / /f r o ma nI 2 Cd e v i c e . / / / /I tu s e st h eb o o l e a np a r a m e t e rf o rW i r e . e n d T r a n s M i s s i o n ( ) / /t ob ea b l et oh o l do rr e l e a s et h eI 2 C b u s . / /T h i si si m p l e m e n t e di nA r d u i n o1 . 0 . 1 . / / / /O n l yt h i sf u n c t i o ni su s e dt or e a d . / /T h e r ei sn of u n c t i o nf o ras i n g l eb y t e . / / i n tM P U 6 0 5 0 _ r e a d ( i n ts t a r t ,u i n t 8 _ t* b u f f e r ,i n ts i z e ) { i n ti ,n ,e r r o r ; W i r e . b e g i n T r a n s m i s s i o n ( M P U 6 0 5 0 _ I 2 C _ A D D R E S S ) ; n=W i r e . w r i t e ( s t a r t ) ; i f( n! =1 ) r e t u r n( 1 0 ) ; n=W i r e . e n d T r a n s m i s s i o n ( f a l s e ) ; i f( n! =0 ) r e t u r n( n ) ; / /h o l dt h eI 2 C b u s

/ /T h i r dp a r a m e t e ri st r u e :r e l a s eI 2 C b u sa f t e rd a t ai sr e a d . W i r e . r e q u e s t F r o m ( M P U 6 0 5 0 _ I 2 C _ A D D R E S S ,s i z e ,t r u e ) ; i=0 ; w h i l e ( W i r e . a v a i l a b l e ( )& &i < s i z e ) { b u f f e r [ i + + ] = W i r e . r e a d ( ) ; } i f(i! =s i z e ) r e t u r n( 1 1 ) ; } r e t u r n( 0 ) ; / /r e t u r n:n oe r r o r

playground.arduino.cc/Main/MPU-6050

12/13

4/11/13

Arduino Playground - MPU-6050


/ // /M P U 6 0 5 0 _ w r i t e / / / /T h i si sac o m m o nf u n c t i o nt ow r i t em u l t i p l eb y t e st oa nI 2 C d e v i c e . / / / /I fo n l yas i n g l er e g i s t e ri sw r i t t e n , / /u s et h ef u n c t i o nM P U _ 6 0 5 0 _ w r i t e _ r e g ( ) . / / / /P a r a m e t e r s : / / s t a r t:S t a r ta d d r e s s ,u s ead e f i n ef o rt h er e g i s t e r / / p D a t a:Ap o i n t e rt ot h ed a t at ow r i t e . / / s i z e :T h en u m b e ro fb y t e st ow r i t e . / / / /I fo n l yas i n g l er e g i s t e ri sw r i t t e n ,ap o i n t e r / /t ot h ed a t ah a st ob eu s e d ,a n dt h es i z ei s / /as i n g l eb y t e : / / i n td a t a=0 ; / /t h ed a t at ow r i t e / / M P U 6 0 5 0 _ w r i t e( M P U 6 0 5 0 _ P W R _ M G M T _ 1 ,& c ,1 ) ; / / i n tM P U 6 0 5 0 _ w r i t e ( i n ts t a r t ,c o n s tu i n t 8 _ t* p D a t a ,i n ts i z e ) { i n tn ,e r r o r ; W i r e . b e g i n T r a n s m i s s i o n ( M P U 6 0 5 0 _ I 2 C _ A D D R E S S ) ; n=W i r e . w r i t e ( s t a r t ) ; / /w r i t et h es t a r ta d d r e s s i f( n! =1 ) r e t u r n( 2 0 ) ; n=W i r e . w r i t e ( p D a t a ,s i z e ) ; / /w r i t ed a t ab y t e s i f( n! =s i z e ) r e t u r n( 2 1 ) ; e r r o r=W i r e . e n d T r a n s m i s s i o n ( t r u e ) ;/ /r e l e a s et h eI 2 C b u s i f( e r r o r! =0 ) r e t u r n( e r r o r ) ; } r e t u r n( 0 ) ; / /r e t u r n:n oe r r o r

/ // /M P U 6 0 5 0 _ w r i t e _ r e g / / / /A ne x t r af u n c t i o nt ow r i t eas i n g l er e g i s t e r . / /I ti sj u s taw r a p p e ra r o u n dt h eM P U _ 6 0 5 0 _ w r i t e ( ) / /f u n c t i o n ,a n di ti so n l yac o n v e n i e n tf u n c t i o n / /t om a k ei te a s i e rt ow r i t eas i n g l er e g i s t e r . / / i n tM P U 6 0 5 0 _ w r i t e _ r e g ( i n tr e g ,u i n t 8 _ td a t a ) { i n te r r o r ; e r r o r=M P U 6 0 5 0 _ w r i t e ( r e g ,& d a t a ,1 ) ; } r e t u r n( e r r o r ) ; [Get Code]

More Share Share Share Share Share | Share

playground.arduino.cc/Main/MPU-6050

13/13

You might also like