Introduction
Fuzzy logic (FL) and its application.
This article will continue the introduction with a more
detailed look at how one might use FL. A simple
implementation will be explained in detail beginning in
the next article. Accompanying outside references are
included for interested readers.
In the last article, FL was introduced
and the thrust of this article series presented. The
origin of FL was shared and an introduction to some of
the basic concepts of FL was presented. We will now look
a little deeper.
Why Use Fuzzy Logic
FL offers several unique features that
make it a particularly good choice for many control
problems.
1) It is inherently robust since it
does not require precise, noise-free inputs and can be
programmed to fail safely if a feedback sensor quits or
is destroyed. The output control is a smooth control
function despite a wide range of input variations.
2) Since the FL controller processes
user-defined rules governing the target control system,
it can be modified and tweaked easily to improve or
drastically alter system performance. New sensors can
easily be incorporated into the system simply by
generating appropriate governing rules.
3) FL is not limited to a few feedback
inputs and one or two control outputs, nor is it
necessary to measure or compute rate-of-change
parameters in order for it to be implemented. Any sensor
data that provides some indication of a system's actions
and reactions is sufficient. This allows the sensors to
be inexpensive and imprecise thus keeping the overall
system cost and complexity low.
4) Because of the rule-based
operation, any reasonable number of inputs can be
processed (1-8 or more) and numerous outputs (1-4 or
more) generated, although defining the rulebase quickly
becomes complex if too many inputs and outputs are
chosen for a single implementation since rules defining
their interrelations must also be defined. It would be
better to break the control system into smaller chunks
and use several smaller FL controllers distributed on
the system, each with more limited responsibilities.
5) FL can control nonlinear systems
that would be difficult or impossible to model
mathematically. This opens doors for control systems
that would normally be deemed unfeasible for automation.
How is Fuzzy logic is used?
1) Define the control objectives and
criteria: What am I trying to control? What do I have to
do to control the system? What kind of response do I
need? What are the possible (probable) system failure
modes?
2) Determine the input and output
relationships and choose a minimum number of variables
for input to the FL engine (typically error and
rate-of-change-of-error).
3) Using the rule-based structure of
FL, break the control problem down into a series of IF X
AND Y THEN Z rules that define the desired system output
response for given system input conditions. The number
and complexity of rules depends on the number of input
parameters that are to be processed and the number fuzzy
variables associated with each parameter. If possible,
use at least one variable and its time derivative.
Although it is possible to use a single, instantaneous
error parameter without knowing its rate of change, this
cripples the system's ability to minimize overshoot for
a step inputs.
4) Create FL membership functions that
define the meaning (values) of Input/Output terms used
in the rules.
5) Create the necessary pre- and
post-processing FL routines if implementing in S/W,
otherwise program the rules into the FL H/W engine.
6) Test the system, evaluate the
results, tune the rules and membership functions, and
retest until satisfactory results are obtained.
LINGUISTIC VARIABLES
In 1973, Professor Lotfi Zadeh
proposed the concept of linguistic or "fuzzy" variables.
Think of them as linguistic objects or words, rather
than numbers. The sensor input is a noun, e.g.
"temperature", "displacement", "velocity", "flow",
"pressure", etc. Since error is just the difference, it
can be thought of the same way. The fuzzy variables
themselves are adjectives that modify the variable (e.g.
"large positive" error, "small positive" error ,"zero"
error, "small negative" error, and "large negative"
error). As a minimum, one could simply have "positive",
"zero", and "negative" variables for each of the
parameters. Additional ranges such as "very large" and
"very small" could also be added to extend the
responsiveness to exceptional or very nonlinear
conditions, but aren't necessary in a basic system.
SUMMARY
FL does not require precise inputs, is
inherently robust, and can process any reasonable number
of inputs but system complexity increases rapidly with
more inputs and outputs. Distributed processors would
probably be easier to implement. Simple, plain-language
IF X AND Y THEN Z rules are used to describe the desired
system response in terms of linguistic variables rather
than mathematical formulas. The number of these is
dependent on the number of inputs, outputs, and the
designer's control response goals.
THE RULE MATRIX
In the last article the concept of linguistic variables
was presented. The fuzzy parameters of error
(command-feedback) and error-dot
(rate-of-change-of-error) were modified by the
adjectives "negative", "zero", and "positive". To
picture this, imagine the simplest practical
implementation, a 3-by-3 matrix. The columns represent
"negative error", "zero error", and "positive error"
inputs from left to right. The rows represent
"negative", "zero", and "positive" "error-dot" input
from top to bottom. This planar construct is called a
rule matrix. It has two input conditions, "error" and
"error-dot", and one output response conclusion (at the
intersection of each row and column). In this case there
are nine possible logical product (AND) output response
conclusions.
Although not absolutely necessary, rule matrices usually
have an odd number of rows and columns to accommodate a
"zero" center row and column region. This may not be
needed as long as the functions on either side of the
center overlap somewhat and continuous dithering of the
output is acceptable since the "zero" regions correspond
to "no change" output responses the lack of this region
will cause the system to continually hunt for "zero". It
is also possible to have a different number of rows than
columns. This occurs when numerous degrees of inputs are
needed. The maximum number of possible rules is simply
the product of the number of rows and columns, but
definition of all of these rules may not be necessary
since some input conditions may never occur in practical
operation. The primary objective of this construct is to
map out the universe of possible inputs while keeping
the system sufficiently under control.
STARTING THE PROCESS
The first step in implementing FL is to decide exactly
what is to be controlled and how. For example, suppose
we want to design a simple proportional temperature
controller with an electric heating element and a
variable-speed cooling fan. A positive signal output
calls for 0-100 percent heat while a negative signal
output calls for 0-100 percent cooling. Control is
achieved through proper balance and control of these two
active devices.

