FemmeVerbeek / Arduino_LSM9DS1

LSM9DS1 Library for Arduino
Other
63 stars 14 forks source link

Using the library for internal and external LSM9DS1 #14

Open gswonk opened 3 years ago

gswonk commented 3 years ago

The BLE Sense has an internal IMU. I need an additional one at a different address. Both SparkFun and Adafruit sell an external version.

Does this library support the alternate address of an additional IMU?

FemmeVerbeek commented 3 years ago

Somebody used it on an external IMU using a classic Aduino UNO with only 5% of the memory, so yes it can be done. I don't know if he had to modify any internal register addresses.

gswonk commented 3 years ago

Thank you.

I turns out on the Arduino BLE sense there are two different I2C busses.

Glenn

On Mon, Feb 1, 2021 at 12:56 PM FemmeVerbeek notifications@github.com wrote:

Somebody used it on an external IMU using a classic Aduino UNO with only 5% of the memory, so yes it can be done. I don't know if he had to modify any internal register addresses.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-771151699, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKRQJUVTY2L3UAY4LSDS44IOPANCNFSM4VETNBFA .

FemmeVerbeek commented 3 years ago

I'm not a specialist on the I2C busses. AFAIK that communication is in the wire library.

gswonk commented 3 years ago

Correct, there are two instances on the BLE sense.

Wire and Wire1.

I do have it partially working with two LSM9DS1. I can give you the examples code when I finish it.

Glenn

On Mon, Feb 1, 2021 at 1:13 PM FemmeVerbeek notifications@github.com wrote:

I'm not a specialist on the I2C busses. AFAIK that communication is in the wire library.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-771162139, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKTTGAFU7UOWYQTQPJ3S44KRHANCNFSM4VETNBFA .

FemmeVerbeek commented 3 years ago

I'll probably never use it myself, but perhaps for others reading this.

gswonk commented 3 years ago

Femme,

Thanks for your library. I use it on the BLE Nano sense.

So can you confirm that the accel and gyro always are at the same output data rate?

I think you say that you can only utilize the accel, which is what I want to do.

So, I just need to disable or not enable the gyro.

IMU.setGyroODR(0); // switch off gyro IMU.setAccelODR(2); // 50 Hz ODR

I did confirm that there are two I2C interfaces - internal and external. Use with Wire or Wire1 - or both.

So theoretically, you can use up to three devices (one internal, two external).

thanks, glenn

On Mon, Feb 1, 2021 at 1:43 PM FemmeVerbeek notifications@github.com wrote:

I'll probably never use it myself, but perhaps for others reading this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-771179267, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKSSYSUDN6I3XAVJIODS44OAVANCNFSM4VETNBFA .

FemmeVerbeek commented 3 years ago

Hi Glenn, Correct, and yes that's how to disable the gyro. There are three operational modes 0=off , 1= Accel only , 2= Gyro +Accel, see int getOperationalMode(); When both are working they always share the same ODR.

Note that the ODR values in the documentation tables are not acurate, not good enough for navigation purposes. The library measures the actual ODR at every setting change and stores it internally, but this was not designed to serve multiple IMU's. If you need the acurate number per IMU, you must store it yourelf. You can get the values by calling getAccelODR() getGyroODR() and getMagnetODR()

Femme

gswonk commented 3 years ago

Femme,

Thank you so much.I owe you a beer.

I am working on a commercial product and am not sure based on high volume pricing which one is best. We are working on a proof of concept prototype and the LSM9DS1 was the easiest to acquire.

Do you have an opinion on which IMU is the best based on accuracy and price.

thanks,

glenn

On Sat, Feb 6, 2021 at 4:09 PM FemmeVerbeek notifications@github.com wrote:

Hi Glenn, Correct, and yes that's how to disable the gyro. There are three operational modes 0=off , 1= Accel only , 2= Gyro +Accel, see int getOperationalMode(); When both are working they always share the same ODR.

Note that the ODR values in the documentation tables are not acurate, not good enough for navigation purposes. The library measures the actual ODR at every setting change and stores it internally, but this was not designed to serve multiple IMU's. If you need the acurate number per IMU, you must store it yourelf. You can get the values by calling getAccelODR() getGyroODR() and getMagnetODR()

