IMU / Gyroscope

Accelerometers measure acceleration, and a gyroscope measures angular velocity.   The three axes of gyroscope rotation are either referenced about x, y, and z, or as roll, pitch, and yaw.   When you combine the data from an accelerometer and a gyroscope, you create an inertial measurement unit (IMU).   When you add a magnetometer, then it is possible to calculate attitude and heading, or AHRS.  

A Euler angle describes the orientation in degrees around s single reference point in three dimensional space, typically in aircraft terms of roll (x), pitch (y), and yaw (z).   Normally the Euler angle is from 0 ° to 180 °


float degPerSec(float radPerSec) {
  float f = radPerSec * 180.0 / PI;
  return f;
}

 

The quality of the gyroscope has a big impact on the jitter/speed/drift.   The two basic measurements are zero offset and zero noise.   Zero offset can be compensated for by taking measurements while the device is at rest and then calibrating your device.   Zero noise can be reduced with low pass filtering.  

A magnetometer is a device that measures magnetic field, typically expressed in Tesla T or Gauss G.  

 

Tilt Angle

Pitch, roll, and yaw refer to angular motion (rotations) around the X, Y, and Z axes.   Linear motion (translations) around the X, Y, and Z axes is called surge, sway, and heave.   Yaw is derived from the triaxial magnetometer data.   The magnetometer provides the north direction, and the accelerometer gives the down direction.   Pitch and roll angles can be derived from acceleration when the accelerometer is in a static condition with the absence of linear acceleration.   The accelerometer cannot be moving!

A gyroscope only measures angular velocity and cannot be used to define any Euler angles.   The gyroscope values can be used to correct for an acceleration vector that is not down, and when the sensor is rotating or accelerating.  

Double integration of acceleration to get tilt is messy and usually doesn't work due to sensor drift and noise.   The solution is to merge data from accelerometer, gyroscope, and magnetometer to derive what is called AHRS (attitude and heading reference system).  

Adafruit has a AHRS library that will do the calculation using either the Mahony, Madgwick, or NXP alogrithms.   If your set of sensors don't match the supported list, then you can calculate the tilt angle (inclination) while the sensor is at rest using the following Arduino code based calculation:


double pitch = atan2 (accelAvg.y ,(sqrt((pow(accelAvg.x,2)) + (pow(accelAvg.z,2)))));
double roll = atan2(-accelAvg.x ,(sqrt((pow(accelAvg.y,2)) + (pow(accelAvg.z,2)))));

float Yh = (magY * cos(roll)) - (magZ * sin(roll));
float Xh = (magX * cos(pitch))+(magY * sin(roll)*sin(pitch)) + (magZ * cos(roll) * sin(pitch));
double yaw = atan2(Yh, Xh);

How to Fuse Motion Sensor Data into AHRS Orientation (Euler/Quaternions)

AHRS for Adafruit's 9-DOF, 10-DOF, LSM9DS0 Breakouts (older)

 

Zero Offset & Zero Noise Accelerometer / Gyroscope Performance

Below is a summary of the zero noise and offset performance of the following five accelerometer + gyroscope devices using the calibration and performance sketch shared here.  

AF #4438 LSM6DSOX   (AHRS)

AF #3463 FXOS8700 + FXAS21002 (AHRS)

AF #4569 ISM330DHCX + LIS3MDL (AHRS)

AF #4502 ST ISM330DHCX

AF #3886 MPU-6050

AHRS - works with Adafruit AHRS Library that will calculate heading, pitch, and roll (Euler angle) from the IMU data.   Firmware compatible products: AF #4438 LSM6DSOX,   AF #4517 LSM6DSOX + LIS3MDL,   AF #4565 LSM6DSOX + LIS3MDL,   AF #4692 LSM6DSO32,   AF #4503 LSM6DS3TR-C,   AF #4634 LSM9DS1,   AF #3387 LSM9DS1,   AF #3463 FXOS8700 + FXAS21002

AF #4692 LSM6DSO32  has same pinout & firmware as LSM6DSOX in AF #4438, AF #4517, AF #4565

AF #4097 ADXL343 has same pins/firmware as ADXL345 as See also: AF #4097, AF #4147, AF #1231

 

