Jump to content
I2Cdevlib Forums

All Activity

This stream auto-updates     

  1. Last week
  2. Earlier
  3. I am looking for a working example of motion detection on MPU6050. I hope to combine it with the DMP example sketech.
  4. I have seen following calculations at library of the mpu6050. Why is calculated XAxisFinal, YAxisFinal and ZAxisFinal accelerometer values as following? If (XAxisFinal>0.99) XAxisFinal=1; if (YAxisFinal>0.99) YAxisFinal=1; if (ZAxisFinal>0.99) ZAxisFinal=1; or if (XAxisFinal<-0.99) XAxisFinal=-1; Can not the values of XAxisFinal, YAxisFinal and ZAxisFinal bigger than 1 or smaller than -1?
  5. I had a similar problem. I resolved it my adding the i2cdev and mpu6050 library folders to the MY DOCUMENTS/ARDUINO/LIBRARIES FOLDER. For some reason they need to be there even if they exist in the library folder of ARDUINO residing in the Program Files Folder.
  6. I had a similar problem. I resolved it my adding the i2cdev and mpu6050 library folders to the MY DOCUMENTS/ARDUINO/LIBRARIES FOLDER. For some reason they need to be there even if they exist in the library folder of ARDUINO residing in the Program Files Folder.
  7. Hello, I have the following scenario for which I am trying to calculate the associated metrics. An IMU functioning at 100HZ has been used to capture accelerometer (3 axis) and gyroscope (3 axis) data for a body in motion. The data is presented in an excel spreadsheet with frame, Ax (m/ss), Ay, Az, Gx(deg/s), Gy, Gz. From this data I am looking to calculate the Vmax during the downward phase of motion as well as for the upward phase. I also would like to calculate the maximum displacement (ie transition point from downward to upward phase). I know the double integration method is the recommended approach but I am unsure of what conditions must be applied to achieve reliable results. Also, are the calculations that can be done in Excel or must one use MATLab or similar computing software to process the data? Thanks in advance!
  8. Hello,So I'm a newbie trying to build my first self balancing robot using MPU6050 and L928n Driver, I got this tested code (which it was supposed to work ok since I'm using the same hardware and connections). But as i run the code it got stuck in the message "DMP ready! Waiting for first interrupt...". Does anyone have an I idea what problem this could be? Here is the code: #include "PID_v1.h" #include "LMotorController.h" #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #define MIN_ABS_SPEED 20 MPU6050 mpu; // 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 VectorFloat gravity; // [x, y, z] gravity vector float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector //PID double originalSetpoint = 165; double setpoint = originalSetpoint; double movingAngleOffset = 0.1; double input, output; int moveState=0; //0 = balance; 1 = back; 2 = forth double Kp = 0; // First adjustment double Kd = 0; // Second adjustment double Ki = 0; // Third adjustment PID pid(&input, &output, &setpoint, Kp, Ki, Kd, DIRECT); // kp = 55,kd=0.9 double motorSpeedFactorLeft = 0.6; double motorSpeedFactorRight = 0.6; //MOTOR CONTROLLER int ENA = 10; int IN1 = 6; int IN2 = 7; int IN3 = 8; int IN4 = 9; int ENB = 11; LMotorController motorController(ENA, IN1, IN2, ENB, IN3, IN4, motorSpeedFactorLeft, motorSpeedFactorRight); //timers long time1Hz = 0; long time5Hz = 0; volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } void setup() { // 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 // (115200 chosen because it is required for Teapot Demo output, but it's // really up to you depending on your project) Serial.begin(115200); while (!Serial); // wait for Leonardo enumeration, others continue immediately // 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(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.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...")); 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(); //setup PID pid.SetMode(AUTOMATIC); pid.SetSampleTime(10); pid.SetOutputLimits(-255, 255); } 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(")")); } } 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) { //no mpu data - performing PID calculations and output to motors pid.Compute(); motorController.move(output, MIN_ABS_SPEED); } // 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; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); #if LOG_INPUT Serial.print("ypr\t"); Serial.print(ypr[0] * 180/M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180/M_PI); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); #endif input = ypr[1] * 180/M_PI + 180; } }
  9. I had one of my GY-521's that would always fail the testConnection() function and also would not calibrate. So before throwing it away I ran the getDeviceID() function and discovered that its ID was 0x39. On investigation in MPU6050.cpp, the return value is only true if the ID is 0x34, even further, the following functions (all of the offsets) only work with DeviceID's less than 0x38 !!! int16_t MPU6050::getXAccelOffset() { uint8_t SaveAddress = ((getDeviceID() < 0x38 )? MPU6050_RA_XA_OFFS_H:0x77); // MPU6050,MPU9150 Vs MPU6500,MPU9250 I2Cdev::readBytes(devAddr, SaveAddress, 2, buffer); return (((int16_t)buffer[0]) << 8) | buffer[1]; I changed my MPU6050.cpp values to suit my DeviceID to "getDeviceID() < 0x3A ", because mine was 0x39, it now works fine!!! Does anyone know what the range is? Thanks
  10. Hi, I am new in the arduino sorry in advance for if I am wrong. I am using dmp I want use mpu6050 interrupt for my low power consumption. Please help me out
  11. I am trying to get the data from an accelerometer , i.e BMI160. how I will get x,y and z values from driver to appliaction..if anybody worked on it please help me out..it's urgent! reference link https://github.com/BoschSensortec/BMI160_driver. data sheet: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMI160-DS000.pdf Thanks in advance!
  12. Hello, I´m new with this sensor, but have been reading a lot. I´m pretty sure you should change set up in the library MPU6050_6Axis_MotionApps_V6_12.h. Regards Santiago
  13. In C++, you can specify default argument values in the prototype declaration. So you're on the right track, but the default values in this case are actually false. https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h#L800
  14. Greetings, There is a piece of code called setMemoryBank, in the MPU6050 class (MPU6050.cpp). It looks like this: void MPU6050::setMemoryBank(uint8_t bank, bool prefetchEnabled, bool userBank) { bank &= 0x1F; if (userBank) bank |= 0x20; if (prefetchEnabled) bank |= 0x40; I2Cdev::writeByte(devAddr, MPU6050_RA_BANK_SEL, bank); } This is used in dmpInitialize() (MPU6050_6Axis_MotionApps20.h). Likewise, further down in dmpInitialize() writeProgMemoryBlock() is called to write the DMP code to the IMU. However, inside writeProgMemoryBlock() there is another call to setMemoryBank, but only takes one argument. The function isn't overloaded anywhere. I'm assuming it's the same function without the two booleans set to True. But I'd like to know for sure. I can't find this code anywhere else. Likewise, writeMemoryBlock() is called with 4 parameters instead of 6. I feel like this code shouldn't be here, or it's for a different API. writeProgMemoryBlock() is all wrong as well.
  15. To download McAfee Antivirus, kindly open up the web browser and visit mcafee.com/activate then enter your activation code and press enter, then choose your language and country. At last, verify your email address to activate the product. McAfee provides a full range of security products such as antivirus, firewall and anti-spyware programs. Also, learn how to uninstall McAfee.
  16. Hi! I would like to report that the Upload button does not exist and therefore there is no way for me to upload a csv. Thank you in advance.
  17. Hi there, I am using MPU6050 with two servos. With some extra addings to example MPU6050_DMP6_using_DMP_V6.12 there was no problem with servos. But when I wanted to use BMP180 and combined all of these in one code I get FIFO overflow. I was looking for solutions but none of them solved my problem exactly(or can't apply correctly). I tried to minimize the readings of datas of BMP180 and I get FIFO overflow less frequently. But servos are still slow and respond the changes of MPU6050 litte lately. So this lagging absolutely ruins the project and I cannot make any progress without solving this problem. I would be grateful if anyone can help me. Here is my code: /* Arduino nano için; Bmp180 pinleri: sda -> a4 scl -> a5 vın -> 5v gnd -> gnd Mpu6050 pinleri: vcc -> 5v gnd -> gnd scl -> a5 sda -> a4 int -> d2 RGB Led pinleri: d9, d10, d11 Servo Motor pinleri: d7, d8 Buzzer pinleri: d12 */ #include <Wire.h> #include <Adafruit_BMP085.h> #include<Servo.h> #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#include "MPU6050.h" // not necessary if using MotionApps include file #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #include <Servo.h> Servo myservo,myservo2; // create servo object to control a servo #define seaLevelPressure_hPa 1013.25 Adafruit_BMP085 bmp; int R=9; int G=10; int B=11; const int buzzer = 12; MPU6050 mpu; // uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual // quaternion components in a [w, x, y, z] format (not best for parsing // on a remote host such as Processing or something though) //#define OUTPUT_READABLE_QUATERNION // uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles // (in degrees) calculated from the quaternions coming from the FIFO. // Note that Euler angles suffer from gimbal lock (for more info, see // http://en.wikipedia.org/wiki/Gimbal_lock) //#define OUTPUT_READABLE_EULER // uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/ // pitch/roll angles (in degrees) calculated from the quaternions coming // from the FIFO. Note this also requires gravity vector calculations. // Also note that yaw/pitch/roll angles suffer from gimbal lock (for // more info, see: http://en.wikipedia.org/wiki/Gimbal_lock) #define OUTPUT_READABLE_YAWPITCHROLL // uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration // components with gravity removed. This acceleration reference frame is // not compensated for orientation, so +X is always +X according to the // sensor, just without the effects of gravity. If you want acceleration // compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead. //#define OUTPUT_READABLE_REALACCEL // uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration // components with gravity removed and adjusted for the world frame of // reference (yaw is relative to initial orientation, since no magnetometer // is present in this case). Could be quite handy in some cases. //#define OUTPUT_READABLE_WORLDACCEL // uncomment "OUTPUT_TEAPOT" if you want output that matches the // format used for the InvenSense teapot demo //#define OUTPUT_TEAPOT #define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards #define LED_PIN 11 // (Arduino is 13, Teensy is 11, Teensy++ is 6) #define SERVO_PIN 7 // use pin 9 for servo control #define SERVO_PIN2 8 bool blinkState = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // packet structure for InvenSense teapot demo uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { //Kırmızı renk elde etmek için... analogWrite(R,255); analogWrite(G,0); analogWrite(B,0); //delay(500); Serial.begin(38400); Serial.println("Ucus Bilgisayari deneme"); if (!bmp.begin()) { Serial.println("BMP280 bulunamadi!"); analogWrite(R,255); analogWrite(G,0); analogWrite(B,0); while (1) {} } myservo.attach(SERVO_PIN); myservo2.attach(SERVO_PIN2); myservo.write(0); // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 48; Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // Serial.begin(115200); while (!Serial); // wait for Leonardo enumeration, others continue immediately // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to // the baud timing being too misaligned with processor ticks. You must use // 38400 or slower in these cases, or use some kind of external separate // crystal solution for the UART timer. // initialize device Serial.println(F("Initializing I2C devices...")); mpu.initialize(); pinMode(INTERRUPT_PIN, INPUT); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); if(!mpu.testConnection()){ analogWrite(R,255); analogWrite(G,0); analogWrite(B,0); } // wait for ready Serial.println(F("\nSend any character to begin DMP programming and demo: ")); while (Serial.available() && Serial.read()); // empty buffer while (!Serial.available()); // wait for data while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.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...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), 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); } void loop() { //Yeşil renk elde etmek için... analogWrite(R,0); analogWrite(G,255); analogWrite(B,0); //Serial.print("Sicaklik = "); Serial.print(bmp.readTemperature()); //Serial.println(" *C"); //Serial.print("Basinc = "); Serial.print(bmp.readPressure()); //Serial.println(" Pa"); //Serial.print("Yukseklik = "); Serial.print(bmp.readAltitude()); //Serial.println(" metre"); //Serial.print("Deniz seviyesinde basinc = "); Serial.print(bmp.readSealevelPressure()); //Serial.println(" Pa"); //Serial.print("Gercek Yukseklik = "); Serial.print(bmp.readAltitude(seaLevelPressure_hPa * 100)); //Serial.println(" metre"); Serial.println(""); // 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(); 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; #ifdef OUTPUT_READABLE_QUATERNION // display quaternion values in easy matrix form: w x y z mpu.dmpGetQuaternion(&q, fifoBuffer); Serial.print("quat\t"); Serial.print(q.w); Serial.print("\t"); Serial.print(q.x); Serial.print("\t"); Serial.print(q.y); Serial.print("\t"); Serial.println(q.z); #endif #ifdef OUTPUT_READABLE_EULER // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetEuler(euler, &q); Serial.print("euler\t"); Serial.print(euler[0] * 180/M_PI); Serial.print("\t"); Serial.print(euler[1] * 180/M_PI); Serial.print("\t"); Serial.println(euler[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); Serial.print("ypr\t"); Serial.print(ypr[0] * 180/M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180/M_PI); //Output to servo myservo.write(180-(90+ ypr[2] * 180/M_PI)); myservo2.write(180-(90+ ypr[1] * 180/M_PI)); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_REALACCEL // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); #endif #ifdef OUTPUT_READABLE_WORLDACCEL // display initial world-frame acceleration, adjusted to remove gravity // and rotated based on known orientation from quaternion mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q); Serial.print("aworld\t"); Serial.print(aaWorld.x); Serial.print("\t"); Serial.print(aaWorld.y); Serial.print("\t"); Serial.println(aaWorld.z); #endif #ifdef OUTPUT_TEAPOT // display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = fifoBuffer[0]; teapotPacket[3] = fifoBuffer[1]; teapotPacket[4] = fifoBuffer[4]; teapotPacket[5] = fifoBuffer[5]; teapotPacket[6] = fifoBuffer[8]; teapotPacket[7] = fifoBuffer[9]; teapotPacket[8] = fifoBuffer[12]; teapotPacket[9] = fifoBuffer[13]; Serial.write(teapotPacket, 14); teapotPacket[11]++; // packetCount, loops at 0xFF on purpose #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } }
  18. Hello and thanks in advance for the great library, I'm planning to use the MPU6050 as the IMU of my university rocket team's 3km apogee rocket for telemetry. The problem is, it means that I would have to use the 16g range of the accelerometer. It's desirable to use the device's DMP as it's the most precise and hassle-free solution, but I didn't seem to find a way to set the device's range to 16g while using its DMP. I tried modifying the teapot example to include the line mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_16); after the device initialization and after the DMP initialization but it didn't work. Is it possible? If no, what method would you recommend for processing the raw data? Or even, is there a better solution than the MPU6050 for my application? I've looked at the BNO055, but unfortunately that chip is too expensive for my team compared to the MPU. I'm using an Arduino nano for development with PlatformIO (VS Code). We plan to use the ESP32 as our micro.
  19. I am facing the exact same issue, did you find a solution to this? Any suggestions will be a great help. Thanks in advance.
  20. No one to help??? how do i get this fault eliminated?
  21. Dear, I try to restore a friends machine, that drives over un-level ground and need to hold a vertical device always perfectly vertical using 1x 12VDC motor. Stabilization is done on 1 axis. Not 2 I believe. His former old friend build a Arduino Uno board with on top a DUALCHANNEL H-BRIDGE motor shield from ELECROW.COM and on top of that board a prototype shield v.5 board containing a GY-521 sensor ( MPU 6050 I believe). We managed to get his old code back via relatives of his former friend who look like this : #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #include "PID_v1.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 MPU6050 mpu; // 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 VectorFloat gravity; // [x, y, z] gravity vector float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // PID double kp = 20, ki = 0, kd = 0; double Setpoint = 0; // leveled double Input = 0, Output = 0; PID PID1(&Input, &Output, &Setpoint, kp, ki, kd, DIRECT); // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } void setup() { // 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(115200); // initialize DMP devStatus = mpu.dmpInitialize(); // Offsets for calibrating mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); // 1688 factory default // 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(")")); } // Motor_1 controll pin initiate; pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(9, OUTPUT); // Speed control //Enable the Motor Shield output; pinMode(6, OUTPUT); digitalWrite(6, HIGH); //PID initiate PID1.SetMode(AUTOMATIC); PID1.SetSampleTime(1); PID1.SetOutputLimits(-255, 255); } 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(); 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; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); Input = ypr[2] * 180 / M_PI; PID1.Compute(); //Output to motor shield control_motor(Output); //Display Euler angles in degrees Serial.print("ypro\t"); Serial.print(ypr[0] * 180 / M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180 / M_PI); Serial.print("\t"); Serial.print(ypr[2] * 180 / M_PI); Serial.print("\t"); Serial.println(Output); } } void control_motor(double pwm_value) { int pwm = round(pwm_value); if (pwm < -255) pwm = -255; if (pwm > 255) pwm = 255; if (pwm > 0) { //Set the motor direction CW digitalWrite(4, LOW); digitalWrite(5, HIGH); analogWrite(9, pwm); //Set the motor speed } else { //Set the motor direction CCW digitalWrite(4, HIGH); digitalWrite(5, LOW); analogWrite(9, pwm); } } But once I connect my arduino uno board and launch the program I get this error message: Arduino: 1.8.13 (Windows 7), Board:"Arduino Uno" V2:1:10: fatal error: I2Cdev.h: No such file or directory #include "I2Cdev.h" ^~~~~~~~~~ compilation terminated. exit status 1 I2Cdev.h: No such file or directory ZIP file does not contain a map or valid library What do I need to do? Thanks for any help. Very welcome when you don't have any arduino experiences !!! Kind regards,
  22. hello.... first I would like to thank all of the people that built such a great library to make mpu6050 sensor easy to use. I'm currently working on measuring joint angle based on two IMU sensors (mpu6050). I managed to get the quaternion values of each sensor and convert it to euler angles using dmp FIFO. But I have a question about the library "MPU6050_6Axis_MotionApps20.h". Does it depends on Kalman Filter or what?.
  23. Pleaaase I would like to work with three MPU-6050 acelerometers too. Did someone get the answer? :(
  1. Load more activity
×
×
  • Create New...