Jump to content
I2Cdevlib Forums

All Activity

This stream auto-updates

  1. Last week
  2. Earlier
  3. Hi....It appears as though the issue was with the document ways for the libraries on my windows 10 PC. I downloaded an adjusting robot sketch that utilizes similar libraries as the MPU6050_DMP6 sketch and it assembled with practically no issues. I then, at that point, subbed the MPU6050_DMP_6 sketch and it likewise ordered with practically no issues.
  4. Hello, how do you connect Arduino and two MPUs?
  5. Hi Niharika, can you tell me which IDE you are using to develop this application?
  6. I'm too having the same errors while compiling. As I'm using Arduino IDE downloaded from the Windows Store, Program files/Program files(x86) won't have an Arduino folder. How to solve these errors?
  7. Pretty late response :-) I see the same behaviour when doing the zero-offset-calibration in a certain position, but then powering up the MPU in a very different position.
  8. Hey! when i run the raw program first it shows this - Initializing I2C devices... Testing device connections... MPU6050 connection failed and then stars printing values hows this possible ? it says that connection failed but then prints the value a/g: -108 724 16704 747 765 -258 a/g: -120 752 16608 758 767 -231 a/g: -116 752 16728 785 790 -244 a/g: -148 708 16748 766 782 -232 Please help me
  9. Seems like the link for the AD7746 documentation is broken https://www.i2cdevlib.com/docs/html/class_a_d7746.html
  10. Is there any example code around that uses the dmpGetYawPitchRoll code and fixes the yaw data with an external magnetometer?
  11. Dear, Here are a "new" version of your program about HMC5843. With centering datas for "correct" evaluation of vector magnitude which should be "constant", with no pertubating magnetic field. Best regards HMC5843_raw_v05.ino
  12. Hello guys. I am trying to make an alarm for a moving object using mpu6050. I connected the sensor to Arduino and tried to attach it to an object from my house, in case someone moves it, even very slowly, I want to know. The problem is that i made the motion interrupt setting but if i move the object slowly, it does not detect anything, whereas If i tap it, I get imediately an alarm. What you think, what should I tune? Does it have a connection with the accelerometer range or sample rate? Thanks. // Here it is set the motion detect routine . You are able to set the sensitivity of the module. // The values motion duration and motion threshold sets the sensitivity of the module. mpu6050_writeByte(MPU6050_RA_INT_ENABLE, 0x40); //MOTION DURATION mpu6050_writeByte(MPU6050_RA_FF_DUR, 1); //MOTION THR mpu6050_writeByte(MPU6050_RA_FF_THR, sensitivity); mpu6050_writeByte(0x68, MPU6050_PWR1_CYCLE_BIT); mpu6050_writeByte(0x6C, 135); _delay_ms(1);
  13. Dear Rusell, I could not understand either that same concern. I totally get your point, taking the -521 LSB as the offset and 35 (ºC) as the offset measurement conditions (as could checked in the datasheet screenshot provided below). However, adding that offset value instead of subtracting it and adding 35 results in an accurate reading value. Also consider that if you extend the temperature's measurement through the time, the board will self-heat. I noticed risings around 0.6 to 1 degree. Please, before slopping any opinion here, keep in mind that the readings were tested to be accurate (see the attached image, I know is cropped up it was the only way it fixed 500 kb with a decent resolution). Kind regards to the community, Fran Hdez. #include "MPU6050.h" #include "Wire.h" int16_t temp_raw; float temp; MPU6050 sensor; void setup() { Serial.begin(57600); Wire.begin(); sensor.initialize(); if (sensor.testConnection()) { Serial.println("Sensor attached successfully"); } else { Serial.println("Error at sensor attachment"); } } void loop() { // Screen showing the MPU temperature read (16-bit in 2's Complement format, interpreted by default as a negative number). temp_raw = sensor.getTemperature(); temp = float(temp_raw + 521)/340 + 35.0 Serial.println (temp); delay (100); }
  14. I am looking for a working example of motion detection on MPU6050. I hope to combine it with the DMP example sketech.
  15. 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?
  16. 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.
  17. 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.
  18. 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!
  19. 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; } }
  20. 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
  1. Load more activity
  • Create New...