LIS3DH Accelerometer

Contents

Description

LIS3DH front view
LIS3DH bottom view

FIG 1 - LIS3DH: [Left] top view, [Right] bottom view

The LIS3DH from STMicroelectronics is described in the datasheet (P2) as an ultra-low-power high-performance three-axis linear accelerometer belonging to the "nano" family, with digital I2C/SPI serial interface standard output. The device features ulra-low-power operational modes that allow advanced power saving and smart embedded functions.

STM have provided two sources of documentation. The datasheet is quite general. For driver development it's necessary to refer to AN3308 Application Note  which provides a much more detailed discussion of the sensor than the datasheet.

This accelerometer is described as being suitable for motion activated functions, free-fall detection, click/double-click recognition, pedometers, display orientation, gaming and VR input devices, impact recognition and logging, vibration monitoring, etc.

The LIS3DH measures acceleration with a capacitive type sensor.

The values in the following table have been sourced from the product datasheet.

Parameter DIS3DH
Package and size 16-lead LGA package, footprint 3mm x 3mm x 1mm.
Operating voltage range 1.71V to 3.6V
Supply current
Normal mode (typically)
ODR:  1Hz = 2 µA
ODR:  50Hz = 11 µA
Supply current
Low-Power mode (typically)
ODR:  50Hz = 6µA
Supply current
Power-down mode (typically)
0.5µA
Zero-g level offset accuracy Typically ±40 mg
Measurement ranges ±2g, ±4g, ±8g, ±16g.
Default is ±2g.
Output resolution Low-power mode: 8-bit
Normal mode: 10-bit
High resolution: 12-bit
Sensitivity (High) 1 mg/LSB (±2g) to 12 mg/LSB (±16g)
Sensitivity (Normal) 4 mg/LSB (±2g) to 48 mg/LSB (±16g)
Sensitivity (Low) 16 mg/LSB (±2g) to 192 mg/LSB (±16g)
Output data rate (ODR) 1Hz to 400Hz for all three modes,
plus 2 x 'special' ODRs.
Serial interfaces I2C, SPI (4-wire and 3-wire).

I2C Interface

I2C and SPI (4-wire & 3-wire) are available. I2C is selected by tying the CS pin to High.

I2C supports standard (100HkHz) and fast data (400kHz) transfer modes.

There is a choice of two I2C addresses depending upon the state of the SDO pin:

  • 0x18 : SDO pin connected to GND
  • 0x19 : SDO pin connected to VDDIO i.e operating voltage.

Acceleration Sampling Options

This accelerometer has a simple range of user options unlike some of the more complicated devices available from other manufacturers.

Power Modes

  • Power-down Mode

    Very low current consumption mode (typically 0.5 µA) where data conversions are stopped but the serial interface is still available. This is the default mode after the power-up sequence has completed.
  • Low-power Mode

    Data resolution is 8-bits, left aligned and in two's complement format.

    Output data rates (ODR) is configurable in seven steps between 1Hz and 400Hz and are user selectable. These ODR's are common with Normal and High-resolution modes.

    Additionally there are two special low-power ODRs: 1.60kHz and 5.376kHz.
  • Normal Mode

    Data resolution is 10-bits, left aligned and in two's complement format.

    Output data rates (ODR) is configurable in seven steps between 1Hz and 400Hz and are user selectable. These ODR's are common with Low-power and High-resolution modes.

    There is an additional special ODR of 1.344kHz (also available in High-resolution mode).
  • High-resolution mode

    This mode appears to be an extension to Normal mode but with a higher 12-bit resolution. From Table 5 in Application Note AN3308 it's apparent there is no power usage penalty for use of this mode over 10-bit Normal mode.

    Output data rate selections are the same as for Normal mode.

Additional User Selections

  • Acceleration ranges

    Ranges available: ±2g, ±4g, ±8g, ±16g. Default is ±2g.
  • High-pass Filter

    The LIS3DH has a high-pass bandwidth filter to eliminate the DC component of the measured acceleration.

    The bandwidth of the high-pass filter depends on the selected ODR. The Application Note AN3308 has an excellent explanation for the operational use of this filter from Page 17.