2022 IMU's In Stock
Product Features Connections
Adafruit LSM6DSOX + LIS3MDL 9 DOF IMU
Accelerometer ±2/±4/±8/±16 g at 1.6 Hz to 6.7 kHz update rate
Gyroscope: ±125/±250/±500/±1000/±2000 dps at 12.5 Hz to 6.7 kHz
I2C Address 0x6A or 0x6B
Gyro zero rate and noise lower than MPU6050 & LSM6DS33
3-axis magnetometer
AHRS
I2C, STEMMA QT
Adafruit 9-DOF LSM9DS1 Breakout Accelerometer range is ±2/±4/±8/±16 g
Gyroscope range is ±245/±500/±2000 dps ranges
Magnetometer range is ±4/±8/±12/±16 gauss
$$ and out of stock
AHRS
I2C, STEMMA QT
AF #4502 ST ISM330DHC 6 DOF
Accelerometer + Gyroscope
Industrial quality performance, but $$
Accel ±2/±4/±8/±16 g at 1.6 Hz to 6.7KHz
Gyro ±125/±250/±500/±1000/±2000/±4000 dps to 6.7 kHz
Offset 0.006 rad/sec.   Noise +/-0.002 rad/s technical guide
SPI, I2C, STEMMA QT
AF #4438 LSM6DSOX 6 DOF
See also LSM6DSO32 #4692 with accel to 32g
Accelerometer + Gyroscope
Accel ±2/±4/±8/±16 g at 1.6 Hz to 6.7KHz
Gyro ±125/±250/±500/±1000/±2000 dps at 12.5 Hz to 6.7 KHz
High performance & low noise
Offset 0.007 rad/sec.   Noise +/-0.003 rad/s
technical guide
(AHRS)
I2C, STEMMA QT
AF #4692 LSM6DSO32 6 DOF
Similar to the LSM6DSOX, but accel up to 32g
Accel: ±4/±8/±16/±32 g at 1.6 Hz to 6.7KHz
Accel is noisier than LSM6DSOX and ISM330DHCX
gyroscope: ±125/±250/±500/±1000/±2000 dps at 12.5 Hz to 6.7 kHz ±2000 dps
technical guide
DigiKey
SPI, I2C, STEMMA QT
AF #3886 MPU-6050 6 DOF
Accelerometer + Gyroscope
Old
Offset 0.04 rad/sec.   Noise +/-0.05 rad/s
Accl +/-2g,+/-4g,+/-8g,+/-16g
Gyro +/-250,+/-500,+/-1000,+/-2000 dps
Bandwidth filter 5,10,21,44,94,184,260 Hz
10,000 g shock tolerant
Accel output data rate 1 kHz
Gyro total RMS noise 0.05 deg/s
Gyro output data rate 8 kHz
technical guide
I2C, STEMMA QT
AF #3463 FXOS8700 + FXAS21002 9 DOF
Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002
Ideal for AHRS (attitude and heading reference system) because of it's low zero-rate level gyroscope
Accel ±2 g/±4 g/±8g
Gyro ±250/500/1000/2000°/s
Output data rates to 800 Hz
technical guide
AHRS
 

AHRS - works with Adafruit AHRS Library that will calculate heading, pitch, and roll (Euler angle) from the IMU data.  

 

 

Pre 2022
Product Features Connections
AF #4569 ISM330DHCX + LIS3MDL FeatherWing 9 DOF
Accelerometer + Gyroscope + 3-axis magnetometer
Industrial quality performance
I2C, STEMMA QT
AF #4502 ST ISM330DHC 6 DOF
Accelerometer + Gyroscope
Industrial quality performance.   Expensive
4000 dps range
Offset 0.006 rad/sec.   Noise +/-0.002 rad/s
SPI, I2C, STEMMA QT
AF #4438 LSM6DSOX 6 DOF
Accelerometer + Gyroscope
High performance & low noise
Offset 0.007 rad/sec.   Noise +/-0.003 rad/s
I2C, STEMMA QT
AF #3463 NXP FXAS21002 9 DOF
Accelerometer + Gyroscope + Magnetometer
Discontinued
Offset 0.01 rad/sec.   Noise +/-0.01 rad/s
AF #4485 LSM6DS33 + LIS3MDL
(also sold as AF #4480 LSM6DS33)
9 DOF
Accelerometer + Gyroscope + Magnetometer
Offset 0.034 rad/sec.   Noise +/-0.015 rad/s
AF #4464 ICM-20649 6 DOF
Accelerometer + Gyroscope
Wide range
Offset 0.023 rad/sec.   Noise +/-0.015 rad/s
I2C, STEMMA QT
AF #3387 LSM9DS1 9 DOF
Accelerometer + Gyroscope + Magnetometer + Temperature
Offset 0.02 rad/sec.   Noise +/-0.05 rad/s

 

Links

How to Fuse Motion Sensor Data into AHRS Orientation (Euler/Quaternions)

EEPROM Memory

Gyroscope Calibration

Magnetometer Calibration

Comparing Gyroscope Datasheets

Accelerometer, Gyro and IMU Buying Guide

Orientation estimation and movement recognition using low cost sensors

 


Do you need help developing or customizing a IoT product for your needs?   Send me an email requesting a free one hour phone / web share consultation.  

 

The information presented on this website is for the author's use only.   Use of this information by anyone other than the author is offered as guidelines and non-professional advice only.   No liability is assumed by the author or this web site.  

Sensors

Sensor Calibration

Sensitivity, Resolution, Response Time, etc.

50000 PPM (5%) CO2 Sensors

MQ Gas Sensors

MQ Gas Sensors

MQ-6 LPG Gas Sensor

MQ-6 LPG Gas Sensor

MQ-7 carbon monoxide CO Gas Sensor

MQ-7 Carbon Monoxide Gas Sensor

Sensor to microcontroller / data acquisition device cables

Accelerometers

IMU / Gyroscope

Magnetometer

Audio

Thermocouple

AF Sensirion SHT40 Temperature & Humidity Sensor

Motion Sensors

object detection sensors

Object Detection Sensors

Strain Gauge

Color

Pressure

Liquid Flow Meter

Operational Amplifiers

Components

Tools

Basic Components

Suppliers

VAC

XBee I/O Line Passing

xBee wireless communication modules with Arduino

xBee wireless communication modules + Arduino

I2C bus / SPI / 1-Wire

UART TTL Serial RS-232

LoRa Communications

Triac

Light Emitting Diode (LED)

NeoPixels

4-20 mA Current Loops

Human Health & Electrical Power

HMI

imgAlt

Mobile Apps

Hall Effect Sensor

NTC Thermistor

Amplify an Analog Signal

Offset a input signal

Electric Motors

Laptop 12V Power Supply

MCP2515 CAN Bus Module

TJA1050 CAN Bus Module

1.2" 4-Digit 7-Segment LED Display

Batteries

2022 Character Display Comparison

Logic Level Converter

Circuit Protection

Diodes

PMOS / P-Channel MOSFET

Logic Level NMOS / N-Channel MOSFET

Voltage Measurement

Analog to Digital Conversion (ADC)

Variable output VDC

Turn On/Off Noisy DC Device

ADC Analog Input