Jump to content
I2Cdevlib Forums

All Activity

This stream auto-updates     

  1. Today
  2. Yesterday
  3. Hello , i'm french student and iam using MPU6050 SPARKFUN with MPU6050.DMP6, but the sensor block in '' Initializing I2C devices..." what is the problem please ? thanks for your answer
  4. Last week
  5. ICM-20948 DMP load error

    Hi, I'm trying to flash the DMP image to an ICM-20948 to use the built-in sensor fusion. I've adapted my source code to use the code from the "Embedded MotionDriver (eMD) ICM-20948 v.1.0 for Nucleo Board" functions. I'm using nRF52832 to talk to ICM-20948 through I2C. My problem is twofold: 1) The transfer of the DMP firmware (dmp3a) sometimes fails. The ICM-20948 NACKs a byte (strangely it always seems to be a packet in memory bank 19 or 30), and then I have to power-cycle the chip to get an ACK from any register read/write. 2) In the cases where the DMP firmware transfer is successful, the verification routine fails. The bytes that my device reads back to compare to the firmware bytes are just all zeroes. For reference, this is the firmware upload routine from the MotionDriver source code: int inv_icm20948_firmware_load(struct inv_icm20948 * s, const unsigned char *data_start, unsigned short size_start, unsigned short load_addr) { int write_size; int result; unsigned short memaddr; const unsigned char *data; unsigned short size; unsigned char data_cmp[INV_MAX_SERIAL_READ]; int flag = 0; if(s->base_state.firmware_loaded) return 0; // Write DMP memory data = data_start; size = size_start; memaddr = load_addr; while (size > 0) { write_size = min(size, INV_MAX_SERIAL_WRITE); if ((memaddr & 0xff) + write_size > 0x100) { // Moved across a bank write_size = (memaddr & 0xff) + write_size - 0x100; } result = inv_icm20948_write_mems(s, memaddr, write_size, (unsigned char *)data); if (result) return result; data += write_size; size -= write_size; memaddr += write_size; } // Verify DMP memory data = data_start; size = size_start; memaddr = load_addr; while (size > 0) { write_size = min(size, INV_MAX_SERIAL_READ); if ((memaddr & 0xff) + write_size > 0x100) { // Moved across a bank write_size = (memaddr & 0xff) + write_size - 0x100; } result = inv_icm20948_read_mems(s, memaddr, write_size, data_cmp); if (result) flag++; // Error, DMP not written correctly if (memcmp(data_cmp, data, write_size)) return -1; data += write_size; size -= write_size; memaddr += write_size; } #if defined(WIN32) //if(!flag) // inv_log("DMP Firmware was updated successfully..\r\n"); #endif return 0; } I've looked at the I2C lines on a scope, and the bytes are successfully written to the ICM-20948, but somehow they are not making it to the DMP memory. I've attached a screenshot of the NACK event (third byte). I assume the following constants are suitable for the ICM-20948: #define DMP_LOAD_START 0x90 #define REG_MEM_START_ADDR (BANK_0 | 0x7C) #define REG_MEM_R_W (BANK_0 | 0x7D) #define REG_MEM_BANK_SEL (BANK_0 | 0x7E)
  6. Earlier
  7. Thanks a lot. After calibrating my sensor, it kinda stopped drifting.
  8. Problem resolved. The problem was the configuration of the INT pin. MPU6050 for some reason does not respond when it issues a pulse with a duration of 50 us, when DMP data ready. The problem was solved by the INT pin configuration so that the MPU6050 held its pin until the data was read.
  9. The gyro values give you angular velocity, not tilt angle.
  10. Hello. i need to know what should i do run run an adxl375 with using adxl345 sources. these two are nearly the same acceleration sensors but adxl375 is with wider range. i will appreciate if anyone help me about it. i need to know what kind of parameter i need to change. i have already tried the raw data example of adxl345 on adxl375, but i just get zero values. thank in advance.
  11. Hello, I would like to know the difference between the output Euler angles and the output yawpitchroll in the DMP6 example from Jeff Rowberg library. The details I would like to know are in terms of how they both work, their frames of reference, fixed or mobile referential and the sequences used like XYZ or ZYX etc. Thank you.
  12. I never use this VHDL code as previously mentioned. It is possible to guess that this VHDL code is not for I2C MPU6050 (or the code is using an external processor to transform i2c to serial). Perhaps it's the problem . An other Mike Field's project is interesting : http://hamsterworks.co.nz/mediawiki/index.php/I3C2 It's a dedicated i2c processor. Because I was interesting in this project I tried it but it but never work. It's very easy to find why : - source code of "i3c2_assemble.c" shows clearly the instruction "MASTERACK" (a very very important instruction) - in VHDL source code i3c2.vhd you never see this very important instruction. I guess the last version is not published. It is then impossible to make both files to work together. I have written Mike Field without answer but discover recently when reading Mike Field's source code there is another email address. Have try to email him. FYI I used already other Mike Field source code without problem. Good luck
  13. I have problem with MPU6050. Approximately every 1 - 2 minutes I get the NACK on the I2C bus from the sensor. This situation arises entirely by chance. I receive NACK during read "Current FIFO buffer size" register, but after reading this register again, the device responds normally. Do not know what could be the reason?
  14. Hey there. I just stumbled upon your site a couple days ago. I have a project to try and measure the vibrations wirelessly inside of a (quite large) machine. WIth the adafruit feather esp8266 and an ITG/MPU6050 breakout board. I have tried to apply the auto calibration scripts posted on the forums...and even the suggested manual one with 'raw' values. But neither managed to give me values that weren't obscenely far away from all zeros except for z at 16364 or simply never worked at all (the auto cal) As I have come to understand it, 16384 is the raw value for 1g. Or approx 9.81m/s/s. Is this correct? My problem however is, when running the example file MPU6050-DMP6-ESPWIFI.ino...and trying to read/plot OUTPUT_READABLE_REALACCEL...I have a large offset in the output data that I don't know how to interpret. My X . and Y converge to (nearly) zero after 15~seconds...however my Z converges around 3900...somethings...What is the unit that this function outputs? Gs? m/s/s? // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); // 1788 factory default for my test chip These Offsets take RAW values. However when adjusting them even a tiny amount the new plotted values are incredibly off. And because I'm unsure of the plotted value units. I'm not sure what I should exactly be reading nor where to begin with on adjusting the calibrated values. For further infos, the room this is being tested in, is about 16 degrees C...I've seen mentioned temperature needs to be calibrated...Could this is part of the issue? Thank you for the amazing work! As a side question, How do I adjust to different sensitivities 4/8/16Gs...within the arduino code/registers? MPU6050::getFullScaleAccelRange(x) x being between 0 and 3, I have found on the library...is this correct? Thanks again! I'll continue to hunt around the forums, incase I managed to just miss the subject posted somewhere else and update accordingly
  15. FYI I have done FPGA interface with mpu6050 but in a way you are probably not interested in. Because I used a AVR Mega16 free soc I have make a i2c peripheral which is compatible 90% with the true peripheral. This is documented in French in the Wikiversité : https://fr.wikiversity.org/wiki/Very_High_Speed_Integrated_Circuit_Hardware_Description_Language/Travail_pratique/Utiliser_des_shields_Arduino_avec_les_FPGA#De_l'I2C_pour_accéder_à_d'autres_capteurs If you have no experience with soc, I think it would be better for you to use Mike Field's work : http://hamsterworks.co.nz/mediawiki/index.php/MPU6050_sensor_RTL Good luck
  16. Hello everyone, I am trying to interface mpu 6050 with fpga, can anyone help me in acquiring the data from the sensor.
  17. MPU6050 calibration

    Hello guys I have been trying to get yaw values from gyro MPU6050 for my application. The application is basically to control a robot's movement with respect gyro readings. Recently I started facing some issues relating calibration of the gyro. In my code I am mapping all the values of the whole range of yaw (-180 to 180) to pwm range (0 to 200). So ideally the sensor should get calibrated every time at value 100. The situation I am facing is that it gets calibrated at 100 just 3 times out of 10. What may be the possible issue? I am attaching the code for reference. Thank you GYRO.txt
  18. I am interested in any feedback or caveats regarding the following capacitance measurement method before I begin setting it up. For an experiment, I have come across the need to measure and track the spacing between two samples, with resolution of 0.1 mm or better. Due to the constraints of the rest of my setup, after a little bit of research, it appears to me that a capacitive measurement method is most suitable to infer the spacing. Consider the following simplification as the goal: I would like to measure/track the distance between 2 copper plates (each 2cm X 2cm) that essentially form a big capacitor. Note: AD7746 below is a 2-channel, 24-bit sigma-delta Capacitance-to-digital converter The idea: Starting with C=ε0εrAdC=ε0εrAd, where the plate area the dielectric of air are constant, it's of course true that the measured capacitance is inversely proportional to distance. So I could first take some calibration data, and using that, adjust accordingly to infer the distance from any measured capacitance value. The measurement method: Given my fairly stringent requirement of 0.1 mm resolution or better, I plan to go for a precise measurement by using Analog Devices capacitive measurement IC AD7746 datasheet: http://www.kynix.com/uploadfiles/pdf/AD7746ARUZ.pdf. What things should I be careful about to get as clean a measurement as possible, or what aspects can I improve upon? Could the above get me my desired resolution, or is it prone to error sources that I'm not seeing? One possible improvement is: I was thinking, since AD7746 has two channels, I could even use the extra channel to also simultaneously measure a separate pair of completely fixed/reference plates, and use that to nullify any temperature or EMI effects. Hmm, not sure how important those factors are... UPDATE (more detail): A bit more about my setup, and what constraints exist: The experiment involves a larger sample that is directly above, kissing the top plate. The sample is about 75mm X 75mm (non-metallic) and it sort of crushes the top plate down during the vertical motion. As a result, there is no scope for placing any sensors vertically parallel to the Y-axis motion. Any sensing of the vertical displacement/gap would have to be accomplished either horizontally, or with parts mounted on a board in the position of the bottom plate. With that said, the top plate was added just for my proposed way of measurement, and is not strictly necessary. My primary goal is to measure how far away my aforementioned 75mm X 75mm sample ends up vertically from the bottom. UPDATE (Measurement result): I ran a quick test on the capacitive measurement, and I was able to distinguish the capacitance data fairly clearly at about 0.2 mm steps in the displacement. The noise I'm getting in the capacitance measurement is, as of now, too large to get better resolution than that. I am trying to vary a few things to see if I can improve the SNR in the capacitance measurement.
  19. Same issue here. After: (MPU6050.ccp) void MPU6050::initialize() { setClockSource(MPU6050_CLOCK_PLL_XGYRO); setFullScaleGyroRange(MPU6050_GYRO_FS_250); setFullScaleAccelRange(MPU6050_ACCEL_FS_2); setSleepEnabled(false); // thanks to Jack Elston for pointing this one out! } ... * <pre> * AFS_SEL | Full Scale Range | LSB Sensitivity * --------+------------------+---------------- * 0 | +/- 2g | 8192 LSB/mg * 1 | +/- 4g | 4096 LSB/mg * 2 | +/- 8g | 2048 LSB/mg * 3 | +/- 16g | 1024 LSB/mg * </pre> So the MPU6050_6Axis_MotionApps20.h expands... uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) { // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g) v -> x = vRaw -> x - gravity -> x*8192; v -> y = vRaw -> y - gravity -> y*8192; v -> z = vRaw -> z - gravity -> z*8192; return 0; } But the MPU 6050 Product Specification says: If the values are queried with the Rowberg-Skript, they are to low. But if I divide the "output_readable_realaccel" aaReal by 8192 instead 16384 it seems to be correct. How to fix it correctly? Sorry for take up the old topic, but its pretty confusing.
  20. MPU- 6050

    What are the prblems / limitations of using MPU-6050? How can we overcome with these problems?
  21. MPU- 6050

    What are the prblems / limitations of using MPU-6050? How can we overcome with these problems?
  22. Thanks for the info. I can't understand why the constant value of 36.53 is added to convert degrees C in the code that everyone uses. The data sheet says the offset is -521 and since the sensitivity is 340 per degree c, surely 521/340 = 1.53 ?? Yes, I do see the 35 degrees under Conditions - but this was the test condition that the spec was determined under - right? Why is it (apparently) added to the 1,53 to get the 36.53 ? Thanks Russell
  23. I see that this a very old thread but in these days I'm facing the thread subject. Using an MPU9250 and the Invensense motion driver (6.1), I'm able to put compass data in the fifo while DMP is enabled, without hacks on the original DMP firmware. I achieved this result by changing the original fifo reset function: the slave 1 fifo bit must be enabled before activating the fifo and dmp features in user control register. The resulting saved record is: 8 byte of compass data (compass status1 + 6 bytes of true data + compass status 2) followed by the original DMP record. Another way: the slave 1 fifo bit can be enabled after the FIFO and DMP enabling (for example: elsewhere in the user code), but a proper fifo purge is required to discard the incomplete records and gain the correct sync against the FIFO. These solutions work on my device using 200 hz DMP sample rate + 100Hz compass sample rate (every compass sample is repeated two times in FIFO, gestures enabled and quaternion disabled), but them are totally undocumented and more testing is needed, so, I would like to know if anyone use similar solutions and if there are know issues. Regards.
  24. Hi! I'm trying to communicate with the MPU6050 in MATLAB, where if I send a request 'A' via serial bluetooth to the Arduino UNO, I get the current reading of the euler angle. This kind of works for me at the moment, but if I request the serial print out of the angle too many times in a row, or to frequently, I get some kind of FIFO overflow, so that I have to reset the arduino and re-initialize the Bluetooth connection before I can use it again. It usually takes less than 5-10 requests before the MPU hangs and does not respond anymore. I'll post my arduino code below. I reqest the angle by sending the character 'A' via bluetooth to the arduino. In the same way, I use a motor shield so that I can control two DC-motors that are connected to the arduino as well, by sending various commands via bluetooth. #include <SoftwareSerial.h> SoftwareSerial BT(5, 6); // creates a "virtual" serial port/UART // connect BT module TX to D5 // connect BT module RX to D6 // connect BT Vcc to 3.3V, GND to GND #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 mpu; #define OUTPUT_READABLE_EULER #define LED_PIN 13 // char val = 0; int speed = 40; int a =0; 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 int angle; // 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 // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { //Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin // 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 serial communication // Serial.begin(9600); BT.begin(9600); while (!Serial); // wait for Leonardo enumeration, others continue immediately mpu.initialize(); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(38); mpu.setYGyroOffset(-91); mpu.setZGyroOffset(46); mpu.setZAccelOffset(1682); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { mpu.setDMPEnabled(true); 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(LED_PIN, OUTPUT); } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // MPU run // 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) { if (BT.available() ) { val = BT.read(); if (val == 'F') { //forward @ speed 40 digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(13, LOW); //Establishes forward direction of Channel B digitalWrite(9, LOW); //Disengage the Brake for Channel A digitalWrite(8, LOW); //Disengage the Brake for Channel B analogWrite(3, speed); //Spins the motor on Channel A at speed 50. (full speed = 255) (variable speed defined at 50 as standard) analogWrite(11, speed); //Spins motor Channel B at speed 20. } else if(val == 'G') { //Backwards @ speed 40 digitalWrite(12, LOW); //Establishes Backwards direction of Channel A digitalWrite(13, HIGH); //Establishes Backwards direction of Channel B digitalWrite(9, LOW); //Disengage the Brake for Channel A digitalWrite(8, LOW); //Disengage the Brake for Channel B analogWrite(3, speed); //Spins the motor on Channel A at speed 40. (full speed = 255) (variable speed defined at 50 as standard) analogWrite(11, speed); //Spins motor Channel B at speed 40 } else if (val == 'B'){ //Breaks both Channels digitalWrite(9, HIGH); //Eengage the Brake for Channel A digitalWrite(8, HIGH); //Eengage the Brake for Channel B } else if (val == 'L'){ //Turn left @ speed 20 digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A digitalWrite(8, HIGH); //Engage the Brake for Channel B analogWrite(3, speed); //Spins the motor on Channel A at speed 40. (full speed = 255) } else if (val == 'R'){ //Turn left @ speed 20 digitalWrite(13, LOW); //Establishes forward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B digitalWrite(9, HIGH); //Engage the Brake for Channel A analogWrite(11, speed); //Spins the motor on Channel A at speed 40. (full speed = 255) } else if (val == 'A') { // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetEuler(euler, &q); // Serial.print("\n"); BT.println(euler[0] * 180/M_PI); // Serial.print(euler[1] * 180/M_PI); // Serial.print("\t"); // Serial.println(euler[2] * 180/M_PI); // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } } } // 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; } }
  25. Hi do you have mpu9250 version of your calibration code? i tried to make it wrk on 9250 but no success so far. it says mpu6050 conncetion failed. of course i change 0x68 values and tried series of related numbers but no success. If you can help me on this one really preciate it
  26. were you able to get data from magnetometer? We are getting same issue.
  27. Were you able to resolve this. We are facing same issue with magnetometer.
  28. hello, I just need to ask which of the values from the mpu6050 library are accurate? I mean, which of the following values has no effect from movement of sensor. I already have used an non library complemetary filter, but that also gives messed up angles when sensor is moved. #define OUTPUT_READABLE_QUATERNION #define OUTPUT_READABLE_EULER #define OUTPUT_READABLE_YAWPITCHROLL #define OUTPUT_READABLE_REALACCEL #define OUTPUT_READABLE_WORLDACCEL #define OUTPUT_TEAPOT
  1. Load more activity