PID tuning, too slow to stabilize and overshooting

drich

New Member
Hello,

I'm building my very first quadcopter totally from scratch, using a Lynxmotion mini V-Tail frame, and motors from the same brand.
My controller board is a raspberry pi with software that I wrote entirely by myself, with a fixed update rate at approximately 100Hz. I'm using an Invensense MPU-9150 as IMU.

After a very long time trying to avoid noise on accelerometer and filter all the data using an EKF, I'm now facing a big problem with the PID controlling the attitude of my quadcopter.

If I hold it by its tail (letting its head falling forward) and let the controller raising it to horizontal, it takes several seconds (almost 10 seconds in worst cases) to stabilize. That's way too long, so I increase the P parameter just a little bit, then the drone starts oscillating more and more until becoming totally uncontrollable, and it was still too slow to stabilize !

Did someone already had a similar problem on this forum ? Do you think that it does come from the PID or maybe my EKF filtering ?

Thank you o/
 
Last edited by a moderator:
Text was white, changed font color to black to allow people to read.

Many people have had similar problems, but none exactly the same as yours that I know of.

First off what algorithm are you using to stabilize? Also how are you outputting PWM to the ESCs from the Pi? Serial connected Arduino?


Vibrations can cause the IMUs to give faulty data, but with a custom flight controller this in unlikely to be the problem. If you are sure of your method of using the P and I values, then it sounds like you have too low I and too high P. To adjust set the I to 0, and adjust the P just high enough that you get high speed oscillations, then adjust back a little. Then adjust I too high and dial back. I gain calculates the value over time, so it is important not to get it too low, but you don't want oscillations so you have to lower it just to where the oscillations stop. .
 
I'm using an EKF to filter noise of accelerometer, gyro and magnetometer. Then, I use a simple complementary filter to convert filtered values to roll/pitch/yaw, and finally my PID simply controls the motors to adjust the drone's attitude. Am I missing something in this processing chain ?

The PWM is generated on the Pi itself, using a DMA buffer (https://github.com/sarfata/pi-blaster)
By the way, it seems that the RPM of the motors are not constant, all of them just "peak" sometimes. Is it a common thing on drones ? Maybe a too cheap battery ? (I dont have any other motor/ESC from different brand, so I can't test to determine where it comes from).

Actually, it seems that the "too slow to stabilize" problem is due to my accelerometer filtering, which is too heavy and slow to average. But if I reduce this filtering, the data is too noisy and increases overall instability :confused:
I don't think I can reduce vibrations more, as you can see on this picture, the IMU is already mounted on two Moongel slices and hold by a single rubber band (and data wire passes between the two Moongel slices).

Setting the I parameter of my PID just makes the drone drifting away.. And since many people say that P and D are way more important, I will leave it to zero for now :D

Thank you for helping x)
 
Last edited:
I'm using an EKF to filter noise of accelerometer, gyro and magnetometer. Then, I use a simple complementary filter to convert filtered values to roll/pitch/yaw, and finally my PID simply controls the motors to adjust the drone's attitude. Am I missing something in this processing chain ?

The PWM is generated on the Pi itself, using a DMA buffer (https://github.com/sarfata/pi-blaster)
By the way, it seems that the RPM of the motors are not constant, all of them just "peak" sometimes. Is it a common thing on drones ? Maybe a too cheap battery ? (I dont have any other motor/ESC from different brand, so I can't test to determine where it comes from).

Actually, it seems that the "too slow to stabilize" problem is due to my accelerometer filtering, which is too heavy and slow to average. But if I reduce this filtering, the data is too noisy and increases overall instability :confused:
I don't think I can reduce vibrations more, as you can see on this picture, the IMU is already mounted on two Moongel slices and hold by a single rubber band (and data wire passes between the two Moongel slices).

Setting the I parameter of my PID just makes the drone drifting away.. And since many people say that P and D are way more important, I will leave it to zero for now :D

Thank you for helping x)
The only thing controlling altitude at this stage should be throttle. Quadcopters (unlike planes and helicopters) are inherently unstable. Even if the motors are spinning the exact speed and creating the exact thrust the quad will flip and hit the ground. This is because it is about as stable as a rock. Are you stabilizing or trying to control altitude? A normal quadcopter makes maybe a thousand changes per second just to hover, even then it will drift without the person's hand on the stick. Is any of this new to you?
 
Erf sorry I was talking about attitude, no 'L' involved :D.
About altitude, yes, the only thing that controls it is the throttle.

My thread is about stabilizing, I'm actually trying to get stable hovering. I think that at the current state, it could fly with a stabilization amplitude of several meters, but I don't have the guts (nor the money) to try..

Sorry about this mistake, my english is far from perfect

Edit:
Is any of this new to you?
All of this is new to me as it is my very first drone. I started to built it with absolutely no knowledges in aircrafts/drones, but only in programming and electronics
 
Hi,
thank you for putting me one the right track :D
I finally got it flying \o/
In the case someone have the same problem in the future, I was integrating my PID output over time instead of outputting it directly to the motors (yeah, was a bit stupid..)
Still need to slightly tweak filters and PID coeffs, but it flies now !
 
Hi,
thank you for putting me one the right track :D
I finally got it flying \o/
In the case someone have the same problem in the future, I was integrating my PID output over time instead of outputting it directly to the motors (yeah, was a bit stupid..)
Still need to slightly tweak filters and PID coeffs, but it flies now !

Hi, This is my problem too, but what do you mean about "integrating over time" ?
Here is my psudo code for each axis:

Code:
rate_needed_to_stabilize = Stabilizer_Controller_PID
rate_output = Rate_Controller_PID

rate_output goes to motors...
 
Back
Top