HongshiTan / RTIMULib2

9-dof, 10-dof and 11-dof IMU fusion library for Linux systems (development version)
Other
72 stars 240 forks source link

STM LSM9DS1 using SPI #5

Closed gmsanchez closed 2 years ago

gmsanchez commented 2 years ago

Hi, I am trying to use RTIMULib2 on a Raspberry Pi model 3B+ running Ubuntu 20.04 with an SPI attached LSM9DS1 IMU. After compiling and installing the library, I get this output whenever I run RTIMULibDrive:

Settings file RTIMULib.ini loaded
********************************************verison : 1.2
Using fusion algorithm RTQF
min/max compass calibration not in use
Ellipsoid compass calibration not in use
Accel calibration not in use
Incorrect LSM9DS1 accel/mag id 104

The modified parts of RTIMULib.ini are:

# #####################################################################
# 
# RTIMULib settings file

# General settings
# 

# IMU type - 
#   0 = Auto discover
#   1 = Null (used when data is provided from a remote IMU
#   2 = InvenSense MPU-9150
#   3 = STM L3GD20H + LSM303D
#   4 = STM L3GD20 + LSM303DLHC
#   5 = STM LSM9DS0
#   6 = STM LSM9DS1
#   7 = InvenSense MPU-9250
#   8 = STM L3GD20H + LSM303DLHC
#   9 = Bosch BMX055
#   10 = Bosch BNX055
#   11 = HMC5883L + ADXL345 + L3G4200D
IMUType=6

# 
# Fusion type type - 
#   0 - Null. Use if only sensor data required without fusion
#   1 - Kalman STATE4
#   2 - RTQF
FusionType=2

# 
# Is bus I2C: 'true' for I2C, 'false' for SPI
BusIsI2C=false

# 
# I2C Bus (between 0 and 7) 
I2CBus=1

# 
# SPI Bus (between 0 and 7) 
SPIBus=0

# 
# SPI select (between 0 and 1) 
SPISelect=0

# 
# SPI Speed in Hz
SPISpeed=500000

# 
# I2C slave address (filled in automatically by auto discover) 
I2CSlaveAddress=107

If the IMU is connected on the I2C bus, RTIMULib works correctly.

Using AccelGyroMag.py and modifying lsm9ds1.py on lines 34 and 35, where SPI device is 0 for Accelerometer and Gyroscope and 1 for the Magnetometer, works. So I am assuming it is not a SPI port configuration issue.

If there is some information missing just let me know and I add as needed.

Thanks in advance!

HongshiTan commented 2 years ago

Hello, sorry for such a long delay. I have referred to the official specification. and it seems a mistake on the default value of WHO_AM_I reg. I will fix it and thanks for your information.

gmsanchez commented 2 years ago

Hi

Thanks for the fix. May I ask if the LSM9DS1 is supposed to work while connected to the SPI interface? I keep getting errors while trying to use the IMU in this way.