Page 237 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 237
214 Chapter 7 Arithmetic Operations
m
variables, then there can be as many as n rules to produce each output linguistic
variable, one to cover each case. That would be unattractive, but heuristics are used to
substantially reduce this number of rules using common sense.
But before the results can be applied, fuzzy outputs must be further processed, or
defuzzified, to produce a single output value that represents the combined effect of all of
the fuzzy outputs. In our example, a single output would be a numerical grade for the
course. The end result of the rule evaluation step is a collection of suggested or "raw"
fuzzy outputs. These values were obtained by plugging current conditions (fuzzy input
values) into the system rules in the knowledge base. The raw results cannot be supplied
directly to the system outputs because they may be ambiguous. For instance, one raw
output can indicate that a grade should be B+ with a degree of confidence of 50% while,
at the same time, another indicates that the grade should be C- with a degree of
confidence of 25%. A simple "max defuzzification" technique, which outputs the
maximum of all the degrees of confidence, ignores all other degrees of confidence, and
gives inferior results. A better defuzzification step resolves multiple-degree ambiguities
by combining the raw fuzzy outputs into a composite numerical output using
singletons. The singleton for a linguistic variable is a single value assigned to the
output variable if the rules produce this linguistic variable with a degree of confidence of
1, and all other linguistic variables have a degree of confidence of zero. For instance, the
singleton for A+ might be 100, the singleton for A might be 95, that for A- might be
90, and so on. Singletons Sj are weighted by fuzzy output degrees of confidence Fj, for n
such outputs, normalized to a degree of confidence of one, in the expression (19)
Figure 7.23 shows a 6812 fuzzy inference kernel. When the fuzzification step
begins, a MEM instruction fuzzifies the inputs. The current value of the system input is
in accumulator A, index register X points to the first membership function definition,
and a index register Y points to the first fuzzy input. As each fuzzy input is calculated by
executing a MEM instruction, the result is stored to the fuzzy input, and both X and Y
are updated automatically to point to the locations associated with the next fuzzy input.
For each system input, a DBNE instruction executes as many MEM instructions as a
system input has fuzzy input linguistic variables. Thus MEM and DBNE handle one
system input's fuzzification. Repeated such program segments handle each system input.
Each trapezoidal membership function is defined by four 8-bit parameters, XI, X2,
St, and S2. XI is where the trapezoid's left slope intercepts Y = 0, and X2 is where the
trapezoid's right slope intercepts Y = 0. SI is the trapezoid's left slope (AY/AX), and S2
is the trapezoid's right slope (-AY/AX), but a slope of 0 is defined as a vertical line.
More complicated membership functions can be evaluated by the TBL instruction,
which interpolates arbitrary table functions. A 16-bit version of TBL, ETBL, permits
handling 16-bit input variables and 16-bit degrees of confidence.
The rule evaluation step is likewise almost completely executed by the REV
instruction. Before it is executed, fuzzy outputs are cleared, index register X points to a
vector of the rules, Y points to the base address of fuzzy inputs and outputs, and
accumulator A is set for maximum ($FF). Each antecedent expression is represented as
an 8-bit relative offset from index register Y, to read an 8-bit fuzzy input. Antecedents are
separated from consequents with reserved "offset" value $FE. Each consequent expression