LSM9DS1-9 Degrees of Freedom IMU

Buy LSM9DS1SchematicsDatasheetLSM9DS1 LibraryLSM9DS1 Demo Code

The LSM9DS1 chip is a motion-sensing system that implements three functionalities: a three-axis-accelerometer, a three-axis gyroscope, and a three-axis magnetometer.

https://cdn.sparkfun.com//assets/parts/1/0/5/3/3/13284-02.jpg

  • Accelerometer: Accelerometers are devices that measure acceleration, which is the rate of change of the velocity of an object.
  • Gyroscope: are devices that measure or maintain rotational motion. The units of angular velocity are measured in degrees per second (°/s) or revolutions per second (RPS). Angular velocity is simply a measurement of speed of rotation.
  • Magnetometer: Magnetometers measures the general magnetization of magnetic materials like a ferromagnet. Magnetometers also measures the strength and direction of the magnetic field at the point in space.

Wiring LSM9DS1 for Demo

The LSM9DS1 chip supports both SPI and I2C, for this demo, in this demo we will be using I2C. https://developer.mbed.org/media/uploads/lovissahuigita/demo.jpg

LSM9DS1MBED
VDDVOUT
GNDGND
SDAsda
SCLscl

LSM9DS1 Demo Code

This demo code shows how to hook the micro controller with the IMU LSM9DS1 chip, set up the IMU chip, and then read values from the chip. The code reads the accelerometer value, gyroscope value, and the magnetometer value. Then, it prints those values through the serial com port. The documentations for these codes are available at the LSM9DS1 API Documentation.

LSM9DS1 Demo main.cpp

// LSM9DS91 Demo
 
#include "mbed.h"
#include "LSM9DS1.h"
 
// refresh time. set to 500 for part 2 and 50 for part 4
#define REFRESH_TIME_MS 1000
 
// Verify that the pin assignments below match your breadboard
LSM9DS1 imu(p9, p10);
 
Serial pc(USBTX, USBRX);
 
//Init Serial port and LSM9DS1 chip
void setup()
{
    // Use the begin() function to initialize the LSM9DS0 library.
    // You can either call it with no parameters (the easy way):
    uint16_t status = imu.begin();
 
    //Make sure communication is working
    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
    pc.printf("Should be 0x683D\r\n");
}
 
int main()
{
    setup();  //Setup sensor and Serial
    pc.printf("------ LSM9DS1 Demo -----------\r\n");
 
    while (true)
    {
        
        imu.readAccel();
    
        pc.printf("A: %2f, %2f, %2f\r\n", imu.ax, imu.ay, imu.az);
 
        imu.readGyro();
        
        pc.printf("G: %2f, %2f, %2f\r\n", imu.gx, imu.gy, imu.gz);
 
        imu.readMag();
        
        pc.printf("M: %2f, %2f, %2f\r\n\r\n", imu.mx, imu.my, imu.mz);
       
        wait_ms(REFRESH_TIME_MS);
    }
}

LSM9DS1 Demo Video


Please log in to post comments.