Jump to content
I2Cdevlib Forums

Leaderboard


Popular Content

Showing content with the highest reputation since 03/29/2017 in all areas

  1. 4 points
    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.zip
  2. 2 points
    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! violinuxer
  3. 1 point
    Joe Walsh

    Why is the DMP yaw stable?

    I'm running the DMP example for Arduino. Upon startup the yaw value wanders for about ten seconds before stabilizing at ~38°. Pitch and roll are stable from the start, but after the ten seconds everybody is basically perfect. This is confusing to me because of the way sensor fusion works. In a fused sensor the acceleration vector is used to cancel drift in the x and y gyro readings, and a magnetometer does the same for roll around z. The MPU-6050 doesn't have a magnetometer, so why does the yaw stabilize? I know something's not quite right with the yaw; it drifts for a while when pitch and roll are steady from the start. However, from looking at the erratic drift in the raw gyro rates, I don't see a reason why the yaw would ever stabilize. I realize that I'm kind of asking "How does DMP work" and that nobody really knows. But maybe someone has an idea? Anyway, thanks for the work you've done, Jeff. Your praises shall be sung to the farthest reaches of the interwebs, followed by lusty cursings of InvenSense. But maybe a kind word every once in a while.
  4. 1 point
    HI Jeff... I'm Mochammad Habib Bachtiar as student of trunojoyo university in Indonesia. In this semester I have project about motion capture use a MPU6050 & Arduino Uno. but my focus is gyroscope with horizontal motion at upper arm, lower arm, and hand. so each segmen one sensor. I want ask you about that. how to modified some source code at arduino until this raw value become to angular rate. Please explain source code base from x, y & z axis.... Thank's Jeff ....
  5. 1 point
    Hello.. I have the small query. The code for reading accelerometer and gyro data from MPU 6050 is written by Jeff is as follow: // 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 © 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; // 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); } void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // 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"); int start=millis();Serial.print(start);Serial.print("\t"); Serial.print(ax); Serial.print("\t"); Serial.print(ay); Serial.print("\t"); Serial.print(az); Serial.print("\t"); Serial.print(gx); Serial.print("\t"); Serial.print(gy); Serial.print("\t"); Serial.println(gz); #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)); //Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF)); //Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF)); //Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF)); //#endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } I just delete the thing which i don't know and made a small code as follow: #include "I2Cdev.h" #include "MPU6050.h" #include "Wire.h" MPU6050 accelgyro; int16_t ax, ay, az; int16_t gx, gy, gz; #define OUTPUT_READABLE_ACCELGYRO #define LED_PIN 13 bool blinkState = false; void setup() { Wire.begin(); Serial.begin(38400); accelgyro.initialize(); pinMode(LED_PIN, OUTPUT); } void loop() { accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); int start=millis();Serial.print(start);Serial.print("\t"); Serial.print(ax); Serial.print("\t"); Serial.print(ay); Serial.print("\t"); Serial.print(az); Serial.print("\t"); Serial.print(gx); Serial.print("\t"); Serial.print(gy); Serial.print("\t"); Serial.println(gz); blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } Now i am not sure about the importance of the if and elseif statement (for an example) : #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)); Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF)); Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF)); Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF)); #endif Can anyone help me to understand the importance of the if and elseif condition that has been used in the Jeff's code? Thanks.
  6. 1 point
    Vinesh Saini, You are commiting a BIG mistake! You CANNOT connect directly the MPU6050 to the Arduino. If you read the datasheet you will see that the highest Vcc is 3.46v!!!! (http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf). So you will need a level shifter to connect the MPU6050 to the arduino and 3.3V suplied by the arduino. Finally you should have a look on the Arduino website http://playground.arduino.cc/Main/MPU-6050. Regards,
  7. 1 point
    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.
  8. 1 point
    You need to combine the values with constants defined for the sensor in order to get correct reading. Consider looking at this implementation of mpu6050_getConvData(): https://github.com/mkschreder/martink/blob/master/sensors/mpu6050.c
  9. 1 point
    bmsrao

    mpu-6050 dmp access

    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)?
  10. 1 point
    Just wondering if anyone knows why we are diviing by 8 and 4 in the cailbration function void calibration(){ ax_offset=-mean_ax/8; ay_offset=-mean_ay/8; az_offset=(16384-mean_az)/8; ???
  11. 1 point
    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?
  12. 1 point
    YES, try to use DMP, check the example DMP sketch and adapt it to your project. I believe you can work without the interruptions, but you will need to read the fifo buffer at least at the same frecuency (I recommend higher) that the DMP is working. You can change DMP's frecuency to your needs. If you read at lower frecuency it will overflow and start giving errors. Just mopdify the example sketch and erase the interruption part, put a delay to get the frecuency you want (just to try) and check that it works. If using DMP you will also need to calibrate your MPU.
  13. 1 point
    Hi luisrodenas, thank you for your attention! I must say that I'm using an Arduino Leonardo and I'm running the sketch for calibration according to your instructions on the first post, in a plain horizontal table and completely as possible still. I'm using the Jeff's library as it is distributed with none modifications as your sketch, the only thing I changed was the I2C address to be 0x68 to work with my breakout board for MPU-6050. I ran your sketch with the default parameters: int buffersize=1000; //Amount of readings used to average, make it higher to get more precision but sketch will be slower (default:1000) int acel_deadzone=8; //Acelerometer error allowed, make it lower to get more precision, but sketch may not converge (default:8) int giro_deadzone=1; //Giro error allowed, make it lower to get more precision, but sketch may not converge (default:1) I ran it for about 10 minutes and the output I get through the serial port was recorded in the file attached. It seems to me that this condition, never occurs, so I believe that's why I can't get a sucessfull calibration from your sketch. Anyway I appreciate your help and your share of this sketch. Keep up with the good work! MPU6050_calibration_sketch_output.txt
  14. 1 point
    sam123

    STM32 F4 I2CDevLib Port

    i am working on a project "Evaluation of a 3 axis accelerometer and gyroscope".I just have the theoretical knowledge about I2C and all other related aspects regarding this project but i am new to the programming and have no idea how to start the coding part.Here is the short description of my project. I have STM32F407 microcntroller board and GY521 breakout board(MPU6050) my microcontroller acts as a master and mpu 6050 acts as a slave and interfacing has to be done to establish the so called "communication"between these two via I2C bus and code has to be written in software Cocoox Coide MPU 6050 consists of accelerometer and gyroscope sensors which reads sensor values....when interfacing is done.....This is what the project is all about.So could you please help me in coding
  15. 1 point
    Hi Ben, The numbers you are seeing appear to be all multiples of 4. This is extremely unlikely in a real-world situation, and makes me think that the way you are reading registers and/or converting data for storage in your variables has a problem with (1) register read orders, (2) byte orders, or (3) bit orders. Or, possibly, you are shifting values somehow after reading them. The various ACCEL_*OUT_H/L registers each contain 8 bits of the 16-bit raw sensor value. The _H register is the high byte (MSB), and the _L register is the low byte (LSB). If you read them independently and combine them, then you should store them into a signed 16-bit integer container something like this: int16_t accel_x = (ACCEL_XOUT_H << 8) + ACCEL_XOUT_L; Is this what you are doing, or something very close anyway?
  16. 1 point
    Hi guys, The setRate() method only applies to raw measurements, but not to the DMP which has its own rate. This is defined on line 261 (currently) of MPU6050_6Axis_MotionApps_20.h. The default rate is 100Hz (the last byte is 0x01), but you can increase it to 50Hz by changing that byte to 0x03 instead. To the best of my knowledge, the internal sensors are still read at a very fast rate, but the DMP algorithms compensate such that the output data is appropriate for 50Hz intervals. If you don't want to use the interrupt pin (which is a shame since it's much more efficient), you can simply poll regularly for a FIFO count that is >= 42 (which is the size of a typical MotionApps 2.0 DMP packet), and read those 42 bytes anytime they are available until there are less than 42 bytes available. It's kind of an ugly way to do it, but it does work as long as you read fast enough that the FIFO doesn't overflow (>= 1024 bytes).
  17. 1 point
    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).
  18. 0 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.
  19. 0 points
    Hello friends, I am trying to make a self balancing robot, so I found some tutorials regarding Complementary filters. In that tutorial there is a equation for take acceleration and gyro value, these are the equation, x_acc = (x_acc_ADC - x_acc_offset) * x_acc_scale; gyro = (gyro_ADC - gyro_offset) * gyro_scale; form that I obtained following values, ax= 0 gy= -159 x_acc= 148.00 gyro= 11000.00 ax= -116 gy= -184 x_acc= -84.00 gyro= -1500.00 ax= -40 gy= -175 x_acc= 68.00 gyro= 3000.00 ax= -48 gy= -177 x_acc= 52.00 gyro= 2000.00 ax= 4 gy= -183 x_acc= 156.00 gyro= -1000.00 ax= -60 gy= -190 x_acc= 28.00 gyro= -4500.00 ax= -84 gy= -192 x_acc= -20.00 gyro= -5500.00 ax= -92 gy= -184 x_acc= -36.00 gyro= -1500.00 ax= -88 gy= -164 x_acc= -28.00 gyro= 8500.00 Here is my code, #include <Wire.h> #include <I2Cdev.h> #include <MPU6050.h> MPU6050 mpu; int16_t ax, ay, az; int16_t gx, gy, gz; float x_acc, gyro; void setup() { // put your setup code here, to run once: Serial.begin(1200); Serial.println("Initialize MPU"); mpu.initialize(); } void loop(){ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); Serial.print("ax= "); Serial.print(ax); Serial.print("\t\t"); Serial.print("gy= "); Serial.print(gy); Serial.print("\t\t"); x_acc= (ax - (-74))*(2); Serial.print("x_acc= "); Serial.print(x_acc); Serial.print("\t\t"); gyro= (gy - (-181))*(500); Serial.print("gyro= "); Serial.print(gyro); Serial.print("\n"); } Please let me know whether that values are correct or not, if it is not please help me to correct it.. Thank you!
  20. 0 points
    I am not sure I am correct or not but Integration of angular velocity should give you static angle right?
  21. 0 points
    hi jeff! Shame Include me in this topic with questions rather than answers, electromechanical engineering student I am, I am Colombian, from there the reason for my writing. AM Working with the MPU 6050 and I want to ask if possible control by an FPGA, a Spartan 3e exactly, I researched on the web but I always find that when using this sensor with arduino, or through microcontrollers, I have able to find information (FPGA + MPU6050) Sorry for the inconvenience, I hope I can collaborate, thank you very much.
  22. 0 points
    hola jeff! que pena incluirme en este tema con preguntas en vez de soluciones, soy estudiante de ingeniería electromecánica, soy colombiano, de ahí el porque mi escritura. estoy trabajando con el mpu 6050 y quisiera preguntarte si es posible controlarlo por medio de una FPGA, exactamente una Spartan 3e, he investigado en la web pero siempre me encuentro con que el sensor se controla por arduino o por micro controladores. disculpa la molestia, espero me puedan colaborar, muchas gracias
  23. 0 points
    Sir, I used the MPU 6050 program from Github...its strange that all my a/g values shows zero ....dont know whether its a communication program or problem with my library please help me out as i am new to this. the program i used is: #include "Wire.h" #include "DebugUtils.h" // 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 "MPU60X0.h" #include <SPI.h> // 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 MPU60X0 accelgyro; int16_t ax, ay, az; int16_t gx, gy, gz; #define LED_PIN 13 bool blinkState = false; void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) Wire.begin(); // 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"); // configure Arduino LED for pinMode(LED_PIN, OUTPUT); } void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // these methods (and a few others) are also available //accelgyro.getAcceleration(&ax, &ay, &az); //accelgyro.getRotation(&gx, &gy, &gz); // 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.print(az); Serial.print("\t"); Serial.print(gx); Serial.print("\t"); Serial.print(gy); Serial.print("\t"); Serial.println(gz); // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); }
  24. 0 points
    Sorry that I too am opening this thread up again. What exactly does the X, Y and Z components of the accelerometer represent? Am I correct in thinking that if any one of the axes are pointing directly upwards away from the earth it (without noise) it should be displaying 1g (16384 at 2g setting). If any of the axes are pointing straight down it should be reading -1g (-16384). all axis reading zero when they are pointing directly horizontal. Then a value for the X-axis is its projection onto the vertical 1g reference? If I am right, what would be the best way to manipulate the data to accurately measure angles at points in time.
  25. 0 points
    Hi Jeff , sorry to reopen this post... I am a french student in an engeneering school and I am using the crius aiop v2 on my robot. On this board there is an MPU6050 and I am communicating with it thanks to your code. I tested a lot of codes like the one on arduino playground and the one of Kristian Lauszus with the Kalman filter. However I am still having big issues with this sensor... Correct me if I am wrong but when I am reading the raw data for the accelerometer I am supposed to get for x, y and z : 0 , 0 and 0.98 right ? However when I am just reading the right registers (my sensor is put still on my desk) I am getting those values instead : accX accY accZ 8324.00 4768.00 14496.00 8208.00 4768.00 14536.00 8216.00 4704.00 14296.00 8288.00 4684.00 14608.00 8356.00 4724.00 14464.00 8372.00 4784.00 14588.00 8280.00 4736.00 14408.00 8332.00 4748.00 14356.00 Since I am using your code, the sensor is set on a scale range of +/-2g which means that the sensitivity of the accelerometer is of 16384 LSB/g. I know that to understand the raw datas I need to divide them with the sensitivity and get something near 0, 0, 0.98 even if there is an error. However with the values I am having it is no where near from what it should be... I tried the code from arduino playground and I am having the same raw datas, the same thing with the Kalman filter... There are a lot of guides but I must be missing something... I am just reading the right registers but those raw datas doesn't make any sense at all... So I would like to know if you think those datas are strange and if you happened to find something similar, I happened to find some talk on the internet which says that there is a version of the MPU6050 that doesn't have the same scale ranges and not the same sensitvities... I don't think I have that much of bad luck... Thank you for your help, Ben.
×