[Introduction to accelerometer] Let's use the tap detection function

In the [Introduction to Accelerometer] series, we will explain the basic usage and application methods, focusing on analog devices' accelerometers. In this article, we will introduce how to use the "offset register" built into the ADXL345.

[Introduction to accelerometer] Click here for the series list

What is offset calibration?

What is offset?

Offset means compensation, compensation, etc. It refers to a value that represents the difference (distance, deviation, relative position) from the reference position. Devices such as sensor devices and signal processing op amps output a certain amount of error from the ideal, and this error is called offset error or offset error. The acceleration sensor itself also has an offset error, as shown in the figure below. The output level when no acceleration is applied (acceleration = 0g) is It is specified as "0g Offset".This offset error introduces an error into the acquired acceleration level, which can be a problem. Also, the offset error varies depending on the individual.
Perform event processing based on the acceleration threshold introduced earlier "Free fall/active interrupt, tap interrupt, etc., the threshold acceleration set may not be appropriate due to the effect of the offset error. Also, when using an accelerometer to determine the tilt angle, the measured tilt angle contains an error due to the offset error.Therefore, depending on the application, there are cases where calibration is performed to correct the offset error.

 

Data sheet excerpt "0g OFFSET"
Data sheet excerpt "0g OFFSET"

For reference, I measured the 0g offset of the ADXL345 at hand, and the results are as shown in the figure below. In an ideal state, the acceleration output is 0g because the X/Y axes are orthogonal to the direction of gravity, and the input acceleration for the Z axis is +1g, but it was confirmed that there was an offset error in the measured values. (In detail, in addition to the 0g offset, the sensitivity and other axis sensitivities may also have some influence).

Get Og offset value
Get Og offset value

Calibration method using offset register

The ADXL345 contains an initial offset correction register. This register writes data in 8-bit, two's complement format. Also, 1LSB represents approximately 15.6 (mg/LSB). When a correction value is written to this offset register, the acceleration value stored in the data register is "the sum of the measured acceleration and the value written in the offset register". For example, if the ADXL345 had an initial offset of +156 (mg), you can cancel the initial offset by writing -156 (mg) to the offset register. Since the ADXL345 data format is 10 bits, the resolution is 3.9 (mg). Therefore, if it is necessary to perform correction with an accuracy of 15.6 (mg) or more, it is necessary to perform correction on the processor side.

 

Let's calibrate

We will create a sample program using the "offset register" using the acceleration sensor "ADXL345" and the open hardware platform "Arduino".

 

Things to prepare

Here is what I prepared to evaluate the accelerometer this time.

 

・PC with Arduino IDE installed (Download Arduino IDE from here)

Arduino Nano compatible board 

Accelerometer ADXL345 

・Others (USB cable (for Arduino and PC connection), breadboard, wires)

 

Combine the above parts to form a circuit as shown in the figure below. Power supply to Arduino Nano is supplied by USB bus power from PC. The ADXL345 supports SPI and I2C interfaces, but this time we will use the I2C interface. It also uses the INT1 pin of the interrupt pin.

Connection diagram
Connection diagram

Program content

The flow of the program first acquires data with the ADXL345 placed horizontally on the desk. After that, write the acquired data to the offset register. After that, when new data is acquired, it is checked whether the value set in the offset register is reflected. You can download the project file created with the Arduino IDE, so if you are interested, please get it from the "Document Download" below.

 

 

operation check

Let's check the operation with the created program. As shown in the video below, it was confirmed that there was an error before offset calibration. On the other hand, when offset calibration was performed, it was confirmed that the error was corrected. This method is a simple method called single calibration (one-point correction), but if you want to perform more precise calibration, you will need to rotate the product during correction. If I have the opportunity, I would like to write an article about calibration again. Also, offset characteristics change with temperature, so in applications where temperature fluctuations are large, there may be cases where calibration is performed according to temperature changes. Analog Devices, Inc. has an accelerometer called ADXL355 with very small temperature drift. It is also possible to omit the work of offset calibration due to temperature fluctuations, so I would like to introduce it on another occasion.

Download the sample code verified this time

We provide the Arduino project file that we implemented this time. Please apply from here and give it a try.

About Accelerometer ADXL345

The ADXL345 used this time is a 3-axis digital output acceleration sensor. The main features are as follows.

・A standard accelerometer that is very easy to use with built-in ADC, operation function block, and FIFO
・Acceleration data adopts general I2C/SPI in digital serial method
・The 3-axis type sensor is a rectangular coordinate (X, Y, Z), and the acceleration acting on each axis can be obtained.
・The maximum detectable acceleration can be set in the range of 2g to 16g, and the sampling range is as wide as ~3.2kHz, so it can be applied to various applications such as impact, tilt, and motion detection.
・Flexible mode to reduce current consumption

For more information on the ADXL345, visit www.adxl345.com. data sheet Please refer to. Also, this accelerometer is very easy to use, so if you want to evaluate an accelerometer from now on, please try it on the evaluation board.

 

At the end

If you have any questions about the contents of this article, or if you have any problems with selecting or using accelerometers, please contact us from the following.



Analog Devices Manufacturer Information Top

If you want to return to Analog Devices Manufacturer Information Top, please click the button below.