Figure 1 - A simple block diagram of
the control system.
It is necessary to establish a meaningful system for
representing the linguistic variables in the matrix. For
this example, the following will be used:
"N" = "negative" error or error-dot input level
"Z" = "zero" error or error-dot input level
"P" = "positive" error or error-dot input level
"H" = "Heat" output response
"-" = "No Change" to current output
"C" = "Cool" output response
Define the minimum number of possible input product
combinations and corresponding output response
conclusions using these terms. For a three-by-three
matrix with heating and cooling output responses, all
nine rules will need to be defined. The conclusions to
the rules with the linguistic variables associated with
the output response for each rule are transferred to the
matrix.
WHAT IS BEING CONTROLLED AND HOW:

Figure 2 - Typical control system
response
Figure 2 shows what command and error look like in a
typical control system relative to the command setpoint
as the system hunts for stability. Definitions are also
shown for this example.
DEFINITIONS:
INPUT#1: ("Error", positive (P), zero (Z), negative (N))
INPUT#2: ("Error-dot", positive (P), zero (Z), negative
(N))
CONCLUSION: ("Output", Heat (H), No Change (-), Cool
(C))
INPUT#1 System Status
Error = Command-Feedback
P=Too cold, Z=Just right, N=Too hot
INPUT#2 System Status
Error-dot = d(Error)/dt
P=Getting hotter Z=Not changing N=Getting colder
OUTPUT Conclusion & System Response
Output H = Call for heating - = Don't change anything C
= Call for cooling
SYSTEM OPERATING RULES
Linguistic rules describing the control system consist
of two parts; an antecedent block (between the IF and
THEN) and a consequent block (following THEN). Depending
on the system, it may not be necessary to evaluate every
possible input combination (for 5-by-5 & up matrices)
since some may rarely or never occur. By making this
type of evaluation, usually done by an experienced
operator, fewer rules can be evaluated, thus simplifying
the processing logic and perhaps even improving the FL
system performance.

Figures 3 & 4 - The rule
structure.
After transferring the conclusions from the nine rules
to the matrix there is a noticeable symmetry to the
matrix. This suggests (but doesn't guarantee) a
reasonably well-behaved (linear) system. This
implementation may prove to be too simplistic for some
control problems, however it does illustrate the
process. Additional degrees of error and error-dot may
be included if the desired system response calls for
this. This will increase the rulebase size and
complexity but may also increase the quality of the
control. Figure 4 shows the rule matrix derived from the
previous rules.
SUMMARY
Linguistic variables are used to represent an FL
system's operating parameters. The rule matrix is a
simple graphical tool for mapping the FL control system
rules. It accommodates two input variables and expresses
their logical product (AND) as one output response
variable. To use, define the system using plain-English
rules based upon the inputs, decide appropriate output
response conclusions, and load these into the rule
matrix.