Four-axis accelerometer filtering

Accelerometer filtering experiment parameters:

 

Sampling frequency Fs=250Hz

Cutoff Frequency

The motor is not turned on

Turn on the motor and hover

Turn the flight controller without turning on the motor

Raw output (Raw)

260 Hz

260Hz

260Hz

Inside MPU6050 (LPF)

94 Hz

94 Hz

94 Hz

2阶(Butterworth)

30 Hz

30 Hz

30 Hz

8 Depth window sliding (Window)

N/A

N/A

N/A

data analysis

4 groups of drawing comparison (A)

4 groups of drawing comparison (C)

4 groups of drawing comparison (F)

4 groups of FFT transform (B)

4 groups of FFT transform (D)

N/A

8 groups of RMSE (E)

N/A

 

illustrate:

1. All data come from MPU6050, the sampling period of the microcontroller is 4ms, that is, the sampling frequency Fs=250Hz

2. Turn on the motor to hover: tie the diagonal arms, turn on the four motors at the same time, and untie the ropes to fly the aircraft in the air without falling. Since there is no fast wireless data transmission, the actual flight hovering accelerometer output has not been tested , so the test results are only approximate for reference.

3. Raw output Raw: According to the chip manual configuration, the maximum bandwidth of the low-pass filter is 260Hz, that is, the cutoff frequency is 260Hz. Approximate as raw accelerometer output

4. MPU6050 internal LPF: According to the configuration of the chip manual, the LPF here is 94Hz, which is used to test the internal LPF performance

5. 2nd-order Butterworth: The cut-off frequency is selected as 30Hz, and the Raw is filtered

6. 8 Depth Window Sliding: The average sliding filter widely used on four axes, with a depth of 8, filters Raw

 

Test results (the following ">" means: "Better than"):

A (the motor is still not turned on):


in conclusion:

Static smoothing performance: Window sliding>Butterworth>LPF>Raw


B (the motor is still not turned on):


in conclusion:

1. From the FFT transformation results of Raw, it can be seen that the static accelerometer is similar to white noise, and its amplitude is evenly distributed on Fs/2

2. The LPF results were less than satisfactory. The cut-off frequency of LPF is 94Hz, and there should be a large amplitude drop at 94Hz, but this amplitude change is not obvious, which shows that the built-in LPF performance of MPU6050 needs to be improved

3. The effect of the 2nd-order Butterworth filter is much better. Before 30Hz, the spectrum is roughly the same as that of Raw, and then there is a large amplitude attenuation at 30Hz, indicating that the filter has played a role.

4. The window average sliding filter has an incredible phenomenon, and this amplitude attenuation is particularly regular! In view of the poor signal analysis of the author, I will not expand it here.

5. In fact, the effect can be seen from the FFT results of the window sliding filter. The simple average filtering effect does have a good effect on the spectrum, at least better than the built-in LPF effect. The effect would be better if LPF and window average sliding were applied at the same time on the four axes

 

C (power on and hover):


in conclusion:

After turning on the motor, the result is the same as the static smoothing performance: Window sliding>Butterworth>LPF>Raw


D (power on and hover):


in conclusion:

1. From the FFT transformation results of Raw, it can be seen that the accelerometer when the motor is turned on is significantly different from the result when the motor is stationary: first, the amplitude has changed significantly, from the original 200~600 to the current 10000~60000, This is due to the huge amplitude caused by the mechanical vibration after turning on the motor; the second is the frequency distribution, it can be clearly seen that there is a large amplitude distribution around 40Hz and 90Hz, indicating that most of the signal frequencies generated by mechanical vibration are distributed in these two Near the frequency range, and we do not need signals near this frequency, which means: we need to use some kind of filter, at least cut off at 40Hz or 90Hz , and the signals above this frequency will be shielded .

2. The LPF results are strange. In the low frequency stage, the amplitude of 0~40Hz is extremely small, but there is a large amplitude distribution at 100Hz, which looks like a high-pass filter rather than a low-pass filter. Although the set LPF is cut off at 94Hz, there is still a large vibration signal after 94Hz, which once again proves that the effect of the built-in LPF of the MPU6050 is not very satisfactory.

