Aug 12, 2010, 07:20 AM
Registered User
Joined Aug 2010
9 Posts
Quote:
 Originally Posted by dcaspi Proper credentials for the complementary filter go to RoyLB, who is the owner of this thread
Oh I am realy sorry if i am overly posted in this thread... If it is then because of my utter curiosity of this subject...
Aug 12, 2010, 08:19 AM
Registered User
Joined Jan 2009
461 Posts
ramee,

Quote:
 Originally Posted by ramee So you are going to use PID in attitude perspective. am I right.. ok .. It is the same thing i was implemented too...but integeration of the attitude makes lot of troble for me. I gain makes quad unstable under even low disturbances. Yes it will bring quad back to level flight but it creates more overshoot and low frequency oscillations of the quad.
Don't forget - you don't need the I term to be active all the time. You only need it when you desire to hold a precise attitude. If your inputs (joysticks) represent rates, then a zero input = zero rate = constant attitude. So only activate the I when the sticks are near zero. Also, in general, if you have oscillations, it means a gain is too high. It might not necessarily be the I gain - all 3 gains influence each other to some extent. Also, I'd check to make sure the Kalman filter is working correctly before I'd wrap any feedback loops around it.

Quote:
 Any way i have seen in a research paper that have implemented PID in this way. But they have also used a fourth component to P,I,D the derivative of rate d(rate)/dt to increased the bandwith of the controller. Can you explain this.
There's nothing written in stone that says all you can have are P I and D terms. Your controller can have whatever order it needs - as many derivatives of derivatives and/or integrals of integrals. You can think of derivative control as providing anticipation, so it can increase the speed of response of the system, which is what bandwidth means (more on all this later).

Having said that, I don't recall seeing this paper. Can you send it to me, or at least send me a link or the details?

Quote:
 Nice quad frame you have got there... Good luck with your work..
Its my frame in the sense that I paid for it. I didn't design it. See the first post for credit.

- Roy
Aug 12, 2010, 08:39 AM
Registered User
Joined Jan 2009
461 Posts
Quote:
Originally Posted by ramee

Quote:
 Originally Posted by dcaspi Proper credentials for the complementary filter go to RoyLB, who is the owner of this thread
Oh I am realy sorry if i am overly posted in this thread... If it is then because of my utter curiosity of this subject...
ramee,
No worries. The ironic thing is, having designed the filter, I'm not sure I will use it in my own quad! It has several drawbacks, some of which I think can be fixed and some which can't. It does not provide a consistent gyro bias reference, but I think this can be improved. It also uses trig functions, which are computationally expensive, but these could be replaced by table lookups. It also assumes that the three attitudes are completely independent of each other and are the integrals of the angular rate - which is not at all true as I've said earlier, except in approximation. This can't be overcome, but it can be accommodated. By its nature, the quad will be spending most of its time near hover. If its far from hover, then its only going to be there transiently during aerobatics, for example.

- Roy
Aug 12, 2010, 08:57 AM
destructive testing expert
Kiryat Yam, Israel
Joined Apr 2009
348 Posts
Quote:
 Originally Posted by RoyLB ...It also uses trig functions, which are computationally expensive, but these could be replaced by table lookups....
I've seen some really coarse approximations (in the UAVX code I believe), something like a table with 8 entries or so for the trig function. But then I may be mistaken.
The wonder is that those things do work. Overall I think people use sensors with bad accuracy, do approximate calculations etc. and it still works. For me it is interesting to understand why.

Dror
 Aug 12, 2010, 10:26 AM Registered User Joined Aug 2010 9 Posts Roy; Yes there are some drawbaks in complementry filter than kalman filter. But complemetery filters are easy to tune and more computationaly efficient. but it can not completly eliminate the gyro drift i think. What i have implement in my system is also use the assumption that three axis are independent.I am not building a acrobatic quad but more forcus on stability even autonomus flight. So quad will most of time be in near hovering. Do you have finalised your controller... I am using microchip dsPIC33f128MC804, nice micro with dsp capabilty with 4 hardware PWM modules 9 channel 12 bit 500ksps ADC, 4- Input capture pins, Aslo comes with CRC calculator (hardware of course)- nice when you have rf link for communication with quad. I will send that paper to you..needs lot of search though Thanks for the clarification about PID and theory . I have implement PID inattitude sense not for the rates... soon i will be able check it to control rates and see the differance.
