Electronics components, Integrated circuits, Microcontrollers, Projects, Tutorial

Accelerometer: how does it work and how to use it?

The accelerometer is present in every smartphone, tablet, and portable videogames. In this post, are shown the operation and how to use a module with Arduino.

How does the accelerometer work?

It’s a MEMS (Microelectromechanical system), to learn more about this system, click on the links below.

What are MEMS?Click here

MEMS manufacturingClick here

Inside the chip, there’s a mobile mass attached to micrometric springs, and the mass’s motion is converted to electric signals. Can detect inclination angle and static or dynamic accelerations. Static acceleration produces produce a constant force on the body, like gravity. While dynamic acceleration isn’t uniform, for example, vibrations and motion change.

Capacitive accelerometer

In this type, the mobile mass has conductive tips that form a capacitance with stationary tips. When there’s an acceleration, the mobile part moves, and C1 and C2 capacitances change value.

capacitive accelerometer
(a) is the accelerometer diagram, showing the mobile mass in green, the folded beam that serves as a spring, and the fixed plates. (b) is the microstructure. Source: (Zhou et al., 2017).

Piezoelectric accelerometer

When mechanical pressure is exerted on a piezoelectric material, the latter produces a potential difference.

piezoelectric material
When a force F is applied over the piezoelectric material, the crystalline structure is deformed. Atoms with different electronegativities are moved, causing polarization and forming an electric dipole. Consequently, many dipoles are formed in series and parallel, creating a resulting potential difference. Source: All about circuits.

The piezoelectric effect is reversible. A direct current can stretch or compress the material, depending on the direction. While the alternate current makes the material vibrate. The most used piezoelectric materials are quartz and PZT (lead zirconate titanate).

pzt structure
PZT crystalline structure, each sphere represents an atom. On the right, structure deformation when it receives a mechanical strain. Source: cts.

In the piezoelectric accelerometer, the motion of the mass attached to a spring exerts pressure on a piezoelectric disk and it transmits electric signals to be processed for measurement.

Piezoresistive accelerometer

Proof mass’s motion exerts force over a piezoresistive material, the latter changes electrical resistance that is measured by a strain gauge. It’s an instrument with a Wheatstone bridge that measures material’s deformation.

piezoresistive accelerometer
A 3D image of a piezoresistive accelerometer with 8 piezoresistors, 2 in each flexure. Source: (Dutta, 2011).

Other types of accelerometers will be subject to another post.

Where else are accelerometers used?

  • The accelerometers are used in notebooks to protect HD data from falls. When a fall is detected, the notebook shut down the hard drive to not damage data reading.
  • It’s a very important component in rockets and missiles, to measure the variation of speed and help with inertial navigation.
  • A drone needs an accelerometer for flight stabilization.
  • Airbag systems on automobiles have an accelerometer to detect a collision and activate the airbag.
  • Rotative machines use accelerometers to detect vibrations.

The accelerometer shield ADXL345

ADXL345 accelerometer
This is the module used with Arduino on this post’s project. The 14 pins chip is the accelerometer and another with 4 terminals is a voltage regulator.

ADXL345 is a 3-axis capacitive accelerometer with 13 bits resolution and low power. Can measure between ±2g and ±16g. g is the Earth’s gravity acceleration, whose value is 9,81 m/s², and detects changes in inclination angle lower than 1º. This chip was manufactured by Analog Devices.

accelerometer block diagram
This is the chip’s block diagram. Every accelerometer chip must have an analog-digital converter (ADC) to convert sensor’s electric signals into digital signals, that must pass through a filter, to go to control and interrupt logic. FIFO is a memory management technology to minimize processing and power consumption. Source: Analog Devices.

More information about the chip is in the datasheet.

Example of a demonstration project

The ADXL345 is connected to an Arduino Uno board with an I²C internet protocol. This will be subject to another post.

accelerometer connected to Arduino
You must connect the 5V and GND Arduino terminals to the module’s terminals with the same name.
Arduino-SCL-SDA-1
The shield terminal’s SDA and SCL must be connected to Arduino’s SDA and SCL respectively.

To simplify the code, download two libraries shown in the video.

In the program below, the first 3 lines are libraries that must be included. The Wire.h serves to make I²C communication.

#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <Wire.h>

Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();  //initializes //the library with accel variable.

void setup() {
  Serial.begin(9600);  
   if(!accel.begin())
   {
      Serial.println("No ADXL345 sensor detected.");//This message appears //when the sensor isn't connected to SCL and SDA.
      while(1);
   }
}
void loop() {
   sensors_event_t event;//The event variable uses the structure //sensors_event_t.
   accel.getEvent(&amp;event);//Function that collect accelerometer data.
   Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  ");//Printing measures.
   Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  ");
   Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");
   Serial.println("m/s^2 ");
   delay(500);
}
measures accelerometer
The serial screen must be like this.

It’s possible to use this accelerometer only with Wire.h library. However, it would have to use the registrators’ addresses, which need to be explained in a dedicated post.

Liked it? Take a second to support Electrical e-Library on Patreon!

About Pedro Ney Stroski

Leave a Reply

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