Understanding the LSM6DS3 measurement data
Static measurements
Before trying to understand movement we simply read out accelerometer and gyroscope data over a certain period of time. I used 1s for the measurements.
First we simply lay down the magic wand flat onto the table and measure. Here are the results:
| gyroscope |
gyroscope corrected |
|
|
Since there is no movement, we expect the gyroscope values to be all zero. It can be seen, that there is a small offset error in the measurements. I take the average of all gyroscope values and subtract the offset from the measured values, which gives us the plot on the right.
Now the accelerometer measurements:
| Accelerometer horizontal |
Accelerometer vertical |
|
|
Even though the lsm6ds3 does not move, we nevertheless see an acceleration on the z-axis. This is due to the earth gravity and corresponds to 1g
When putting the magic wand vertically, which is its default orientation, then it is the (negative) y-axis, which sees gravity. We can also see that this position is slightly less stable and there are more variations in the x and z values.
The measurements tell us the lsm6ds3 orientation in space, shown below:
When moving down, we move in negative y direction, moving from left to right means moving in negative x direction and moving back means moving in negative z direction.
Linear movements
When moving linearily, the gyroscope should always measure the same values. Gravity will also constantly affect the different axis in the same way (no transfer from one axis to another) which simplifies interpretation of the data substantially.
In order to keep things simple, we first make measurements where we move the wand along the y-axis (up-down), then along the x-axis (left-right) and finally along the z-axis (back and forth). First up-down:
| Accelerometer up-down movement |
Up-down movement with gravity correction |
|
|
As expected, we see up-down acceleration. In the left plot we have unfiltered data from the accelerometer, while on the second one I try to compensate for gravity. We see that in this case the oscillation happens around zero.
Left right (movement along the x-axis) and back-forth (movement along the z-axis) is even simpler because the corresponding axis is not affected by gravity.
| Left right movement |
Left right movement gravity compensated |
|
|
| Back-forth movement |
Back-forth movement gravity compensated |
|
|
Last not least, we can try to calculate the velocity at which the lsm6ds3 is moving in space. I do this for the back and forth movement.
We observe that the oscillation amplitude of the velocity curve on the z-axis increases slowly, and that the velocities for the x and y axis slightly increase. Since the velocity is calculated by integration of the acceleration values, any small error is added at each summation step, resulting in the observed effect.
Rotation
Rotation is measured by the gyroscope, which measures the speed of rotation around any of the new axis. Here is a gyroscope measurement when rotating arounc the x-axis:
To calculate an angle we must therefore integrate the gyroscope values. The gyroscope output data rate is programmed to 104 Hz, which means the the time between measurements is ~ 10 ms. dt in the integration is therefore 1/104 s. The orientation of the IMU during the roation is shown here:
When looking at the accelerometer data during rotation we see changes in y and z, while the acceleration in x direction is virtually zero.
--
Uli Raich - 2026-01-03
Comments