Aug 12, 2010, 10:40 AM
Registered User
Joined Aug 2010
9 Posts
Quote:
 Originally Posted by RoyLB ramee, Having said that, I don't recall seeing this paper. Can you send it to me, or at least send me a link or the details? - Roy
this is the link to that paper..

please look at the eq 7 under attitude control..
Aug 12, 2010, 12:36 PM
Registered User
Joined Jan 2009
461 Posts
Quote:
 Originally Posted by dcaspi I've seen some really coarse approximations (in the UAVX code I believe), something like a table with 8 entries or so for the trig function. But then I may be mistaken. The wonder is that those things do work. Overall I think people use sensors with bad accuracy, do approximate calculations etc. and it still works. For me it is interesting to understand why. Dror
Dror,

That's the beauty of feedback! Used properly, it can make up for a multitude of sins and ignorance. Used improperly, of course, it can cause instability.

Here's a quick hint as to why it works so well: http://en.wikipedia.org/wiki/Feedbac...nsfer_function. On top of this drawing, realize that the designer has some freedom to pick the regions (in the frequency domain) where feedback can cancel the dynamics of the device its trying to control.

- Roy
Aug 12, 2010, 12:42 PM
Registered User
Joined Jan 2009
461 Posts
Quote:
 Originally Posted by ramee Roy; ... Do you have finalised your controller... I am using microchip dsPIC33f128MC804, nice micro with dsp capabilty with 4 hardware PWM modules 9 channel 12 bit 500ksps ADC, 4- Input capture pins, Aslo comes with CRC calculator (hardware of course)- nice when you have rf link for communication with quad. ...
ramee,

My controller board is AVR-based, as you can see in the first post. It's probably not the optimal choice for Quad control, but I'd like to see how far I can get with it since I have it. I will probably move up to an ARM device in the future. I did look at the dsPICs at one point. I liked that there is an interface between Scilab/Scicos to generate code for these chips. Ultimately, though, if I'm going to move up, I might as well go full 32-bit

- Roy
Aug 12, 2010, 12:52 PM
Registered User
Joined Jan 2009
461 Posts
Quote:
 Originally Posted by ramee this is the link to that paper.. http://hoffmann.stanford.edu/papers/GNC08_QuadTraj.pdf please look at the eq 7 under attitude control..
ramee,

That is a very good paper. The STARMAC guys have some other good papers, too, like this one: http://hoffmann.stanford.edu/papers/...mics_GNC07.pdf

I didn't remember that they were using a 4 term controller in the paper you referenced. All of page 5 contains really good information for control theory:

- tranfer function
- thrust "delay" *
- root locus
- increasing the bandwidth via feedback
- reference commands
- digital filters

I hope to cover enough ground that a non-expert can understand most of what's on that page.

- Roy

