unisev Posted December 6, 2014 Report Share Posted December 6, 2014 Thank's for this very good share !! Quote Link to comment Share on other sites More sharing options...
wambo0402 Posted March 10, 2015 Report Share Posted March 10, 2015 Hello!First of all thank you for your sketch. Really makes things easier. But i have still some problems with it...I tried to make it a little bit faster by commenting out some delay() but the sketch didn't like that. it stops at some (maybe random) point.I also tried to leave the delay() where they were and just commented out all the Serial.print... because i won't need those messages in my project. Your sketch didn't like that either. same behaviour as when i don't use the delay(). and last but not least i tried to get rid of the delays AND the serial output (except for the finish message). guess what....sketch STOPS.my question is:why doesn't it work when someone tries to make it faster / get rid of the serial output? i really changed nothing else. just commented out some delays and some serial output. i would appreciate if someone could explain this behaviour to me greets, wambo Quote Link to comment Share on other sites More sharing options...
luisrodenas Posted March 11, 2015 Author Report Share Posted March 11, 2015 Hello wambo, please attach the modified version of the sketch that is not working for you and I will take a look. Quote Link to comment Share on other sites More sharing options...
misiek303 Posted May 27, 2015 Report Share Posted May 27, 2015 So I am running with the issue from the begining of this thread. I can see just "..." and calibration can't finished. I use Arduino YUN currently and 1.1v of the sketch. I have below outpus of means values.. Send any character to start sketch. MPU6050 Calibration SketchYour MPU6050 should be placed in horizontal position, with package letters facing up.Don't touch it until you see a finish message. MPU6050 connection successfulReading sensors for first time...Calculating offsets...6744 713 17482 54 -693 220-2092 -1526 15153 54 1354 -802119 710 17488 -969 -1717 1245116 714 15154 1078 1354 -1826118 -1524 17488 -969 -693 2270121 712 15149 1078 330 -2850121 714 17487 -969 331 3293117 718 15151 1078 -694 -2850121 -1527 17485 -969 330 2269117 713 15149 1078 330 -1826119 716 17483 -969 -692 1245117 -1527 15150 1078 330 -801118 713 17491 -1993 329 221120 714 17490 2102 -693 221120 -1523 15153 -1994 330 -802120 714 17487 2102 330 1245-2085 713 15151 -1993 -693 -802120 -1525 17484 2101 330 221122 712 15154 -1994 330 221118 714 17491 2102 -693 -802118 -1522 15150 -1993 1354 1244119 714 17484 1078 -1717 -1826117 714 15157 -969 1355 2269115 -1523 17489 1078 -693 -1826116 713 15150 -969 330 1245115 713 17485 1078 -693 -802118 -1525 15152 -969 1354 221117 714 17484 1078 -1717 221117 718 15150 -969 1353 -802121 713 17484 1078 -693 1245115 -1525 15149 -1993 330 -802118 713 17486 2101 -693 221117 713 17486 -1993 1354 221118 -1525 15153 2102 -1717 -802116 713 17485 -1993 1353 1245-2089 715 15149 2102 -693 -1826119 -1524 17485 -1993 330 2269117 714 15152 2102 330 -1826113 713 17488 -1994 -693 1245120 -1524 15152 2101 330 -802117 712 17484 -3017 330 221116 714 15147 3126 -694 221119 -1524 17493 -3017 329 -802120 715 15147 3125 330 1245120 717 17488 -3018 -694 -802117 -1527 15154 3126 330 221116 713 17485 -3017 330 222117 714 15152 3126 -693 -802115 -1524 17489 -3017 330 1245117 717 17486 2102 330 -1826 Any ideas ? Quote Link to comment Share on other sites More sharing options...
misiek303 Posted May 28, 2015 Report Share Posted May 28, 2015 I just have tried UNO and YUN again. Calibration not working on both. Gotta do something wrong here. A5 -> SCL A4 -> SDA 3.3V GND D2 -> INT Connects just fine with 0x68 address, I have not changed sketch. using 1.1v. Any ideas ? Thanks. Quote Link to comment Share on other sites More sharing options...
EvilSmoker Posted July 1, 2015 Report Share Posted July 1, 2015 Hi luisrodenas I'am using Arduino UNO R3, and I have same problem as #6 / #29 I can see just "..." and calibration can't finished. Whats wrong? Quote Link to comment Share on other sites More sharing options...
kylerustler58 Posted November 6, 2015 Report Share Posted November 6, 2015 Hello, can someone please assist me in implementing ths into a project of mine? I'm building a lateral G-Force meter for a Supra and I want to either be able to set the zero at the press of a momentary button and have it save permanently until the button is pressed again even if the device is powered off and back on, or have it reset the zero every time the device is powered on. Preferably the momentary button method. Would I have to use EEPROM or the PROGMEM features in the code? Quote Link to comment Share on other sites More sharing options...
nasirmail10 Posted November 12, 2015 Report Share Posted November 12, 2015 Interesting... tested a GY51 module connected to an Arduino Nano. Works good so far without any editing. Thanks for your effort.Here's my result :Send any character to start sketch.Send any character to start sketch.Send any character to start sketch.MPU6050 Calibration SketchYour MPU6050 should be placed in horizontal position, with package letters facing up.Don't touch it until you see a finish message.MPU6050 connection successfulReading sensors for first time...Calculating offsets.....................FINISHED!Sensor readings with offsets: 0 4 16379 0 -1 1Your offsets: -1081 -907 1483 127 30 11Data is printed as: acelX acelY acelZ giroX giroY giroZCheck that your sensor readings are close to 0 0 16384 0 0 0If calibration was succesful write down your offsets so you can set them in your projects using something similar to mpu.setXAccelOffset(youroffset) Quote Link to comment Share on other sites More sharing options...
ekchess Posted March 6, 2016 Report Share Posted March 6, 2016 I downloaded the calibration sketch today, 5-Mar-2016, v1.1, and used it to calibrate a new MPU6050 breakout board using an Arduino Uno. The sketch worked perfectly. Thank you, luisrodenas, for the development and updates. Quote Link to comment Share on other sites More sharing options...
strayVoltage Posted March 12, 2016 Report Share Posted March 12, 2016 Hello everyone, Just wanted to share some help for those of you who are having problems with the auto-calibration not working, such as in posts #11 and #29 and others. I had the same problem, and it turned out to be caused by an outdated version of the i2cdev library. go here https://github.com/jrowberg/i2cdevlib and download the latest version of the i2cdev library. Replace your old version of the i2cdev library in your Arduino libraries folder with the new one. Voila! Quote Link to comment Share on other sites More sharing options...
brundylop Posted March 17, 2016 Report Share Posted March 17, 2016 Hi everyone, Even after updating my I2C library like StrayVoltage suggested in#35, the sketch does not converge for me. I think I've found the underlying problem in my setup: setXGyroOffset (and the Y,Z functions too) cannot handle negative inputs. In my code, I declare: accelgyro.setXAccelOffset(-1); accelgyro.setYAccelOffset(-1); accelgyro.setZAccelOffset(-1); accelgyro.setXGyroOffset(-1); accelgyro.setYGyroOffset(-1); accelgyro.setZGyroOffset(-1); But then when I read them out with Serial.print(accelgyro.getXAccelOffset()); Serial.print(accelgyro.getYAccelOffset()); Serial.print(accelgyro.getZAccelOffset()); Serial.print(accelgyro.getXGyroOffset()); Serial.print(accelgyro.getYGyroOffset()); Serial.print(accelgyro.getZGyroOffset()); I see -1 ; -1; -1 ; 63 ; 63 ; 63 That is, the accelerometer is able to handle negative inputs, but the Gyroscope functions freak out and change -1 to 63. I think this has to do with negative representation (63 = 111111 in binary) but what's odd is that 64 is a 6 bit number, not 8 or 16 That's why my sketch doesn't converge. It seems like the sketch is trying to add negative numbers when the readings are positive, so that the sum is 0. But instead of adding a negative number, it is positive; thus the indefinite cycling. I am looking into how to fix this, but my programming background is still crappy: edited to add my system: I'm using a Teensy 3.2 with the SparkFun 9150 breakout board, with both the old and new I2C dev libraries. ( I need to comment out Wire.h in my calibration.ino code because of conflicting libraries) I still see the same problem when I use my Arduino Uno instead of the Teensy Quote Link to comment Share on other sites More sharing options...
brundylop Posted March 17, 2016 Report Share Posted March 17, 2016 I think I got it! Looking at the MPU6050.cpp code in the library, there are 2 Gyrofunctions: getXGyroOffset and getXGyroOffsetUser after re-declaring the offset inputs as int16_t and using setXGyroOffsetUser made the difference. It converges now! Quote Link to comment Share on other sites More sharing options...
icehawk101 Posted May 5, 2016 Report Share Posted May 5, 2016 Updating from I2Cdev to I2Cdevlib worked for me Quote Link to comment Share on other sites More sharing options...
Cerin Posted May 8, 2016 Report Share Posted May 8, 2016 >Put the MPU6050 as horizontal as possible and leave it there, don't touch it. My MPU6050 is oriented vertically (e.g. its z-axis is really my x-axis). Will this calibration program still work? Quote Link to comment Share on other sites More sharing options...
strayVoltage Posted May 8, 2016 Report Share Posted May 8, 2016 Cerin, i actually didn't go back and look at the code again so take this with a grain of salt, but im pretty sure it will not correctly calculate acceleration (gyro will probably be ok) offsets if the orientation is changed. The program is expecting to see the force of gravity on one axis, and accounts for this when calculating the offsets. If you do not edit the code to change what axis is expecting to see gravity, the offsets probably wont converge, and if they do will be very wrong. It might be possible to re-write the program to intelligently detect which axis is detecting gravity (reads ~16000 at level rest) and run a smarter calibration routine. When i needed to reorient my sensors i just fooled the code into switching my axis for me, something like: axisX = -readAxis(y); if you go this route you will need to think carefully about how to switch up your axes to maintain a valid coordinate system. Happy coding! Quote Link to comment Share on other sites More sharing options...
Cerin Posted May 8, 2016 Report Share Posted May 8, 2016 Cerin, i actually didn't go back and look at the code again so take this with a grain of salt, but im pretty sure it will not correctly calculate acceleration (gyro will probably be ok) offsets if the orientation is changed. The program is expecting to see the force of gravity on one axis, and accounts for this when calculating the offsets. If you do not edit the code to change what axis is expecting to see gravity, the offsets probably wont converge, and if they do will be very wrong. It might be possible to re-write the program to intelligently detect which axis is detecting gravity (reads ~16000 at level rest) and run a smarter calibration routine. When i needed to reorient my sensors i just fooled the code into switching my axis for me, something like: axisX = -readAxis(y); if you go this route you will need to think carefully about how to switch up your axes to maintain a valid coordinate system. Happy coding! Thanks for the warning. That's what I was afraid of. I decided to simply reorient my sensor to the default. I just calibrated it and it seems to have converged correctly. lapedNok 1 Quote Link to comment Share on other sites More sharing options...
LeolaLario Posted May 17, 2016 Report Share Posted May 17, 2016 Hi..thanks for sharing this information. As per my knowledge the one issue that I have is that the I2C address of the MPU6050 object is incorrectly set to 0x69 by default, this is NOT the default address of the IMU. It took me the longest time to figure out why my sensor wasn't connecting pcb assembly Quote Link to comment Share on other sites More sharing options...
Cerin Posted May 17, 2016 Report Share Posted May 17, 2016 Hi..thanks for sharing this information. As per my knowledge the one issue that I have is that the I2C address of the MPU6050 object is incorrectly set to 0x69 by default, this is NOT the default address of the IMU. It took me the longest time to figure out why my sensor wasn't connecting Where does it say 0x69 is the default? All the example code I've found says 0x68 is the default, which works perfectly for me. Quote Link to comment Share on other sites More sharing options...
strayVoltage Posted May 17, 2016 Report Share Posted May 17, 2016 Hi..thanks for sharing this information. As per my knowledge the one issue that I have is that the I2C address of the MPU6050 object is incorrectly set to 0x69 by default, this is NOT the default address of the IMU. It took me the longest time to figure out why my sensor wasn't connecting The address is not incorrect, the mpu6050 has an address select pin 'AD0' that selects address between 0x68 and 0x69. Your electrical connections must match your code. This is important in case you run into another i2c device which uses the same address, or more likely you wish to use 2 mpu6050 modules at once in order to get better data, which may be useful for solving gyro drift problems in applications which require low gyro drift. Quote Link to comment Share on other sites More sharing options...
LolaRobben Posted May 28, 2016 Report Share Posted May 28, 2016 Hi! I've been trying to calibrate my accelerometer with luis rodenas code however, the code isn't uploaded on the arduino and the same message comes back again and again: "no 'uint8_t MPU6050::dmpInitialize()' member function declared in class 'MPU6050' " Anybody has an idea why? Quote Link to comment Share on other sites More sharing options...
sarwadenj Posted August 20, 2016 Report Share Posted August 20, 2016 Hi, I am compiled your code calibrating the MPU6050's offsets but it showing error: 'buff_gx' does not name a type buff_gx=buff_gx+gx; so please help me go get out of these error. Quote Link to comment Share on other sites More sharing options...
andrewic Posted September 6, 2016 Report Share Posted September 6, 2016 Hello, I am having some trouble with offsets.... I can run the calibration script, have it converge, get some sensible offsets, plug them into the RAW sketch and then get good results (i.e. close to zero on X, Y accels and on all 3 gyros) using getMotion6(). So far so good. But my real application is interrupt driven, and I'm basing it closely on the DMP6 sketch. I plug my offsets into my version of that sketch, which loads the FIFO on interrupt with getFIFOBytes(), and then uses dmpGetAccel() and dmpGetGyro() to read the raw values from the FIFO packet. And when I do that, the results are rubbish, my X accel goes from close to zero to ~200. Same sensor, same Arduino, firmly fixed and unmoved on the same desk. Switch back to the RAW script, all is good again. Any ideas what I might be doing wrong? (What I want to get to eventually is a sketch which runs a self-calibration of the X axis accel offset at startup, and sets the offset accordingly, because in my eventual use case setting up the sensor and clamping it accurately horizontal will be difficult. I only really care about the X-axis accel and gyro.). Thanks for any tips! Andrew Quote Link to comment Share on other sites More sharing options...
andrewic Posted October 2, 2016 Report Share Posted October 2, 2016 Hello, I am having some trouble with offsets.... Answering my own question... The order of events in the code was wrong, the offsets were being loaded and then overwritten by a reset. Andrew Quote Link to comment Share on other sites More sharing options...
nevoeiro1974 Posted November 30, 2016 Report Share Posted November 30, 2016 Hi luisrodenas I have a question : Do I use the same values for whatever full scale I'm using at the gyro and accel ? What I mean is, if I have MPU9255_GYRO_FULL_SCALE_2000DPS or MPU9255_GYRO_FULL_SCALE_250DPS, the function works without changing anything ? I ask that since values oscilate within different scales at least for the Accelerometer. Also I have a suggestion : When you do the average, you are adding all the samples and dividing by the number of samples at the end. That may lead to overflows easy if the sample number is too large. What I suggest is why not take a first read, and then, inside the loop, take another read, add it to the first and divide by 2, that result adds to another read and divides by 2 so on and so forth, that way you don't get to higher numbers to operate with. a=readAccelX; for (int n=0;n<samples;n++) { a=a+readAccelX; a >> 1 ; } Quote Link to comment Share on other sites More sharing options...
atmega Posted February 3, 2017 Report Share Posted February 3, 2017 I connected mpu-6050 to Arduino pro micro 5v. I run the calibration script, and after 15min didn't have a result. So i updated I2Cdev, and added some lines to debug script. I print means for every iteration, and it looks crazzy. What is wrong? All script parameters are default. Unfortunatelly before calibration it works quite good... Maby you know default parameters? Vcc - 4,7 Ad0 - LOW SDA - 2 SCL - 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.