Page 238 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 238

7,7 Summary                                                         215


        is represented as an 8-bit relative offset from index register Y, to write an 8-bit fuzzy
        output. The consequents end with a reserved value $FE, if more rules must be evaluated,
        or $FF, after the last rule is evaluated. The condition code V signifies whether
        antecedents are being processed (V = 0) or consequents are being processed (V = 1).
            Besides REV, the more complex REVW instruction allows each rule to have a
        separate weighting factor, and EMIND and EMAXD can be used to implement 16-bit
        rule evaluation.
            The WAV instruction calculates the numerator and denominator sums for weighted
        average of the fuzzy outputs. Before executing WAV, accumulator B must be loaded with
        the number of iterations, index register Y must be pointed at the list of singleton
        positions in the knowledge base, and index register X must be pointed at the list of fuzzy
        outputs in RAM. If the system has more than one system output, the WAV instruction
        is executed once for each system output. The final divide is performed with a separate
        EDIV instruction placed immediately after the WAV instruction.
            The EM ACS instruction can be used to evaluate 16-bit linguistic variables. A
        separate but simple program segment must calculate the sum of linguistic variables,
        which is automatically calculated by the WAV instruction.
            The 6812 is currently the only microcontroller that has machine instructions that
        can be used to implement the complete fuzzy inference kernel. These machine
        instructions speed up execution of the kernel by a factor of about 10 over software
        evaluation that uses ordinary instructions. This feature makes the 6812 the
        microcontroller of choice for time-critical applications that use fuzzy logic.
            In conclusion, fuzzy logic provides fuzzy rather than crisp boundaries. Linguistic
        variables indicate a degree of confidence. Combinations of variables are presumed to be
        true to the worst-case (minimum) degree of confidence, and alternatives are presumed to
        be true to the best-case (maximum) degree of confidence. Final values are weighted sums
        of typical values, using degrees of confidence as weights. Such fuzzy logic systems are
        currently being applied to automotive control and other rather complex control systems,


        7.7 Summary

        This chapter covered the techniques you need to handle integer and floating point
        arithmetic in a microcontroller. We discussed the conversion of integers between any two
        bases and then discussed signed and unsigned multiple precision arithmetic operations
        that had not been discussed in earlier examples. Floating-point representations of
        numbers with a fractional part, and the algorithms used to add and multiply floating-
        point numbers, were discussed together with the problems of rounding and conversion.
        The IEEE standard floating-point format was used throughout these discussions. We
        ended with the use of the stack for holding the arguments for arithmetic subroutines and
        showed how you can write a sequence of subroutine calls to evaluate any formula.
            You should now be able to write subroutines for signed and unsigned arithmetic
        operations, and you should be able to write and use such subroutines that save results on
        the stack. You should be able to convert integers from one representation to another and
        write subroutines to do this conversion. You should be able to write numbers in the
        IEEE floating-point representation, and you should understand how these numbers are
        added or multiplied and how errors can accumulate.
   233   234   235   236   237   238   239   240   241   242   243