3. The 2nd-order Butterworth filter effect is much better than the LPF effect. After turning on the motor, it can be seen that the signal spectrum before 30Hz is basically the same as the Raw distribution, indicating that the real signal output is retained. After 30Hz, the amplitude of the signal is significantly attenuated, effectively filtering out the interference signal caused by the high-frequency motor vibration.

4. There is still an incredible phenomenon for the window average sliding filter. This kind of regular spectrum is really incomprehensible, but it is consistent with the original output in the low frequency band, and the vibration signal generated by the motor is also effectively suppressed in the high frequency part. So it is possible to apply this method to accelerometer filtering on four axes, at least better than the internal LPF effect.

 

E (8 groups RMSE):


This figure is very interesting, RMSE (Root-Mean-Square-Error) root mean square error, which is often used to characterize the accuracy of the estimation. The smaller the RMSE, the higher the accuracy. Since it is a static test and a motor-on-hover test, the RMSE here is used to represent the smoothness of the data.

in conclusion:

Data smoothness performance with or without the motor: Window Slide>Butterworth>LPF>Raw

 

F (motor is not turned on):


This test is used to compare the delay characteristics of Butterworth and window sliding filters

in conclusion:

Data smoothness performance indicator: Window sliding>Butterworth>Raw

 

In order to see the delay characteristics more clearly, the following figure enlarges the three output curves of the Y-axis at the 980th sampling point:


in conclusion:

Data delay performance characteristics: Raw>Butterworth>Window sliding, which means that the Butterworth filtering delay is less than 8-depth window sliding filtering.

 

Final summary:

1. Try not to use the built-in LPF filter of MPU6050. While this LPF can smooth out the output compared to the raw accelerometer output, it performs quite poorly on the FFT spectrum.

2. The widely used window average sliding filter has good performance in both FFT and RMSE performance, so it is a wise choice to use window average filter for general basic applications (low-speed motion or four-axis beginners).

3. To achieve better filtering effect, FIR or IIR filter is a better choice. The author tested the second-order 30Hz Butterworth filter, although the smoothness RMSE is only a little worse than the window average sliding (but better than the LPF), but the data real-time performance index is nearly double the response speed of the former. Therefore, in the advanced stage of making four axes, you can consider replacing the average sliding of the window with the Butterworth filter.


This article is reproduced from: http://blog.csdn.net/nemol1990/article/details/41811061


Accelerometer filtering experiment parameters:

 

Sampling frequency Fs=250Hz

Cutoff Frequency

The motor is not turned on

Turn on the motor and hover

Turn the flight controller without turning on the motor

Raw output (Raw)

260 Hz

260Hz

260Hz

Inside MPU6050 (LPF)

94 Hz

94 Hz

94 Hz

2阶(Butterworth)

30 Hz

30 Hz

30 Hz

8 Depth window sliding (Window)

N/A

N/A

N/A

data analysis

4 groups of drawing comparison (A)

4 groups of drawing comparison (C)

4 groups of drawing comparison (F)

4 groups of FFT transform (B)

4 groups of FFT transform (D)

N/A

8 groups of RMSE (E)

N/A

 

illustrate:

1. All data come from MPU6050, the sampling period of the microcontroller is 4ms, that is, the sampling frequency Fs=250Hz

2. Turn on the motor to hover: tie the diagonal arms, turn on the four motors at the same time, and untie the ropes to fly the aircraft in the air without falling. Since there is no fast wireless data transmission, the actual flight hovering accelerometer output has not been tested , so the test results are only approximate for reference.

3. Raw output Raw: According to the chip manual configuration, the maximum bandwidth of the low-pass filter is 260Hz, that is, the cutoff frequency is 260Hz. Approximate as raw accelerometer output

4. MPU6050 internal LPF: According to the configuration of the chip manual, the LPF here is 94Hz, which is used to test the internal LPF performance

5. 2nd-order Butterworth: The cut-off frequency is selected as 30Hz, and the Raw is filtered

6. 8 Depth Window Sliding: The average sliding filter widely used on four axes, with a depth of 8, filters Raw

 

Test results (the following ">" means: "Better than"):

A (the motor is still not turned on):


in conclusion:

Static smoothing performance: Window sliding>Butterworth>LPF>Raw


B (the motor is still not turned on):


in conclusion:

1. From the FFT transformation results of Raw, it can be seen that the static accelerometer is similar to white noise, and its amplitude is evenly distributed on Fs/2