Femme

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-774563918, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKRZDPOYCDVQMJ6RH6TS5XK2LANCNFSM4VETNBFA .

FemmeVerbeek commented 3 years ago

No, sorry. The LSM9DS1 is a big seller. If the specs are good enough for you it is probably a good choise. The ODR is a bit disappointing. The makers promised 952Hz, but in reality it is closer to 500Hz. They say you need 2000 for drone flight orientation.

gswonk commented 3 years ago

Ok, thanks.

I only need 10/second and does not work with the default code.

I know your code works because I blink the LED and it works as stated.

thanks,

glenn

On Sat, Feb 6, 2021 at 4:27 PM FemmeVerbeek notifications@github.com wrote:

No, sorry. The LSM9DS1 is a big seller. If the specs are good enough for you it is probably a good choise. The ODR is a bit disappointing. The makers promised 952Hz, but in reality it is closer to 500Hz. They say you need 2000 for drone flight orientation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-774565715, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKQUSRX4D3UIJT73CELS5XM5ZANCNFSM4VETNBFA .

gswonk commented 3 years ago

Femme,

I was able to get the external LSM9DS1 to work on the NANO33BLE.

Unfortunately, I had to modify the code to force the use of Wire, not Wire1.

I tried declaring IMUexternal separately, but it didn't work.

See the code below.

thanks,

glenn

ifdef ARDUINO_ARDUINO_NANO33BLE

///LSM9DS1Class IMU(Wire1); LSM9DS1Class IMU(Wire);

// By default on the NANO33BLE, the code uses the internal I2C bus. // If needed, also enable using the LSM9DS1 on the external I2C bus. LSM9DS1Class IMUexternal(Wire);

else

LSM9DS1Class IMU(Wire);

endif

On Sat, Feb 6, 2021 at 4:36 PM glenn swonk glenn@swonk.com wrote:

Ok, thanks.

I only need 10/second and does not work with the default code.

I know your code works because I blink the LED and it works as stated.

thanks,

glenn

On Sat, Feb 6, 2021 at 4:27 PM FemmeVerbeek notifications@github.com wrote:

No, sorry. The LSM9DS1 is a big seller. If the specs are good enough for you it is probably a good choise. The ODR is a bit disappointing. The makers promised 952Hz, but in reality it is closer to 500Hz. They say you need 2000 for drone flight orientation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-774565715, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKQUSRX4D3UIJT73CELS5XM5ZANCNFSM4VETNBFA .

FemmeVerbeek commented 3 years ago

It does not make sense to me. The declaration you refer to is in the private section, so IMUexternal should not be visible outside the library. Didn't you forget to init the new Object? The idea of OOP is that you reuse code, not rewrite it. The library predeclares and inits one object of the LSM9DS1Class called IMU.

If you want to use a second chip you should declare it yourself in your sketch.
e.g.

ifndef ARDUINO_ARDUINO_NANO33BLE

LSM9DS1Class IMUexternal(Wire); IMUexternal.begin(); // don't forget to init your object. ... ...

endif

That should give you two objects IMU which was already predeclared connected to Wire1 IMUexternal connected to Wire

gswonk commented 3 years ago

Femme,

Yes I agree. I just needed a quick fix to keep moving forward on my project.

I will do as suggested and update you when it is working.

I will also provide you with some working code for pitch and roll processing based on the IMU acceleration.

thanks,

glenn

On Sun, Feb 7, 2021 at 2:07 PM FemmeVerbeek notifications@github.com wrote:

It does not make sense to me. The declaration you refer to is in the private section, so IMUexternal should not be visible outside the library. Didn't you forget to init the new Object? The idea of OOP is that you reuse code, not rewrite it. The library predeclares and inits one object of the LSM9DS1Class called IMU.

If you want to use a second chip you should declare it yourself in your sketch. e.g.

ifndef ARDUINO_ARDUINO_NANO33BLE

LSM9DS1Class IMUexternal(Wire); IMUexternal.begin(); // don't forget to init your object. ... ...

endif

That should give you two objects IMU which was already predeclared connected to Wire1 IMUexternal connected to Wire

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FemmeVerbeek/Arduino_LSM9DS1/issues/14#issuecomment-774776578, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBXCKQGOMUOIACWGSRC3PTS54FKFANCNFSM4VETNBFA .