MEMS accelerometers, magnetometers and orientation angles



When developing devices in which it is necessary to evaluate orientation angles, the question may arise - which MEMS sensor to choose. Sensor manufacturers provide many parameters from which we need to obtain useful information about the quality of the sensor.

To understand what kind of angle accuracy we can count on, you need to make a certain amount of effort.

TL; DR : A small script for Octave / MATLAB is described, which allows to estimate errors in calculating orientation angles from MEMS measurements of accelerometers and magnetometers. At the script input - parameters of sensors from datasheets (and / or calibration errors). The article may be useful to those who begin to use inertial sensors in their devices. A small educational program on the sensors is included. Link to github too.

We immediately accept the following conditions:

  • We want to evaluate the orientation angles of a stationary device.

    Why?
    , .
  • To estimate angles, we will use MEMS measurements of accelerometers and magnetometers.

1. Brief educational program


Orientation angles




We will understand the orientation angles of the object as the Euler angles - roll, pitch, yaw, connecting the object’s own XYZ coordinate system and the local east-north-top coordinate system (ENU - East North Up). The roll, pitch, yaw angles denote the rotation that the XYZ axes must make in order to move in the ENU axis. Accordingly, zero angles mean that the X axis of the object is facing east, the Y axis of the object is looking north, and the Z axis is up.

The rotation order of the axes is from the last angle: first on yaw (around the Z axis), then on pitch (around the Y axis), then on roll (around the X axis).

Accelerometer


This is a sensor that measures the projection of apparent acceleration onto the sensitivity axis. It seems - because it measures gravity too, even while the accelerometer is stationary. It is easiest to imagine an accelerometer as a weight on a spring; its issued measurements are proportional to the degree of tension of the spring. If the accelerometer is at rest, the spring is stretched only by gravity. If it accelerates, then there will be a sum of forces: inertia of the weight(F=ma→) and gravity (Fg=mg→)

We accept the following model of measurements of the triad of orthogonal (mutually perpendicular) accelerometers:

aXYZ=maβ‹…AXYZ+ba+na,

Where aXYZ- measured acceleration in SSC (own coordinate system) XYZ, ma- skew matrix of axes and scale factors of the accelerometer, AXYZIs the vector of true acceleration in CCK XYZ, baIs the zero displacement vector of the accelerometer, na- measurement noise.

The skew matrix of the axes and scale factors is as follows:

ma=[1+ma,1,1ma,1,2ma,1,3ma,2,11+ma,2,2ma,2,3ma,3,1ma,3,21+ma,3,3],

where the elements are located on the main diagonal (1+ma,1,1,1+ma,2,2,1+ma,3,3) Are the scale factors and their errors along the three axes of the accelerometer, and the remaining elements of the matrix are the distortions of the axes of the accelerometer.

Accelerometer selection from datasheet

MPU-9250


  • β€” Zero-G Initial Calibration Tolerance (Β±60mg X,Y, Β±80mgZ) β€” g10βˆ’3;
  • β€” Initial Tolerance (Β±3%) β€” . , 10βˆ’2;
  • β€” Cross Axis Sensitivity (Β±2%) β€” 10βˆ’2;
  • β€” Noise Power Spectral Density (300ΞΌgHz)β€” g10βˆ’6;
  • β€” Low Pass Filter Response (5βˆ’260Hz)β€” , . . ;

:

Οƒnoise=G0β‹…Ξ noise;


ADIS16488A:


  • β€” Bias Repeatability (Β±16mg) β€” g10βˆ’3;
  • β€” (Sensitivity) Repeatability (Β±0.5%) β€” ;
  • β€” Misalignment Axis to frame (Β±1∘) β€” , (, );
  • β€” Noise Density (0.063mgHzrms)β€” g;
  • β€” (3dBBandwidth)β€” , MPU-9250;


Magnetometer


A sensor that measures the projection of magnetic field induction onto the sensitivity axis. The magnetometer is characterized by distortions of hard-iron and soft-iron. Hard-iron distortion is an additive effect when a constant component is added to the measured field. The reason may be, for example, the action of a permanent magnet or a self-zero offset of the sensor. Soft-iron distortion is a multiplier effect reflecting a change in direction and / or attenuation of the magnetic induction vector. This effect can be caused by the presence of a metal object in the immediate vicinity of the magnetometer or by the sensor’s own distortions - an error in the scale factor or a distortion of its sensitivity axis.
We accept the measurement model of the triad of magnetometers:

mXYZ=Smβ‹…MXYZ+bm+nm,

Where mXYZ- magnetometer measurements in CCK XYZ, Sm- diagonal skew matrix of axes and scale factors (which describes the soft – iron effect), MXYZIs the vector of true magnetic induction in SSK, bm- displacement of the zeros of the magnetometer (describes the hard – iron effect), nm- measurement noise.
The matrix of the skew axis and scale factors of the magnetometer:

Sm=[1+Sm,1,1Sm,1,2Sm,1,3Sm,2,11+Sm,2,2Sm,2,3Sm,3,1Sm,3,21+Sm,3,3],

elements located on the main diagonal (Sm,1,1,Sm,2,2,Sm,3,3) Are the scale factors and their errors along the three axes of the magnetometer, the remaining elements of the matrix are the distortions of the axes of the magnetometer. All matrix elements also take into account the effect of soft-iron.

Choice of magnetometer parameters from a datasheet

MPU-9250


, , :

  • β€” (1ΞΌT);
  • β€” (5%);
  • β€” , , β€” (Β±2%);
  • β€” (0.6ΞΌT);

ADIS16488A


  • β€” Initial Bias Error (Β±15mgauss=1.5ΞΌT)β€” , (0.5ΞΌT);
  • β€” Initial Sensitivity Tolerance (2%);
  • β€” Misalignment Axis to axis (0.35∘)β€” , (, );
  • β€” Noise Density (0.042mgaussHz)β€” (TeslaHz);
  • β€” 260Hz;


Calculation of orientation angles


Due to the presence of gravity on the Earth, accelerometers β€œsense” the downward direction. Their measurements are used to calculate roll and pitch angles. Formulas for calculation can be found here . The third is the yaw angle (and in this case, the magnetic azimuth), can be determined due to the presence of the Earth’s magnetic field. The magnetic field induction vector is measured by magnetometers and their measurements are involved in the calculation of the yaw angle. It should be noted that in calculating the magnetic azimuth, magnetometer measurements are used, calculated in the plane. Here you can find the formula for calculating the magnetic azimuth.

roll=atan(aYaZ),

pitch=atan(βˆ’aXaY2+aZ2),

yaw=atan2(mEmN),

Where atan2- full arc tangent function, aX, aY, aZ- measurement of the accelerometer along three axes in the CCK, mE, mN- measurements of the magnetometer along the X ', Y' axes (the measurements of the magnetometers are counted in the plane).

2.





  • roll, pitch, yaw. .
    ?
    , β€” .
  • roll, pitch, yaw XYZ ENU:

    CXYZENU=|cyβ‹…cpβˆ’crβ‹…sy+srβ‹…cyβ‹…spsrβ‹…sy+crβ‹…cyβ‹…spsyβ‹…cpcrβ‹…cy+srβ‹…syβ‹…spβˆ’srβ‹…cy+crβ‹…syβ‹…spβˆ’spsrβ‹…cpcrβ‹…cp|,

    cr=cos⁑(roll), sr=sin⁑(roll), cp=cos⁑(pitch), sp=sin⁑(pitch), cy=cos⁑(yaw), sy=sin⁑(yaw).
  • :

    AXYZ=(CXYZENU)Tβ‹…|00βˆ’1|,


    |00βˆ’1|β€” , , g, (CXYZENU)Tβ€” ( ).
  • :

    aXYZ=(I+ma)β‹…AXYZ+ba+na,
  • () :

    rollβ€²=atan(aYaZ),

    pitchβ€²=atan(βˆ’aXaY2+aZ2).
  • «» , rpy2mat:

    CXYZXYZβ€²=rpy2mat([rollβ€²pitchβ€²0]T),

    roll' pitch' β€” , , β€” .
  • ENU XYZ:

    MXYZ=(CXYZENU)Tβ‹…MENU.
  • :

    mXYZ=Smβ‹…MXYZ+bm+nm.
  • «»:

    mXYZβ€²=CXYZXYZβ€²β‹…mXYZ.
  • «» c :

    yawβ€²=atan2(mYβ€²mXβ€²).
  • roll, pitch, yaw β€” roll', pitch', yaw'.

3. β€”


For the two sensors that we took as an example - ADIS16488A and MPU-9250, the marginal errors in estimating orientation angles were obtained under the combined influence of the errors of the accelerometer and magnetometer.

The table below shows the maximum values ​​of errors received:
AngleMPU-9250ADIS16488A
Roll

30∘

8∘
Pitch

10∘

2∘
Magnetic azimuth

30∘

20∘

The combined effect of the errors of the accelerometer and magnetometer on the errors of estimation of orientation angles:

  • This is how roll estimation errors look like depending on roll and pitch values:

  • Pitch estimation errors depending on roll and pitch values:

  • Errors in estimating magnetic azimuth from roll and pitch angles:

  • Errors of estimation of magnetic azimuth from roll angles and magnetic azimuth:

  • Errors in estimating magnetic azimuth from pitch angles and magnetic azimuth:


- . ?
.



Z (z1β†’z2) , (gβ€²β†’g"). ( ). (Ξ”1β†’Ξ”2). , .

( ) :









( ) :









  • , . . .
  • . .

- :
  • ( ).
  • , , .. β€” .



Authors


Moscow Power Engineering Institute, Department of Radio Engineering Systems

All Articles