2. The LPF results were less than satisfactory. The cut-off frequency of LPF is 94Hz, and there should be a large amplitude drop at 94Hz, but this amplitude change is not obvious, which shows that the built-in LPF performance of MPU6050 needs to be improved

3. The effect of the 2nd-order Butterworth filter is much better. Before 30Hz, the spectrum is roughly the same as that of Raw, and then there is a large amplitude attenuation at 30Hz, indicating that the filter has played a role.

4. The window average sliding filter has an incredible phenomenon, and this amplitude attenuation is particularly regular! In view of the poor signal analysis of the author, I will not expand it here.

5. In fact, the effect can be seen from the FFT results of the window sliding filter. The simple average filtering effect does have a good effect on the spectrum, at least better than the built-in LPF effect. The effect would be better if LPF and window average sliding were applied at the same time on the four axes

 

C (power on and hover):


in conclusion:

After turning on the motor, the result is the same as the static smoothing performance: Window sliding>Butterworth>LPF>Raw


D (power on and hover):


in conclusion:

1. From the FFT transformation results of Raw, it can be seen that the accelerometer when the motor is turned on is significantly different from the result when the motor is stationary: first, the amplitude has changed significantly, from the original 200~600 to the current 10000~60000, This is due to the huge amplitude caused by the mechanical vibration after turning on the motor; the second is the frequency distribution, it can be clearly seen that there is a large amplitude distribution around 40Hz and 90Hz, indicating that most of the signal frequencies generated by mechanical vibration are distributed in these two Near the frequency range, and we do not need signals near this frequency, which means: we need to use some kind of filter, at least cut off at 40Hz or 90Hz , and the signals above this frequency will be shielded .

2.        LPF的结果很奇怪。在低频阶段0~40Hz的振幅极小,反而在100Hz处有较大的幅值分布,看起来就像是高通滤波器,而不像是低通滤波器。虽然设置的LPF在94Hz截止,但是在94Hz后面仍然有较大的震动信号出现,再次证明了MPU6050内置的LPF的效果确实不怎么令人满意

3.        2阶Butterworth滤波器效果比LPF效果好很多。在打开电机后,可以看到在30Hz之前的信号频谱和Raw的分布基本一致,说明保留了真实的信号输出。而在30Hz以后,其信号的幅值有了大幅度的明显衰减,有效的滤掉了高频的电机震动引起的干扰信号

4.        对于窗口平均滑动滤波依旧出现了匪夷所思的现象。这种有规律的频谱实在是看不懂,不过在低频段和原始输出保持一致,而在高频部分也有效的抑制了电机产生的震动信号。所以这种方法应用在四轴上的加速度计滤波是可以的,至少比内部LPF效果要好。

 

E(8组 RMSE):


这个图很有意思,RMSE(Root-Mean-Square-Error)均方根误差,常用来表征估计的准确程度。RMSE越小说明精度越高,这里由于是静止测试和开电机悬停测试,所以这里的RMSE用来表示数据的平滑性。

结论:

无论开电机与否,数据平滑性性能:窗口滑动>Butterworth>LPF>Raw

 

F(未开电机转动):


该测试用来比较Butterworth和窗口滑动滤波的延迟特性

结论:

数据平滑性性能指标:窗口滑动>Butterworth>Raw

 

为了更加清楚的看到延迟特性,下图放大Y轴在980次采样点的三条输出曲线:


结论:

数据延迟性能特性:Raw>Butterworth>窗口滑动,也就是说Butterworth滤波延迟小于8深度的窗口滑动滤波。

 

最后总结:

1.        尽量不要用MPU6050内置的LPF滤波。虽然相比于原始加速度计输出,该LPF可以平滑输出,但是在FFT频谱上的表现相当差劲。

2. The widely used window average sliding filter has good performance in both FFT and RMSE performance, so it is a wise choice to use window average filter for general basic applications (low-speed motion or four-axis beginners).

3. To achieve better filtering effect, FIR or IIR filter is a better choice. The author tested the second-order 30Hz Butterworth filter, although the smoothness RMSE is only a little worse than the window average sliding (but better than the LPF), but the data real-time performance index is nearly double the response speed of the former. Therefore, in the advanced stage of making four axes, you can consider replacing the average sliding of the window with the Butterworth filter.


This article is reproduced from: http://blog.csdn.net/nemol1990/article/details/41811061


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325856084&siteId=291194637