echo '' ;

Embedded Sensor – ADXL345

This article is a continuation of the series on “Embedded Sensor – ADXL345” and carries the discussion on Size, Functional Diagram, Pin Configuration, Application, Features and Benefits, ADXL345 Interface accelerometer, and Projects with this accelerometer. This sensor from Analog Devices

Digital output data is formatted as 16-bit twos complement and is accessible through either an SPI (3- or 4-wire) or I2C digital interface.

The ADXL345 is well-suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0°.

Several special sensing functions are provided. Activity and inactivity sensing detect the presence or lack of motion by comparing the acceleration on any axis with user-set thresholds. Tap sensing detects single and double taps in any direction. Free-fall sensing detects if the device is falling. These functions can be mapped individually to either of two interrupt output pins. An integrated memory management system with a 32-level first in, first out (FIFO) buffer can be used to store data to minimize host processor activity and lower overall system power consumption.

Low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation.

Features and Benefits

  • Ultralow power: as low as 23 μA in measurement mode and 0.1 μA in standby mode at VS = 2.5 V (typical)
  • Power consumption scales automatically with bandwidth
  • 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16g.
  • Embedded memory management system with FIFO technology minimizes host processor load
  • Single tap/double tap detection
  • Activity/inactivity monitoring
  • Free-fall detection
  • Supply voltage range: 2.0 V to 3.6 V
  • I/O voltage range: 1.7 V to VS
  • SPI (3- and 4-wire) and I2C digital interfaces
  • Flexible interrupt modes mappable to either interrupt pin
  • Measurement ranges selectable via serial command
  • Bandwidth selectable via serial command
  • Wide temperature range (−40°C to +85°C)
  • 10,000 g shock survival
  • Pb free/RoHS compliant
  • Small and thin: 3 mm × 5 mm × 1 mm LGA package

Functional Block Diagram of ADXL345

ADXL345 Functional Block Diagram

Size

ADXL345 IC
  • It’s very thin and Small in size
  • 3 mm × 5 mm × 1 mm
  • 14-lead, plastic package.

Pin Configuration

ADXL345 Pin Configuration

Application

  • Handsets
  • Medical instrumentation
  • Gaming and pointing devices
  • Industrial Instrumentation
  • Personal navigation devices
  • Hard disk drive (HDD) protection

Single Tap and Double Tap Feature and Configuration

ADXL345 has an inbuilt single-tap and double-tap detection feature. We already have experience with electronic gadgets mostly

  • Mobile Phone: Double tap to wake up my screen.
  • Smart Watches: Single tap to wake up my screen.

So, we can create many use cases by using these features.

To enable this feature, Need to configure the ADXL345 first. Then enable the Single tap and double-tap interrupt.

Configure the ADXL345

  • Set Threshold
  • Set Duration
  • Set Latency
  • Set Window

Set Threshold

The THRESH_TAP (0x1D) register is eight bits and holds the threshold value for tap interrupts.  We need to set the value 0 to 255 based on our needs. The scale factor is 62.5 mg/LSB which means, each value increments by 1 in this register, adds 62.5mg. For example, If you set this register to 10, the threshold value is 625mg. If you set 255 (0xFF), then the threshold value is 16g.

The magnitude of the tap event is compared with the value in THRESH_TAP for normal tap detection.

In this example, we are going to set the threshold as 16g. So, the value has to be 255. This means that you need at least 16g acceleration in X, Y, and Z-AXIS for the tap to qualify as TAP.

  • Example: AEW_I2C_Write( 0x1D, 255);

Set Duration

The DUR (0x21) register is eight bits and contains an unsigned time value representing the maximum time that an event must be above the THRESH_TAP threshold to qualify as a tap event. The scale factor is 625 µs/LSB. A value of 0 disables the single-tap/double-tap functions.

In this example, we are going to set the threshold as 150ms. So, the value has to be 240. (240 * 625µs = 150ms).

  • Example: AEW_I2C_Write( 0x21, 240);

Set Latency

The LATENT (0x22) register is eight bits and contains an unsigned time value representing the wait time from the detection of a tap event to the start of the time window (defined by the window register) during which a possible second tap event can be detected. The scale factor is 1.25 ms/LSB. A value of 0 disables the double-tap function.

In this example, we are going to set the threshold as 175ms. So, the value has to be 140. (140 * 1.25ms = 175ms).

  • Example: AEW_I2C_Write( 0x22, 140);

Set Window

The WINDOW (0x23) register is eight bits and contains an unsigned time value representing the amount of time after the expiration of the latency time (determined by the latent register) during which a second valid tap can begin. The scale factor is 1.25 ms/LSB. A value of 0 disables the double-tap function.

In this example, we are going to set the threshold as 318ms. So, the value has to be 255. (255 * 1.25ms = 318ms).

  • Example: AEW_I2C_Write( 0x23, 255);

Enable the Single tap and Double-tap

