With this tutorial you learn to set up one of the features of the IMU and manage the interrupt generated when the feature's sensing conditions are met.. Each feature can be fine tuned setting up trigger and duration values. Once set up, the IMU monitors the relevand accelerometer and gyroscope values looking for the data pattern that corresponds to the expected event. In this case we expect a shock.
image developed using Fritzing.
No additional hardware is needed to use this tutorial.
CurieIMU.h is the library that gives access to all the parameters, features and readings of the IMU chip of the 101 board. This unit contains a three axes accelerometer and a three axes gyroscope. This library is part of the 101 board core and it is loaded together with the core files for Arduino or Genuino 101. In this tutorial we set up the Shock detection feature and we enable its interrupt.
none
A shock is when the sensor reads a significative acceleration for a very short time. The thdeshold defines how big the acceleration should be to be considered relevant, while the duration that is either 50 or 75 ms. These two fixed values have been defined to spot the shock pattern in high g events. Once set up threshold and duration, the interrupt is armed and the callback function is set to eventCallback
, When the interrupt is asserted, the execution goes to the callback function where the getInterruptStatus lets you check for the various axis and orientation combinations, finding exactly on which axis and which direction the shock happened.