Monday, January 28, 2008

Sunday, Loops and Simulation

The Simulated weather for Sunday was Rain all day. The Reality was that after 10am it did not really rain again until 4:00pm. So I went flying. I'm currently working on altitude hold, but the wind was really gusty gusting from 5 to 20mph. A helicopter takes less energy to fly when moving than when it is hovering. If you try to hover in one spot with gusty winds the helicopter balloons up and down as the wind speed increases and decreases. This makes it very hard to sort out the altitude hold loop as you are never sure if the up and down is wind or oscillation's. I could hover lower and get a better handle on how the altitude loop gain is but until I have it hovering at high (recoverable) altitude I'm not going to play with the altitude hold down low. The altitude hold will have to wait until a calmer day.



So since I could not do altitude hold I thought I'd work on heading hold. In flying around with the magnetic heading hold engaged the helicopter seems relatively stable but the tail wandered a few degrees each way. I always thought that it was some local magnetic variation, that may contribute, but in looking at the data the tail target vs actual error is often 3 to 6 degrees and it wanders a bit. It seems to hold an offset. The standard way to fix this in a control loop is to add some integral error term and the result is The oscillation's you see on the left. So I turn down the I term (to 5% of the P term) and turn up the D term and its better, but still not ideal. You can still see some 3 to 4 second oscillations when steady and a fair bit of overshoot when perturbed. I'd been doing the default PID tuning of turning the P gain up to the point where it just starts to oscillate and taking the Ziegler-Nichols values you can find on the web. I conceptually understand what is going on, but this is straining my control system theory. (My only official control theory class was all done as laplace transforms in 1983) Early in my professional career(1985 to 1991) I did a fair number of analog and mixed analog/digital control systems, but always with a adult supervision from a controls person. Since 1991 I've mostly been a software coder. So in trying to relearn all of this I have a several specific questions that I'd love have any lurking control theory guys help me with.

Most control theory books, articles and tuning discussions assume you have a linear plant. In reality most of my "Plants" will be integral in nature. IE I do not control the thing I'm trying to close the loop on directly, I really control the acceleration or rate. So there are one or two physical integrals between my control input and the thing I want to control. See the example to the left.
If I just close the loop around the whole thing, its going to be really unstable. So my plan was to have Target Position yield Target Velocity Target Velocity yield target Pitch and Target Pitch yield Pitch Rate. This would have hard limits for each intermediate step. IE max velocity will be 5m/sec, regardless of the position error. Clearly every intermediate step in this will have a proportional gain term, any advice on which ones should have integral terms and when I should reset the integrals to zero?





I'm also struggling with a stupid simple question I have about PID terminology. You can express a PID as

control= P*(error+I*integral+D*difference_or_rate)

or You can express a PID loop as

control = (P*Error)+(I*Integral )+(D*difference_or_rate)

When you look at the standard Ziegler-Nichols chart :
for PID P = .6Gu I=2/PU D=PU/8 Is this for the first form or the second? When you measure Pu I assume Pu is the oscillation period in samples (this is a discrete system), or have I made a wrong assumption here?

Lastly is the guidance for standard linear PID tuning even valid for this sort of plant? If not can one provide some guidance on tuning such loops?

14 comments:

Anonymous said...

IANCE but have you seen this article:http://www.embedded.com/2000/0010/0010feat3.htm

It describes a precision positioning system as one of the examples. There lots of gems of info as well.

heroineworshipper said...
This comment has been removed by the author.
Anonymous said...

vicacopter.com has all this done. Would be surprised if 10Hz DGPS didn't improve altitude hold.

Paul Breed said...
This comment has been removed by the author.
Paul Breed said...

Herowineworshipper,
Did you get my private E-Mails on RC groups? I sent two in the last 72 hours and did not see a reply.

Its fine to ignore them, but I just wanted to make sure you got them.

Aerospike said...

I'm in no way a controls expert (just a student of computer science with some basic math knowledge), but I'm having trouble to understand how

P*(error+I*integral+ D*difference_or_rate)
can be the same as
(P*Error)+(I*Integral) +(D*difference_or_rate)

How can one expression be transformed into the other?

Paul Breed said...

The two expressions are only the same if you scale the I and D constants by P, the problem I'm trying to get an answer to is that in PID tuning suggestions they give recommended values for P,I,D but don't say which form the equation is in, thus the recommendations for I,D are off by a factor of P depending on which assumption you make.

Christian Menge said...
This comment has been removed by the author.
Christian Menge said...

This might help:

Christian Menge said...

Third time is a charm...sorry about that.

href="http://wiki.flightgear.org/
flightgear_wiki/index.php?
title=Autopilot_Tuning_Resources

jfb said...

Integrals don't make your plant any less linear. Just add 1/s^2 to your plant. Probably root locus will do the job to find your coefficients, too. :)

jfb said...

My bad, not add, multiply.

jfb said...

That reminds me. If you want no oscillations you want to pick your gain on the root locus graph as one on the real line. If it's imaginary you'll have overshoot and whatnot.

Anonymous said...

ทุกใจนักเดิมพันอย่างเเน่นอน UFABET เว็บหลัก คาสิโนออนไลน์ บาคาร่า สล็อต แทงบอล ดีที่สุด ufabetcoins รวมเกมเดิมพันออนไลน์ทุกค่าย ทุกเกม ทุกเเขนงไว้ในเว็บไซต์เดียว ซึ่งถือเป็นเว็บไซต์เดิมพันที่ครบวงจร เเละตอบโจทย์นักเดิมพันมากที่สุด !! เว็บไซต์เดิมพันออนไลน์ที่มีความปลอดภัยสูง 100% บริการทุกระดับประทับใจ เปิดให้บริการตลอด 24 ชั่วโมง.