Blackboard's Inertial Module

Overview of the ST LSM9DS1 0-axis inertial module

591

Communicating with the ST Micro LSM9DS1 Iertial Module.

The Blackboard has an onboard LSM9DS1 ‘iNemo’ multi-sensor package. This inertial module has an accelerometer, gyroscope, and Magnetometer, all of which have 3-axes. The iNemo module can be communicated through both SPI and I2C, but on the blackboard it is only connected via SPI.

How the iNemo module is connected to the blackboard

The iNemo module is connected through the FPGA fabric of the Blackboard’s Zynq chip. The iNemo module shares pins for its SPI and I2C functions, but the configuration used in the provided HDF only route SPI connections to the LSM9DS1. The SPI0 Data and clock lines are connected to the LSM9DS1’s corresponding pins. The iNemo’s Accelerometer/Gyroscope Slave Select pin is connected to SPI0’s CS0 pin and the iNemo’s Magnetometer Slave Select is wired to CS1. CS2 is left disconnected. Driving CS0 low will select the Acc/Gyro for SPI communication. Driving CS1 low will select the Magnetometer. Only one chip select should be driven low at a time.

Figure 1. LSM95DS1 block diagram
Figure 1. LSM95DS1 block diagram

The iNemo datasheet details how SPI transactions with the device are formatted. A brief description is provided below, but make sure you read the device’s manual as it covers everything in more detail.

Communicating with the acc/gyro over SPI

To perform a read or write to the accelerometer/gyro, at the beginning of the transfer the master must indicate whether the transaction is a read or a write, as well as send the address of the register to access. The R/W bit is the first bit sent (1 for read, 0 for write), followed by the 7 bit address, most-significant sent first. After the first byte, the master must send more bytes to receive/write data from/to registers.

In a read, the master need only send a valid address in the first byte, all other bytes can contain anything (they have no effect other than extending the length of the SPI transaction). Since the master device receives as many bytes as are written, the first received byte in the transfer can be discarded. The 2nd byte onwards will contain valid data. For a write, the master sends an address in the first byte and data to write starting at that address in the following bytes. Data received from the iNemo device during a write transaction can be ignored, but should be removed from the receive FIFO after the transaction.

Addressing

By default, during transactions containing multiple bytes (not including the address/RW byte), the address accessed will be incremented after each byte. This is true for reads and writes. For a read, data from the base address will show up in the FIFO first followed by the data from the next register. For writes, data to write to the base address is sent after the first byte, and data to go to subsequent addresses should be sent sequentially.[reword] If you do not want the address to increment during multi-byte transfers, auto-inc can be disabled (see the iNEMO data sheet for information on how).

Important Accelerometer/Gyroscope registers

Below are addresses of registers for the accerometer and gyroscope you might want to know. You’ll need to read the data sheet of the inertial module for details on the function of each register.

  • WHO_AM_I 0x0F : Acc/gyro device identification
  • CTRL_REG1_G 0x10 : Control reg 1 (Gyroscope)
  • OUT_X_G 0x18,0x19 : Gyroscope x-axis 16-bit data
  • OUT_Y_G 0x1A,0x1B : Gyroscope y-axis 16-bit data
  • OUT_Z_G 0x1C,0x1D : Gyroscope z-axis 16-bit data
  • CTRL_REG6_XL 0x20 : Control reg 6 (Accelerometer)
  • OUT_X_XL 0x28,0x29 : Accelerometer x-axis 16-bit data
  • OUT_Y_XL 0x2A,0x2B : Accelerometer y-axis 16-bit data
  • OUT_Z_XL 0x2C,0x2D : Accelerometer z-axis 16-bit data
  • OUT_TEMP_L 0x15 : Lower 15-bit of Temperature data
  • OUT_TEMP_H 0x16 : Upper 16-bit of Temperature data

The Gyroscope can be enabled by writing 0xA0 to control register 1. This enables and configures an output data rate of 476 Hz After being enabled Gyroscope X,Y, and Z data can be read. Similarly, the accelerometer can be enabled with a 0xA0 write to control register 6 which enables and sets the output data rate of the accelerometer to 467Hz.

Communicating with the Magnetometer

The magnetometer is accessed similarly to the acc/gyro over SPI, but has a 6-bit address. The extra bit in the first byte is instead used to indicate whether the address is incremented in multi-byte transactions; The first bit sent is the R/W bit (1:read, 0:write), the second sent is the auto-inc bit (1:inc, 0:no inc), the last 6 bits are the register address most significant first.

Important Magnetometer registers

  • WHO_AM_I 0x0F : Magnetometer device identification
  • CTRL_REG3_M 0x22 : Magnetometer control reg 3
  • OUT_X_L_M 0x28 : Magnm X-axis lower 8-bits of data
  • OUT_X_H_M 0x29 : Magnm X-axis upper 8-bits of data
  • OUT_Y_L_M 0x2A : Magnm Y-axis lower 8-bits of data
  • OUT_Y_H_M 0x2B : Magnm Y-axis upper 8-bits of data
  • OUT_Z_L_M 0x2C : Magnm Z-axis lower 8-bits of data
  • OUT_Z_H_M 0x2D : Magnm Z-axis upper 8-bits of data

The Magnetometer can be enabled via its Control register 3. setting the lowest 2 bits in the register enable continous conversion mode, and data can be continously read from the data registers. setting just the lowest bit configures the magnetometer for a single conversion.

Figure 2. LSM95DS1 SPI timing diagram
Figure 2. LSM95DS1 SPI timing diagram