Hello nebbian,

I'm looking at adapting this software to a flight controller that uses a micro with hardware floating point, so I'm also interested in this PID controller...

In studying the three PID controllers in the cleanflight "flight.c" module, I noticed something that I can't figure out and I wondered if you could shed some light on it.

I am looking at the relative ranges of the variables used to calculate the error between rate commanded by the stick and rate measured by the gyro... In the two PID controllers that are inherited from MultiWii (pidMultiwii and pidRewrite), we see scaling on rcCommand[] and gyroData[] that results in a ratio of somewhere between 7 and 10...

Example:

If rcCommand[] has a range of +/-500, and the MPU6040 gyro has a range of +/-32800, we see rcCommand[ROLL] being scaled by 27/16, with a resulting range of +/-843. gyroData[] is divided by 4, with a resulting range of +/-8200. Finally, this gives us a ratio of 8200/843 = 9.73, which suggests that response to gyro variations is about 10 times greater than the response to stick commands (assuming rollPitchRate = 0).

If we look at the same situation in the floating point "pidBaseflight" controller, we see that rcCommand[ROLL] is scaled by 20/50, with a resulting range of +/-200, and the gyroDat[] value is used without scaling, so it has a range of +/-32800. This gives us a ratio of 32800/200 = 164.

This difference in ratio suggests that the pidBaseflight controller is much, much more sensitive to gyro rate than it is to the stick command rate. I'm wondering if this means that in order for this PID controller to work in a similar fashion to the two integer-math controllers, you need to have yawRate and rollPitchRate cranked up to something like 64, so that the rate ratio is in a similar ballpark?

Since you've flown with this PID Controller and I haven't, did you find the stick rate values had to be much greater than with the "stock" PID controllers?

Sorry for the picky-sticky detail... and thanks for any light you can shed on this for me...

Cheers, Jon.

nebbian wrote:dominicclifton wrote:

Yes to the video and Yes to the Tuneup! Please chat to Lux as I'm sure he'd be very interested in your findings.

Here's a video I made today, apologies for the wind noise in the microphone...

... video snipped out...

Awesome, thanks. I've been in contact and will take this further with him.