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

210                                         Chapter? Arithmetic Operations

        terminate after a fixed number of bits, so that some type of rounding must be done.
        Furthermore, assuming that the leading digit of the decimal fraction is nonzero, as many
        as three leading bits in the binary fraction may be zero. Thus, if one is using this step to
        convert to a binary floating-point number, probably 24 bits after the leading zeros should
        be generated with the 24th bit rounded appropriately. Notice that the multiplication by 2
        in this conversion process is carried out in decimal so that BCD arithmetic with the
        DAA instruction is appropriate here much like the CVBTD subroutine of Figure 7.9.
            The conversion of a binary floating-point number to a decimal floating-point
        number is a straightforward variation of the process above and is left as an exercise.
            This section covered the essentials of floating-point representations, arithmetic
        operations on floating-point numbers, including rounding, overflow, and underflow, and
        the conversion between decimal floating-point numbers and binary floating-point
        numbers. Hi Ware's C and C++ libraries illustrate subroutines for adding, subtracting,
        and multiplying single-precision floating-point numbers. This section and these libraries
        should make it easy for you to use floating-point numbers in your assembly language
        programs whenever you need their power.



        7,6 Fuzzy Logic


        This section, taken from the Motorola CPU 12 reference manual (Rev. 1), section 9,
        gives a general introduction to fuzzy logic concepts and illustrates an implementation of
        fuzzy logic programming. There are a number of fuzzy logic programming strategies;
        this discussion concentrates on the methods that use 6812 fuzzy logic instructions.
            In general, fuzzy logic provides for set definitions that have fuzzy boundaries rather
        than the crisp boundaries of Boolean logic. A Boolean variable is either true or false,
        while in fuzzy logic, a linguistic variable has a value that is a degree of confidence
        between 0 and 1. A value can be "0.2 (or 20%) confident." For a specific input value,
        one or more linguistic variables may be confident to some degree at the same time, and
        their sum need not be 1. As an input varies, one linguistic variable may become
        progressively less confident while another becomes progressively more confident.
            Fuzzy logic membership Junctions better emulate human concepts like "I got a B
        on the last quiz" than Boolean functions that are either absolutely true or absolutely
        false; that is, conditions are perceived to have gradual or fuzzy boundaries. Despite the
        term "fuzzy," a specific set of input conditions always deterministically produces the
        same result, just as in conventional control systems. Fuzzy sets provide a means of
        using linguistic expressions like "I got a B" in rules that can then be evaluated with
        numerical precision and repeatability. We will see that fuzzy membership functions help
        solve certain types of complex problems that have eluded traditional methods, as we
        study how fuzzy logic could compute a student's course grade from his or her quiz scores.
            An application expert, without any microcontroller programming experience, can
        generate a knowledge base. In it, membership functions express an understanding of the
        system's linguistic terms. And in it, ordinary language statement rules describe how a
        human expert would solve the problem. These are reduced to relatively simple data
        structures (the knowledge base) that reside in the microcontroller memory.
   228   229   230   231   232   233   234   235   236   237   238