Giter Club home page Giter Club logo

Comments (15)

thegreatgunbantoad avatar thegreatgunbantoad commented on July 20, 2024

I assume the code isn't working as is, the protocols looks similar, you might have gotten lucky. If you hook the USB port on the Wemos up to a serial emulator you should get some diagnostics out.

from ispindel.

Bananamannn avatar Bananamannn commented on July 20, 2024

Thanks for the speedy reply. I did hook it up too a serial monitor but the only thing it told me was that the accelerometer was not detected, didn't seem like super useful info.

From what I've read (not that I'm an expert or anything) it seems like the MPU9250 & MPU6500 use the same library. However the MPU9250 (https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU9250) version of the MPU6050 library currently used is about 4 years old and has all different commands in it so it just comes up with a heap of errors when I try and build new firmware in Platform.IO

from ispindel.

Bananamannn avatar Bananamannn commented on July 20, 2024

After some hours of reading and having an epiphany I've managed too get the standard code using the library for the MPU6050 working by commenting out line 68 in file MPU6050.cpp and replacing it with "true". I believe the error is occurring because the device ID of the MPU6500 is not 0x38. After looking at the datasheet it should be 0x70, but that doesn't work either. Any ideas??

bool MPU6050::testConnection() {
//    return getDeviceID() == 0x38; 
    return true;
}

from ispindel.

pppedrillo avatar pppedrillo commented on July 20, 2024

Mind share the datasheet?

MPU6050 lib will not work if ID is 0x70. Function GetDeviceID() reads 6 bits (which is enough for 6050 id == 0x34 b110100, but not enough for 6500 id == 0x70 b1110000.
Simply put, it must read 7 bits to get id == 0x70.

from ispindel.

stefschin avatar stefschin commented on July 20, 2024

In Datasheet says:
image
As I see in Schematics, by default, AD0 is connected low, so ID is b1101000 wich is 0x68
image

from ispindel.

pppedrillo avatar pppedrillo commented on July 20, 2024

As I see in Schematics, by default, AD0 is connected low, so ID is b1101000 wich is 0x68

This schematics is for 9250, not 6500 ?? @stefschin
And for 9150/9250 ids are 0x68 and 0x71 I believe.

from ispindel.

stefschin avatar stefschin commented on July 20, 2024

It's the only schematic I found as MPU 6500
https://www.smart-prototyping.com/MPU6500-6DOF-Sensor-Breakout-Board
I think it's same circuit for both ICs.
And in datasheet has same ID as MPU 6500

Screenshot_20211010-095430

MPU9150 is a MPU6050 with integrated AK8975 magnetometer
MPU9250 is a MPU6500 with integrated AK8963 magnetometer
Somebody can try with 0x68 or 0x69?

from ispindel.

Bananamannn avatar Bananamannn commented on July 20, 2024

I have tried "getDeviceID()" with both 0x68 & 0x69 and both give back an error

from ispindel.

pppedrillo avatar pppedrillo commented on July 20, 2024

I have tried "getDeviceID()" with both 0x68 & 0x69 and both give back an error

How many bits you was reading?

from ispindel.

Bananamannn avatar Bananamannn commented on July 20, 2024

I have tried "getDeviceID()" with both 0x68 & 0x69 and both give back an error

How many bits you was reading?

I'm sorry. I don't know how to test that :(

from ispindel.

pppedrillo avatar pppedrillo commented on July 20, 2024

I have tried "getDeviceID()" with both 0x68 & 0x69 and both give back an error

How many bits you was reading?

I'm sorry. I don't know how to test that :(

As I said function getDeviceID() from the MPU6050 lib reads only 6 bits.
You need to read 7 bits to get any values grater than 0x3f as device ID

from ispindel.

stefschin avatar stefschin commented on July 20, 2024

Sorry for delay but I was on a trip. I think we have made some mistakes about the code.
What I was talking about is Slave Address, but thinking that they are not the same for both devices. But reading datasheet both are the same: 0x68 for AD0 pin low and 0x69 for AD0 pin high. So nothing to worry until here.
You can see it on driver code: MPU6050.h line 60

#define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
#define MPU6050_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC)
#define MPU6050_DEFAULT_ADDRESS MPU6050_ADDRESS_AD0_LOW

and has the purpose to communicate with different devices on same I2C bus.

In other side to check if device is correctly connected, you can read Register 117, WHO_AM_I, that returns the contents of the upper 6 bits of the MPU-60X0’s 7-bit I2C address, in this case 0x34.
As you can see on MPU6050.cpp line 68

bool MPU6050_Base::testConnection() {
return getDeviceID() == 0x34;
}

This function reads ID on this way:

uint8_t MPU6050_Base::getDeviceID() {
I2Cdev::readBits(devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, buffer, I2Cdev::readTimeout, wireObj);
return buffer[0];
}

Now, for MPU-6500, it has same register 117, WHO_AM_I but is different:

image

As we can see it's 0x70 and has 8 bit instead of 6 returned before.
Anyway surely there are other differences between this two ICs that can make a bad communication or sensor readings. Normally I would search for other driver that's specific for MPU-6500 and compatible with the driver that uses iSpindel code. Or edit MPU-6050 driver to make it work with MPU-6500...
I can do it with more time but unfortunately both devices are not recommended for new designs, new Motion Sensor that I see for Arduino is LSM6DS3 but I didn't check for Arduino Library.
Hope it helps, cheers

from ispindel.

Bananamannn avatar Bananamannn commented on July 20, 2024

Hey guys. Thanks for all your help / advise. I went and did some reading of the things you've been discussing and came to the following conclusions:

  1. MPU6500 works using the MPU6050 library on the ISpindel as the command used are the same on both chips
  2. .getDeviceID return 56 on the MPU6500

So I have altered iSpindel.cpp file, line 970 bool con = accelgyro.testConnection(); has been replaced with

 bool con = false;
  if (accelgyro.getDeviceID()==56)
  {
    con = true;
  }
  if (accelgyro.getDeviceID()==0x38)
  {
    con = true;
  }

This makes both MPU6050 & MPU6500 chip work perfectly. Is this something that could be uploaded into the main branch?

from ispindel.

pppedrillo avatar pppedrillo commented on July 20, 2024
2\. getDeviceID return 56 on the MPU6500

FYI 56 dec is 0x70 and thats what they said in the datasheet

from ispindel.

stale avatar stale commented on July 20, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from ispindel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.