Jump to content
I2Cdevlib Forums

Search the Community

Showing results for tags 'mpu6050'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • I2Cdevlib Web Tools
    • I2C Protocol Analyzer
    • I2C Device Entry Interface
    • I2C Device Library API
  • I2Cdev Platform Discussion
    • Arduino (ATmega)
    • Arduino Due (ARM Cortex M3)
    • MSP430
    • Other Platforms
  • I2C Device Discussion
    • AD7746 capacitance-to-digital converter (Analog Devices)
    • ADS1115 16-bit A/D converter (Texas Instruments)
    • ADXL345 3-axis accelerometer (Analog Devices)
    • AK8975 3-axis magnetometer (AKM Semiconductor)
    • BMA150 3-axis accelerometer (Bosch Sensortec)
    • BMP085 pressure sensor (Bosch Sensortec)
    • DS1307 real-time clock (Maxim)
    • HMC5843 3-axis magnetometer (Honeywell)
    • HMC5883L 3-axis magnetometer (Honeywell)
    • iAQ-2000 indoor air quality sensor (AppliedSensor)
    • IQS156 ProxSense capacitive touch sensor (Azoteq)
    • ITG-3200 3-axis gyroscope (InvenSense)
    • L3G4200D 3-axis accelerometer (STMicroelectronics)
    • MPL3115A2 Xtrinsic Smart Pressure Sensor (Freescale)
    • MPR121 12-bit capacitive touch sensor (Freescale)
    • MPU-6050 6-axis accelerometer/gyroscope (InvenSense)
    • MPU-9150 9-axis accelerometer/gyroscope/magnetometer (InvenSense)
    • PanelPilot multi-screen digital meter (Lascar Electronics)
    • SSD1308 128x64 OLED/PLED driver (Solomon Systech)
    • TCA6424A 24-bit I/O expander (Texas Instruments)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Would anyone be able to explain these general terms about the library? 1. How does the Digital Motion Processing (DPM) within the chip work? What does it do?2. How does the interrupt work? What is it caused by? I have a heavy sketch going on in the meantime (SD card, display, heart rate sensor.etc) in the background. Can it still be used with all these modules without delaying other functions?3. How does the library incorporate quaternions? Thanks Daniel
  2. Hi there, I am trying to use this library with my MPU6050 and Arduino to count steps and it is working great but it is taking up too much flash. Is there anyway to reduce the amount flash this library takes up? Daniel
  3. Hey everyone reading! I'm trying to get 9DOF working by using an MPU6050 (on a GY-521 breakout) along with an HMC5883L. I've got both the examples (RAW and DMP) working on my MPU6050 with just the MPU6050 hooked-up. Now I'm wondering about how to extend functionality by adding the HMC5883L through the auxiliary I2C bus of the MPU6050. Will the MPU6050 DMP example work with the HMC5883L hooked-up to the MPU6050? What should I do to get them both working together nicely? I can't seem to find any documentation on this, besides using each sensor independently of the other. Thanks for the help!
  4. Hello i would like to ask some help on how to interface the dsPIC30F4013 to MPU6050 i got the example code from jrowberg using the dsPIC30 in mplab x i build it and it was ok however i would like to know what external crystal is used for this example and if there is a schematic for this that would be great thanks in advance!
  5. Hello, I have been trying to find a solution for this issue for a while now. Any info/suggestion/pointing in the right direction would be of great help. I am working on a project where I extract quaternions to deduce orientation using MPU6050 (DMP). I use the Arduino and libraries by Jeff Rowberg for calibration and reading from sensor. I have had a prototype working with MPU6050 mounted the standard way(gravity along Z) and it works fine. I then built a custom PCB with MPU6050 chip, which is then assembled to my project. The difference being, PCB is assembled such that the gravity is not along Z, it is along X. It doesn't work as I expected (like the initial prototype). When I turn on the device, I do some initial calculations to reference it (world to body coordinates conversion). This doesn't behave as I expect. My questions are, 1. Does the DMP or library assume that the gravity is always aligned along Z by default? 2. What steps should I follow to tell the DMP/Sensor that the gravity is aligned along X and not Z? I am not an electronics guy and haven't worked extensively with sensors. So, if what I ask is stupid, please forgive me. Please do share your thoughts. Many Thanks. Kind Regards, Kailash
  6. Dear all, I am working on a small project and need to have the sample rate up to 50Hz. I ran to a thread in Arduino Forum community and someone said that he was able to change a setting from 0x0A to 0x03 in MPU6050.h to have the sample rate moved up from 18Hz to 50Hz. I am not able to locate that line of code in mpu6050.h file. I am currently using your MPU6050 raw code. It works great for me. The thread is here.Thank you very much. http://forum.arduino.cc/index.php?topic=109441.0;wap2 Ji
  7. I am building a head tracker for FPV using the MPU-6050. I need to add a button so that a user can tap it to say essentially 'this is the new center'. I imagine this should be done using the set____Offset functions but for the life of me I can't figure it out. Are the set___Offset functions accepting raw acceleration/gyro values, gravity free accelerations, etc? Sorry if this is a duplicate question, I've tried searching the forums but I'm not even sure I'm using the correct terminology. Thanks!
  8. I am building a head tracker for FPV using the MPU-6050. I need to add a button so that a user can tap it to say essentially 'this is the new center'. I imagine this should be done using the set____Offset functions but for the life of me I can't figure it out. Are the set___Offset functions accepting raw acceleration/gyro values, gravity free accelerations, etc? Sorry if this is a duplicate question, I've tried searching the forums but I'm not even sure I'm using the correct terminology. Thanks!
  9. To the I2CDev community, I am having trouble understanding the units of the MPU6050::dmpGetGyro() functions from the MPU6050_6Axis_MotionApps20.h file in the MPU6050 library (I can't find any documentation for the functions). It seems that these functions do not output raw integers like the MPU6050::getMotion6() function in the main library. In fact, I have figured out empirically that the dmpGetGyro(VectorInt16 *v, const uint8_t* packet) function outputs integers in degrees/second when the gyro range is the default of +/- 2000 deg/sec, but I would like a precision greater than 1 degree/second, and I cannot find out how to convert the 16 bit dmpGetGyro(int16_t *data, const uint8_t* packet) values to deg/second. Furthermore, if I change the gyro range (and therefore also the sensitivity), the readings change, and I need to know how to convert my readings at each sensitivity. My question is similar to this unanswered one from stack overflow. Thank you so much for your response.
  10. HI Jeff, i work in UAV project with nrf52, i use a gy+-87 as motion's sensor . i have update your library of mpu 6050 for nrf 51 to nrf52 and it worked well based on the i2cdev library of nrf. i wrote a similar lirary for the hmc5883 inspired from yours for adruino, but i have some problem, the first that when i set a bypass to MPU6050, it seems that didnt work because i don't receve any data from the mag sensor, second when i try a lonely mag sensor hmc5883, i get data but the function of set gain and set mode seems didnt work because the when i receive data , all parameters of the sensor are the default parameters. can u take an eye please in my library and try to fixed the problem because i see that all the code was right mpu6500.c mpu6500.h i2cdev.c i2cdev.h main.c
  11. Hello there! I am beginner at this and I want to obtain the following: the raw gyroscope and accelerometer data from my MPU6050 (sparkfun edition). I did that. set the frequency of the IMU at 100 Hz. How to do this? the GNSS(GPS) data from arduino type GPS module. I did that. check/ set GPS frequency to 100 Hz. How to do this? use the MPU6050 fsync function so that I could get : 1 set of acc/gyro data at the same time as getting 1 set of gps data 99 sets of acc/gyro data (time spent since the beginning = 1 s) 1 set of acc/gyro data at the same time as getting 1 set of gps data 99.... etc. How to do this? Thank you! P.S. I need proper description:D
  12. Hi, Question about Accelerometer Scale Sensitivity Factor wrong values reading I have read accel values 8192 at +/- 2g but its should read 1g of 16384 at sensitivity of 2g From Datasheet https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf P.29 AFS_SEL | Full Scale Range | LSB Sensitivity--------+------------------+----------------0 | +/- 2g | 16384 LSB/g1 | +/- 4g | 8192 LSB/g2 | +/- 8g | 4096 LSB/g3 | +/- 16g | 2048 LSB/g Is somethings wrong? Thanks in advance.
  13. Hello, I am trying to interface the MPU6050 with Cypress PSoC 5 LP097 and read out the values. However I find that the values I read out are always zeroes. I have been struggling on this issue for quite long and do not know how to proceed ahead. Any tips are appreciated. Below is the code : File : MPU6050.c void Wakeup(void) { writeBit(MPU6050_RA_PWR_MGMT, MPU6050_PWR1_SLEEP_BIT,0); } void readbyte(uint8_t reg, uint8_t *data) { readbytes(reg,1,data); } bool readbytes(uint8_t reg, uint8_t len, uint8_t *data) { int i = 0; bool readSuccess = false; while (I2C_MSTR_NO_ERROR == I2C_MasterSendStart(MPU6050_DEVICE_ADDRESS, I2C_WRITE_XFER_MODE)); while (I2C_MSTR_NO_ERROR == I2C_MasterWriteByte(reg)); while (I2C_MSTR_NO_ERROR == I2C_MasterSendRestart(MPU6050_DEVICE_ADDRESS, I2C_READ_XFER_MODE)); while (i < (len-1) ) { data[i++] = I2C_MasterReadByte(I2C_ACK_DATA); } data = I2C_MasterReadByte(I2C_NAK_DATA); readSuccess = true; I2C_MasterSendStop(); UART_PutString("I2C read completed \n"); return readSuccess; } void writeBit(uint8_t reg, uint8_t num, uint8_t data) { uint8 pwr_mgmt_reg = 0; readbyte(reg,&pwr_mgmt_reg); // read the current value of pwr_mgmt_register UART_PutString("Pw mgmnt reg value = "); UART_PutChar(pwr_mgmt_reg + CONVERT_TO_ASCII); UART_PutString("\n"); pwr_mgmt_reg &= ~(1<<num); //set the sleep bit in the register // pwr_mgmt_reg &= 0x3F; writebyte(reg,pwr_mgmt_reg); //write back after setting the pin. } void writebyte(uint8_t reg, uint8_t data) { //uint8 i = 0; while (I2C_MSTR_NO_ERROR == I2C_MasterSendStart(MPU6050_DEVICE_ADDRESS, I2C_WRITE_XFER_MODE)); //start sequence while (I2C_MSTR_NO_ERROR == I2C_MasterWriteByte(reg)); //reach the reg address. //I2C_MasterSendRestart(SLAVE_ADDR, 0x00); while (I2C_MSTR_NO_ERROR == I2C_MasterWriteByte(data)); //write the data I2C_MasterSendStop(); //stop sequence UART_PutString("-----I2C write completed \n"); } bool readGyroData(uint8_t* rBuffer, uint8_t length) { return readbytes(MPU6050_RA_ACCEL_XOUT_H, length,rBuffer); } File main.c : #include "MPU6050.h" #include "project.h" #include <stdio.h> #include <stdbool.h> #define BUFFER_SIZE 0x1F4u #define CONVERT_TO_ASCII 0x30 #define MPU6050_DEVICE_ADDRESS 0x68u #define MPU6050_RA_ACCEL_XOUT_H 0x3Bu #define MPU6050_RA_PWR_MGMT 0x6Bu #define MPU6050_PWR1_SLEEP_BIT 0x06u /*MPU data read buffer*/ uint8_t I2C_RBUFFER[BUFFER_SIZE]; bool readGyroData(uint8_t* rBuffer, uint8_t length); int main(void) { CyGlobalIntEnable; /* Enable global interrupts. */ uint8 i; /* Place your initialization/startup code here (e.g. MyInst_Start()) */ I2C_Start(); UART_Start(); Wakeup(); for(;;) { /* Place your application code here. */ if (true == readGyroData(I2C_RBUFFER,0x0E)) { //14 bytes to read including temp. UART_PutString("GY 521 data : \n"); for(i = 0; i < 14; i++) { UART_PutCRLF(I2C_RBUFFER + CONVERT_TO_ASCII); } CyDelay(50); } else { UART_PutString("no data to read"); } } }
  14. I have a final project at the school. Me and my friend make an earthquake detector with mpu6050 sensor Which makes me and my friend confused is how i measure the irregular numbers of this mpu6050 Is there any way how to convert the numbers generated by mpu6050 into the Richter scale (SR) Do i have to custom that number into SR to display into lcd. sorry my bad english. here is my code // I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class // 10/7/2011 by Jeff Rowberg <jeff@rowberg.net> // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib // // Changelog: // 2013-05-08 - added multiple output formats // - added seamless Fastwire support // 2011-10-07 - initial release /* ============================================ I2Cdev device library code is placed under the MIT license Copyright (c) 2011 Jeff Rowberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================== */ // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project #include "I2Cdev.h" #include "MPU6050.h" // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for InvenSense evaluation board) // AD0 high = 0x69 MPU6050 accelgyro; //MPU6050 accelgyro(0x69); // <-- use for AD0 high int16_t ax, ay, az; int16_t gx, gy, gz; int16_t vx, vy, vz; int xmax, xmin, ymax, ymin ,zmax, zmin; // uncomment "OUTPUT_READABLE_ACCELGYRO" if you want to see a tab-separated // list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read, // not so easy to parse, and slow(er) over UART. #define OUTPUT_READABLE_ACCELGYRO // uncomment "OUTPUT_BINARY_ACCELGYRO" to send all 6 axes of data as 16-bit // binary, one right after the other. This is very fast (as fast as possible // without compression or data loss), and easy to parse, but impossible to read // for a human. //#define OUTPUT_BINARY_ACCELGYRO #define LED_PIN 13 bool blinkState = false; void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize serial communication // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but // it's really up to you depending on your project) Serial.begin(38400); // initialize device Serial.println("Initializing I2C devices..."); accelgyro.initialize(); // verify connection Serial.println("Testing device connections..."); Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); // use the code below to change accel/gyro offset values /* Serial.println("Updating internal sensor offsets..."); // -76 -2359 1688 0 0 0 Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76 Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359 Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688 Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0 Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0 Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0 Serial.print("\n"); accelgyro.setXGyroOffset(220); accelgyro.setYGyroOffset(76); accelgyro.setZGyroOffset(-85); Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76 Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359 Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688 Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0 Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0 Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0 Serial.print("\n"); */ // configure Arduino LED for pinMode(LED_PIN, OUTPUT); pinMode(11, OUTPUT); digitalWrite(11,LOW); delay(10000); accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); xmax=ax+2000; xmin=ax-2000; ymax=ay+2000; ymin=ay-2000; zmax=az+2000; zmin=az-2000; } void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); /*int t=10; vx=ax*t; vy=ay*t; vz=az*t;*/ if (ax>xmax||ax<xmin||ay>ymax||ay<ymin||az>zmax||az<zmin){ digitalWrite(11,HIGH); delay(8000); digitalWrite(11,LOW); } // these methods (and a few others) are also available //accelgyro.getAcceleration(&ax, &ay, &az); //accelgyro.getRotation(&gx, &gy, &gz); #ifdef OUTPUT_READABLE_ACCELGYRO // display tab-separated accel/gyro x/y/z values Serial.print("a/g:\t"); Serial.print(ax); Serial.print("\t"); Serial.print(ay); Serial.print("\t"); Serial.println(az); #endif #ifdef OUTPUT_BINARY_ACCELGYRO Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF)); Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF)); Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF)); #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } thanks for the help master
  15. I'm trying to calibrate my MPU6050, i tried to follow the guide here: http://www.i2cdevlib.com/forums/topic/91-how-to-decide-gyro-and-accelerometer-offsett/ But the values my sensor gives me were all around: a/g: 3980 1512 3892 -6 70 -9 a/g: 4056 1452 3884 28 51 -19 a/g: 4088 1304 3712 17 49 -14 a/g: 4068 1340 3820 7 66 14 a/g: 4044 1332 3628 40 104 -16 a/g: 4072 1336 3896 2 47 16 a/g: 4088 1332 3760 19 62 -14 a/g: 4004 1448 3728 16 48 -4 a/g: 3980 1444 3740 18 29 -1 a/g: 4112 1432 3828 7 56 14 a/g: 4092 1376 3736 8 55 -4 a/g: 3936 1528 3560 -26 122 -13 When i tried to add this values to my offset, the offset simple gets BIGGER. I tried than using the sketch calibration by Luis Ródenas (i put on pastebin here) It says at the end: Sensor readings with offsets: 7 -4 16382 0 0 0 Your offsets: -426 -165 1525 -3 -14 0 Data is printed as: acelX acelY acelZ giroX giroY giroZ Check that your sensor readings are close to 0 0 16384 0 0 0 If calibration was succesful write down your offsets so you can set them in your projects using something similar to mpu.setXAccelOffset(youroffset) When i add these values to my sensor it gets: a/g: -44 60 16252 -19 -6 -10 a/g: 68 12 16444 14 -14 6 a/g: -132 -44 16340 -3 4 -2 a/g: -68 80 16248 18 10 12 a/g: -28 108 16068 -18 -7 2 a/g: 16 -80 16368 -26 14 -15 a/g: 32 76 16324 -16 4 4 a/g: -8 60 16092 -5 2 7 a/g: 32 -40 16288 2 11 1 a/g: -16 44 16384 14 -14 -3 a/g: -92 32 16608 3 -18 -7 a/g: -80 -88 16384 20 1 -9 The wide range betwen positive and negative numbers here make me worries about my sensor has any problems. Yes it's wired corect. I'm using the raw values to get these values, no i cant use DMP because it uses interuption and my interuption port are being used by my encoders. So i'm being that stupid that can see the problems or theres something here?
  16. I have tried the below program to interface mpu6050 with esp8266-12e and arduino uno both show fifo overflow issue when additional program is used. And it's giving this issue only when I include some delay in program like 1sec delay removing that delay it will work fine with no problems (now I have added delay just for test purpose that is:I will actually be throwing the data in firebase which will have more than 5 seconds delay when throwing angular data that time also it's going to give me overflow which happened) how do I sort this issue? Here is my code: #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#include "MPU6050.h" // not necessary if using MotionApps include file // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 mpu; #define OUTPUT_READABLE_EULER //#define OUTPUT_READABLE_YAWPITCHROLL //#define OUTPUT_READABLE_REALACCEL //#define OUTPUT_READABLE_WORLDACCEL //#define OUTPUT_TEAPOT #define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards //#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) bool blinkState = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // packet structure for InvenSense teapot demo uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = true; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { Serial.begin(9600); // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE //Wire.begin(4,5); Wire.begin(); //Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif while (!Serial); // wait for Leonardo enumeration, others continue immediately Serial.println(F("Initializing I2C devices...")); mpu.initialize(); pinMode(INTERRUPT_PIN, INPUT); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // wait for ready Serial.println(F("\nSend any character to begin DMP programming and demo: ")); while (Serial.available() && Serial.read()); // empty buffer while (!Serial.available()); // wait for data while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(-4); mpu.setYGyroOffset(7); mpu.setZGyroOffset(65); mpu.setZAccelOffset(1318); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); // attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING); //mpuInterrupt = true; mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it's okay to use it //Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } // configure LED for output // pinMode(LED_PIN, OUTPUT); } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything mpu_data(); delay(1000); } void mpu_data(void) { if (!dmpReady) return; // wait for MPU interrupt or extra packet(s) available //while (!mpuInterrupt && fifoCount < packetSize) // { // other program behavior stuff here // . // . // . // if you are really paranoid you can frequently test in between other // stuff to see if mpuInterrupt is true, and if so, "break;" from the // while() loop to immediately process the MPU data // . // . // . //} fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if(fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) { fifoCount = mpu.getFIFOCount();} // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); mpu.resetFIFO(); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; Serial.println(fifoCount); if (fifoCount > 2) { ////// clear fifo buffer mpu.resetFIFO(); } #ifdef OUTPUT_READABLE_QUATERNION // display quaternion values in easy matrix form: w x y z mpu.dmpGetQuaternion(&q, fifoBuffer); Serial.print("quat\t"); Serial.print(q.w); Serial.print("\t"); Serial.print(q.x); Serial.print("\t"); Serial.print(q.y); Serial.print("\t"); Serial.println(q.z); #endif #ifdef OUTPUT_READABLE_EULER // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetEuler(euler, &q); Serial.print("euler\t"); Serial.print(euler[0] * 180/M_PI); Serial.print("\t"); Serial.print(euler[1] * 180/M_PI); Serial.print("\t"); Serial.println(euler[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); Serial.print("ypr\t"); Serial.print(ypr[0] * 180/M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180/M_PI); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_REALACCEL // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); #endif #ifdef OUTPUT_READABLE_WORLDACCEL // display initial world-frame acceleration, adjusted to remove gravity // and rotated based on known orientation from quaternion mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q); Serial.print("aworld\t"); Serial.print(aaWorld.x); Serial.print("\t"); Serial.print(aaWorld.y); Serial.print("\t"); Serial.println(aaWorld.z); #endif #ifdef OUTPUT_TEAPOT // display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = fifoBuffer[0]; teapotPacket[3] = fifoBuffer[1]; teapotPacket[4] = fifoBuffer[4]; teapotPacket[5] = fifoBuffer[5]; teapotPacket[6] = fifoBuffer[8]; teapotPacket[7] = fifoBuffer[9]; teapotPacket[8] = fifoBuffer[12]; teapotPacket[9] = fifoBuffer[13]; Serial.write(teapotPacket, 14); teapotPacket[11]++; // packetCount, loops at 0xFF on purpose #endif } } I saw this link :http://arduino.stackexchange.com/questions/10308/how-to-clear-fifo-buffer-on-mpu6050 and made changes but, no effect (note: I get proper data if I remove 1s delay in main void() loop if not it will give this fifo problem)
  17. I have tried the below program to interface mpu6050 with esp8266-12e and arduino uno both show fifo overflow issue when additional program is used. And it's giving this issue only when I include some delay in program like 1sec delay removing that delay it will work fine with no problems (now I have added delay just for test purpose that is:I will actually be throwing the data in firebase which will have more than 5 seconds delay when throwing angular data that time also it's going to give me overflow which happened) how do I sort this issue? Here is my code: #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#include "MPU6050.h" // not necessary if using MotionApps include file // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 mpu; #define OUTPUT_READABLE_EULER //#define OUTPUT_READABLE_YAWPITCHROLL //#define OUTPUT_READABLE_REALACCEL //#define OUTPUT_READABLE_WORLDACCEL //#define OUTPUT_TEAPOT #define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards //#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) bool blinkState = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // packet structure for InvenSense teapot demo uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = true; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { Serial.begin(9600); // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE //Wire.begin(4,5); Wire.begin(); //Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif while (!Serial); // wait for Leonardo enumeration, others continue immediately Serial.println(F("Initializing I2C devices...")); mpu.initialize(); pinMode(INTERRUPT_PIN, INPUT); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // wait for ready Serial.println(F("\nSend any character to begin DMP programming and demo: ")); while (Serial.available() && Serial.read()); // empty buffer while (!Serial.available()); // wait for data while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(-4); mpu.setYGyroOffset(7); mpu.setZGyroOffset(65); mpu.setZAccelOffset(1318); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); // attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING); //mpuInterrupt = true; mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it's okay to use it //Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } // configure LED for output // pinMode(LED_PIN, OUTPUT); } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything mpu_data(); delay(1000); } void mpu_data(void) { if (!dmpReady) return; // wait for MPU interrupt or extra packet(s) available //while (!mpuInterrupt && fifoCount < packetSize) // { // other program behavior stuff here // . // . // . // if you are really paranoid you can frequently test in between other // stuff to see if mpuInterrupt is true, and if so, "break;" from the // while() loop to immediately process the MPU data // . // . // . //} fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if(fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) { fifoCount = mpu.getFIFOCount();} // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); mpu.resetFIFO(); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; Serial.println(fifoCount); if (fifoCount > 2) { ////// clear fifo buffer mpu.resetFIFO(); } #ifdef OUTPUT_READABLE_QUATERNION // display quaternion values in easy matrix form: w x y z mpu.dmpGetQuaternion(&q, fifoBuffer); Serial.print("quat\t"); Serial.print(q.w); Serial.print("\t"); Serial.print(q.x); Serial.print("\t"); Serial.print(q.y); Serial.print("\t"); Serial.println(q.z); #endif #ifdef OUTPUT_READABLE_EULER // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetEuler(euler, &q); Serial.print("euler\t"); Serial.print(euler[0] * 180/M_PI); Serial.print("\t"); Serial.print(euler[1] * 180/M_PI); Serial.print("\t"); Serial.println(euler[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); Serial.print("ypr\t"); Serial.print(ypr[0] * 180/M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180/M_PI); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_REALACCEL // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); #endif #ifdef OUTPUT_READABLE_WORLDACCEL // display initial world-frame acceleration, adjusted to remove gravity // and rotated based on known orientation from quaternion mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q); Serial.print("aworld\t"); Serial.print(aaWorld.x); Serial.print("\t"); Serial.print(aaWorld.y); Serial.print("\t"); Serial.println(aaWorld.z); #endif #ifdef OUTPUT_TEAPOT // display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = fifoBuffer[0]; teapotPacket[3] = fifoBuffer[1]; teapotPacket[4] = fifoBuffer[4]; teapotPacket[5] = fifoBuffer[5]; teapotPacket[6] = fifoBuffer[8]; teapotPacket[7] = fifoBuffer[9]; teapotPacket[8] = fifoBuffer[12]; teapotPacket[9] = fifoBuffer[13]; Serial.write(teapotPacket, 14); teapotPacket[11]++; // packetCount, loops at 0xFF on purpose #endif } } I saw this link :http://arduino.stackexchange.com/questions/10308/how-to-clear-fifo-buffer-on-mpu6050 and made changes but, no effect (note: I get proper data if I remove 1s delay in main void() loop if not it will give this fifo problem)
  18. Hi all, I'm trying to use the mpu6050 as a shock sensor (ie if a shock is > 2g's log the force and timestamp it). Here's the twist, I managed to get the MOT_INT working, but I eventhough i see changes in force required ro triggger an interrupt ( setting MOT_THR byte) I can't map it reliably to an actual G value. Each accelerometer output is on 16bits (signed) but the threshold is set on 8bits (signed) (which means you can only set the interrupt as 1/128th of the actual resolution ?). Also, once the interrupt is triggered, how am I supposed to find the "triggering value" in the fifo stack ? If you have any idea, please share
  19. Hello to everyone, I'm new in this forum and i'm searching for some help. I need to use two MPU6050 on the same arduino uno but i don't know how to do this, i need to send xyz (accelerometer and gyroscope) values to Max MSP via serial port. I'm not a programmer but an electroacoustic composer and i need to use two sensors to control gestures by a performer. I hope in your help. Thank you in advance Paolo accelerometro.zip
  20. I am using arduino leonardo to serially print the raw data from the mpu6050 example given alongwith its library.But after around 10 seconds, it stops sending data....please help
  21. Hi, I have a quick question regarding the FIFO of MPU6050. Using Arduino Uno, I read six raw signals from accelerometer and gyroscope using FIFO. Arduino checks the number of bytes in FIFO periodically (roughly at around 1ms), and when the FIFO has more than 36 bytes (i.e., three samples), it reads in those 36 bytes of raw data from FIFO. (no interrupt for this) Problem is, one or two bytes at the beginning of the 36-byte packet simply disappear from time to time even when there happens no FIFO overflow, and because of this, it is almost impossible to use the data reliably for waveform display on a tablet. Is there any good way to prevent this kind of problem? Your help will be greatly appreciated. Thanks.
  22. Hi, I tried MPU_DMP6.ino and it compiles without error for UNO (haven’t tested on real board), but I am using DUE board and the sketch won’t compile for the arduino due board. Could you please tell me why I am getting this error, will be helpful. MPU6050_DMP6.ino: In function 'void setup()': MPU6050_DMP6:165: error: 'TWBR' was not declared in this scope If I put it as a comment then it compiles without error. but still dont know if it will actually work or not. Thank you.
  23. Greetings, My project requires connecting multiple MPU sensors and sending all rotation data to comp using USB. I have the single sensor code working absolutely fine. Now i am hooking up 2 sensors. Idea is : Tie together the SDA, SCL, Vcc, GND and INT lines of both MPUs together. Connect the AD0 pins of MPUs to different Arduino pins. Declare only 1 MPU6050 object (as given by jeff rowberg) with devAddr = 0x69 (I dont want to maintain X no. of object for X no. of sensors. My project going ahead may need 8+ sensors and i don't want to have 8+ MPU objects in my Arduino) Whenever any sensor needs to be Init / Read / Written to, enable that sensor by writing HIGH to AD0 pin, and writing LOW on all other AD0 pins of other sensors. Once the particular sensor has been enabled, i use the normal mpu functions from my MPU6050 object which have been provided by Jeff. Now while initializing, i enable sensor 1, call mpu.initialize, testconn, dmpInit.... etc... , then i enable sensor 2, and do the same. Same method is followed to collect data from all sensors. Problem is, only Sensor 2 gives valid output. Sensor 1 gives corrupt values. I debugged the problem a little bit, it seems only the sensor which i initalize the last (sensor 2 in above case) gives valid values. I first thought that when i init the second sensor using the single mpu object, it overwrites some SW vars in this object that were previously set by first sensor. Then when i try to access the Sensor 1 with this object, these overwritten values cause problems and arduino ends up reading garbage. However i went through the whole MPU library to see if there are any private / public vars that are MPU specific and that Jeff's code might be saving. but i found nothing. It seems almost all the seful function straightaway call I2CDev Read/WriteBit. This implies as long as the correct device's AD0 is HIGH, and MPU's SW object's devAddr = 0x69, everything should work fine. And yet it does not. Can someone help ? Thanks
  24. Hello! I have installed Jeff Rowberg's i2cdevlib library which I can use for my MPU-6050 to make it interact with Arduino. However, I have an odd problem with one of its functions. It's got a function to turn the accelerometer & gyroscope readings into linear acceleration. This is the definition of the function: uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) { // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g) v -> x = vRaw -> x - gravity -> x*8192; v -> y = vRaw -> y - gravity -> y*8192; v -> z = vRaw -> z - gravity -> z*8192; return 0; } However, whenever the function is called in the example code: // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); I get values way off, when I'm not even moving my MPU-6050! These are a few of the values I get: areal -473 423 -425 areal -460 400 -450 areal -471 522 -458 areal -322 276 -582 Do you know how I can fix this? Thanks! -George
  25. Hallo everyone, does someone know what's kind of battery should i use for mpu6050,because i want to use the battery to power the mpu6050,i have tried use tow serial Li-ion which are up t 3v,and SDA ,SCL and INT will be connected to the Arduino,i run the code in the computer,but it didn't work. When i connect it to 3.3v pin of the Arduino and it works again.Can anyone know the reason? In the Datasheet it says mpu6050 can work between 2.4v-3.4v. Thanks
×
×
  • Create New...