Fuzzy Application Library/Technical Applications/Fuzzy Logic Design
Fuzzy Logic Design: Methodology, Standards, and Tools
by Constantin von Altrock
Citation Reference: This paper was published in Electronic Engineering Times in July 1996. The Fuzzy Logic Application Note series is published by Inform Software Corporation on its Internet server to promote the use of fuzzy logic technologies in applications.
When Lotfi Zadeh introduced the world to fuzzy logic in 1965, he forgot to include, or rather was unprepared to include a user's manual. Though he created fuzzy logic as a mathematical discipline that would allow designers create systems directly from human intuition and experience, the practice of actually applying it has for many years been a rather trial and error, arbitrary art. In other words, fuzzy logic's development methodology has remained a rather open issue. As a result, the initial users of fuzzy logic in real-world applications were intrepid researchers such as Abe Mamdani in the field of control engineering and Hans Zimmermann in business modeling. Today, this situation is much different. Fuzzy logic has become a commonly used technology and through the large number of successful applications development tools, as well as a development methodology, have evolved. The methodology has become part of an upcoming extension of an International Electrotechnical Commission standard (IEC 1131-3), providing designers with a guide through all steps of a fuzzy logic development project. With such standardized methodology, designers will be relieved from spending exuberant amounts of time experimenting with fuzzy logic before they can use it in their applications. Even better, designers will not need to study long and dry standards reports, because the upcoming generation of fuzzy logic design tools already incorporate much of this standardized methodology in their development environments.
1. Fuzzy Logic Development Tools
Because a key element of fuzzy logic is its characteristic trait which transforms the binary world of digital computing into a computation based on continuous intervals, true fuzzy logic must be emulated by a software program on a standard microcontroller/-processor. Initial attempts at this software emulation proved to be very inefficient. Even a small fuzzy logic system required approximately one second to compute on a standard 8051 microcontroller. For most real-time control applications, this was much too slow. Some vendors looked into hardware acceleration of fuzzy logic by designing fuzzy coprocessors. Today, such hardware acceleration devices are available from many vendors including Fujitsu, Siemens, SGS-Thomson, and VLSI. While fuzzy coprocessors can compute fuzzy logic systems in only fractions of a millisecond, a coprocessor design can be much more expensive than a software-only solution on a standard microcontroller.
How can you get both high performance and low cost at the same time? In 1992, Intel Corp.'s microcontroller group teamed up with Inform Software Corp., a U.S./German software firm that has pioneered the fuzzy logic development tool market with its "fuzzyTECH microkernel" software architecture that provides implementations of fuzzy logic much more efficiently than previous emulation technologies. Now, the same example of a small fuzzy logic system running on a standard 8051 requires about one millisecond to compute, an acceleration of about 1000 times. This computational performance is sufficient for many real-time control systems, and renders the use of expensive fuzzy coprocessors unnecessary in most applications. Since 1992, the fuzzyTECH microkernel solution has been licensed by most other MCU vendors including Microchip, Texas Instruments, Siemens, SGS-Thomson, Mitsubishi, and Motorola. Table 1 shows computing performance figures for fuzzy logic systems of various sizes. The fuzzy logic systems used for this benchmarking range from a simple position controller (Bench0) to one of the most complex fuzzy logic embedded systems ever implemented (Bench4); consisting of 500 rules, 8 input, and 4 output variables. The source code for these benchmarks can be downloaded from this site.
2 In / 1 Out
2 In / 1 Out
|20 FAM Rules
2 In / 1 Out
|80 FAM Rules
3 In / 1 Out
|500 FAM Rules
8 In / 4 Out
|8051: fuzzyTECH MCU-51 Edition, assembly code generation, 8 bit resolution, test device 80C51, 12 MHz||1.0 ms
0.45 KB ROM
0.54 KB ROM
0.58 KB ROM
1.0 KB ROM
3.0 KB ROM
|M37XXX: fuzzyTECH MCU-37XXX Edition, assembly code generation, 16 bit resolution, test device M37400||0.8 ms
0.61 KB ROM
0.76 KB ROM
0.77 KB ROM
1.3 KB ROM
3.9 KB ROM
|PIC16C5X:fuzzyTECH MCU-MP Edition, assembly code generation, 8 bit resolution, test device PIC16C74, 20 MHz||0.4 ms
0.32 KB ROM
0.41 KB ROM
0.44 KB ROM
0.7 KB ROM
2.2 KB ROM
|80C196: fuzzyTECH MCU-96 Edition, assembly code generation, 16 bit resolution, test device 80C196KD, 20 MHz||0.19 ms
0.63 KB ROM
0.69 KB ROM
0.78 KB ROM
1.17 KB ROM
3.47 KB ROM
|TMS-320: fuzzyTECH MCU-320 Edition, assembly code generation, 16 bit resolution, test device TMS-320C52/ 20 ns||0.020 ms
0.85 KB ROM
0.99 KB ROM
1.06 KB ROM
1.8 KB ROM
5.7 KB ROM
|PC: fuzzyTECH Precompiler Edition, C code generation, 16 bit resolution, test device 80486SX, 33 MHz, MS-C 8.00||0.05 ms
0.73 KB OBJ
0.82 KB OBJ
0.89 KB OBJ
1.27 KB OBJ
3.5 KB OBJ
Table 1. Comparison of Computing Performance and Memory Requirement for Different Fuzzy Logic Systems
How does the fuzzyTECH microkernel accomplish an increase in software computational efficiency of 1000 times? The key is to incorporate as many computational steps as possible into the fuzzy compiler, thus the microcontroller must compute very little at runtime. For example, at compile time, fuzzyTECH clusters the rule base into segments, requiring the microcontroller to evaluate only a small fraction of the rule base at runtime. In the a case of a rule base containing 500 rules, the microcontroller first determines which of the segments contain rules that apply to the current input conditions. This can reduce the number of rules that need to be evaluated at runtime to perhaps 100. Rules that do not apply to the current input conditions in the fuzzy computation do not influence the result and would only add unnecessary cycles to the fuzzy computation. In another step, the microcontroller determines which of the rules are dominated by others. These dominated rules also play no part in influencing the result and are thus eliminated from the computation as well. This subsequent step can reduce the number of rules that must be computed at runtime to around 25, sometimes fewer. Typically, only 5% of the rules in a fuzzy logic system actually need to be computed. This two-step determination of a rule segment, containing the influencing rules before actually computing an inference result, is quite fast at runtime because it uses a segmentation made at compile time.
Another key technique implemented in the fuzzyTECH microkernel is resolution analysis. In a microcontroller implementation of fuzzy logic, computations in the defuzzification step often consume most of the total inference time. This occurs because a straightforward implementation of the defuzzification in 8-bit resolution involves a 32-bit by 16-bit division. By analyzing the information flow in a fuzzy logic system during compilation, the fuzzyTECH development software can split up the final 32/16 bit division into a number of 8/8 bit divisions before the defuzzification and one 16/8 bit division afterwards. This operation is considerably faster, yet delivers the same accuracy.
Hence, the major reason for the fast execution of fuzzy logic on standard microcontrollers using the fuzzyTECH microkernel techniques lies in the identification and definition of intelligent shortcuts during compile time on the development PC. Because even very small modifications of the fuzzy logic system definition may require completely different shortcuts, this analysis must be performed by the fuzzyTECH compiler on each compile. This analysis is what makes hand-coding the fuzzy logic algorithm is so impractical. Any time even a small modification of the fuzzy logic system is made by the designer, very significant modifications in the assembly code may become necessary.
|Figure 1. Fuzzy Design Wizards in fuzzyTECH Guide Designers Through All Major Steps of Standard Development Methodology large|
Not only do tools like fuzzyTECH provide optimal implementations of fuzzy logic, they also speed system design by relieving the developer from writing fuzzy logic code. The more advanced tools available today incorporate extensive GUIs which not only provide the developer with a graphical representation of the system structure, but also highly interactive optimization tools to help the user gain a deeper understanding of how their inference is computing a given solution. If designers are to create fuzzy systems which draw on intuition and experience, they are best served by tools which provide informative feedback to help them understand the details of the fuzzy logic inference process.
2. Development Methodology
The fuzzy logic development methodology as currently under standardization involves five steps:
1. Specification of linguistic variables
2. Definition of inference structure
3. Formulation of fuzzy rules
4. Off-line analysis, testing and verification
5. On-line optimization
A fuzzy logic system implements a control strategy by "if-then" fuzzy rules that use fuzzily defined expressions such as "pretty_low" or "relatively_high". The specification of these expressions is provided by the linguistic variables. More succinctly, the linguistic variables are the "vocabulary" that the fuzzy rules use to express the strategy. State-of-the art fuzzy logic software development tools automate the specification of linguistic variables and automatically generate the documentation of the design process. For example, fuzzyTECH features the Fuzzy Variables Wizard that creates the complete definition of linguistic variables based on the standardized development methodology.
Many fuzzy logic systems consist of multiple components. For example, one component may estimate a process variable for which a sensor does not exist by utilizing related input signals. Based on this fuzzy estimation and other inputs, another component could define the actual control strategy. Each component of a fuzzy logic system contains a subset of the complete fuzzy rule set and is thus called a "rule block". To connect rule blocks to each other, intermediate linguistic variables are used. Because these variables are never fuzzified or defuzzified, no membership functions are required. Connecting rule blocks with input, output, and intermediate linguistic variables defines the inference structure of the fuzzy logic system. State-of-the-art fuzzy logic development tools support visual definition of this inference structure (Figure 2).
The rule blocks in the fuzzy logic design contain the actual control strategy. Fuzzy rule design falls into two steps. The first is the formulation of initial rule blocks, and the second is to optimize the rules based on analysis and testing in the last two design steps. The formulation of initial rule blocks in fuzzyTECH is made easier by the Fuzzy Rule Wizard that uses a structured audit approach to create complete rule blocks automatically.
While the first three steps of a fuzzy logic development - definition of variables, structure, and rules - are the design phase of the development, the next two steps cover the debugging phase. In the debugging phase, analyzers and editors are used to visualize the computation of the fuzzy logic inference. For example, the fuzzy rules are checked for consistency and completeness. In interactive debugging, the designer simulates specific input conditions for the fuzzy logic system and evaluates its reaction. If the performance is not satisfactory, the analyzers point the designer toward the respective rules and variables that require tuning. Depending on the application, process simulations and recorded process data may also be used in this fourth development step.
|Figure 2. Analyzer and Editor Windows in fuzzyTECH During System Optimization large|
In some applications, the final tuning and verification of the fuzzy logic system can only be completed when the fuzzy logic system controls the process in real time. A technique known as "on-line" debugging lets designers connect the microcontroller to the PC running fuzzyTECH by a serial cable or in-circuit emulator. The designer may then conduct the same analyses on-line that were performed off-line in the previous development step. By optimizing linguistic variables and fuzzy rules "on-the-fly", the reaction of the process under control relative to the modified fuzzy logic controller can be studied.
3. ISO 9000 Compliant Development
As previously discussed, today's fuzzy logic development tools already provide support of the standard development methodology which should let designers create well-structured solutions right from the beginning. However, using a standard development methodology is only one of two significant development issues. What remains is standard documentation. As more and more companies become ISO 9000 certified, comprehensive documentation of developed systems becomes a key requirement for most designers. Here is where tomorrow's fuzzy logic development tools will further support the designers.
Documentation standards, as set fourth by the ISO 9000, not only cover the design itself, but all design modifications as well. However, with most industrial designs, even if the documentation was accurate at the time of system completion, after a number of quick last minute modifications under the pressure of a development schedule, the once clear documentation can become inaccurate and confusing for those who follow.
|Figure 3. fuzzyTECH's Built-in Documentation Generator Exports the Complete Documentation Report into MS-Word large|
For these reasons, tomorrow's fuzzy logic development tools will integrate a documentation component combined with a revision control system. Because the development tool automatically records design decisions and design changes during development, it automatically generates a complete system documentation and modification report. For example, fuzzyTECH outputs this documentation directly to a standard word processor, such as MS-Word, where it can be printed directly or be further formatted and expanded as necessary.