Now my exams are finally over I have started cracking on again with the quad. Over the past few days I've made a massive number of improvements:
- Improved signal loss handling. The previous method used the watchdog timer to initiate a reset upon a signal loss, effectively leaving the quad dead in the water. I've now freed up a timer peripheral and configured it to disable all the motors upon signal loss. However the main difference is this method can instantly resume once the signal is reestablished, so a momentary glitch won't result in a guaranteed crash.
- Improved filtering. I've now configured the MPU6050 to use its on-board digital low pass filter, massively reducing noise, and I've switched to a second order complementary filter, again improving signal quality.
Original angle estimate I was flying with (green is the filter output, red is the integrated gyroscope output).
After configuring LPF.
With 2nd order complementary filter.
- Added code to calibrate the ESC's on every startup. This means every ESC is now balanced, and I'm using the full ESC throttle range unlike the last model.
- Designed a Labview interface, allowing me to monitor the sensor outputs and modify the PID constants on the fly. Screenshot.
Thanks to this interface it is now a much simpler task to tune the PID coefficients, so for now the quad is sat in its frame while I get the PID re-tuned for the new ESC throttle curve and filter response. However, I've ran into the problem of having to choose between good disturbance rejection and good command tracking. By increasing the coefficients I can make the quad perfectly lock onto an angle, allowing for near perfect hovering, but this increased differential term makes the quad incredibly slow to respond to commands, making flying the thing a nightmare. I need to do further research into how to solve this, or if PID is really the best tool for this problem.
I will probably aim for somewhere in the middle tomorrow, then take it off its frame to see how the new filters really perform, which I have high hopes for.