* (see this thread, starting about here:http://www.rcgroups.com/forums/showp...&postcount=325 for an explaination of the delay in thrust and what can be done about it.
 Aug 13, 2010, 07:00 AM Registered User Joined Jan 2009 461 Posts All 5 motors and ESCs have their bullet connectors soldered Thanks to Nelson from the Robotics group and the Hive, the connectors between the motors and the ESCs are soldered in place. I just need to heat up the heat-shrink on all 5 motors. - Roy
 Aug 13, 2010, 08:01 PM Registered User Joined Jan 2009 89 Posts Hello Roy, Good to see that you are making progress in this project. After a long haitus me and my brother have put some more time. There will be some updates to the code base soon. Cheers
Aug 14, 2010, 09:53 AM
Registered User
Joined Jan 2009
461 Posts
Quote:
 Originally Posted by brij Hello Roy, Good to see that you are making progress in this project. After a long haitus me and my brother have put some more time. There will be some updates to the code base soon. Cheers
Hi brij,

Thanks! Good to hear from you! I am looking forward to seeing the new code!

- Roy

p.s Brij designed and assembled the quad controller board
Aug 15, 2010, 07:36 AM
Registered User
Joined Aug 2010
9 Posts
Quote:
 Originally Posted by RoyLB From a rate perspective, rate would be considered your "P" term and attitude your "I" term. From an attitude perspective, attitude would be the P and rate would be the D. It can be confusing. I should probably stay away from the term "PID" altogether, at least until I delve into it a little further. So, let me say is this way: my quad will employ rate and attitude feedback, and will probably use some integral feedback on attitude as well. - Roy
Roy

This weekend i tried PID in attitude sense but, I caused system to be oscilatory and slow responce. I can not decrease the I because system is more slow responsive and can't increse as system is more unstable.

So removeing I altogeter , system becomes stable again but quad is not perfecly level because of the uneven weight distribution. In flying this caused very high drift that i couldn't control.

So i think some how I is required in the controller to stable hover. And it is better system to be more reponsive too.

So i am thinking to implement two step control .. as you sugested ... one for velocity control inner loop and another outer loop for position control. Do you have a idea of the timing for these loops. Currently only loop running is at 1Kz.

And i would love to know how velocity loop should be. Yes gyro rate can be used as P term there.. but how to implement I term... is that I is comming from integration of anguler error rates or should i neglect Integration part altogether...
Aug 16, 2010, 04:36 AM
Registered User
Joined Jan 2009
461 Posts
Quote:
 Originally Posted by ramee Roy This weekend i tried PID in attitude sense but, I caused system to be oscilatory and slow responce. I can not decrease the I because system is more slow responsive and can't increse as system is more unstable. So removeing I altogeter , system becomes stable again but quad is not perfecly level because of the uneven weight distribution. In flying this caused very high drift that i couldn't control. So i think some how I is required in the controller to stable hover. And it is better system to be more reponsive too. So i am thinking to implement two step control .. as you sugested ... one for velocity control inner loop and another outer loop for position control. Do you have a idea of the timing for these loops. Currently only loop running is at 1Kz. And i would love to know how velocity loop should be. Yes gyro rate can be used as P term there.. but how to implement I term... is that I is comming from integration of anguler error rates or should i neglect Integration part altogether...

ramee,

Its difficult to diagnose PID tuning issues over a forum (or at least it is for me). The terms aren't totally independent - you may find that after tuning I you may need to go back and adjust P (probably should be reduced in your case) and D (probably increased for you), for example.

Another situation that an I term can be used for is asymmetric mass distributions. However, you can also put a constant bias into the motors to compensate for this (assuming it is constant).

I'm not at the point of determining loop timing yet. The loops can run at the same iteration rate. The outer loop is typically "slower" meaning lower gain (or higher time constant).

The way I will implement the feedback loops (as implied by the paper you linked) is to determine a desired rate and a desired attitude based on the joystick commands and subtract the sensor values from the desired values. Then, if necessary, apply integral feedback on the attitude error - but only when commanding near zero rates (i.e. the joystick is near center in a rate command system). At other times, the integrator is just frozen.

- Roy
 Aug 25, 2010, 12:30 PM Registered User Joined Jan 2009 461 Posts Radio on its way; Optical flow sensor Hobby King finally got another shipment of the Turnigy 9X 9Ch Transmitter w/ Module & 8ch Receiver (Mode 2) (v2 Firmware). So I guess that's my radio - at least for now. I also received some free samples of an optical flow sensor from Centeye. See here for more info: http://www.diydrones.com/profiles/bl...gPost%3A177115. I'll upload some pics when I get home. Mine looks slightly different from the one in the link. I'll indicate in future posts just what an optical flow sensor is and why its useful. - Roy