The data back in the absence of interference is perfect. I thought I could really react to the current tilt of the plane and then adjust, I was naïve to take this data directly, and adjust the PID parameters for three weeks without progress. When there is no progress, I began to think of what was wrong, I used processing hit an oscilloscope out, the data returned to the drawing of the waveform displayed on the computer, found the problem: The motor is not open when the data is very good, the motor is open data can not be seen, because the impact of motor vibration on the accelerometer is very large, And our angle is the test acceleration measurement, the return is simply garbled!!!
Set the heart, feel the filter, the accelerometer returns the inclination of low-pass filtering, the gyroscope is affected by the vibration is very small, do not need filtering. Low-pass filtering we do not need to know, this is also eliminated, the reason is that after filtering the data although very good-looking, but will cause great delay, the plane is biased to the other side, but also show biased on this side, this is only suitable in some do not need too sensitive places.
Here is a simple and efficient algorithm to save me, do not need to use the Kalman filter such a high-level algorithm is enough to let it fly and fly very well, some people call him data fusion algorithm, in fact, not so Xuan.
The gyroscope is affected by vibration is very small, it returns the angular velocity, angular velocity * time is integral, each cycle read the current angular velocity and then add up, such as the first angular velocity 20 degrees/s, a cycle of 0.02s, such as my cycle of 22ms. That's why we knew it was 0.4 degrees. The first turn 2, the second Turn 3, the third time to turn-1, a total of turn 2+3-1=4. Some people will ask, is such points accurate? Very accurate! I began to feel that it was not reliable, and later found very reliable. Two or three side 0 points will produce three or four degrees of deviation, it does not matter, we use the exact angle (accelerometer return, acceleration return angle, a bit around) to correct.
Without correction, the formula is like this
Angle = angular velocity * Cycle time + original angle
Plus, after the correction
Angle =95%* (angular velocity * cycle time + original angle) +5%* accurate angle
For these two data weighted average, so that both the constant, but also to ensure that 0 points do not drift, good, very good!
After that, the PID is given up, do not believe to try.
Original link: http://blog.sina.com.cn/s/blog_69c23ea50101k4a6.html
Four-axis motor vibration (RPM)