LIS3DH Accelerometer Review

Nowadays, there are cheap devices for measuring acceleration – accelerometers. In this text I wrote about my experience with the widely used accelerometer LIS3DHTR. This is a three-axis digital 8/10/12-bit MEMS accelerometer with up to 16g overload and I2C (or SPI) control.

Theory

It must be said that all our measuring instruments actually show abstract signals. Our task, as engineers, is to correctly interpret these signals to an error acceptable to us.

Acceleration (Acceleration) is a vector physical quantity that determines the rate of change in the speed of a body, that is, the first derivative of speed with respect to time. Shows how much the velocity vector changes per unit time. From a mathematical point of view, acceleration is the derivative of speed with respect to time.

The unit of acceleration is meters per second squared [м/с^2]. In technology, acceleration is most often measured in units of g, where g is the acceleration of gravity.

Sensitivity – the ratio of the change in the output signal of the meter to the change in the measured value that causes it. Absolute sensitivity is determined by the formula S = Dy/Dx.

Dy – change(increment) day off meter signal. In our case, the decimal number is the output of the ADC.

Dx – change (increment) measurable quantities. In our case, acceleration.

Sensitivity is essentially the gain of the sensor.

Observational error – deviation of the measured value of a quantity from its true (actual) value. The unit of measurement is the same as the measured value.

Integer – expansion of the set of natural numbers obtained by adding zero and negative numbers to it

Natural number – numbers that arise naturally when counting (1, 2, 3, 4, 5, 6, 7 and so on). The sequence of all natural numbers arranged in ascending order is called a natural series

Hardware

If you admire the LIS3DHTR chip, you will notice that it is written on the case 8308 CEN 4QW JA

marking on the housing 8308 CEN 4QW JA (this is LIS3DHTR)

marking on the housing 8308 CEN 4QW JA (this is LIS3DHTR)

To a first approximation, the accelerometer can be viewed like this.

The pinout of the chip is like this

It is worth noting that input pin 7 (SA0) hardware determines the least significant digit in the I2C address of the microcircuit on the I2C bus. Thus, a maximum of two copies of the LIS3DHTR chip can be placed on one I2C bus. In my case, a voltage of 3.3V is connected to the SA0 pin. This means that the 7-bit I2C address will have the following pattern xxx_xxx1. We will clarify the remaining categories in the spec a little later.

In a second approximation, you can see a micro-electronic-mechanical MEMS system inside. Capacitors are mounted here and their capacitance changes depending on the acting acceleration force. You can also see the temperature sensor, multiplexers, amplifier, ADC, control circuit, SPI transceiver, I2C transceiver and queue. This is a very complex product, as if from another planet.

Of course, they won’t tell or show us how the accelerometer is implemented in real life, since MEMS structures are proprietary information. Here they will only dissolve the chip in acid.

Software part

On the I2C bus, the address of the microcircuit has the pattern 0b001100x. For my electronic board it turns out 0b0011001. 0b0011001=0b 001_1001=0x19.

Now we need to remember what the I2C interface is. This is a synchronous serial half-duplex, two-wire method of transmitting binary data with a common bus topology. Data is transmitted least significant bit first in big endian format.

In my case kaleidoscope of I2C addresses it turns out 0x19(base) 0x32(write) 0x33(read).

A tire scan shows exactly what you need.

The LIS3DH chip has as many as 42 eight-bit I2C registers for configuration and diagnostics. After initialization, reading the contents of the registers shows these values.

There are a lot of configuration variables. However, the main bit fields for most applications these are these configuration variables. The remaining fields of the accelerometer registers can be left at their default values, which are applied when power is applied, and samples will still appear.

Like any other digital chip, the accelerometer produces results in the form of a sequence of integers – samples. It should be noted that one sample with acceleration measurement is stored in two I2C registers at once: high and low. Moreover, the sample is aligned to the left (<--). This is what it looks like for 12 bit mode.

Therefore, the sample must be extracted correctly. After reading the sample, it must be converted from parrots to acceleration. To do this, you need to multiply the integer by the value of the intercode transition. This is how we get the overload value in units of g. For this purpose, the spec presents Look Up table No. 4.

https://docs.google.com/spreadsheets/d/1f0YGGvLOf4vWyav78WgTI6Y5A2EVZUQD4rPidkr7vhg/edit?gid=1604564175#gid=1604564175

Now I turn on the log and the measurements are poured directly into the UART CLI

So we managed to get the accelerometer working. Success.

Advantages of ASIC LIS3DHR

++There is an ID register (WHO_AM_I) that always shows the value 0x33. This way you can do an autotest test of the electronic board.

Disadvantages of ASIC LIS3DHR

–It is not clear how to measure in meters per second squared. The device provides g-scale values. The fact is that everyone has their own g. As latitude increases, g increases.

LIS3DHR accelerometer applications

1–You can make a car or bicycle headlight, which itself will turn red when the device slows down.

2–Determination of the inclination of poles for power lines. To know where to call a repair team.

3–Automatic screen orientation on mobile devices (phones, tablets), vehicle rollover sensor in telematics units.

4–With proper digital processing, you can make a pedometer.

5–I saw timer cubes that themselves understood which edge they were on and thereby counted down the required time, then made a sound.

6–A very accurate accelerometer can estimate the latitude where the change occurs.

7–If you integrate the acceleration, you get the speed. By integrating the speed we get the path. So it turns out that an inertial navigation system can be made from an accelerometer.

8–You can make a free fall sensor. For example, for automatically opening a parachute or for parking fragile reading plugs in hard drives when a LapTop falls.

Results

I managed to learn how to use the accelerometer. Configure and read measurements.

As a result of the work, I realized for the future that if the board has an accelerometer, then the direction of the X and Y, Z axes should be indicated with silk-screen printing. Otherwise, it will be problematic to debug the firmware.

I also do not recommend connecting the accelerometer via I2C. Better on SPI, the chip supports SPI. The fact is that the I2C bus tends to freeze, so much so that only a power reset helps.

I hope this text will help others understand how to work with accelerometers.

Dictionary

Acronym

Decoding

I2C

Inter-Integrated Circuit

SPI

Serial Peripheral Interface

MEMS

micro-electromechanical systems

Links

Questions

1–How to convert the g-force values ​​(g) measured by the accelerometer into meters per seconds squared, if the acceleration of free fall is different everywhere on the globe and increases with increasing latitude?

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *