cancel
Showing results for 
Search instead for 
Did you mean: 

Linux Driver support for LSM6DSM module.

AKuma.20
Associate II

Hi Team,

I am working on LSM6DSM sensor bringup in linux kernel-4.9. I am using the following imu sensor driver sources (https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/tree/linux-4.9.y-gh/drivers/iio/imu/st_lsm6dsm). The driver is loading and the sensor is getting registered. The sysfs prints some random accelerometer and gyroscope values and When I probed the Interrupt pin I didn't get any interrupt.

Is the above driver is enough to add support for accelerometer and gyroscope. ?

Could you please help me to solve this issue ?

Regards,

Ajith.

9 REPLIES 9
Eleon BORLINI
ST Employee

Hi @AKuma.12esh​ ,

Based on the linux drivers, did you configured all the device register to correctly get the data and the interrupt events?

I mean SPI/I2C, ODR, operating mode, FIFO mode (if any), as for example depicted in the app note AN4987?

1. Write CTRL1_XL = 60h // Acc = 416 Hz (High-Performance mode)
2. Write INT1_CTRL = 01h // Acc data-ready interrupt on INT1

And are you referring to a FIFO or to a mechanical event generated interrupt?

-Eleon

AKuma.20
Associate II

Hi @Eleon BORLINI (ST Employee)​ 

Thanks for your response,

My design uses I2C intereface, operating mode is accelerometer and gyroscope sensors active with independent ODR and I want to implement interrupt mechanism to get new values.

Till now I didn't modify the driver. As per my understanding the following driver (https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/tree/linux-4.9.y-gh/drivers/iio/imu/st_lsm6dsm) provides basic support for the sensor module and I need to modify the register values in the driver based on the application. Please correct me if I am wrong.

Regards,

Ajith.

Hi @Eleon BORLINI​ ​ 

Thanks for your response,

I am referring to a mechanical event generated interrupt and my design uses I2C intereface, operating mode is accelerometer and gyroscope sensors active with independent ODR.

Till now I didn't modify the driver. As per my understanding the following driver(https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/tree/linux-4.9.y-gh/drivers/iio/imu/st_lsm6dsm) provides basic support for the sensor module and I need to modify the register values in the driver based on the application. Please correct me if I am wrong.

Regards,

Ajith.

Hi Ajith @AKuma.12esh​ ,

yes the drivers have not to be modified, but you have to configure the register for the data acquisition.

You can check this article if it can be of some support for the Linux project implementation.

-Eleon

Hi @Eleon BORLINI (ST Employee)​ 

Thanks for your response,

I understood the application of interrupt pin (INT1) and If I write INT1_CTRL = 01h I am getting the interrupt pin going high.

I am facing another issue, The accelerometer updates the values in a particular time intervals. If I move the board the accelerometer doesn't update the new values immediately after some time interval only it updates the values. And Even If don't move the board also I am getting new values after that time period.

In which mode accelerometer updates the new values only if it gets movement ?

Can you share the procedure/example for the mechanical event generated interrupt mode ?

Regards,

Ajith.

Hi Ajith @AKuma.12esh​ ,

>> The accelerometer updates the values in a particular time intervals. If I move the board the accelerometer doesn't update the new values immediately after some time interval only it updates the values.

If I well understand... Are you referring to the fact that the accelerometer dataout updates in different times or to the interrupt notification? In the first case, you have to check (or set) the device ODR (the CTRL1_XL reg or CTRL2_G values), and you can also check the dataready signal interrupt that can be driven to the INT1 pin by setting the INT1_DRDY_XL bit of the INT1_CTRL register to 1. In the second case, I think it is normal, in the sense that you can get a mechanical interrupt after different interrupt intervals, depending on when you cross the predefined threshold.

>> Can you share the procedure/example for the mechanical event generated interrupt mode?

You may check the application note AN4987 at Chapter 5, Interrupt generation paragraph.

-Eleon

Hello Eleon BORLIN,

In the post you shared

xval=`echo "scale=2;$xraw*$rscale*$factor" | bc`

Why the raw value is being multipled with scale and factor?cant we do it by simply multiplying the raw value with the sensitivity at a given full scale?

Also the accelermeter values : Accelerometer value: [ 1.62, -255.53, -17.43 ] are little Odd to me. each axis max and min value should lie between +-9.8 g

What is the unit here?

similiarly this calculation : accel_y = int(yraw * rscale * 256.0 / 9.81) . How this is arrived?

Br,

Hi @darla14​ , @AKuma.12esh​ ,

I agree with you there is something wrong there in the data conversion, or at least unclear, making the conversion depending on the value of scale value... For this reason, to simplify the question I suggest you to refer to these conversion code lines (lsm6dsm_reg.c:(

  • accelerometer
float_t lsm6dsm_from_fs2g_to_mg(int16_t lsb)
{
  return ((float_t)lsb * 0.061f);
}
  • gyroscope
float_t lsm6dsm_from_fs125dps_to_mdps(int16_t lsb)
{
  return ((float_t)lsb * 4.375f);
}

-Eleon

Hi @Eleon BORLINI​ 

>> If I well understand... Are you referring to the fact that the accelerometer dataout updates in different times or to the interrupt notification?<<

I am referring that the accelerometer dataout updates in different times. If I increase the sampling frequency rate the accelerometer dataout updates quickly.

If I use trigger mode data capture using the following commands I am getting some improved data output with Interrupt.

iio_generic_buffer -a --device-num 2 --trigger-name trigger0 -c 3

sys/bus/iio/devices/iio:device2 lsm6dsm_accel-trigger

8.019180 -0.484380 9.542884 500271098652 

7.168226 -0.693082 9.610458 500347337698 

3.724344 -0.191360 9.798828 500424233057

Is there any application available to simulate the sensor outputs in GUI ?

Regards,

Ajith.