So my concern about clashing filters was right: with the MPU6050 DLPF set to 5Hz, take-off was fine, but drift was present exactly as before; setting the MPU6050 to anything higher than that led to a ‘bouncy’ takeoff, to the extent that at 45Hz, Phoebe couldn’t get herself off the floor – more like a slightly manic bouncing on a trampoline. It’s a shame the MPU6050 doesn’t allow different filtering on different axes, but such is life!
The real problem is how the vertical velocity PID operates; specifically it has a P gain of 150 which is huge compared to the equivalent horizontal velocity gains. It needs this to fight off gravity and get Phoebe in the air – for example for her to take-off at a speed of 0.3 m/s results in an increase in PWM pulse width across all blades of 50us which is huge meaning any noise getting through also gets multiplied up.
There are a couple of things I could try:
- increase the hover speed from its default 590 to something perhaps more realistic based upon real flight measurements – the corresponding flight logs show the PWM pulse width of 630us required for a stable hover – an increase of 40us over the current 590 default. Some of this is likely to be due to the old motors and blades I’ve swapped back to to check whether a dodgy motor is the cause of the yaw. Upping the hover default PWM rate allows a significant reduction in the vertical velocity PID P gain (perhaps by a factor of 10, and a matching integral gain change) meaning much reduced influence of vertical noise.
- use a rolling average of the z-axis accelerometer to feed the PID input – since the code is sampling at 6ms cycles, and average of say the last 10 readings will lead to an additional level of filtering to about 16Hz – the downside is lag introduced in the reaction, but actually vertical flight generally doesn’t require the fast reaction that horizontal correction does.
If the weather holds (it wasn’t forecast to be at all good for testing today), I’ll try at least the first option.
P.S. The weather held just long enough – with hover set to 630, vertical velocity PID P and I dropped to 30, and dlpf set to 3 (45Hz filter) takeoff was fine. Landing was an unenthusiatic affair, so I think the I gain can go down further perhaps to 10 in line with the previous P:I ratio of 150:50.