Measuring Acceleration

The LIS3DH measures both static and dynamic acceleration. Acceleration is reported in units of g where 1g = 9.81 m/s2 i.e. the acceleration due Earth's gravity.

Static acceleration is that which is imparted upon the sensor by the Earth's gravitational field. If the sensor is laid horizontally on a (perfectly) flat surface and is completely motionless then the acceleration along the X-axis and Y-axis will be 0g The z-axis acceleration will be 1g

Dynamic acceleration refers to the component of acceleration resulting from the motion or changes in velocity experienced by the sensor over time.

The raw acceleration value is read from two 8-bit registers[1]. The two bytes are combined to a single binary representation with size dependant upon the resolution. This is converted from its Two's Complementary format to a signed integer.

This is then scaled by simple division with the divisor being the sensitivity (LSB/g). The sensitivity depends upon the measurement range and data resolution. The float type result is the acceleration value in units of g.

FIFO Queue

The FIFO is a queue mechanism (First In - First Out) that when activated automatically begins storing datasets of raw acceleration values. This is a common feature on most of these styles of sensor.

The FIFO stores X-axis, Y-axis and Z-axis acceleration values. Unlike some other accelerometers on the market the LIS3DH does not offer any selectivity options i.e. all three DOF values are always stored. The FIFO can hold up to a maximum of 32 complete X, Y and Z samples.

The FIFO give the microcontroller host "breathing space" to carry on with other tasks as the sensor continues to produce acceleration samples. A configurable interrupt is available that will alert the host when the FIFO is near full. At this time the entire FIFO contents can be burst read and processed.

Refer to the datasheet for further details of the FIFO. It's operation is quite simple compared to some of the LIS3DH's competitors.

Sensor Generated Interrupts

Many intelligent digital accelerometer sensors offer a set of functional interrupts. The LIS3DH is no exception.

The chip has two interrupt pins; INT1 and INT2. The sensor's interrupts can be mapped to either of these pins. Host microcontrollers can define which interrupts are assigned to these pins then monitor the pins for the assigned activities.

Interrupts available include:

  • Inertial interrupts:

    These interrupts are defined by setting upper and/or lower acceleration thresholds that if exceeded trigger the interrupt. There are two types of inertial interrupts: free-fall and wake-up that are user configurable.
  • 6D/4D Orientation detection:
    • 4D orientation detects four main positions: portrait, portrait flipped, landscape left, and landscape right.
    • 6D orientation detects all six possible positions of a device, including face-up, face-down, along with the four landscape/portrait orientations.
  • Click recognition:

    Single click and double click, both configurable by the user with several timing and latency settings available.

Temperature Sensor

The LIS3DH has an auxiliary ADC (Analog to Digital Converter) that is available for customer use through three input pins: ADC1, ADC2 and ADC3. Converted data is available through six x 8-bit registers (two for each ADC pin).

The chip has an internal temperature sensor, possibly used as part of the acceleration measurement conversion process. The user also has access to this temperature sensor by configuring a bit in the TEMP_CFG_REG  register which connects the temperature sensor to ADC3.

LIS3DH Chip ID

LIS3DH chips have a product ID value written to non-volatile memory at point of manufacture.

This value can be read from the WHO_AM_I register and should return 0x33.

LIS3DH MicroPython Driver for micro:bit

An LIS3DH MicroPython driver specifically written for the BBC micro:bit has been developed as part of this series on MicroPython for the micro:bit. The driver webpage also provides a detailed description of the driver's methods and properties with sample code.

The driver implements the base functionality (i.e. acceleration measurements [and temperature], setting output data rates, setting measurement ranges) offered by this sensor. Also included is a simple tool for measuring angles from the horizontal.

The FIFO and all interrupts (with the exception of Data Ready) are not available in this driver.