Leaderboard
Popular Content
Showing content with the highest reputation since 08/01/2013 in all areas
-
Arduino Sketch to automatically calculate MPU6050 offsets
lolizz00 and 10 others reacted to luisrodenas for a topic
I have made an Arduino sketch that simplifies the task of calibrating the MPU6050's offsets. Easy steps: - Wire your MPU6050 to your Arduino. - Put the MPU6050 as horizontal as possible and leave it there, don't touch it. - Check the sketch in order to configure your MPU's I2C address (0x68 or 0x69). - Upload the sketch to your Arduino. - Open Arduino serial monitor and send any character to the Arduino. - Wait. - Write down your offsets for that particular MPU6050 and use them with library's functions "...setoffset..." in your projects. There are also a few options in the code in case you want to fine tune it. There may be bugs, or maybe it does not converge for everyone, so let me know your experience. I use it with an Arduino DUE, configured to 400KHz I2C bus speed, but I think you can use any Arduino and standard bus speed (100KHz). If people find it useful maybe Jeff can add it to the library once it is bugfree. Happy new year. UPDATE 30th January: New version 1.1 available. It fixes a bug related to variables overflowing in Arduinos other than the DUE. MPU6050_calibration_v1.1.zip11 points -
Respected Sir, I got some data from accelerometer and gyrometer using MPU 6050 with arduino. But i am not able to interpret numerical values of it. Can you help me to figure out this information? here i am sending you some of data: Accelarometer Gyrometer Ax Ay Az Gx Gy Gz -6616 13880 -1380 915 -68 -49 -6624 13924 -1496 909 -41 -136 -6680 13896 -1408 917 -46 -148 -6636 13996 -1508 913 -35 -111 -6668 13896 -1616 902 -47 -47 -6716 13944 -1496 916 -43 -40 -6616 13972 -1412 879 -57 -5 -6584 13884 -1536 918 -47 -25 -6920 14192 -1584 892 -10 -164 -7792 15016 -1524 1022 -80 -68 -6928 14244 -1484 773 -112 261 -6396 13764 -1416 939 -72 112 -6636 14020 -1596 892 -43 -154 -6520 13836 -1524 946 4 -242 -6776 13916 -1552 926 8 -333 -6916 14008 -1568 891 -64 -54 -6592 13936 -1460 866 -113 216 Thanks.6 points
-
Hello, Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board. Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site. They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line. They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead. I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes. Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on. I found a similar problem described on the Adafruit website http://forums.adafruit.com/viewtopic.php?f=19&t=54496 This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that. I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino. I was wanting to know if you could tell me if there is any reason why doing sampleI = adc.getConversionP1GND(); quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right? Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website double calcIrms(int NUMBER_OF_SAMPLES, int Channel) { double ADC_COUNTS = 24512; //portion of 15bit count used for range double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100 for (int n = 0; n < NUMBER_OF_SAMPLES; n++) { lastSampleI = sampleI; if(Channel == 1) { sampleI = adc.getConversionP1GND(); } else if(Channel == 3) { sampleI = adc.getConversionP3GND();; } else { return 0; } lastFilteredI = filteredI; filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI); // Root-mean-square method current // 1) square current values sqI = filteredI * filteredI; // 2) sum sumI += sqI; } double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS)); double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES); //Reset accumulators sumI = 0; return Irms; } void loop() { Irms1 = calcIrms(100, 1); // Calculate Irms only Irms3 = calcIrms(100, 3); // Calculate Irms only apparentPower1 = supplyVoltage * Irms1; //extract Apparent Power into variable apparentPower3 = supplyVoltage * Irms3; //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again. Any help you could provide would be appreciative, esp if you see that I am doing something stupid. Regards WanaGo4 points
-
Understanding raw values of accelerometer and gyrometer
Keerthi Reddy and 3 others reacted to Jeff Rowberg for a topic
Hi @vrutangs, The accelerometer and gyroscope measurements are explained in the MPU-6050 datasheet in the GYRO_CONFIG and ACCEL_CONFIG register descriptions (sections 4.4 and 4.5 on pages 14 and 15). The scale of each depends on the sensitivity settings chosen, which can be one of +/- 2, 4, 8, or 16g for the accelerometer and one of +/- 250, 500, 1000, or 2000 deg/sec for the gyroscope. The accelerometer produces data in units of acceleration (distance over time2), and the gyroscope produces data in units of rotational velocity (rotation distance over time). The output scale for any setting is [-32768, +32767] for each of the six axes. The default setting in the I2Cdevlib class is +/- 2g for the accel and +/- 250 deg/sec for the gyro. If the device is perfectly level and not moving, then: X/Y accel axes should read 0 Z accel axis should read 1g, which is +16384 at a sensitivity of 2g X/Y/Z gyro axes should read 0 In reality, the accel axes won't read exactly 0 since it is difficult to be perfectly level and there is some noise/error, and the gyros will also not read exactly 0 for the same reason (noise/error).4 points -
velocity from acceleration
Johnnydofs and 2 others reacted to hatt0002 for a topic
Hi, I am currently doing a project in which I need to capture the acceleration of a pivoted rotating wooden beam. From the acceleration, I need to determine the velocity. I am using Jeff's teapot sketch with the mpu6050 and I have managed to also include the acceleration in the teapotPacket to print acceleration in processing. I know that velocity is the first integral of acceleration. Such integral can be expressed as: v = u + AT, where v is the current velocity, u is the velocity before, A is the acceleration and T is a time interval. This is my code for the velocities in the three directions with sampling time of 1ms: vX = uX + (AX)*0.001; //vX = current velocity in the X direction, uX = velocity in the previous iteration, AX = acceleration in the x direc uX = vX; //setting the current velocity as the previous velocity vY = uY + (AY)*0.001; uY = vY; vZ = uZ + (AZ)*0.001; uZ = vZ; If I move the sensor say in the x direction, acceleration in the x direction increases and when I stop the sensor, acceleration becomes negative and converges to zero, as expected. The velocity seems to be calculated and printed right when increasing from zero to a particular value. Now my problem is, that when I stop moving the sensor, velocity does not go back to zero when the sensor is stationary, but it decreases by a small amount only (say it stops decreasing at 0.5m/s. This gets worse when the sensor is moved faster. It seems like the acceleration is read more than the deceleration (decreasing acceleration) and therefore, less negative values for acceleration are captured. Can anybody help me? Thanks, Hatt3 points -
DMP without interrupts
lapedNok and 2 others reacted to dario111cro for a topic
Hello, Is it possible to pool data from DMP when needed instead of it writing to FIFO constantly? Similar like you can write 0x3B and read 14 registers to get raw data... Thanks, Dario3 points -
Tips on Reading Accelerometer Data
MattE and 2 others reacted to Coldreactor64 for a topic
I just recently found out how to accurately read the Accelerometer Data off the MPU6050 You may get an output like this: MPU-6050 Read accel, temp and gyro, error = 0 accel x,y,z: 1856, 308, 15604 temperature: 30.435 degrees Celsius gyro x,y,z : -33, -252, -235, and you see its not obvious on how to understand this data. What I found out is that is this: If your scale is +-2G Divide by 2048 If your scale is +-4G Divide by 4096 If your scale is +-8G Divide by 8192 If your scale is +-16G Divide by 16384 Thank you- Jeremy Hall3 points -
MPU6050_DMP_DUE_FIFO_OVERFLOW
constanceog11 and 2 others reacted to anqurarora for a topic
Hi, I am using MPU6050 with your written code in DMP mode on Arduino due and it's working fine stand alone.. But I have to integrate some other things into my code like (Due timer library to generate software interrupt every second, external interrupt on pin 52 to count pulses ). when i tried to integrate them in one code i have FIFO Overflow problem. even though i tried to run it at as low as 20hz by changing the registers value in the "3dmath.h" file. can you please help me out with this problem i am facing. my project is kind of stuck at this point. Thank you. #include <DueTimer.h> #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 mpu; //#define OUTPUT_READABLE_WORLDACCEL #define OUTPUT_READABLE_REALACCEL #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) #define LED_PIN1 12 bool blinkState = false; bool blinkState1 = 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 double vel_data; double vel; double Dummy = 0 ; double t_s = 0; double S[2] = {0,0}; double Q[2] = {0.05,0.05}; double R[2] = {0.5, 0.01}; double Y[2] = {0,0}; double X[2] ={0,0}; double P[2] = {0.5,0.5}; double K[2] = {0, 0}; uint32_t timer = 0; uint32_t dt = 0; int16_t sample,sped=0; int16_t ax, ay, az; int16_t gx, gy, gz; int16_t sensorValue; char val; int count; bool flag; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); Wire1.begin(); //TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif Serial1.begin(115200); //115200 or 19200 while (!Serial1); // wait for Leonardo enumeration, others continue immediately Serial1.println(F("Initializing I2C devices...")); mpu.initialize(); // verify connection Serial1.println(F("Testing device connections...")); Serial1.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // wait for ready // Serial1.println(F("\nSend any character to begin DMP programming and demo: ")); // while (Serial1.available() && Serial1.read()); // empty buffer // while (!Serial1.available()); // wait for data // while (Serial1.available() && Serial1.read()); // empty buffer again // load and configure the DMP Serial1.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(-1); //220 inc. will inc. mpu.setYGyroOffset(-24); //76 mpu.setZGyroOffset(51); //-85 mpu.setZAccelOffset(1788); // increasing number will increase 16384 // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial1.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial1.println(F("Enabling interrupt detection (Arduino Due external interrupt 2)...")); attachInterrupt(2, dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it's okay to use it Serial1.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) Serial1.print(F("DMP Initialization failed (code ")); Serial1.print(devStatus); Serial1.println(F(")")); } // configure LED for output pinMode(LED_PIN, OUTPUT); delay(5000); attachInterrupt(52, rpm_fun, FALLING); Timer.getAvailable().attachInterrupt(firstHandler).start(1000000); // from DueTimer library delay(50); } void firstHandler(){ // Software interrupt every one second. Serial1.println("int"); flag = true; } void rpm_fun() // Hardware interrupt to count external pulses. { count = count + 1; } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything 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 // . // . // . } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial1.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // 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); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; #ifdef OUTPUT_READABLE_REALACCEL // display real acceleration, adjusted to remove gravity // -----Get data from MPU-6050----- mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); sample = -(aaReal.x); //Dummy = (abs(sample)>80) ? ((double)sample/16384)*9.81 : 0; Dummy = (double)sample/16384 * 9.81; t_s = (((double)micros() - timer)/1000000); // -----Get data from Arduino UNO----- Wire1.requestFrom(2, 1); // request 1 byte from slave device #2 while(Wire1.available()) // slave may send less than requested { sped = Wire1.read(); // receive a byte as character vel_data = ( 0.85 *((double)(sped)* 0.216)) + (0.15 * X[1]); // Serial1.println(sped); // print the character } //--------Prediction------- X[0] = X[0]; // Velocity X[1] = X[1]; // Acceleration P[0] = Q[0]; P[1] = t_s * Q[1]; //-------Kalman Gain-------- S[0] = P[0] + R[0]; S[1] = P[1] + R[1]; K[0] = P[0]/S[0]; K[1] = P[1]/S[1]; //--------Update------------- //vel = vel + t_s * Dummy; Y[0] = vel_data - X[0]; Y[1] = Dummy - X[1]; // Y[1] = Dummy - X[1]; X[0] = X[0] + (K[0]*Y[0]); X[1] = X[1] + (K[1]*Y[1]); P[0] = P[0] - (K[0]*P[0]); P[1] = P[1] - (K[1]*P[1]); timer = micros(); #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } }3 points -
Is there a way to disable gyroscope drift compensation?
Johnnydofs and 2 others reacted to sharst for a topic
Hello, I'm using I2Cdevlib to read out the fused DMP data from an MPU-6050 breakout board, and I'm absolutely amazed at the amount of precision I get from such a low-cost sensor! I've got one problem though: I attached the sensor to a mobile robot, which sometimes moves in large circles, i.e. the gyroscope will register the same small turn velocity over a long period of time. During these periods, after ~8 seconds the yaw reading of the sensor stabilizes at some point and I don't get rotation updates anymore. From what I gathered from other posts, I assume that the DMP tries to cancel out gyro drift by subtracting any constant gyro reading that it gets from the next readings. I guess what happens is that the DMP thinks my slowly moving robot is actually the gyroscope drifting and tries to compensate. (I can actually see the yaw moving in the opposite direction for a short while when I stop the robot mid-turn.) So my question is: Is there some way I can turn off gyro drift compensation in the DMP? I can take care of slow drifts myself by measuring the gyro drift when I'm completely sure that the robot isn't moving. It would be a pity if I couldn't use this great sensor and library because I can't disable this feature. Thanks a lot for your responses, Simon3 points -
How to convert the gyroscope readings to Degrees/Second?
Johnnydofs and 2 others reacted to Vickylance for a topic
Sorry If this question is already answered or is way too noob.... I am a novice programmer and I dont really know how to get Degrees/second mpu.getRotation(&gx, &gy, &gz); gyroRoll = gx/131.0; gyroPitch = gy/131.0; gyroYaw = gz/131.0; Is this correct ? Does my gyroRoll, gyroPitch, gyroYaw give values in degrees/second? I want the values to use in my quadcopter code... Also I didnt change any default sensitivity in my MPU6050. Actually I am using Hextronik Nanowii V01 flight controller which is Arduino Leonardo. Also I got another doubt, Is ± 250 °/s more sensitive to changes and give wider range of raw values and ± 2000 °/s is less sensitive to changes and gives narrow range of raw values??? Sorry if these questions are way too noob, I just cant confirm anywhere the above assumptions that I have made.3 points -
No interrupt signal from sparkfun mpu6050
Johnnydofs and 2 others reacted to damienLAURENT for a topic
Hello, Thanks to Jeff for his work ! I couldn't even try using DMP without his code... The MPU6050_raw works well with my sparkfun mpu6050 connected to an arduino uno. The MPU6050_DMP6 has an irregular behavior. When launching, the serial monitor says "DMP ready! Waiting for first interrupt...", and indeed it waits a pretty long time... The interrupt pin is connected to arduino pin 2 I've also tried to connect the vio to arduino 3.3v The point is that I've no interrupt signal when connecting an oscilloscope on INT pin of the mpu... is there a hardware issue ? or should I initialize something in the mpu ? Thanks for your response damien3 points -
Hi, I know that there are some eamples showing how to put magnetometer data into DMP. For example this one: http://www.i2cdevlib.com/forums/topic/111-arduino-example-sketch-to-read-magnetometer-while-dmp-is-on/ but it does not make any sensor fusion. I couldn't find any library which would make magnetometer fusion inside DMP. Does such library exist? Maybe code in this file MPU6050_9Axis_MotionApps41.h make DMP+magnetometer fusion? I couldn't find any tips in the code and right now I am not able to test it. So the question is: does such library exist or the only way to do this is to make own fiters (for example complementary filter)? Maybe there is some MPU9150 library that can be used with MPU6050+magnetometer?3 points
-
mpu-6050 dmp access
luis_costa and 2 others reacted to bmsrao for a topic
hello jeff rowberg, I B.M.S.RAO.I am an engineering final year student. I am doing a project which is having mpu-6050, and using ATMEGA32L (8-bit) micro controller. My task is to display the YAW rate, PITCH rate, ROLL rate on the hyper terminal, and I succeeded to get the raw data, But in the datasheet, there was no data about how to access the DMP register, I tried a lot to get these details, but I didnt get the adequate information regarding dmp access and no relevant data on internet also ,meanwhile I saw your code(C++ language) in github website to get YAW rate ,PITCH rate ,ROLL rate and you said ,you have used reverse engineering method to get that data. Sir its my kind request, please help me how to get the above YAW rate, PITCH rate, ROLL rate. Sir I cant afford to use arduino based, spark fun based hardware kits and their soft wares. I have stand-alone ATMEGA32L (8-bit) micro controller, avr studio version 6. Regarding this; I had sent a mail (how to get dmp data in mpu-6050) to invensense, where they replied me that to use Embedded_MotionDriver_5.1.But I have nil knowledge regarding the Embedded_MotionDriver_5.1. Sir I humbly request you to please help me. Is it possible to get the code that you have mentioned in the git hub website in C language or in any algorithm form (like flowchart to access dmp registers)?3 points -
Arduino Sketch to automatically calculate MPU6050 offsets
Melika Barzegaran and 2 others reacted to ankur6ue for a topic
Why are we dividing by 8 and 4 before setting the offsets? Where is that documented? Or is just a step to prevent wide changes in the offset and help the optimization converge?3 points -
Hi I'm new to Arduino and I'm trying to use a 6DOF IMU (the MPU-6050) along with the i2cdevlib. I've been able to set the libraries and to execute a sketch in order to calculate the offset of the IMU starting from the raw data. Now I'm trying to execute the example code that i found on the github of the i2cdevlibhttps://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino setting the output in the YPR modeCode: #define OUTPUT_READABLE_YAWPITCHROLL with and without my offset parameters. In both sketches I found the same issue. The data on the serial shift from the initial position for 5-8 second showing an increment of several degrees (depends on the cases but usually there are 12-25 degrees) of the YPR angles without moving the IMU. The same thing happen with the Euler anglesCode: #define OUTPUT_READABLE_EULER I've tried also to execute the quaternion output modeCode: #define OUTPUT_READABLE_QUATERNION which i don't know how to read (I'm just started learning about this) but the value I read on the serial seems to stay "stable". I might solve this with a delay from the turn on which allow me to see of how much degrees the IMU "virtually moved" and then subtract that value to future reading (such as another offset) but i find this not usefull since I need the IMU to have the right angles on the turn on. Thanks for reading, hope someone could help me2 points
-
Hi everyone, After searching in forums i found out that people have different values for the "setXGyroOffset/setYGyroOffset/setZGyroOffset/setZAccelOffset" functions. But i can't understand how i can find what values i need to use. Can somebody explain me how do i choose the parameters for those functions? Thanks in advance.2 points
-
roll affecting yaw?
Johnnydofs and one other reacted to hatt0002 for a topic
Hi friends, I have managed to read from two mpu6050 on DMP. Both sensors are fitted on a piece of board and are perfectly levelled. My problem is that when I tilt the sensors such that I increase/decrease Roll, the Yaw is changed, even when the sensors are not rotated on the z axis. Is it normal that rolling affects yawing? Furthermore, the change in Yaw for both sensors is not the same, and there will be a difference in yaw of 8 deg between the two sensors for a 45deg rolling. Thanks in advance, Hatt2 points -
Hey everyone! Thought I'd share my version of an auto-offset calibration sketch; it converges all offsets in about 20s or so. Just upload and watch the serial (at 38400bps)! A note on how it works/converges: - the code takes an initial guess for each offset (supplied at the top of the sketch), takes a certain number of readings from the MPU-6050 (the # of readings it takes is defined by countMax), and averages those number of readings. If that average is less than the value errorCheck, it assumes that axis has converged - if the average isn't less than errorCheck, it will subtract a certain amount from the initial guess - if the errorCheck you set is too small, or the initial guess is smaller than what the solution is, it wont converge - in this case either choose a larger value for errorCheck or a larger initial guess I've given some initial guesses / settings which should help you get to where you need to be; just watch the serial - it'll tell you what the average reading from the MPU-6050 was for each guess, you'll want that average to be as close to 0 as possible for each axis. Enjoy! MPU6050_calibration.zip2 points
-
I was under the impression that the default range for the MPU-6050 accelerometer was +/-2g, but after doing some datalogging I'm beginning to think that is only the case for the raw values (i.e. using MPU6050_raw.ino) and not true when using the DMP (i.e. using DMP6050_DMP6.ino). The values I obtained are half of what I believe they should be, leading me to believe that with DMP the default range is +/-4g. I found a line in MPU6050_6Axis_MotionApps20.h that only confuses me more: // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g) If the sensitivity is 2g, doesn't 1g = 16,384? Or am I reading the datasheet incorrectly? At this point I'm pretty confused and hopefully somebody can clear it all up for me...2 points
-
Hi everybody, I was wondering if any development is runing for odroid SBC ? If not Iwanted to kindly request that http://www.hardkernel.com/main/products/prdt_info.php?g_code=G1434522398252 points
-
roll and pitch angles ranges
Johnnydofs and one other reacted to hassan ali for a topic
Hi everybody... I've been working on a project recently and i need to measure the roll and pitch angles of a moving platform, but the problem is that the value of these angles starts from 0 then reaches 90, then starts to decrease again to reach 0 (positive or negative 90 degrees of course) ... what i need to do is to have this value in the range of zero to 180 (positive or negative) not from zero to 90 as it is now ... do anyone have any idea??2 points -
Arduino freezes randomly using MPU6050 and SD shield
Johnnydofs and one other reacted to wambo0402 for a topic
Hello! I'm trying to log the acceleration measured by a MPU6050 on a GY-521 breakout board on a microSD card using a microSD shield made by Sparkfun. Because the MPU6050_DMP6 sketch from the MPU6050 library of Jeff Rowberg (also using his I2Cdev lib) and the dataLogger sketch from the SDfat library both worked very good (when runnning alone) i thought i could combine them to achieve my goal. I deleted the (for my use) unnecessary code and instead of printing the acceleration data to the serial monitor i print it to the logfile. But this is not working so great. The sketch stops working completely random. Sometimes it runs for a couple of minutes, sometimes only for a few seconds. When it freezes i have to reset the arduino and it runs again for some time. I just can't figure out what the problem is. Here is what i already tried: 1) check the connections SD shield is just put on top of the arduino MPU -> Arduino VCC -> 5V GND -> GND SCL -> Analog 5 SDA -> Analog 4 INT -> Digital 2 solder points look good 2) check memory usage don't remember the exact value but it was stable and there was enough free memory 3) a LOT of different approaches how to handle the data all with pretty much the same results, i will spare you the details because mostly it was "try and error" Here is the basic sketch i described: ///////////////////////////////////////////////////////////////////////////////// #define BUTTON_PIN 4 ///////////////////////////////////////////////////////////////////////////////// //////////////Includes, Constants and Objects for datalogging//////////////////// #include <SdFat.h> // SD chip select pin. Be sure to disable any other SPI devices such as Enet. const uint8_t chipSelect = 8; //#define LOG_ACC // Log file base name. Must be six characters or less. #define FILE_BASE_NAME "DATA" // Error messages stored in flash. #define error(msg) error_P(PSTR(msg)) // File system object. SdFat sd; // Log file. SdFile file; //Variable for collumn separation ************* char tab = ';'; ///////////////////////////////////////////////////////////////////////////////// //////////////////////Includes, Constants and Objects for MPU//////////////////// #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#define OUTPUT_READABLE_REALACCEL // 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 SparkFun breakout and InvenSense evaluation board) // AD0 high = 0x69 MPU6050 mpu; //MPU6050 mpu(0x69); // <-- use for AD0 high //#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' }; ///////////////////////////////////////////////////////////////////////////////// //////////////////////////////User functions///////////////////////////////////// //------------------------------------------------------------------------------ // Write data header. void writeHeader() { file.print(F("accel_X")); file.print(tab); file.print(F("accel_Y")); file.print(tab); file.print(F("accel_Z")); file.println(); } //------------------------------------------------------------------------------ // error messages void error_P(const char* msg) { sd.errorHalt_P(msg); } //------------------------------------------------------------------------------ // Interrupt detection volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } //------------------------------------------------------------------------------ // setup function void setup() { const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1; char fileName[13] = FILE_BASE_NAME "00.CSV"; Serial.begin(115200); //while (!Serial) {} // wait for Leonardo //delay(1000); pinMode(BUTTON_PIN, INPUT_PULLUP); Serial.println(F("Press Button to start")); while(digitalRead(BUTTON_PIN)) {} //wait for button // Initialize the SD card at SPI_HALF_SPEED to avoid bus errors with // breadboards. use SPI_FULL_SPEED for better performance. if (!sd.begin(chipSelect, SPI_FULL_SPEED)) sd.initErrorHalt(); // Find an unused file name. if (BASE_NAME_SIZE > 6) { error("FILE_BASE_NAME too long"); } while (sd.exists(fileName)) { if (fileName[BASE_NAME_SIZE + 1] != '9') { fileName[BASE_NAME_SIZE + 1]++; } else if (fileName[BASE_NAME_SIZE] != '9') { fileName[BASE_NAME_SIZE + 1] = '0'; fileName[BASE_NAME_SIZE]++; } else { error("Can't create file name"); } } if (!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) error("file.open"); do { delay(10); } while (Serial.read() >= 0); Serial.print(F("Logging to: ")); Serial.println(fileName); // Write data header. writeHeader(); // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize device Serial.println(F("Initializing I2C devices...")); mpu.initialize(); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // 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(99); mpu.setYGyroOffset(-35); mpu.setZGyroOffset(67); mpu.setZAccelOffset(1106); // 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(0, dmpDataReady, RISING); 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(13, OUTPUT); } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything if (!dmpReady) return; // wait for MPU interrupt 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 // . // . // . } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || 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 if (mpuIntStatus & 0x02) { // 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); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; // get real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); file.print(aaReal.x); file.write(tab);//*************** file.print(aaReal.y); file.write(tab);//*************** file.println(aaReal.z); // Force data to SD and update the directory entry to avoid data loss. if (!file.sync() || file.getWriteError()) Serial.println(F("write error")); if (!digitalRead(BUTTON_PIN)) { // Close file and stop. file.close(); Serial.println(F("Done")); while(1) {} } } } If you have any ideas how to solve this issue, any help will be greatly appreciated. wambo2 points -
GY-86
Samellanak and one other reacted to nicnac for a topic
Hey! I've got a GY-86 with MPU6050, a Barometer and the HMC5883L. On the Arduino (UNO) I get the MPU to work. But I can't figure out how to get the magnetometer data! I2C scanner tells me: Scanning... I2C device found at address 0x68 ! I2C device found at address 0x77 ! done and 0x68 is definately the mpu6050. And since I know, that it can be a master again, I suspect, that the other would be barometer and the HMC is on the slave of the MPU. Am I right with that? Can anybody tell me how I can proceed? Check my assumption or just get the mag data? Any help much appreciated!!2 points -
Weather station + MPU6050
Williamtaw and one other reacted to aile_alhenai for a topic
Hi to all! I am using the MPU-6050 sensor, among others, as a part of my graduation project. I am trying to use the MPU6050 together with the BMP180 (and some other simpler sensors), and with some intuition I could manage to make them work together by just taking the raw data from the MPU6050. All my attempts to use the needed libraries to acquire the yaw/pitch/roll data format and take into account the DMP and the fifo buffer the sensor itself has while using other sensors in the same program have failed, maybe because I don't have so much experience with programming. I attach my code, because maybe you could help me to make it work. The MPU6050 example works, as far as I don't mix it with other sensors. I use different functions as part of the main code, like these ones: But all I get from the ypr variables are zeros. Any help would be really appreciated. Kind regards, María.2 points -
MPU6050 Library Problem!!
Johnnydofs and one other reacted to eemziyaozcelik for a topic
i imported i2cdev.h and mpu6050.h library. But it doesnt work. Help me please. Error code; MPU6050.cpp:1997:6: error: prototype for 'bool MPU6050::getMotionStatus()' does not match any in class 'MPU6050' bool MPU6050::getMotionStatus() { ^ In file included from MPU6050.cpp:37:0: C:\Users\ziya.ozcelik\Documents\Arduino\libraries\MPU6050/MPU6050.h:611:17: error: candidate is: uint8_t MPU6050::getMotionStatus() uint8_t getMotionStatus();2 points -
mpu6050 interfacing with 8051
Johnnydofs and one other reacted to mnnnrng for a topic
Can anyone please help me in interfacing mpu6050 with 8051? I dont have the library. neither i have any idea about how to use it. please help me.2 points -
How can we change the default setting of gyro and accelero sensitivity?
Johnnydofs and one other reacted to vrutangs for a topic
Hi.. The default is seeting for accelero is +/-2G and for gyro is +/-250deg/sec. So what are the changes one should make in mpu6050.cpp and mpu6050.h to change default setting? thanks in advanced.2 points -
MPU-6050: changing a default setting in the I2Cdevlib class
Johnnydofs and one other reacted to vrutangs for a topic
HI.. I am using MPU 6050 for accelero and gyro data. The default setting in the I2Cdevlib class is +/- 2g for the accel and +/- 250 deg/sec for the gyro. So that means i can detect maximum of 250 deg/s and it will saturate at 250 (in the plot) if my angular velocity is more than 250 deg/s. So how can we change to the +/- 2000 deg/s? Also, is it possible to change only gyro scale and retaining the accelerometer range which is +/- 2g (inbuilt)? Any help is highly appreciated. thanks.2 points -
Sketch hanging when interrupt routine called [MPU6050]
Johnnydofs and one other reacted to AlexGodbehere for a topic
Hi all. I'm using an MPU6050 to obtain orientation information for a quadcopter, however when the function that is attached to the interrupt pin is ran (to obtain the orientation data from the FIFO buffer), the sketch crashes. Sometimes, the console prints the first few characters of "Getting Sensor Data!", which is called in the routine. Am I doing anything seriously wrong? Main Sketch: Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(0, AP_getSensorData, RISING); // Actually pin 2-(5?) AP_Sensors.cpp: // Library header #include "Sensors_.h" #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #include "Serial_.h" #include <SFE_BMP180.h> #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif /************************************** * LED DEFINITIONS *************************************/ #define LED_GREEN 9 #define LED_YELLOW 10 #define LED_YELLOW2 11 #define LED_YELLOW3 12 #define LED_RED 13 // Code MPU6050 onboardIMU; extern bool systemError; int ultrasonicAlt; // 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 byte error, address; int nDevices; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } bool AP_initSensors() { // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif /************************************** * Scan for I2C Devices *************************************/ Serial.println("Scanning I2C Bus..."); nDevices = 0; for (address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address < 16) Serial.print("0"); Serial.print(address, HEX); Serial.println(" !"); nDevices++; } else if (error == 4) { Serial.print("Unknow error at address 0x"); if (address < 16) Serial.print("0"); Serial.println(address, HEX); } } if (nDevices == 0) Serial.println("No I2C devices found\n"); else Serial.println("Completed I2C Bus Scan...\n"); Serial.println("Initalising I2C Devices..."); onboardIMU.setSleepEnabled(false); onboardIMU.initialize(); // Try to connect to IMU Devices... Serial.println("Connecting to I2C Devices..."); if (onboardIMU.testConnection()) { Serial.println("IMU Connected!:"); // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = onboardIMU.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity onboardIMU.setXGyroOffset(220); onboardIMU.setYGyroOffset(76); onboardIMU.setZGyroOffset(-85); onboardIMU.setZAccelOffset(1788); // 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...")); onboardIMU.setDMPEnabled(true); // enable Arduino interrupt detection // Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); // attachInterrupt(0, dmpDataReady, RISING); mpuIntStatus = onboardIMU.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 = onboardIMU.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(")")); } } else { Serial.println("Unable to find any I2C Devices..."); } Serial.println("Initialising Barometric Sensor..."); AP_initBarometricSensor(); } void AP_getSensorData() { Serial.println("Getting Sensor Data!"); // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = onboardIMU.getIntStatus(); // get current FIFO count fifoCount = onboardIMU.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly onboardIMU.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = onboardIMU.getFIFOCount(); // read a packet from FIFO onboardIMU.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; onboardIMU.dmpGetQuaternion(&q, fifoBuffer); onboardIMU.dmpGetGravity(&gravity, &q); onboardIMU.dmpGetYawPitchRoll(ypr, &q, &gravity); } }2 points -
Hello People, I have got a Problem with the MPU6050_DMP6 Code as it sometimes hangs when its running. It seems to stop randomly after some time and it makes no difference if i have the Arduino powered from USB, USB and Running Serial Monitor or from 9V Battery. I did minor changes to the code: Added Raw Values and Datalogging on a Micro SD Card with a Catalex Micro SD Adapter for Arduino and removed parts like TeaPot Demo and so one because i dont need them for my application. But i dont think this problem occus due to my changes because i think i saw this freezing also with the Basic MPU6050_DMP6 Code. I tried the Datalogging with SD-Library and SDFatLibrary but the Problem occured with both. The FIFO/DMP Rate is set to 25 Hz with 0x02, 0x16, 0x02, 0x00, 0x07 // D_0_22 inv_set_fifo_rate in the MPU6050_6Axis_MotionApps20 Library .h File because i had Fifo Overflow when runnig with 100Hz. Here is my sketch code: I added a Led on Pin 8 with indicates aktivity so i see the led stopping blinking once in a while when i run the code. If i have the serial monitor then it just stoppes writing new lines. Can somebody give me a hint why this happens and how it could be fixed? Or if somebody got a code for Datalogging Yaw Pitch and Roll Values + Raw Values Accelerometer and Gyroskop i would also appreciate very much! I also tried 2 differnet SDCards (one Class 10) and ther was no differnce... I really annoying because i want to log data and when it stops randomly and mostly after not more than 2 to 3 minutes the application is unreliable and useless.... Greets Julian2 points
-
MSP430 + MPU 9150
Samellanak and one other reacted to ibrahims for a topic
Hi im trying to access the magnetometers data. I am using Energia. THe following code is being used. The x,y,z values are all nearly the same. If anyone can please post a fix with code this would be helpful.2 points -
DMP packet description
Hizfrala and one other reacted to JetIgniter2k for a topic
Can someone explain the raw DMP packet information to me. Here's what i know so far. Every packet is 42 bytes. 0:3 QW 4:7 QX 8:11 QY 12:15 QZ 16:19 GX 20:23 GY 24:27 GZ 28:31 AX 32:35 AY 36:39 AZ 40:41 unknown Am I correct in assuming that all the quaternions are double precision floating point numbers? And the gyro and accel are 32 bit int? Are the gyro and accel numbers what the DMP read off of the register when it calculated the quaternions?2 points -
Arduino Sketch to automatically calculate MPU6050 offsets
TheEnginerd and one other reacted to dennisma for a topic
Thanks this worked well first time. I made a slight modification to your code. In the loop() where it prints out the offsets I changed it to the following: Serial.println("Your offsets:\t"); Serial.print("mpu.setXGyroOffset("); Serial.print(gx_offset); Serial.println(");"); Serial.print("mpu.setYGyroOffset("); Serial.print(gy_offset); Serial.println(");"); Serial.print("mpu.setZGyroOffset("); Serial.print(gz_offset); Serial.println(");"); Serial.print("mpu.setXAccelOffset("); Serial.print(ax_offset); Serial.println(");"); Serial.print("mpu.setYAccelOffset("); Serial.print(ay_offset); Serial.println(");"); Serial.print("mpu.setZAccelOffset("); Serial.print(az_offset); Serial.println(");"); The output then becomes the following: Sensor readings with offsets: 4 2 16388 0 0 -2 Your offsets: mpu.setXGyroOffset(37); mpu.setYGyroOffset(-44); mpu.setZGyroOffset(26); mpu.setXAccelOffset(-1282); mpu.setYAccelOffset(-727); mpu.setZAccelOffset(1732); That way I can just copy/paste/format the code and I am done. Just a thought.2 points -
Why should I wait for MPU interrupt (sometimes very long!!!)
nidhin jacob and one other reacted to luisrodenas for a topic
Well, if it works for you... then I guess you can read it using (mpu.dmpGetXXXXXXXX) every time you want, but be sure to read it at a faster frecuency than DMP is running, or fifo will overflow. Anyway, I haven't checked how does this (mpu.dmpGetXXXXXXXX) function work, so I am only speculating. Besides, this long wait you mention has never happened to me. Are you sure that INT pin is connected where it should be connected?2 points -
Arduino Sketch to automatically calculate MPU6050 offsets
swordfish and one other reacted to violinuxer for a topic
Great program you've got working here, should save me a lot of trouble! 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 (i'm pretty sure it should be 0x68). It took me the longest time to figure out why my sensor wasn't connecting Thanks! violinuxer2 points -
Support for this sensor?
Bahox and one other reacted to lectroidmarc for a topic
Hello, I see the MPL3115A2 in the list of supported devices, but it doesn't seem to be present in the code. Even the github link on http://www.i2cdevlib.com/devices/mpl3115a2#source points to code that doesn't exist. I just got one of these so if it's really supported, that would be great. Thanks, Marc2 points -
Hello everyone! I am pretty inexperienced when it comes to computer programming, but I am using the program Jeff posted to use the yaw, pitch, and roll values (I really only need the yaw, though) in a feedback system for a UAV. I am using an Arduino Uno to run the gyroscope, and the program works fine by itself. My issue results from me putting the program on a timer so that it only reads the value every, say, 100 ms. Then FIFO overflow then gets triggered (which makes sense because the values are going in faster than they go out.) Is there any way to bypass this? I noticed one of the past iterations of the program read the values directly instead of from the FIFO buffer, but I didn't understand that version of the program, and I also don't think it had a "ypr" option. Is there an easy way to change the programming, or perhaps a better way to do it? Thanks for any help you can give!1 point
-
Arduino Sketch to automatically calculate MPU6050 offsets
Melika Barzegaran reacted to Susan for a topic
Dear luisrodenas, May I know what is the motivation for the division by 8 and 4 in the calibration function? ax_offset=-mean_ax/8; ay_offset=-mean_ay/8; az_offset=(16384-mean_az)/8; gx_offset=-mean_gx/4; gy_offset=-mean_gy/4; gz_offset=-mean_gz/4; Moreover in calibration function, unlike accelerometer offset value why the (gyro offset - mean gyro value) is divided by 2 instead of 1 which is giro_deadzone? if (abs(mean_gx)<=giro_deadzone) ready++; else gx_offset=gx_offset-mean_gx/(giro_deadzone+1); if (abs(mean_gy)<=giro_deadzone) ready++; else gy_offset=gy_offset-mean_gy/(giro_deadzone+1); if (abs(mean_gz)<=giro_deadzone) ready++; else gz_offset=gz_offset-mean_gz/(giro_deadzone+1); I would be really thankful if I get the reasons for using different divisor value. Thank you.1 point -
This is a great library to work with. Thank you for putting it together. I am looking to measure the pitch of a vehicle (I'm using a bicycle). While using the DMP-6 example code, I get the pitch; which, is great under static conditions. Unfortunately, when I apply the brakes, accelerate, or just move, the pitch will increase moving forward and decrease while braking. Do you have advice on how to compensate or remove the acceleration from the IMU to get accurate values like the static condition? Thanks1 point
-
mpu6050 stops giving raw data after some time
Johnnydofs reacted to hari_1994 for a topic
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 help1 point -
Recently, when I tried to control MPU6050 via Mediatek Linkit One, I found that there seems a problem in readBytes() function in i2cdevlib. Since the I2C buffer of Linkit One is really small, the following code will loop more than one time. Using logic analyzer, I found that the I2C write address will be incorrect after first iteration because of the line 278. Will you guys think that the line 278 needs to be modified to Wire.write(regAddr+k) ? PS. The DMP operates correctly after this modification. 276 for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) { 277 Wire.beginTransmission(devAddr); 278 Wire.write(regAddr); 279 Wire.endTransmission(); 280 Wire.beginTransmission(devAddr); 281 Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH)); 282 Thanks1 point
-
Hi guys, I'm interfacing the mpu6050 with Tiva C arm cortex m4 basesd launchpad "TM4C123GH6PM" I setup up the configuration of the IMU and when I ran I got a weird behavior from PITCH and ROLL readings. The vales should always read zero when leveled up.. but after every 4 or 5 outputs they go high. Roll : 82.890320 Pitch : 44.777519 Roll : 0.119266 Pitch : 82.930687 Roll : 0.070139 Pitch : 82.928864 Roll : 82.983780 Pitch : 44.805222 Roll : 0.049558 Pitch : 0.063718 Roll : 82.967545 Pitch : 0.014765 Roll : 82.964287 Pitch : 44.801392 Roll : 0.035360 Pitch : 82.988754 Roll : 0.035095 Pitch : 82.937157 Roll : 0.042208 Pitch : 82.950836 Roll : 0.161359 Pitch : 0.014031 Roll : 82.955894 Pitch : 0.002605 Roll : 0.021050 Pitch : 82.9338151 point
-
Trouble Compiling
Johnnydofs reacted to rbds for a topic
I am trying to get the MPU6050 example to compile and I can't seem to do it. I am using Arduino 1.0.5 on a Windows computer. So far, I have confirmed that the I2Cdev and the MPU6050 libraries are located in C:/Program Files (x86)/Arduino/Libraries. I have included the helper_3dmath library at the top of the example sketch, but I still cannot get it to compile. There is a long list of errors, but below are a couple. This seems to be an issue with the libraries I have included. C:\Users\Randy\Documents\Arduino\libraries\MPU6050/helper_3dmath.h: In member function 'float Quaternion::getMagnitude()': C:\Users\Randy\Documents\Arduino\libraries\MPU6050/helper_3dmath.h:74: error: 'sqrt' was not declared in this scope .... and: C:\Users\Randy\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:596: error: 'class VectorInt16' has no member named 'x' C:\Users\Randy\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:597: error: 'class VectorInt16' has no member named 'y' Please let me know if I am missing something obvious or if you will need more information to help. Thanks.1 point -
connecting 2 mpu6050
Johnnydofs reacted to Tirocinio for a topic
Hello everybody, We should connect two mpu6050 to an Arduino mega but we don't know how to connect them physically. We know that we have to turn the i2c adress from 0x68 to 0x69 in order to have 2 different adress, one for each sensor. Someone says that it must connect them in parallel but other thinks that it is usefull to set two digital pins high or low to "swich on/off" a sensor in order to read information alternated. moreover we would like to read quarternion or euler data but now we are only able to receive raw data. May anyone help us? thanks1 point -
Manipulating Gyro data to get angular acceleration
Johnnydofs reacted to hlw2451 for a topic
Hello, Complete code novice, I'm using Jeff Rowberg's library and sample code to get the Yaw, Pitch and Roll orientations of the gyro. However wanting to get the angular acceleration using these, (I'm thinking along the lines of, yaw value(t=t+1)-yaw value(t=t)/(time^2), knowing that the sample rate is 10 ms) and then depending on these values, if they are about a certain threshold a light turns on. However I'm very confused where to input these alterations of the code and actually how to write them. Any help really appreciated!1 point -
1 point
-
1 point
-
Understanding raw values of accelerometer and gyrometer
RobertFab reacted to Vinesh Saini for a topic
Hi sir, I am also using MPU6050 accelerometer and gyrometer with arduino UNO. I followed the wiring, VCC to 5v of arduino GND to GND of arduino SDA pin to A4 pin of arduino SCL pin to A5 pin of arduino AD0 to GND of arduino INT to Pin 2 of arduino And I ran I2C scanner code which is given here : http://playground.arduino.cc/Main/I2cScanner But it is not detecting the address. Which is 0x68 default, given in the manual. And when I dump other code to detect the X Y X axes of accelerometer and gyrometer, it is giving only -1 value. Please help me out.1 point -
I am using RedBearLab's Blend Micro with Arduino/MPU6050/example/MPU6050_DMP6 from from https://github.com/jrowberg/i2cdevlib repo. Blend Micro is Arduino + BLE and works with https://github.com/RedBearLab/nRF8001 repo for BLE connection. Following two header files do not work together, causing "error:dmpMemory causes a section type conflict" #include "MPU6050_6Axis_MotionApps20.h" // https://github.com/jrowberg/i2cdevlib #include "RBL_nRF8001.h" // https://github.com/RedBearLab/nRF8001 /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:133: error: dmpMemory causes a section type conflict /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:273: error: dmpConfig causes a section type conflict /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:315: error: dmpUpdates causes a section type conflict From https://github.com/jrowberg/i2cdevlib repo, I am able to successfully compile and run Arduino/MPU6050/example/MPU6050_DMP6 with Blend Micro and GY521/MPU6050, and see results on serial monitor. As soon as I modify Arduino code to support BLE connection, it gives above errors. If I comment out #include <RBL_nRF8001.h> and "ble_xxxx" calls defined in there, I am able to compile, run and see results on serial monitor again. Just to let you know, I am able to modify other example Arduino/MPU6050/example/MPU6050_raw and also establish BLE connection with OSX app on MacBook and see results on OSX app, and off course on serial monitor. This is exactly what I am trying to do with Arduino/MPU6050/example/MPU6050_DMP6 and getting errors mentioned above. Could anyone help?1 point
-
roll and pitch angles ranges
hassan ali reacted to tsimon for a topic
Hi, I am seeing that you can do a full rotation around the z axis using the dmu and get accurate angles. But if you try to read the angle from the x or y axis it only goes to 90 degrees or gives garbabge. It seems that the dmu is making some assumption about the mounting position of the unit and the expected motion. My problem is that I want to read full rotattion from the x axis. I amssuming the gryos are reading correctly and this issue is in the dmu code that generates the quaternion. I am using Euler angles and have also tried YPR. They both behave the same.1 point