Due to a recent small project, I came into contact with Arduino+MPU9250 to obtain acceleration, angular velocity and magnetic field data, and calculate the pitch angle, roll angle and yaw angle. Now we will sort out the searched information and reproduced codes.
Table of contents
2. Detailed explanation of wiring and communication methods
3. Data reading principles and procedures
4. Data initialization and calibration
1. IMU principle
The commonly used IMU inertial sensors are six-axis/nine-axis. The six axes include acceleration on the X, Y, and Z axes and angular velocity on the X, Y, and Z axes. Compared with the six-axis, the nine-axis increases the magnetic field intensity on the X, Y, and Z axes.
Therefore, the accelerometer, gyroscope and magnetometer are integrated in a complete nine-axis IMU .
For a detailed explanation of the principle, please refer to: https://www.youtube.com/watch?v=eqZgxR6eRjo
1. Principle of accelerometer
First, both ends of the moving mass are connected to reeds (Springs) , which are restricted to move in one direction; in addition, fixed plates ( Fixed plates) are also included ; when acceleration is applied in a specific direction , the mass block will move, and the capacitance between the plate and the mass block will change (C1, C2) . The change in capacitance will be measured and correspond to a specific acceleration value.
2. Principle of gyroscope
When the mass moves in a specific direction at a specific speed, and when an external angular rate (Angular Rate) is applied ( as shown by the green arrow ), a force will be generated according to the Coriolis effect , as shown in blue As shown by the arrow, this will produce a partial vertical displacement which, similar to an accelerometer, will cause a change in capacitance. After measurement and processing, it will correspond to a specific angular velocity.
As shown in the figure, the mass is constantly moving. When an external angular rate is generated , the green flexible part around the mass will move and produce a displacement perpendicular to the moving direction (Driving Direction) , causing capacitance. changes (orange and blue areas).
3. Principle of magnetometer
Most magnetometers currently on the market measure the earth's magnetic field based on the Hall Effect or the Magneto-resistive effect .
(1) Hall Effect
On a conductive plate , set current to flow through the conductive plate, and electrons will flow directly from one side of the plate to the other.
Next, a magnetic field is introduced nearby, which interferes with the flow of electrons and deflects them to one side of the plate. The positive charge is deflected to the other side of the plate.
This means that now placing a measuring instrument on both sides will measure a voltage value that depends on the strength and direction of the magnetic field.
(2) Magneto-resistive effect
In the case of the magnetoresistance effect, even using materials that are sensitive to magnetic fields, usually composed of iron and nickel , the resistance of the material changes when these materials are exposed to a magnetic field. The strength and direction of the magnetic field can be obtained by processing and calculating the changes in resistance.