MEMS accelerometers can output different kinds of interrupt signals such as data ready, freefall, portrait/landscape, single-click/double-click, and impact detection, etc. Some accelerometers have built-in wakeup and motionless detection features to automatically switch between lower output data rate (ODR) at low power mode and higher ODR at normal mode according to the motions. But this feature only saves the power consumption of the accelerometer, itself.
Some microprocessors have two or more GPIO pins and users can implement two accelerometer interrupt output pins for wakeup and non-motion detection at the same time. However, in some other cases microprocessors have only one GPIO pin available for the interrupt but users would like to have both functions from one interrupt pin.
In the following chapters, the method of using a high pass filter (HPF) and freefall AND logic scheme to detect wakeup motion and motionless conditions at one interrupt output pin is described. The microprocessor doesn’t need to get involved. When the microprocessor sees the accelerometer interrupt signal rising edge, it means that the non-motion condition of the device has been confirmed. When it sees the falling edge of the accelerometer interrupt signal, then it means the device is in motion.
Figure 1 shows the typical hardware connection between a host processor or a microcontroller and the accelerometer. The host processor only needs to configure the accelerometer one time when powered up through I2C or SPI interface in the initialization routine. Then, the accelerometer will monitor the motion in the background continuously at very low power consumption.
The INT1 output pin of the accelerometer is in push-pull and active high configuration by default. Users can change the configuration to open-drain or active-low for their applications. The voltage level of the INT1 pin is 0.9 * Vdd_IO minimum when high and 0.1 * Vdd_IO maximum when low. The accelerometer Vdd_IO is flexible to match the host processor digital IO voltage level Vcc_IO. If the host processor has only one power supply, then the accelerometer Vdd and Vdd_IO can be tied together to this power supply directly.
When the handheld device has entered the rest condition from motion longer than a certain amount of time, the accelerometer will send an interrupt signal from low to high rising edge on INT1 pin. The host processor can then shut down other components and go to sleep mode to save power.
Whenever there is a motion, the accelerometer will send an interrupt signal from high to low falling edge. Then, the host processor can wake up and turn on other components for normal operation.
If the handheld device remains in motion at normal operation mode, then accelerometer interrupt signal on INT1 pin keeps low. When the device is always at rest at any tilted position, then the accelerometer interrupt signal remains high all the time. Therefore, the host processor can periodically read the level of the accelerometer INT1 pin to double check if the handheld device is at rest or in motion.
Example based on LIS3DH digital accelerometer from STMicroelectronics.
// Initialize accelerometer in the host processor. It only needs to be executed one time after power up in initialization routine.
// configurations for control registers
Write 27h into CTRL_REG1; // Turn on the sensor with ODR = 10Hz normal mode.
Write 01h into CTRL_REG2; // High-pass filter (HPF) enabled with 0.2Hz cut-off frequency for INT1 (AOI1) interrupt generation only.
Write 40h into CTRL_REG3; // ACC AOI1 interrupt signal is routed to INT1 pin.
Write 88h into CTRL_REG4; // Full Scale = +/-2 g with BDU and HR bits enabled.
Write 00h into CTRL_REG5; // Default value. Interrupt signals on INT1 pin is not latched. Users don’t need to read the INT1_SRC register to clear the interrupt signal.
// configurations for wakeup and motionless detection
Write 08h into INT1_THS; // Threshold (THS) = 8LSBs * 15.625mg/LSB = 125mg.
Write 32h into INT1_DURATION; // Duration = 50LSBs * (1/10Hz) = 5s.
Write 95h into INT1_CFG; // Enable XLIE, YLIE and ZLIE interrupt generation, AND logic. It means that the interrupt will be generated when X and Y and Z axis acceleration is within the ±THS threshold simultaneously.
INT1_CFG configuration is the same as freefall event detection. The differences are (1) Freefall interrupt doesn’t need to enable the HPF; (2) Freefall duration is in milliseconds range. 5 seconds duration means the freefall distance is about 122.5 meters which rarely happens to a handheld device.
The above sample code can be illustrated as shown in Figure 2.
• When the handheld device is at rest at any tilted position for longer than 5 seconds, accelerometer INT1 pin will go high from low and stay high as long as the device is still at rest, because after HPF, X/Y/Z axes acceleration are all within ±125mg THS simultaneously.
• The freefall of the handheld device will not make the INT1 pin go high from low because the event of X/Y/Z axes acceleration within ±125mg THS simultaneously doesn’t last longer than 5 seconds.
• Whenever any axis X or Y or Z acceleration goes beyond ±125mg THS due to the motion, the INT1 pin will go low from high and stay low as long as the device is still in motion.
• If the device is at rest for the time shorter than 5 seconds duration and the motion happens again, then the INT1 pin will still stay low and the 5 seconds duration will start counting down from 50LSBs to 0LSB at 10Hz ODR once the device is at rest again.
Using the built-in HPF and freefall event detection scheme, the accelerometer is able to deliver robust interrupt signal for both wakeup and motionless to the microprocessor from its one interrupt pin. The accelerometer works in the background and doesn’t need the microprocessor to get involved. Users are free to configure the accelerometer threshold and duration to meet their applications. In terms of power saving, this solution is more effective than using the handheld device touch screen and button press and microprocessor timer to switch off the screen.
1. STMicroelectronics, Inc.
J. Esfandyari et al, “Applying the interrupt features of a MEMS accelerometer”, EETimes, December, 2011
2. STMicroelectronics, Inc.
AN3308: LIS3DH: MEMS digital output motion sensor ultra low-power high performance 3-axis “nano” accelerometer