This library is included in the Arc32 core. This core can be installed through the Arduino IDEs , where the package is named "Intel Curie Boards".
The Curie IMU library enables an Arduino or Genuino 101 to read the output of the on-board IMU (Inertial Measurement Unit) containing an accelerometer and a gyroscope and elaborate the raw data coming from it.
To use this library:
1#include <CurieIMU.h>
begin()
Initializes the Arduino and Genuino 101 IMU. begin() needs to be called before any other CurieIMU library function.
1CurieIMU.begin()
none
getGyroRate()
Return the gyro data rate, that is the frequency at which the gyroscope is read.
1CurieIMU.getGyroRate()
The gyro data rate expressed in Hz. Allowed values are:
25, 50, 100, 200, 400, 800, 1600, 3200
setGyroRate()
Defines the output data rate of the gyroscope. The data rate is also the sampling frequency and affects the bandwidth of the readings.
1CurieIMU.setGyroRate(int rate)
rate: the rate to be set It can assume one of the following values:
25, 50, 100, 200, 400, 800, 1600, 3200
setGyroRange()
Sets the gyro angular measurement range.
1CurieIMU.setGyroRange()
range: the range to be set.
Allowed values are:
getAccelerometerRate()
Return the accelerometer data rate, that is the frequency - expressed in Hz - at which the accelerometer is read.
1CurieIMU.getAccelerometerRate()
The accelerometer rate in Hz. Values returned are:
setAccelerometerRate()
Defines the output data rate of the accelerometer. The data rate is also the sampling frequency and affects the bandwidth of the readings.
1CurieIMU.setAccelerometerRate(float rate)
rate: the rate to be set in Hz. Allowed values are:
12.5, 25, 50, 100, 200, 400, 800, 1600
getGyroRange()
Returns the gyro angular measurement range.
1CurieIMU.getGyroRange()
The gyro angular range. Returned values are:
2000 (+/-2000°/s), 1000 (+/-1000°/s), 500 (+/-500°/s), 250 (+/-250°/s), 125 (+/-125°/s)
getAccelerometerRange()
Returns the accelerometer range.
1CurieIMU.getAccelerometerRange()
The accelerometer range expressed as multiples of g. Returned values are:
2 (+/- 2g), 4 (+/- 4g), 8 (+/- 8g), 16 (+/- 16g)
setAccelerometerRange()
Sets the accelerometer range as multiples of g.
1CurieIMU.setAccelerometerRange(int range)
range: the range to be set expressed as multiples of g. Allowed values are:
2 (+/- 2g), 4 (+/- 4g), 8 (+/- 8g), 16 (+/- 16g)
autoCalibrateGyroOffset()
Starts an autocalibration of the gyro's offset. During this procedure the board should stay motionless. When finished, this procedure writes the proper offset value in the IMU register that can be read with getGyroOffset.
1CurieIMU.autoCalibrateGyroOffset()
none
autoCalibrateAccelerometerOffset()
Starts an auto-calibration of the accelerometer's offset for the axis specified as argument. This procedure should be executed while the board is kept laying flat and motionless. The offset is stored in the IMU registers and can be read with getAccelerometerOffset.
1CurieIMU.autoCalibrateAccelerometerOffset(int, axis, int target)
axis: the axis to calibrate. It can assume one of these values:
1X_AXIS 2Y_AXIS3Z_AXIS
target: it can be 0 or 1. In particular it has to be used in this way:
1CurieIMU.autoCalibrateAccelerometerOffset(X_AXIS, 0);2CurieIMU.autoCalibrateAccelerometerOffset(Y_AXIS, 0);3CurieIMU.autoCalibrateAccelerometerOffset(Z_AXIS, 1);
The target for Z is 1 because it represents the vertical force of gravity (1g) that should be read when the board is laying flat.
noGyroOffset()
Disables the gyro offset.
1CurieIMU.noGyroOffset()
none
noAccelerometerOffset()
Disables the accelerometer offset.
1CurieIMU.noAccelerometerOffset()
none
gyroOffsetEnabled()
Returns the enable state of the gyro offset
1CurieIMU.gyroOffsetEnabled()
true or false if the feature is enabled or disabled
accelerometerOffsetEnabled()
Returns the enable state of the accelerometer offset
1CurieIMU.accelerometerOffsetEnabled()
true or false if the feature is enabled or disabled
getGyroOffset()
Returns the value of gyro's offset.
1CurieIMU.getGyroOffset(int axis)
axis: the target axis. Can be one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
The value of the offset for the selected axis. The returned value is from -31.25 °/s to +31.25 °/s in discrete steps of 0.061 °/s.
getAccelerometerOffset()
Returns the value of accelerometer's offset for the selected axis
1CurieIMU.getAccelerometerOffset(int axis)
axis: the axis of which we want to get the offset value. Can be one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
The value of the offset for the selected axis. The value returned varies from -495.3 mg to + 495.3 mg in discrete steps of 3.9mg.
setGyroOffset()
Sets the value of gyro offset
1CurieIMU.setGyroOffset(int axis, int offset)
axis: the target axis. Can be one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
offset: the value of the offset to be set. Valid values are from -31.25 °/s to +31.25 °/s in discrete steps of 0.061 °/s.
setAccelerometerOffset()
Sets the value of accelerometer offset
1CurieIMU.setAccelerometerOffset(int axis, int offset)
axis: the target axis. Can be one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
offset: The value of the offset for the selected axis. The value goes from -495.3 mg to + 495.3 mg independent of the range selected for the accelerometer; it varies in discrete steps of 3.9mg.
getDetectionThreshold()
Returns the value of the detection threshold
1CurieIMU.getDetectionThreshold(int feature)
feature: the requested feature. It can assume one of these values:
1CURIE_IMU_FREEFALL2CURIE_IMU_SHOCK3CURIE_IMU_MOTION4CURIE_IMU_ZERO_MOTION5CURIE_IMU_TAP
setDetectionThreshold()
Sets the value of the detection threshold.
1CurieIMU.getDetectionThreshold(int feature, float value)
feature: the requested feature. It can assume one of these values:
value: the value to be set, expressed in mg, according to the accelerometer range set, as follows:
3.91 to 1995.46 mg, in steps of 7.81 mg
2G: 3.91 to 1995.46 mg, in steps of 7.81 mg 4G: 7.81 to 3993.46 mg, in steps of 15.63 mg 8G: 15.63 to 7984.38 mg, in steps of 31.25 mg 16G: 31.25 to 15968.75 mg, in steps of 62.50 mg
2G: 0 to 997.05 mg, in steps of 3.91 mg 4G: 0 to 1991.55 mg, in steps of 7.81 mg 8G: 0 to 3985.65 mg, in steps of 15.63 mg 16G: 0 to 7968.75 mg, in steps of 31.25 mg
2G: 0 to 997.05 mg, in steps of 3.91 mg 4G: 0 to 1991.55 mg, in steps of 7.81 mg 8G: 0 to 3985.65 mg, in steps of 15.63 mg 16G: 0 to 7968.75 mg, in steps of 31.25 mg
2G: 31.25 to 7968.75 mg, in steps of 62.5 mg 4G: 62.50 to 31937.50 mg, in steps of 125.0 mg 8G: 125.0 to 63875.00 mg, in steps of 250.0 mg 16G: 250.0 to 127750.00 mg, in steps of 500 mg
The detection threshold of the chosen feature in mg. The range of the returned values is related to the Accelerometer range setting. See setDetectionThreshold for more details.
setDetectionDuration()
Sets the value of the detection duration or waiting window for the selected feature
1CurieIMU.setDetectionDuration(int feature, float value)
feature: the requested feature. It can assume one of these values:
1CURIE_IMU_FREEFALL2CURIE_IMU_SHOCK3CURIE_IMU_MOTION4CURIE_IMU_ZERO_MOTION5CURIE_IMU_DOUBLE_TAP6CURIE_IMU_TAP_SHOCK7CURIE_IMU_TAP_QUIET
value: the value to be set for each of the features. Some features allow a specific set of values as stated below:
CURIE_IMU_FREEFALL – interval of continuous 0g reading to trigger the interrupt 2.5 to 637.5 ms, in steps of 2.5 ms
CURIE_IMU_SHOCK - The duration of the shock (high-g) condition needed to trigger the interrupt; the sign of high-g must not change during the duration. 50, 75 ms
CURIE_IMU_MOTION - The number of consecutive samples where the threshold value must be exceeded to trigger the interrupt. To get the time correspondent to the samples, divide them by the sampling rate. The value calculated is in seconds. from 1 to 4
CURIE_IMU_ZERO_MOTION - The amount of time where the acceleration read on any of the three axis must stay below the trigger level to activate the interrupt. The value is stored as six bit and is used with a multiplying factor of 1.28, 5.12 or 10.24 seconds. 1.28, 2.56, 3.84, 5.12, 6.40, 7.68, 8.96, 10.24, 11.52, 12.80, 14.08, 15.36, 16.64, 17.92, 19.20, 20.48, 25.60, 30.72, 35.84, 40.96, 46.08, 51.20, 56.32, 61.44, 66.56, 71.68, 76.80, 81.92, 87.04, 92.16, 97.28, 102.40, 112.64, 122.88, 133.12, 143.36, 153.60, 163.84, 174.08, 184.32, 194.56, 204.80, 215.04, 225.28, 235.52, 245.76, 256.00, 266.24, 276.48, 286.72, 296.96, 307.20, 317.44, 327.68, 337.92, 348.16, 358.40, 368.64, 378.88, 389.12, 399.36, 409.60, 419.84, 430.08 S
CURIE_IMU_DOUBLE_TAP – waiting window for the second tap to be read 50, 100, 150, 200, 250, 275, 500, 700 ms
CURIE_IMU_TAP_SHOCK - The time a physical shocking event should happen, exceeding the set threshold, to trigger the interrupt. 50, 75 ms
CURIE_IMU_TAP_QUIET – The time the acceleration reading should stay low to separate two taps. 20, 30 ms
getDetectionDuration()
Returns the value of the detection duration.
1CurieIMU.getDetectionDuration(int feature)
feature: the requested feature. It can assume one of these values:
The detection duration of the chosen feature
interrupts()
Enables interrupt for the selected feature.
1CurieIMU.interrupts(int feature)
feature: the feature for which the interrupt has to be enabled. It can assume one of these values:
1CURIE_IMU_FREEFALL2CURIE_IMU_SHOCK3CURIE_IMU_MOTION4CURIE_IMU_ZERO_MOTION5CURIE_IMU_STEP6CURIE_IMU_TAP7CURIE_IMU_TAP_SHOCK8CURIE_IMU_TAP_QUIET9CURIE_IMU_DOUBLE_TAP
noInterrupts()
Disables interrupt for the selected feature.
1CurieIMU.noInterrupts(int feature)
feature: the feature for which the interrupt has to be disabled. It can assume one of these values:
CURIE_IMU_FREEFALL CURIE_IMU_SHOCK CURIE_IMU_MOTION CURIE_IMU_ZERO_MOTION CURIE_IMU_STEP CURIE_IMU_TAP CURIE_IMU_TAP_SHOCK CURIE_IMU_TAP_QUIET CURIE_IMU_DOUBLE_TAP CURIE_IMU_FIFO_FULL CURIE_IMU_DATA_READY
interruptEnabled()
Return true or false if the interrupt for the selected feature is enabled or not.
1CurieIMU.interruptEnabled(int feature)
feature: the feature for which the interrupt has to be enabled. It can assume one of these values:
1CURIE_IMU_FREEFALL2CURIE_IMU_SHOCK3CURIE_IMU_MOTION4CURIE_IMU_ZERO_MOTION5CURIE_IMU_STEP6CURIE_IMU_TAP7CURIE_IMU_TAP_SHOCK8CURIE_IMU_TAP_QUIET9CURIE_IMU_DOUBLE_TAP10CURIE_IMU_FIFO_FULL11CURIE_IMU_DATA_READY
true or false if the interrupt is enabled or not for the selected feature
getInterruptStatus()
Returns the status of the interrupt for the selected feature.
1CurieIMU.getInterruptStatus(int feature)
feature: the feature for which the interrupt has to be enabled. It can assume one of these values:
1CURIE_IMU_FREEFALL2CURIE_IMU_SHOCK3CURIE_IMU_MOTION4CURIE_IMU_ZERO_MOTION5CURIE_IMU_STEP6CURIE_IMU_TAP7CURIE_IMU_TAP_SHOCK8CURIE_IMU_TAP_QUIET9CURIE_IMU_DOUBLE_TAP10CURIE_IMU_FIFO_FULL11CURIE_IMU_DATA_READY
true or false if an interrupt has been triggered for the selected feature
getStepDetectionMode()
Returns the value of the step detection mode.
1CurieIMU.getStepDetectionMode()
CurieIMUStepMode: the step detection mode. It can assume one of these values:
CURIE_IMU_STEP_MODE_NORMAL CURIE_IMU_STEP_MODE_SENSITIVE CURIE_IMU_STEP_MODE_ROBUST CURIE_IMU_STEP_MODE_UNKNOWN
setStepDetectionMode()
Sets the value of the step detection mode.
1CurieIMU.setStepDetectionMode(in mode)
mode: the step detection mode. It can assume one of these values:
CURIE_IMU_STEP_MODE_NORMAL CURIE_IMU_STEP_MODE_SENSITIVE CURIE_IMU_STEP_MODE_ROBUST CURIE_IMU_STEP_MODE_UNKNOWN
readMotionSensor()
Reads the raw values of the motion sensor (accelerometer + gyro).
1CurieIMU.readMotionSensor(int ax, int ay, int az, int gx, int gy, int gz)
readAccelerometer()
Reads the raw value of the accelerometer.
1CurieIMU.readAccelerometer(int ax, int ay, int az)
To convert the raw value into mg use the following formula: float g = (gRaw/32768.0)*getAccelerometerRange() where gRaw is either ax, ay or az.
readGyro()
Reads the raw value of the gyro.
1CurieIMU.readGyro(int gx, int gy, int gz)
To convert any of the raw values in angular velocity (°/s) use the following formula:
1float av = ( avRaw/32768.9)*getGyroRange()
readTemperature()
Returns the raw value of the temperature value read by the built-in motion sensor
1CurieIMU.readTemperature()
The value of the read temperature is 16 bit signed. To convert this value you can use the following formula:
1Celsius=(raw/512.0)+23
shockDetected()
Returns true if a shock is detected.
1CurieIMU.shockDetected(int axis, int direction)
axis: the axis to check for shock detection. It must have one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
direction: the direction to check for shock detection. It must have one of these values:
POSITIVE from zero to positive axis values
NEGATIVE from zero to negative axis values
true or false if the shock is detected or not on the axis and direction specified.
motionDetected()
Returns true if a motion is detected
1CurieIMU.motionDetected(int axis, int direction)
axis: the axis to check for motion detection. It must have one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
direction: the direction to check for motion detection. It must have one of these values:
POSITIVE from zero to positive axis values NEGATIVE from zero to negative axis values
true or false if the motion is detected or not on the axis and direction specified.
tapDetected()
Returns true if a tap is detected
1CurieIMU.tapDetected(int axis, int direction)
axis: the axis to check for tap detection. It must have one of these values:
1X_AXIS2Y_AXIS3Z_AXIS
direction: the direction to check for tap detection. It must have one of these values:
POSITIVE from zero to positive axis values NEGATIVE from zero to negative axis values
True or false if the tap is detected or not on the axis and direction specified.
stepsDetected()
Returns true if a step is detected.
1CurieIMU.stepsDetected()
true or false if the step is detected or not.
attachInterrupt()
Attach an interrupt action.
1CurieIMU.attachInterrupt(voidFuncPtr callback)
callback: The name of the function to be called on interrupt event
detachInterrupt()
Removes an interrupt action.
1CurieIMU.detachInterrupt()
none