From PID to Fuzzy Control: Taking The Plunge Cautiously | |
The Problem(View more Control information or download preliminary software modules.) Back in the middle '90s, Bob Pease ran columns in "Electronic Design" magazine, deriding fuzzy controllers [1]. What bothered him most was unfounded (and sometimes plain wrong) marketing hype, and the fact that inferior but more complex fuzzy controllers were displacing well-suited PID controllers because clueless managers thought it would be good for business. We intend to show that, given any well-tuned PID controller, it is always possible to configure a fuzzy logic controller that is no more complex, but never less effective. (There you go, a carefully worded claim that is at least as misleading as the hype that you will find in the trade mags, as we will soon show.) If a PID controller's performance is not quite acceptable, perhaps this can serve as a first step toward performance improvements. What's the Fuzz?Fuzzy logic is of course one giant misnomer. There is nothing fuzzy at all about the logic, which is defined in mathematical terms that are precise, repeatable, and programmable. The fuzziness comes from uncertainty about the domain being represented. To apply a fuzzy logic system, you need ideas that you want to represent, otherwise you are using the wrong tool. For the case of a regulating controller, certain performance concerns should be addressed.
In fuzzy logic, an output can be high to some degree, low to some degree, both at the same time. For representing this mathematically, we can select reasonable bounding levels at which it is 100% certain that the output is too high, or 100% certain that the output is too low. Any values between can be considered a mix. When the system settles at the desired setpoint, this implies that the input level is neither too low nor too high, or equivalently, it is an equal mix of each. The region ranging from too low to too high would be centered about the setpoint level, so we can use the difference between the desired setpoint level and the actual output level as the input signal. Between the two extremes and the central balance, some kind of continuous curve defines the compromise between too high and too low. To keep things simple, we can use a linear curve. Thus, the basic control input can be represented by the following input mapping. Given measured deviations from the desired output level, the curves provide fuzzy membership levels for classifying the input values in terms of the two complementary fuzzy input range variables. We can consider input levels in other ways. If observed deviations persist over time, this might change the strategy.
We need a way to represent mathematically what persistently high and persistently low mean. One way to do this is to sum the sequence of deviations from the setpoint, as observed, and compare the sum to reasonable range limits. This running error accumulation is also mapped to fuzzy membership levels in a manner similar to the deviation inputs. Change is good, but rapid change is not so good when the output level is already close to where it is supposed to be. We can note that change tends to become small near the peaks of excursions anyway. Where it tends to be largest is where it tends to be most harmful.
We can estimate the rate of change by observing how much the feedback observations change from sample to sample. We can then characterize change in terms of fuzzy membership levels between too fast forward and too fast reverse. If you have noticed that a lot of inspiration has been drawn from classic PID control to this point, good! A fuzzy controller can't respond to information that it doesn't have. If it has fundamentally less information than a PID controller it will be fundamentally less capable. Where's the Logic In That?So far, all we have done is define some terminology, some fuzzy variables, but nothing about the relationships. That is where the fuzzy logic comes in. If the input variables and the quantities derived from them have deviated from desired levels, we want control rules that drive the levels back. Each heuristic is represented in two parts. If INPUT is TOO LOW, drive output HIGH. If INPUT is TOO HIGH, drive output LOW. If ACCUMULATION is PERSISTENTLY LOW, drive output HIGH. If ACCUMULATION is PERSISTENTLY HIGH, drive output LOW. If SPEED is TOO FAST FORWARD, drive output LOW. If SPEED is TOO FAST REVERSE, drive output HIGH. Each inference rule contributes evidence supporting the action of OUTPUT HIGH or of OUTPUT LOW. The final action must be a combination. We will ignore the popular min-max operators and use an additive combination because we are combining signals, not logical possibility. support for output level LOW OUTPUT = membership of INPUT in TOO HIGH + membership of ACCUMULATION in PERSISTENTLY HIGH + membership of SPEED in TOO FAST FORWARD ; support for output level HIGH OUTPUT = membership of INPUT in TOO LOW + membership of ACCUMULATION in PERSISTENTLY LOW + membership of SPEED in TOO FAST REVERSE ; There are some problems with this:
Now we can compute the control law and generate actual output. To summarize, we will:
To those readers already familiar with fuzzy controllers, there should be no surprises here. What a Long Strange Trip It's BeenThe mathematical choices of representation have finally yielded a fully-defined control system. It is time to implement it and put it to the test. If you wish, you can view the fuzzy control code and classic PID code in separate browser windows. The example code is organized for simplicity of presentation rather than runtime efficiency, and it will compile as C or C++. (Most applications needing fuzzy logic should consider a fuzzy rule evaluator engine; see reference [3] for example). One very easy way to get the code up and running quickly is to patch it into a DAPL system processing command module, but the same results can be obtained in any other context. After tuning parameters for best performance, here are output results in response to the same input sequence: PID: ... 20884 20755 20524 20468 20449 ... FUZZY: ... 20884 20755 20524 20468 20449 ... As you can see, there is no difference. Consequently, the simple fuzzy logic controller just designed is not inferior to its corresponding PID controller. The parameters of the fuzzy controller are directly related to the PID gain parameters, hence this same result can be obtained in every case. The simple fuzzy logic controller is based on three heuristic fuzzy rules adjusted by weighting factors, while the PID controller is based on three heuristic formulas adjusted by gain factors. The fuzzy controller is no more mathematically complex. It therefore has been demonstrated that this fuzzy logic controller is neither less effective nor more complex than its PID counterpart. QED. WHAT?! Is This Some Kind of Joke?Well, yes it is, in a way. It is the same joke as the argument: "Which is better, a fuzzy logic controller or a PID controller?" As we have just seen, a PID controller is just one possible special case of a fuzzy logic controller [4], in much the same way that classical logic is just one possible special case of fuzzy logic. This has not been a waste of your time. It is well known that PID controllers do not always work well, even though they are quite satisfactory most of the time. While a PID controller allows no flexibility of structure, a fuzzy logic controller can be whatever it needs to be (or something quite different from what it needs to be — which explains its reputation). You can start with the fuzzy PID controller, with a fuzzy logic rule set and initial parameter choices that match an established PID configuration. Add rules to cover situations that the PID controller does not address well, and adjust parameters to see what benefits derive, with just as much new complication as you need but no more. With classic PID, you are stuck. Fuzzy control opens up a door — or a Pandora's box — of possibilities. Among these:
But once again, each extension introduces new complexity, including more ways to go wrong. If nothing else, a new set of parameters must be tuned. Generic tuning rules for PID controllers might be 50% hoodoo and 50% ineffective, but there are no tuning rules for fuzzy logic controllers. Conclusions"My system performs fine with classic PID. Why should I consider fuzzy logic?" You shouldn't, unless of course you recently went into management. Control systems should be used to solve problems, not create them. Bob Pease would tell you as much. But let's say that your system performance isn't fine, though you have a pretty good idea of what can be done to address the problem. The question is, how do you get from insight to installation? You could of course hire a consultant to design (build, document, install, support) a controller that includes all of the usual features, plus the specialized twists you want to try. Cheap? Guess again. Amortized over 5000 or more units, expense doesn't matter and that's probably a great way to go. But what if your production line needs just a few units? You might consider a DAP-based control system. The digitizing, processing, and basic control framework are already there. Using the Developer's Toolkit for DAPL, you can patch in your specialized code to replace "compute PID control law." Then compile, download, and run it on the spot. When you find the variation that is effective, you have an industrial- grade implementation that is ready to go into production. And finally, don't panic just because you see that unfortunate term "fuzzy" attributed to a control system. If it is useful to think in terms of "rules" when defining a control solution, fuzzy approaches are an option to consider. Footnotes and References:
Return to the Control page. |