Skip to main content
Visitor II
September 28, 2022
Question

lsm9ds1 minimal configuration

  • September 28, 2022
  • 1 reply
  • 1277 views

Hello,

I have a very simple compass application which needs to poll the magnetometer, accelerometer and gyroscope roughly every 500mS (the board itself has no interrupt lines connected to the lsm9ds1), with the option of powering down for extended periods to save battery, but I can't make head nor tail of the data sheet.

what might be a reasonable register configuration to poll and turn on and off an lsm9ds1?

right now, what I have is this to turn on:

/* gyroscope */
		write_reg(i2c_xaddr, CTRL_REG1_G, 0x78);			// 119 Hz, 2000 dps, 16 Hz BW
		write_reg(i2c_xaddr, CTRL_REG3_G, 0b10000000);		// low power mode, high pass filter disabled
 
		/* accelerometer */
		write_reg(i2c_xaddr, CTRL_REG6_XL, 0x70);			// 119 Hz, 4g
		write_reg(i2c_xaddr, 0x23, 0x02);					// Enable FIFO 
		write_reg(i2c_xaddr, 0x2E, 0xC0);					// Set continuous mode
 
		/* magnetometer */
		write_reg(i2c_maddr, CTRL_REG1_M, 0b11101100);		// Temperature compensation, OM XY ultra high performance, 5Hz, slow ODR, no self test
		write_reg(i2c_maddr, CTRL_REG2_M, 0b00000000);		// 4 gauss (this is the most sensitive; the earths magentic field is around 0.25 to 0.65 gauss)
		write_reg(i2c_maddr, CTRL_REG3_M, 0b00000000);		// low power off, power up continuous conversion
		write_reg(i2c_maddr, CTRL_REG4_M, 0b00001100);		// Z ultra high performance, LSb at lower addressd */

    This topic has been closed for replies.

    1 reply

    ST Employee
    September 30, 2022

    Hi @DCarr.1​ ,

    Your configuration looks ok, but I suggest you to check the C example on Github --> lsm9ds1_read_data_polling.c, where the configuration is the following:

     /* Enable Block Data Update */
     lsm9ds1_block_data_update_set(&dev_ctx_mag, &dev_ctx_imu,
     PROPERTY_ENABLE);
     /* Set full scale */
     lsm9ds1_xl_full_scale_set(&dev_ctx_imu, LSM9DS1_4g);
     lsm9ds1_gy_full_scale_set(&dev_ctx_imu, LSM9DS1_2000dps);
     lsm9ds1_mag_full_scale_set(&dev_ctx_mag, LSM9DS1_16Ga);
     /* Configure filtering chain - See datasheet for filtering chain details */
     /* Accelerometer filtering chain */
     lsm9ds1_xl_filter_aalias_bandwidth_set(&dev_ctx_imu, LSM9DS1_AUTO);
     lsm9ds1_xl_filter_lp_bandwidth_set(&dev_ctx_imu,
     LSM9DS1_LP_ODR_DIV_50);
     lsm9ds1_xl_filter_out_path_set(&dev_ctx_imu, LSM9DS1_LP_OUT);
     /* Gyroscope filtering chain */
     lsm9ds1_gy_filter_lp_bandwidth_set(&dev_ctx_imu,
     LSM9DS1_LP_ULTRA_LIGHT);
     lsm9ds1_gy_filter_hp_bandwidth_set(&dev_ctx_imu, LSM9DS1_HP_MEDIUM);
     lsm9ds1_gy_filter_out_path_set(&dev_ctx_imu,
     LSM9DS1_LPF1_HPF_LPF2_OUT);
     /* Set Output Data Rate / Power mode */
     lsm9ds1_imu_data_rate_set(&dev_ctx_imu, LSM9DS1_IMU_59Hz5);
     lsm9ds1_mag_data_rate_set(&dev_ctx_mag, LSM9DS1_MAG_UHP_10Hz);

    -Eleon

    DCarr.1Author
    Visitor II
    September 30, 2022

    That's brilliant, thanks a lot.

    Do you have an idea for a "lowest power consumption possible" configuration corresponding to "off" when I don't want to be taking any readings for an extended period of time?