Till now, we have configured the ADXL345 Tap parameters. Now let’s enable the tap feature.

  • Enable Tap functionality in X, Y, Z-axis
  • Enable the Tap interrupts

Enable Tap functionality in X, Y, Z-axis

The TAP_AXES (0x2A) register is defined like below.

Where,

Suppress Bit – Setting the suppress bit, suppresses double-tap detection if acceleration greater than the value in THRESH_TAP is present between taps.

TAP_x Enable Bits – A setting of 1 in the TAP_X enableTAP_Y enable, or TAP_Z enable bit enables x-, y-, or z-axis participation in tap detection. A setting of 0 excludes the selected axis from participation in tap detection.

In this example, we are going to enable tap detection in all the X, Y, Z-axis. So, we are setting it to 0x07.

  • Example: AEW_I2C_Write( 0x2A, 0x07);

Enable the Tap interrupts

We are at the last step. We have enabled everything. Finally, we have to enable the Tap interrupts. To do that, we have to use the INT_ENABLE (0x2E) register.

Setting bits in this register to a value of 1 enables their respective functions to generate interrupts, whereas a value of 0 prevents the functions from generating interrupts.

In this example, we are interested in  SINGLE_TAP and DOUBLE_TAP. So, write 0x60 to this register.

  • Example: AEW_I2C_Write( 0x2E, 0x60);
GPIO Interrupt

Note: If you enable the interrupt in INT_ENABLE (0x2E) the register, that won’t toggle you the INT1 or INT2 pin. If you want the pin to toggle, then you have to use the INT_MAP (0x2F) register. That register is defined like below.

Any bits set to 0 in this register send their respective interrupts to the INT1 pin, whereas bits set to 1 send their respective interrupts to the INT2 pin. All selected interrupts for a given pin are OR’ed.

Read the single tap and double tap interrupts

In this example, we are not going to use the GPIO interrupt (INT1 or INT2 pin). Instead, we are going to read the INT_SOURCE (0x30) register. That register defined like below.

Bits set to 1 in this register indicate that their respective functions have triggered an event, whereas a value of 0 indicates that the corresponding event has not occurred. The DATA_READYwatermark, and overrun bits are always set if the corresponding events occur, regardless of the INT_ENABLE register settings, and are cleared by reading data from the DATAXDATAY, and DATAZ registers. The DATA_READY and watermark bits may require multiple reads. Other bits, and the corresponding interrupts, are cleared by reading the INT_SOURCE register.

In this example, we are going to read this register and check whether the 5th bit or 6th bit is set or not.

Example
//Read the interrupt source
ret = AEW_I2C_Read( 0x30, &intr, 1 );

if( intr & DT_INTERRUPT )
{
  printf("Double Tap Detected!!!\r\n");
}
else if( intr & ST_INTERRUPT )
{
  printf("Single Tap Detected!!!\r\n");
}

That’s all. We have enough food on our plates. Let’s start eating it.

We are just reusing the previous application code and adding the single-tap and double-tap functionalities.

ADXL345 Boards

This section will discuss ASXL345 board types. In the Market Various types of boards are available based on This IC.

Generic Board-1: ADXL345 Tripple Axis Accelerometer Board

  • Supply Voltage: 3.3 V/ 5V.
  • Interface Type: I²C, SPI.
  • Sensing Range: ±2g, ±4g, ±8g, ±16g.
  • Sensitivity:
    • X: 28.6 LSB/g.
    • Y: 31.2 LSB/g.
    • Z: 34.5 LSB/g.
  • Ultra Low Power: 40µA in measurement mode, 0.1µA in standby@ 2.5V.
  • Free-Fall Detection.
  • Tap/Double Tap Detection.
  • ₹ 117.00

This you can buy from any online website.

ADXL345 Generic Board
  • Digital Output: SPI / I2C
  • Low Power Consumption
  • Compact Accelemotor / inclinometer
  • 5V/3.3V input support.
  • PCB Board Size: 28mm x 14 mm
  • ideal for noisy power environment

Generic Board-2: ADXL345 Board

  •  Supports 5V/3.3V input
  • Onboard RT9161 faster load at the appropriate speed
  • Ideal for a noisy power environment
  • Application: DIY project.

This you can buy from any online website.

ADXL345 Generic Board-2
  • Pin Pitch : 2.54 mm
  • Length(mm) : 28
  • Width(mm) : 14
  • Height(mm) : 11
  • Weight(g) : 5

Adafruit: ADXL345 Digital Accelerometer

Filling out Adafruit’s accelerometer offerings, we now have the lovely digital ADXL345 from Analog Devices, a triple-axis accelerometer with digital I2C and SPI interface breakout. We added an onboard 3.3V regulator and logic-level shifting circuitry, making it a perfect choice for interfacing with any 3V or 5V microcontroller such as the Arduino.

NEXT Section

In this article we have learned about Embedded Sensor – ADXL345, Next is as follows

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading