345
User’s Manual for all fuzzyTECH 5.3 Editions July 15, 1999 fuzzyTECH ® is a registered trademark of INFORM GmbH Inform Software Corporation ©1999 INFORM GmbH / Inform Software Corp. All rights reserved.

ft531manual

Embed Size (px)

Citation preview

Page 1: ft531manual

User’s Manual for allfuzzyTECH 5.3 Editions

July 15, 1999

fuzzyTECH® is a registeredtrademark of INFORM GmbHInform Software Corporation

©1999 INFORM GmbH /Inform Software Corp.All rights reserved.

Page 2: ft531manual

II

© INFORM GmbH / Inform Software Corporation, 1986-1999

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmittedin any form or by any means – mechanical, electronic, photocopying, recording, or otherwise – without theprior written permission of Inform Software Corporation. fuzzyTECH® is a registered trademark of INFORMGmbH and Inform Software Corporation.

Page 3: ft531manual

III

“It is the mark of an instructed mind to rest satisfied with that degree of precision whichthe nature of the subject admits, and not to seek exactness where only an approximation ofthe truth is possible.”Aristotle, Ancient Greek Philosopher

“Precision is not truth.”Henri Matisse, Impressionist Painter

“So far as the laws of mathematics refer to reality, they are not certain. And so far as theyare certain, they do not refer to reality.”Albert Einstein, Mathematician and Physicist

“In almost every case you can build the same product without fuzzy logic, but fuzzy isfaster and cheaper.”Prof. Lotfi Zadeh, UC Berkeley, Inventor of Fuzzy Logic

“Fuzzy logic lets you focus on solving the problem rather than how to solve the problem.”Wayne Needham, Strategic Project Program Manager, Intel Corporation

“Today, a prerequisite for fast, competent fuzzy logic based solutions is software tools thatare both user-friendly and scientifically cutting edge. fuzzyTECH is such a tool.”Prof. Zimmermann, RWTH Aachen, Founding President of the International Fuzzy Systems Association,Principal Editor of Fuzzy Sets and Systems Journal

Page 4: ft531manual

IV

The fuzzyTECH User’s Manual is divided into the following chapters:

Chapter 1 provides an overview of the basic features of the fuzzyTECHdevelopment system. Make yourself familiar with the fuzzyTECH developmentstrategy by using the animated simulation included in the purchased software.

Chapter 2 describes the setup procedure of an online connection betweenfuzzyTECH and a runtime module as fuzzy system. The steam generatorsimulation serves as example for a runtime module.

Chapter 3 explains individual design steps for the development of fuzzy-logicbased systems and describes the fuzzyTECH design and optimization tools.

Chapter 0 guides you through the development of NeuroFuzzy systems. In thefirst part of this chapter a NeuroFuzzy system is developed using the FuzzyDesign Assistant and trained with fuzzyTECH’s NeuroFuzzy module. Thesecond part explains individual design and optimization steps for NeuroFuzzysystems and describes fuzzyTECH’s cluster modules.

Chapter 5 gives a brief introduction to the theory of Fuzzy Logic andNeuroFuzzy and explains the basics of adaptive systems.

Chapter 6 introduces the fuzzyTECH code generation functions. Integration ofC-code, M-code and ASM libraries are explained. Moreover, it shows how fuzzylogic systems are implemented and how the fuzzy computation kernel infuzzyTECH can be used for your application.

Chapter 7 explains the implementation of new components which are integratedas user defined extensions into the open interfaces of fuzzyTECH.

Chapter 8 contains a glossary, in which essential and frequently usedterminology is explained.

Chapter 9 is regarded as an appendix that contains reference sections on varioustopics, such as installation guidance, memory sizes, files and dictionaries, anoverview on the technical restrictions of all fuzzyTECH editions, contactaddresses for support, and a keyword index allowing quick access to certainsubjects and the license agreement.

Page 5: ft531manual

V

Figures Depending on the options enabled in fuzzyTECH, such window elements asstatusbars, toolbars, list boxes and others may be visible or invisible. Hence, thewindows depicted as screen shots on the following pages may look slightlydifferent from those you see while working with fuzzyTECH.

Conventions In order to ease your understanding of tool descriptions and the instructions,please notice the following conventions:• All filenames are spelled in caps, such as: CRANE.FTL, SETUP.EXE,...• Keys to press are expressed in [brackets]. All user inputs to fuzzyTECH and

the process simulations are put in quotation-marks. Furthermore, the firstletter of a word is capitalized to emphasize that it is a name of a dialog orfield or another entry in one of the fuzzyTECH windows. Such wordsreferring to certain program entries are often put into quotation-marks, too.

• fuzzyTECH uses both the left and the right mouse buttons. “Clicking” or“double clicking” always refers to the left mouse button. Activities with theright mouse button are referred to as “click right” or “double click right.”

• The “main menu” is the upper menu bar in the main window of fuzzyTECH.Activation (clicking) of main menu entries opens a pull down menu for theentry. This pull down menu lists the available functions for the entry. Theseoptions in the main menu are referred to by path names. For example,“File/Open” refers to the option “Open” of the main menu entry “File”.

• In general, clicking with the left mouse button activates pointed elements;double clicking with the left mouse button activates functions for theelement. In fuzzyTECH, the right mouse button is only used for activating“pop-up” menus in some windows. Click right in one of fuzzyTECH’swindows and select the option with the left mouse button to activate a pop-upmenu. The pop-up menus contain functions and options that are availableonly for the associated window. In most windows, these functions andoptions are also accessible through toolbars. You can enable or disabletoolbars through the option Toolbars in the View menu. The way of usingmouse buttons and clicks is similar to most other MS Windows software,such as MS Word or MS Excel.

• Refer to the glossary (Chapter 8) to find explanations for frequently used keywords.

Page 6: ft531manual

VI

1. Getting Started with fuzzyTECH: The Crane Simulation.......................................................................9

2. Online Debugging the Steam Generator Drum Simulation ..................................................................30

3. Designing Fuzzy Logic Systems ...............................................................................................................423.1. First steps ...........................................................................................................................................47

3.1.1. Rapid Application Development with the Fuzzy Design Wizard ...........................................483.1.2. System Definition....................................................................................................................53

3.1.2.1. Structure of a Fuzzy Logic System ..............................................................................533.1.2.2. Editing Objects.............................................................................................................533.1.2.3. Definition of Text Objects ...........................................................................................553.1.2.4. Defining Linguistic Variables ......................................................................................563.1.2.5. Defining Membership Functions..................................................................................643.1.2.6. Defining Rule Blocks...................................................................................................703.1.2.7. Formulation of Fuzzy Rules.........................................................................................75

3.1.3. Optimization and Debugging ..................................................................................................853.1.3.1. Off-line Debug Modes .................................................................................................873.1.3.2. Online Debug Modes ...................................................................................................873.1.3.3. Switching into Debug Mode ........................................................................................883.1.3.4. Test System Performance Using Data..........................................................................893.1.3.5. fuzzyTECH Analyzers ..................................................................................................933.1.3.6. Online Optimization...................................................................................................1013.1.3.7. Connecting fuzzyTECH to other Applications ...........................................................107

3.1.4. fuzzyTECH Documentation and Revision Control System ...................................................1083.1.4.1. Project Information ....................................................................................................1093.1.4.2. Documentation Generator ..........................................................................................1103.1.4.3. Revision Control System ...........................................................................................110

4. NeuroFuzzy Design .................................................................................................................................1144.1. First steps .........................................................................................................................................114

4.1.1. Generating a Fuzzy XOR System by the Fuzzy Design Wizard...........................................1144.1.2. NeuroFuzzy Training of Fuzzy Systems: The XOR Example ..............................................116

4.2. NeuroFuzzy System Design.............................................................................................................1234.2.1. Clustering with fuzzyTECH...................................................................................................135

5. Fuzzy Primer ...........................................................................................................................................1465.1. Fuzzy Logic......................................................................................................................................147

5.1.1. History...................................................................................................................................1475.1.2. Types of Uncertainty .............................................................................................................1495.1.3. Fuzzy Logic Technologies ....................................................................................................155

5.2. Computing Fuzzy Systems...............................................................................................................1655.2.1. Fuzzification..........................................................................................................................1665.2.2. Fuzzy Rule Inference.............................................................................................................171

Page 7: ft531manual

VII

5.2.3. Defuzzification ......................................................................................................................1735.3. NeuroFuzzy Technologies ...............................................................................................................176

5.3.1. Basics of Adaptive Systems ..................................................................................................1765.3.2. Combining Neural and Fuzzy................................................................................................183

5.4. Computing NeuroFuzzy Training ....................................................................................................1855.4.1. Learning Fuzzy Rules............................................................................................................1875.4.2. Learning Fuzzification and Defuzzification..........................................................................190

5.5. Data Clustering ................................................................................................................................192

6. Implementing Fuzzy Runtime Systems.................................................................................................2006.1. Using fuzzyTECH Code Generators ................................................................................................200

6.1.1. fuzzyTECH Runtime Control (ActiveX) ...............................................................................2026.1.2. fuzzyTECH Runtime DLL (FTRUN.DLL)............................................................................203

6.1.2.1. FTRUN API ...............................................................................................................2056.1.2.2. FTRUN Integration Using Software Development Tools..........................................2076.1.2.3. FTRUN Integration in Standard Software .................................................................2096.1.2.4. FTRUN Configuration ...............................................................................................209

6.1.3. Hardware Specific Code........................................................................................................2106.1.3.1. MCU-ST6 Edition......................................................................................................2106.1.3.2. MCU-MP Edition.......................................................................................................2136.1.3.3. MCU-51 Edition ........................................................................................................222

6.1.3.3.1. Fuzzy Library............................................................................................2226.1.3.3.2. RTRCD Communication Module .............................................................2236.1.3.3.3. Generating and Using the Assembler Module ..........................................2236.1.3.3.4. Building an Executable File ......................................................................228

6.1.3.4. MCU-374 Edition ......................................................................................................2306.1.3.5. MCU-96 Edition ........................................................................................................236

6.1.3.5.1. Fuzzy Library............................................................................................2376.1.3.5.2. RTRCD Communication Module .............................................................2376.1.3.5.3. Using the Generated C Module.................................................................2386.1.3.5.4. Building an Executable File ......................................................................244

6.1.3.6. MCU-166 Edition ......................................................................................................2456.1.3.6.1. Fuzzy Library............................................................................................2466.1.3.6.2. RTRCD Communication Module .............................................................2466.1.3.6.3. Using the Generated Assembler Module ..................................................2466.1.3.6.4. Building an Executable File ......................................................................251

6.1.3.7. MCU-320 Edition ......................................................................................................2526.1.3.8. MCU-HC05/08 Edition..............................................................................................258

6.1.3.8.1. Fuzzy Library............................................................................................2586.1.3.8.2. RTRCD Communication Module (only for M68HC08)...........................2596.1.3.8.3. Using the Generated Assembler Module ..................................................2596.1.3.8.4. Building an Executable File ......................................................................264

6.1.3.9. MCU-HC11/12 Edition..............................................................................................2676.1.3.9.1. Fuzzy Library............................................................................................2676.1.3.9.2. RTRCD Communication Module .............................................................2686.1.3.9.3. Using the Generated Assembler Module ..................................................2696.1.3.9.4. Building an Executable File ......................................................................274

Page 8: ft531manual

VIII

6.1.3.10.IA-S5 Edition .............................................................................................................2756.1.4. Portable C Code ....................................................................................................................278

6.1.4.1. Building the fuzzyTECH C Runtime Library .............................................................2796.1.4.1.1. Preprocessor Definitions ...........................................................................280

6.1.4.2. Using the Generated Module .....................................................................................2816.1.4.3. Online Communication Module.................................................................................2906.1.4.4. Compiling and Linking ..............................................................................................2916.1.4.5. Examples....................................................................................................................292

6.1.5. COBOL Code........................................................................................................................2936.1.5.1. COBOL Runtime Library ..........................................................................................2946.1.5.2. Using the Generated Sub-Program.............................................................................2946.1.5.3. Example .....................................................................................................................295

6.1.6. M Code..................................................................................................................................2966.2. Using fuzzyTECH as Server .............................................................................................................297

6.2.1. DDE.......................................................................................................................................2986.2.1.1. fuzzyTECH as DDE Server ........................................................................................2986.2.1.2. fuzzyTECH as DDE Client .........................................................................................300

6.2.2. fuzzyTECH Remote Control Unit (RCU) ..............................................................................3016.2.2.1. C Code .......................................................................................................................3026.2.2.2. MS Excel....................................................................................................................3106.2.2.3. MS VisualBasic..........................................................................................................312

6.2.3. Serial Link .............................................................................................................................315

7. User Extensions of the fuzzyTECH Shell ..............................................................................................3187.1. NeuroFuzzy: User Defined Learn Methods .....................................................................................318

7.1.1. Compile and Register a DLL.................................................................................................3187.1.2. Code Example .......................................................................................................................319

7.2. Online: Implementing User Defined Communication Channels .....................................................321

8. Glossary....................................................................................................................................................323

9. Appendix ..................................................................................................................................................3259.1. Software Installation ........................................................................................................................3259.2. Memory Size ....................................................................................................................................3279.3. Directories and Files ........................................................................................................................3289.4. Features Overview ...........................................................................................................................3329.5. Support Contact................................................................................................................................3379.6. Index ................................................................................................................................................3389.7. License Agreement ..........................................................................................................................342

Page 9: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

9

This first chapter guides you through the first steps you make with fuzzyTECH.Use a built-in crane simulation to:• Get immediate, “hands-on” experience with fuzzy logic by manually

controlling the simulation.• Evaluate solution performance using the fuzzyTECH analyzers.• Test a given control strategy with the built-in simulation.

Tools’ Overview The description of the fuzzyTECH functionality in this section is very brief andcovers only the most important features pertinent to the crane simulations. Referto fuzzyTECH’s integrated help system for a detailed description of all tools,windows and dialogs. You can activate the help system either by pressing the[F1] key or utilizing the “Help” entry in the main menu.

The individual design steps are explained in Chapter 3 in more detail. The basicsof fuzzy logic theory are explained in Chapter 5. If you are not familiar with theconcepts of fuzzy logic, please read this section before proceeding. Thefollowing description has been structured so that you can follow it in parallel onyour PC.

Disabled Features Depending on your fuzzyTECH Edition, you may find options disabled or menuentries depicted in the screen shots that are missing in your fuzzyTECH Edition.Section 9.4 gives a complete function overview of all fuzzyTECH Editions.

fuzzyTECHProgram Group The installation procedure of your fuzzyTECH Edition creates a new entry in the

MS Windows Start menu. You can find the new program group by clicking the button, pointing then to [Programs] and to the folder [fuzzyTECH xxx].

Figure 1 shows this program group. The “fuzzyTECH” option starts thefuzzyTECH Shell. The other options start the process simulations and open thehelp files. Click on “READ ME FIRST” to view the most up-to-date informationabout the software.

Page 10: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

10

Figure 1: The Setup Routine Automatically Creates the fuzzyTECHProgram Group in the Program Menu.

Start the ContainerCrane Simulation

First, start the container crane simulation by clicking the cranesymbol in the fuzzyTECH program group.

Figure 2 shows the crane simulation window. The container (yellow) is alreadypicked up from the ship (red). It must be positioned over the truck (green).

Process Values The box visible in the lower part of the crane simulation window shows the up-to-date values for the variables Angle, Distance and Power. The values of Angleand Distance are computed by the process simulation, while Power is the controlvariable either set manually or by the fuzzy logic controller. Enable the manualcontrol mode by clicking the [Manual] button. The Distance is more than 20yards, while Angle and Power are zero.

Manual Control Use the [-], [0] and [+] buttons to control the Power. First, click once or twice onthe [+] button. This sets the motor power either to 0.75 or 1.5 kilowatts. The jerkcaused by this makes the Angle oscillate lightly, but is not sufficient to put thecrane in motion due to the friction in the mechanical system. At least 3 kilowattsmotor power is required to set the crane head in motion. Now, further increasethe motor power by clicking on the [+] button again. The [0] button resets themotor power setting to zero and the [-] button lets you apply negative motorpower for braking. You can also use the [-], [0] and [+] buttons on yourkeyboard. The [Reset] button sets the crane to its start position..

Control Strategy When you start the crane with very high motor power, you see that, due to thelarge weight of the container, the “container drives the crane” rather than viceversa. This strong feedback of the load to the drive is typical for containercranes, and it causes one of the major difficulties for the control of suchprocesses.

Page 11: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

11

Figure 2: Watch and/or Control the Container Crane in Operation in the CraneSimulation Window. The Control Buttons Let You Either Operate the Crane

Manually or Establish a Link to fuzzyTECH for Automatic Operation.

A Crane Operator The crane operator must position the container over the truck, so that thecontainer can be released. The container must not sway as releasing a swayingcontainer could damage its contents. There exist two simple strategies to positionthe container without swaying over the truck. One is to move the crane headslow enough to prevent any sway of the container. Since you are safe from windgusts with the software simulation of the crane, this certainly works. However, itmay take a long time to reach the target. The other simple strategy is to start withfull power, position the crane head over the target position and wait until thecontainer stops swaying. This works since the sway is of no harm duringtransportation and there are no wind gusts. However, it also takes far too muchtime. Both of these simple strategies are not practical for container cranes. Theopportunity costs of a container ship tied up in a harbor go into thousands ofdollars each hour. Hence, loading and unloading must be completed within aminimum amount of time. Only an anti-sway control strategy of the containercrane operator can achieve this. Try this yourself: start with medium power. Ifyou apply full power right from the start, the container starts to sway verystrongly and takes a long time to stabilize later. If the container sways a littlebehind the crane, you can further increase the power because this situation isstable. The increased power gets the container to the target faster. Watch thecontainer as it moves. If it sways ahead of the crane head, increase the power.This reduces the sway and returns the container to a stable position. It alsomoves the container to the target position faster. If it sways too far back,decrease power to reduce the sway as it is harder to reduce a large sway later.Section 5.1.3 contains more details on crane controller engineering.

Page 12: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

12

Start fuzzyTECH Start your fuzzyTECH Edition first in order to use the pre-defined fuzzy logiccontroller for the container crane simulation. Click the entry “fuzzyTECH xxx”in the Start menu.

fuzzyTECH Shell fuzzyTECH’s main window contains two sub-windows: the “Treeview” and the“Project Editor” window (Figure 3). Both windows can never be closed infuzzyTECH nor can a second set of these windows be opened. However, use thesystem icon to minimize the Project Editor and the symbol to hide or showthe Treeview (see also Viewing Options, page 46).

Figure 3: Main Window of a fuzzyTECH Edition After Start-Up.

Both windows gives an overview of the project’s structure. While the ProjectEditor shows more the relations between all objects of the project, the Treeviewdisplays the hierachic structure of the fuzzy logic system. Similar to the MSWindows Explorer, the Treeview lists all objects as well as the current debugmode or the analyzers used, allowing thus quick access for editing them or thewhole project (see Section 3.1.2.2). Clicking one of the object groups showsfurther sub-groups of components belonging to the corresponding type of object.

Main Menu Bar The main menu bar is part of the main window of fuzzyTECH and containsvarious pull down menus with numerous options, some of which contain furthermenus or dialogs. Note, not all options are available in all editions (see 9.4).Some options, e.g. the NeuroFuzzy option in the main menu Tools, are generatedby add-on modules that might not be included in the standard installation of yourfuzzyTECH edition. Those options are indicated by gray font color. If somemenu items, e.g. the Debug or Analyzer menu, appear in such a gray color - thenthey are deactivated. They need certain prerequisites for being accessible. Referto the fuzzyTECH Help in such cases (“Help/fuzzyTECH Help”). All menuentries are accessible by shortcuts, press the [Alt] key together with theunderlined letter of the respective function. This mechanism is based onWindows conventions. Hardware dedicated packages may generate additionalmenu items that are explained later in this manual (e.g. the FUZZY-166package). For each menu entry, the edition required and other preconditions foruse of this entry are listed. If these paragraphs are missing, either there are nopreconditions or the item is available in all editions.

Page 13: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

13

Main Toolbar The toolbar of the main window provides quick access to most frequently usedfuzzyTECH commands. Note that some editor and analyzer windows have theirown toolbar. Because of this, the toolbars can only be enabled or disabled, butnot be customized. If a symbol appears as deactivated in gray color, then eitherthe preconditions to call this function are insufficient (e.g. a debug mode has tobe active to open an analyzer) or the respective function is not available for yourfuzzyTECH edition (see Section 9.4).

Statusbar At the lower border of the main fuzzyTECH window, a gray bar displaysinformation about current settings, selected commands, modes or about anoperation in progress. The statusbar consists of three fields. The left fieldindicates basic operations of fuzzyTECH, such as loading, saving, or codegeneration. When fuzzyTECH is idle, this field displays “Ready”. The left fieldhas a second function: when the mouse pointer moves over a button of thetoolbar, the left field displays a short description of button’s function. The rightfield of the statusbar always displays the current debug mode. Upon start offuzzyTECH, no debug mode is active and thus the right field displays “DesignMode”. The middle field displays the progress of complex fuzzyTECHoperations, such as loading, saving or the current state of a data transmission.

Load the ContainerCrane Controller Open the File menu either by clicking on the entry “File” in the main menu bar

or the shortcut [Alt] + [F]. This menu contains all functions for opening andsaving files, as well as related functions. Select the option “File/Open” and openthe file “CRANE.FTL” located in the subdirectory“...\SAMPLES\CONTROL\CRANE\”. You may also click on the file name inthe lower part of the File menu, if it is displayed there. Here, the most recentlysaved files are automatically listed for quick reload. The installation routine pre-sets this list. This option can be deactivated in “Tools/fuzzyTECHPreferences/General” by clicking the checkbox of “Recently Used File List”.

While fuzzyTECH opens a project, the middle field of the statusbar displayswhich component of the fuzzy logic controller is currently loaded. Depending onthe speed of your PC, this may be too fast to follow. At the end of the loadingprocedure, fuzzyTECH’s Project Editor and Treeview window display thestructure of the crane controller (Figure 4).

All linguistic variables of the crane controller are listed in the Treeview window.Double-click on the group Input Variables, Output Variables or IntermediateVariables to see all of the project’s variables. “Angle” and “Distance” are theoutput variables (measured variables) of the crane simulation and, hence, theinput variables of the fuzzy logic controller. Power is the input variable(command variable) of the crane simulation and, hence, the output variable of thefuzzy logic controller. There are no intermediate variables in this project.Linking the respective inputs and outputs of the crane simulation and the fuzzylogic controller yields a closed control loop.

Page 14: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

14

Figure 4: After Loading the Project CRANE.FTL, Project Editor and TreeviewShow the Controller’s Structure.

Use fuzzyTECH as serverfor Simulations The Design Mode of fuzzyTECH is where you develop the fuzzy logic controller.

Since you have loaded the already developed controller in the file CRANE.FTL,you can start directly debugging and testing, using fuzzyTECH as server that canbe remote-controlled by an external simulation program. Link the controller tothe simulation by selecting the [Fuzzy] button in the crane simulation. For ashort time, the left field of the statusbar displays “Loading Knowledge Base...”.During this period, fuzzyTECH builds an internal representation of the currentfuzzy logic controller. The middle field of the statusbar shows the progress.After successful completion, the left field of the statusbar shows “Ready” again.The right field of the statusbar now shows the active debug mode: “Debug: RCUDebug Mode”. In addition, a new window titled “Watch: RCU” (Figure 5)opens. This window always shows the current values of all input and outputvariables of the fuzzy logic controller.

Figure 5: The Watch Window Is Active in Any Debug Mode and Always Showsthe Current Values of Input and Output Variables.

Use Either the edit field Value beside the Watch window’s toolbar or the sliderto change the value of the selected variable. Minimize this window by clickingthe system icon to expedite the simulation on slow PCs.

Page 15: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

15

Remote Control Unit If you activate a simulation or another window’s application that uses the“Remote Control Unit” (RCU), a DLL (FTRCU.DLL or FTRCU32.DLL) is usedby the application that has access to several functions of fuzzyTECH. In addition,the RCU DLL starts up fuzzyTECH if fuzzyTECH is currently not activated.After start up, the match between an assumed project and the project currentlyloaded in fuzzyTECH is checked. If the current project matches or a matchingproject can be loaded, then fuzzyTECH switches into “RCU Debug Mode”. Ifone of the checks fails, an error message appears.

Debug Mode When linking to a simulation, fuzzyTECH always checks that the simulation andthe fuzzy logic controller match. The check verifies that all variable names usedare the same in the controller and the simulation. You may program simulationsin any program language under MS Windows or you may use a professionalsimulation software package.

Start the Fuzzy LogicControl of the Crane After you have successfully established the link from the simulation to

fuzzyTECH, the simulation starts using the fuzzy logic controller in fuzzyTECH.In an infinite loop, the crane simulation computes the current values for Angleand Distance and sends them to fuzzyTECH where they are the inputs of thefuzzy logic controller. fuzzyTECH then computes the value of the output variablePower and sends it back to the crane simulation. The crane simulation uses thevalue of Power to compute the reaction of the crane a time unit later and displaysthe new situation in its window. This sequence repeats itself until either the[Stop] or [Reset] button of the simulation is pressed. Depending on thecomputation and video performance of your PC, you see this loop as a smoothmovement of the container crane.

First, the fuzzy logic controller starts with medium power, then speeds up as thecontainer sways a little behind the crane head. As the container is a very heavyone, it sways further back as a result of this power increase. As a reaction, thefuzzy logic controller reduces the motor power to reduce the sway. Uponreaching the target position, the fuzzy logic controller positions the containerdirectly over the target with one overshoot. The button [Reset] puts the containerback in the start position. The button [Stop] lets you halt the simulation at anytime. Pressing [Fuzzy] continues the simulation, and the [Step] button lets yousingle-step through the operation.

Analyze Time Response The graphical simulation gives you an overview of how the fuzzy logiccontroller controls the crane. For more in-depth analyses, fuzzyTECH providesnumerous tools and analyzers. fuzzyTECH provides Time Plots to evaluate thetime response. In order to create a new Time Plot, select “Analyzer/New TimePlot...” to open a Time Plot window without plot items (Figure 6).

Page 16: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

16

Figure 6: “Empty” Time Plot Window without Plot Items

The right list box Plot Items displays all variables displayed in the Time Plot andcan be hidden by clicking the [List Box] symbol. All input and outputvariables can be inserted into the Time Plot by clicking the toolbar buttons [AddInput Variables] or [Add Output Variables] . You can also choose variablesfor display by clicking the button [Configuration ] in the toolbar of the TimePlot or the option “Time Plot Config…” in the pop-up menu of the Time Plot.That invokes the Time Plot Configuration dialog that consists of the three tabbeddialogs Variables, Terms, and Rules (Figure 7).

Figure 7: The Time Plot Configuration Dialog Lets You SpecifyLinguistic Variables, Terms, and Rules for Display in the Time Plot.

The two left list boxes of the “Variables” dialog display elements that you canselect for display. The right list box titled “Variables in Time Plot” shows theelements currently selected for this Time Plot. Just double-click on thehighlighted variable or use the [Add] button to move variables from the left listbox to the right one. You can delete inserted variables by selecting them viamouse click and pressing the [Remove] button. The dialog “Terms” contains theterms of all linguistic variables. The dialog “Rules” lets you select individualrules for display.

For the crane controller the “Variables” dialog shows the three input and outputvariables “Angle”, “Distance”, and “Power” in alphanumeric sequence. Double-

Page 17: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

17

click all three of these variables to move them into the list box “Variables inTime Plot”. After you have selected the three linguistic variables for display,click on the [OK] button to close this window. You may define up to 10 TimePlots in each fuzzyTECH session. Each Time Plot is uniquely identified by anumber in its title bar. On the right side of the Time Plot window, a list boxshows now all selected Plot Items. The left part of the window displays the plotarea. Change to the crane simulation window and start the simulation with the[Fuzzy] button. You now see that the Time Plot window plots the value of allthree control variables over time (Figure 8).

Figure 8: The Time Plot Lets You Analyze Input and OutputVariables, As Well As Rule Firing Degrees Over Time.

A scale for the element highlighted in the Plot Item list box is displayed on theleft border of the plot area. A dotted white horizontal line in the plot area showsthe zero line if it is in the displayed range. Each Time Plot also has its owntoolbar that can be disabled to save screen space. Next, reset the simulation andpress [Fuzzy] while watching the Time Plot window. The blue line (Power) startswith medium positive Power. After the container sways slightly back (red linedeclines), the fuzzy logic controller increases the motor power (blue lineincreases). When the sway becomes too large (red line deep down), the fuzzylogic controller reduces motor power (blue line declines). After reducing thesway (red line comes back up), the fuzzy logic controller increases the motorpower again. The constantly declining green line (Distance) shows the progresstoward the target.

Customizing Time Plots You may set the resolution of the time axis in the toolbar’s drop list to customizea Time Plot. Also, the buttons and in the toolbar let you change the zoom.You may use the [Freeze] button in the toolbar to freeze the display. Use the[List Box] symbol from the toolbar to hide the Plot Items to save screenspace. The [Reset] button clears the plot area. Click the button [Configuration] to add or delete elements from the Time Plot. Move the mousepointer over the buttons without pressing a mouse button to see a quickdescription in the left field of the statusbar. You can also access the toolbarfunctions through the pop-up menu activated by clicking right somewhere in theTime Plot window. You can turn the Time Plot toolbars on and off in the mainmenu View, under the option Toolbars by selecting or deselecting Time Plot.Click on the system icon to close a Time Plot. If you leave the debug mode,all Time Plots are closed automatically. If you have enabled “Save Window

Page 18: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

18

Configuration” in the fuzzyTECH Preferences dialog Save, all Time Plots stillopened while leaving the debug mode are reopened automatically when callingthe debug mode again.

Time Plot of RuleFiring Degrees You may also plot the firing degrees of individual rules. Open a new Time Plot

by selecting “Analyzer/New Time Plot...” then double-click on the “RB1” entryin the “Rule Block:” list box. RB1 is the name of the one and only rule block ofthe container crane controller. The list box “Plot Item:” now displays the entry“RB1.1.1”. The first number after the point identifies the number of the rule inthe respective rule block; the second number is the output variable of the ruleblock to be plotted. Hence, “RB1.1.1” identifies the first rule in rule block RB1and the first output variable of the rule. Next, select the second rule for display.Enter “2” in the field “Rule:” and double-click on the entry “RB1” in the “RuleBlock:” list box. After pressing [OK] a second Time Plot opens that plots thefiring degrees of the first two rules. Start the crane simulation again and youobserve that initially the first rule fires, then the second one. When a rule ishighlighted in the “Plot Item:” list box of the Time Plot, the respective rule isshown abbreviated under the plot area. You may mix any combination oflinguistic variables, terms and rules in a Time Plot.

The Spreadsheet Rule Editor represents a second and much easier possibility toadd rules to the Time Plot. Invoke the Spreadsheet Rule Editor by clicking on therule block in the window of the project editor. Click then into the DoS column toopen a pop-up menu at the end of which is a Time Plot menu. This menu lists allopen Time Plots. Choose the one to which you want to add the rule by clickingit. The added rule is then displayed in the respective Time Plot in the list PlotItems.

AnalyzingControl Surfaces In addition to analyzing time response, you may also analyze the control surfaces

of the fuzzy logic controller. Close the two Time Plot windows to save video andcomputing resources if you have a low-performance PC. Select the option“Analyzer/New 3D Plot...” from the main menu. The 3D Plot, as shown inFigure 9 displays the control surface of the crane controller. The 3D Plot alwaysshows two input variables on the horizontal axis and one output variable in thevertical axis. You may open up to ten 3D Plots in one fuzzyTECH session.

Customizing the 3D Plot The 3D Plot also has its own toolbar. Click on the rightmost arrow-down buttonbeside the right drop-down list to change the resolution of the 3D Plot. Thisdisplays a list of possible plot resolutions. A high resolution can result in slowresponse and redraw times of the time plot, depending on the video andcomputing performance of your PC. You can select the output variable using thesecond rightmost field and the two input variables using the two fields on theleft. The four arrow buttons on the left side of the toolbar rotate the plot in alldirections. A double click on an arrow button starts a (continuous) rotation; thehand button stops this rotation. The [Vertical] button flips the 3D Plot forbetter visibility.

Page 19: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

19

Figure 9: The 3D Plot Draws the Transfer Surface for Two Input Variablesand One Output Variable.

If the output variable selected for the 3D Plot depends on more than the twoinputs displayed, the control surface exhibits dynamic dependence on thesevariables. If the [Repaint] button is pressed, the 3D Plot is repainted every timeone of these other input variables changes to reflect the change in the controlsurface shape. Note that this only results in a smooth display if you have a PCwith very high video and computing performance. Click on the system icon to close a 3D Plot. If you leave the debug mode, all 3D Plots are automaticallyclosed. If you have enabled “Save Window Configuration” in the dialog“ fuzzyTECH Preferences/Save”, all 3D Plots still opened upon leaving the debugmode are automatically reopened when you reenter debug mode.

Display ofOperation Points The red arrows at the three axes and the cyan plot lines always show the current

value of the input and output variables. The [Trace] button lets you also trace theoperating point over time (green trace). Enable [Trace], then reset and start thecrane simulation. The “green trace” starts at the initial position of the crane,Angle=0 and Distance=22, and moves toward the target position Angle=0 andDistance=0. The height of the control surface and its color indicate the reactionof the fuzzy logic controller to the combination of the input variables.

With the Time Plot and 3D Plot, you analyze the “outside” performance of thefuzzy logic controller by using input and output variables. In the next steps, youanalyze the internal structure. The RCU debug mode is closed remotely byclosing the crane simulation.

Linguistic VariableEditors The Treeview window lists all linguistic variables in the system. Simply double-

click on a variable name and on a term name to activate an editor for therespective variable. Each linguistic variable can thus be edited with its “own”variable editor. You can also use the Treeviews pop-up menu to open a variableeditor by choosing the option “New Variable” or “Figure 10 shows the editorwindow for the linguistic variable “Angle”. Click the [Variable] button in themain toolbar or use the shortcut [Ctrl] + [V] create a new linguistic variable.

Page 20: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

20

Figure 10: Variable Editor Window for “Angle”.

Customizing theVariable Editor The Variable Editor shows a plot area of all membership functions defined for

the linguistic variable. The left side of the Variable Editor can be extended with alist box showing the terms for the linguistic variable. A term can be selected byclicking the term name either above the plot area or in the list box. You can alsohide the list box Term using the [Listbox] button of the toolbar. This is usefulto save screen space once the membership functions of the variable are defined.You may also hide the toolbar by disabling the “Variable Editor” option in themenu “View/Toolbars”. All toolbar functions are accessible by the pop-up menuof the Variable Editor. Click right somewhere in the Variable Editor window toactivate this pop-up menu. Click the system icon of the Variable Editorwindow to close a Variable Editor.

Editing Linguistic Terms Double-click on the term name in the list box “Term” of the Variable Editor tochange the properties of an existing term. This opens the Term Properties dialog.The term name is edited in the “Term Name” field. The [Color...] button lets youchange the colors that fuzzyTECH automatically associates to terms. Refer toSection 3.1.2.5 for detailed information about this dialog, creating terms, as wellas defining and editing their membership functions.

Editing System Structurein the Project Editor You define the actual structure of the fuzzy logic controller in the Project Editor

window. Three types of objects exist in the Project Editor: Variables, RuleBlocks and Text. Text objects have no impact on the actual information beingprocessed. Variable interfaces can also contain fuzzification and defuzzification.Rule Blocks contain the fuzzy logic rules of a system design. These elementssuffice to design even complex and hierarchical fuzzy logic systems.

All objects in the Project Editor window can be placed by mouse drag and drop.Keep the [Shift]/[Ö] key pressed to fine position the objects. The mousemovement is then limited to the horizontal or vertical direction, depending on inwhich direction the move started. If you do not want to use the mouse, you canhighlight any object using the [Tab] key, moving it with the cursor keys, andplacing it with the [Return] key.

Page 21: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

21

Properties dialogs The properties of an object can be edited by so-called Properties. There aredifferent ways to open a Properties dialog: click right an object in the ProjectEditor or the object’s name in the Treeview and choose the option Propertiesfrom the pop-up menu or highlight an object and click the symbol [Properties]

in the main toolbar.

Open now the Variable Properties dialog of an input variable by clicking righteither Angle or Distance in the Treeview and choosing the option Properties. Inthe Project Editor window, you can differentiate input and output variableinterfaces by the location of the method icon. With input interfaces, the icon ison the left side of the interface box; with output interfaces it is on the right.

Variable Types For each variable, you can define its type in the “Type” field of the LinguisticVariables Wizard or change it in the Properties dialog. fuzzyTECH support threetypes of variables: input variables, intermediate variables and output variables.Input and output variables are assigned to a rule block via an interface that isdisplayed in fuzzyTECH’s Project Editor as box containing the name of thevariable and the chosen method for fuzzification or defuzzification. Intermediatevariables have no interfaces.

Input Variables For input variables, three different fuzzification methods are supported. In theProject Editor window, each method is represented by a different icon. “FuzzyInput” indicates that the variable is passed into the fuzzy logic system as a“fuzzy” variable, which is as a vector of membership degrees. This is primarilyused in decision support applications where the input stems from a linguisticsource rather than a technical sensor. The fuzzification method, “ComputeMBF”, is the standard fuzzification method used in almost all applications. Thismethod only stores the definition points of the membership functions in thegenerated code and computes the fuzzification at runtime. Some fuzzyTECHMCU Editions (dedicated assembler code generation for microcontrollers) alsosupport the “Look up MBF” method. This method computes the membershipfunctions completely at compile time and stores all values in a table in thegenerated code. This method results in extensive code sizes and is only providedwhere it delivers expedited computation.

Output Variables For output variables, different defuzzification methods exists as well. In theVariable Properties dialog, select Output Interfaces in the Type field to getanother listing in the Methods fields. Analogous to a “Fuzzy Input”, “FuzzyOutput” outputs a vector of the membership degrees of the inference result. Themost often used method is Center-of-Maximum (“CoM”), which delivers thebest compromise of the firing rules. In contrast, Mean-of-Maximum method(“MoM”) delivers the most plausible result. Center-of-Area (“CoA”) is similar tothe CoM method. fuzzyTECH uses a modified CoA algorithm, “Fast CoA”,which circumvents the numerical integration required by the original CoAmethod. The BSUM variants of CoA and MoM defuzzification use the boundedsum rather than the maximum operator to aggregate the individual area pieces.

Page 22: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

22

The Hyper CoM method is used for fuzzy applications, which require not onlypositive experience in the form of recommendations, but also negativeexperience in the form of warnings and prohibitions.

Definition ofFuzzy Logic Rules The large block in the middle of the Project Editor window is the Rule Block.

This block contains the rules of the system describing the control strategy.Double-click on the Rule Block to activate the Spreadsheet Rule Editor. Eachrow corresponds to a single fuzzy logic rule or more, depending on the fact, howmany outputs the Rule Block has. The leftmost column assigns a number to eachrow (gray fields). Clicking on this field highlights the rule; clicking again de-selects it. The next two columns contain the variables Angle and Distance andare titled with IF. The IF field comprises the “if-part” of the rule, i.e. each cell ina variable column represents the terms of the variables that is used as rulecondition. The two columns under the THEN field describe the THEN part of therules, i.e. the rule consequences. The column titled with Power contains itsoutput terms used as rule output. The DoS column contains individual ruleweights. The rule weight ranges from zero to one, indicating the degree, to whicha rule is supported (DoS = Degree of Support).

Figure 11: The Spreadsheet Rule Editor Supports the Definition of Rule Sets.

Add and Modify Rules Simply click a respective cell to change a rule. A pop-up menu shows allpossible values for this cell. If a cell in a variable column has been clicked on,the pop-up menu offers all other terms of this variable. If a cell in a DoS columnhas been clicked on, the pop-up menu lists decimal DoS values from 1.0 to 0.0and the option 0..1. This opens a window containing a slider and a input fieldthat can be used for fine-tuning the rule weight up-to a thousandth.

Use the last, empty row of the table to add a rule. Once you have entered a newrule, another empty row appears at the end of the table. An empty row can alsobe inserted within the Spreadsheet Rule Editor. You can either click right on the

Page 23: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

23

left, gray field displaying the row number. Choose the “Insert Row” option in thepop-up menu. An empty row will be inserted before the row that was selected.Incomplete rules are automatically deleted when the Spreadsheet Rule Editor isclosed. Incomplete rule have either no “if-part”, no “then-part”, or no set “DoS”value. If the IF part consists of more rule conditions (i.e. there are more than onerule input, e.g. Angle and Distance), a cell can be empty. Empty “if-parts” of arule are considered as “don’t care” conditions. A rule that contains an emptyfield is not influenced by the respective variable. Rules containing “don’t care”conditions are not incomplete.

To delete a rule, mark the rule by clicking its row number and press the [Del]key. Or click the row number of this rule, open its pop-up menu and choose theDelete Row option. If you want to deactivate a rule temporarily, set its DoSvalue to 0.0. Thus this rule has no influence on the fuzzy system, is complete andwill not be deleted when closing a Spreadsheet Rule.

Aggregation In the Spreadsheet Rule Editor, click the symbol [Fuzzy Operators] to openthe Operator page of the Rule Block Properties dialog (Figure 12). In this dialog,you specify the aggregation operators. The group “Operator” lets you select theoperator family, the “Parameter” scroll bar and edit field lets you define theparameter exactly. The closer the parameter value is to 0, the more the operatorperforms like a perfect AND; the closer the value is to 1, the more the operatorperforms like a perfect OR. The plot field shows the operator characteristic of theselected operator configuration.

Figure 12: The Rule Block Properties: Operators Dialog

Page 24: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

24

Result Aggregation Choose an fuzzy operator for result aggregation in the field Result Aggregationof the Rule Block Properties/Operators dialog (Figure 12). fuzzyTECH supportstwo methods for result aggregation, the maximum method (MAX) and thebounded sum method (BSUM). If more than one rule have the same result, theMAX method takes the maximum of their DoS values as final result. The BSUMmethod takes the bounded sum. Thus, all firing degrees are summed by using abound of one. Note that BSUM result aggregation is different from BSUM MoMand BSUM CoA. The bounds are zero and one. For more details on computationof aggregation and result aggregation methods, refer to Chapter 5. The usage ofthe operators is depicted in Section 3. Close this dialog now.

Sort Rules In the Spreadsheet Editor’s toolbar, click the button [Sort Rules] to open theSort Rules dialog. Choose in this dialog a criterion, according to which the rulesof this rule block are to be sorted. The sequence of rules as shown in Figure 11 isthe result of sorting Distance according to its terms or, more precisely, themaxima of its membership functions (open the Variable Editor of Distance tocompare this). Sort the rules as shown in Figure 11, since the rules are laterreferenced by their row number.

Rule Block Utilities The design of a rule block can be eased by using the utilities offered in the dialogRule Block Utilities. This dialog can be accessed through the Spreadsheet RuleEditor’s pop-up menu (by clicking with the right mouse key on the grey fieldbelow the Spreadsheet Rule Editor’s toolbar).

Matrix Rule Editor In the Spreadsheet Rule Editor, click the toolbar symbol [Matrix Editor] toactivate the Matrix Rule Editor as shown in Figure 13.

Figure 13: The Matrix Rule Editor Displays a Rule Base as aMatrix.

Page 25: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

25

In contrast to the Spreadsheet Rule Editor, the Matrix Rule editor presents therules in form of matrices. It is possible to switch between the rule editors, butonly one can be open for a rule block at the same time. If the fuzzy systemcontains more than one rule blocks, a rule editor can be open for each rule block.To differentiate different rule blocks, each rule editor shows the name of its ruleblock in its title bar . Many experienced fuzzy logic designers prefer the MatrixRule Editor to the Spreadsheet Rule Editor when designing complex systems. Itcomprises more functions that help to detect rule inconsistencies or rule gaps andallows thus to reduce the total amount of rules to a considerable degree.

The Matrix Rule Editor consists of an IF and a THEN field and, depending onthe number of output variable per rule block, one matrix or more matrices. Allinputs of the rule blocks are listed in the IF field, all outputs - in the THEN field.A term list box is assigned to each variable, from which a term can be selectedfor display in the matrix. A term list box of an input variable appears disabled ingray color, if this is chosen for display in the matrix.

Two variables have to be chosen to display the rule block. Click the toolbarsymbol to swap the axes of the variables displayed in a matrix. For theseselected variables, one matrix cell (or field) is created for all combinations oftheir terms in the matrix. Each matrix cell describes a fuzzy rule or more fuzzyrules. Black cells indicate non-defined rules. Gray-scaled matrix cells rangingfrom white to dark gray indicate defined rules.

Defining Fuzzy Rules Fuzzy Rules and their rule weights (Degree of Support = DoS) are defined bymeans of the mouse and pop-up menus. To add or change a rule, click the matrixcell which represents the combination of the terms that form this rule with theright mouse key. Choose an output term from the menu that pops up to determinethe THEN part of the rule. To define or change a rule’s weight, click again thematrix cell which represents the combination of the terms that form this rule withthe right mouse key. In the pop-up menu, click the output term you want to bethe rule result (THEN part). This opens a side menu from which a DoS valueranging from 0.0 to 1.0 can be chosen as rule weight. To determine a DoS valueexactly up to a thousandth, click the option 0..1 in this side menu. Click itsoption Delete to remove the rule with this output term. Defined rules aredisplayed as tooltip, when the mouse pointer rest over of the respective matrixcell.

Select a matrix cell by clicking it with the left mouse key. The cell selected isdistiguished by a red border line. Click further matrix cell and watch thechanging display in the term list boxes of the IF field. Compare the term namesin the IF fields with the term names assigned to the selected matrix cell on thehorizontal and vertical axis. They are identical and represent the IF part of thefuzzy rule. The THEN part of this rule is represented by the output termdisplayed in the term list box of the THEN field. This helps to understand how toread a rule in the Matrix Rule Editor.

Page 26: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

26

Now choose another term in the term list box of an output variable. All matrixcells containing a rule that uses this output term as rule output (THEN part) areindicated by a red border line. Choose each output term of the output variablePower, watch the result and read the rules. You will notice, that the output termnegative_high is the only term that no defined rule uses as output. Now define arule that uses this term, assign a DoS value to this rule and check the defined rulein the tooltip of the respective matrix cell.

Due to the complexity of the Matrix Rule Editor, its further functions shall not bedescribed here. Please refer to fuzzyTECH’s help system or Section 3.1.2.7.Close the Matrix Rule Editor by clicking the system symbol or click thetoolbar symbol to return to the Spreadsheet Rule Editor.

Test and VerificationUsing Debug Modes Now that you have evaluated the various editors used to design a fuzzy logic

system, the next development steps are optimization and testing. fuzzyTECHoffers numerous debug modes to support this development step. The differentdebug modes are descriped more detailed in Section 3.1.3. All debug modescooperate with the editors and analyzers you have learned to use to expeditesystem verification. When you switch from Design Mode to any of the debugmodes, the entire fuzzy logic system developed is simulated by fuzzyTECH. Alleditors become dynamic, i.e. they graphically display information flow,fuzzification, defuzzification, and rule inference. In addition, most systemcomponents may still be edited during debugging. First, a quick introduction intohandling the Interactive debug mode.

System Test UsingInteractive Debug Mode Enable the Interactive Debug Mode either by clicking the [Interactive] button

on the main toolbar or selecting “Debug/Interactive” from the main menu.Minimize the Watch: Interactive Debug Mode window and the Project Editor.Open a Variable Editor window for each of the three linguistic variables of thecrane controller. Open the Spreadsheet Rule Editor window for the rule block bydouble-clicking it. Hide the Treeview by clicking the main toolbar button [Treeview]. The main fuzzyTECH window should then look similar to Figure 14.

If you drag the small red arrows below the plot area of the membership functionsin the Variable Editors for “Angle” and “Distance”, a thin vertical line shows thefuzzification. The firing degree of each rule is shown by small black bars on bothsides of the DoS values in the Spreadsheet Rule Editor. Click on the bar to seethe exact values. The defuzzification process is shown in the Variable Editor for“Power”.

Set the input variables to the starting position of the crane: “Angle” to 0 and“Distance” to 22. In the Spreadsheet Rule Editor, you see that only the eighthrule in Figure 14 fires. This rule states that in the starting position, the craneshould start with medium power. The defuzzification shown in the VariableEditor for “Power” is unequivocal, and a crane connected to this controller

Page 27: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

27

would now start with 10 kilowatts power. The situation changes after a shorttime. As the crane starts to move, the load of the crane sways behind and thedistance declines.

Figure 14: In Interactive Mode, All Editors Graphically Visualize Inference

Set “Angle” to -10 and “Distance” to 25. This is the stable situation when thecrane motor should be powered up. This situation is represented by the ninth rulethat now fires completely (Figure 15). In a similar fashion, you can now test thefuzzy logic system performance for arbitrary situations. Change the “then-part”of the ninth rule from “pos_high” to “neg_high”, and you instantly see theeffects of this in the Variable Editor for “Power”. Similarly, any change of amembership function or a rule weight is instantly reflected in all editors.

Using Analyzers inInteractive Debug Mode Open the 3D Plot by selecting “Analyzer/New 3D Plot…” and arrange windows

similar to Figure 15. By dragging the red arrows in the 3D Plot, you may selectany controller operating point. All Editors are updated to show fuzzification, ruleinference, and defuzzification for exactly this operating point. Likewise, anychange of input variable values in the Variable Editors for “Angle” and“Distance” is reflected instantly in the 3D Plot. By enabling the Trace option inthe 3D Plot window, any operating points tested are shown in a Trace in the plot.Any modification to the system is instantly visible. Change the “then-part” of the

Page 28: ft531manual

Inform Software Corporation Chapter 1: Getting Started with fuzzyTECH: The Crane Simulation

28

ninth rule from “pos_high” back to “neg_high” and back again. The 3D Plotinstantly shows the effect on the control surface.

Figure 15: Modifications in the System Become Instantly Visible in All Editorsand Analyzers. If You Change the “then-part” of Rule 9 From “pos_high” to

“neg_high”, the Front Left Part of the Transfer Surface Flips Down.

In-depth Analysis of theCrane Controller Start the container crane simulation again (…\SIMCRANE.EXE). Start the crane

by clicking the [Fuzzy] button. All editors and analyzers of fuzzyTECH showfuzzification, rule inference, and defuzzification while the crane is running. Doesyour crane operation look strange now? Then you may have left the “then-part”of the ninth rule at “neg_high”. Just change it back to “pos_high” while the craneoperates.

Statistics Analyzer Activate the Statistics Analyzer by selecting “Analyzer\Statistics” from the mainmenu bar, or by clicking the main toolbar button [Statistics] . In contrast toTime Plot, Transfer Plot, and 3D Plot, the Statistics Analyzer is not displayedwith a own window. Rather, it adds a new column [min-#-max] to eachSpreadsheet Editor open. Open a Spreadsheet Rule Editor to see the Statisticscolumn [min-#-max. It displays for each rule a number plus two small side bars.The number between the bars counts how often the rule has fired with a DoSvalue greater than zero. The frequency a rule fires can either be displayed as

Page 29: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

29

absolute count of cycles or relative count (in view to the determined period.Click the Spreadsheet Rule Editor’s toolbar button [Show Absolute Statistics] or[Show Relative Statistics] to display the frequency a rule fires in absolute orrelative values. Pressing the button [Reset Statistics Counter] resets the counting.

Trace Analyzer The Trace function provides a real-time trace on the target hardware. Becausethe trace buffer is kept on the target hardware, the trace is not limited by thebandwidth of the serial communication. Also, by tracing slow processes, theTrace may be used as a time accelerator by setting a corresponding high value.The maximum size of the trace buffer depends on the resources on the targethardware and is configured at compilation time. The trace frequency may bechanged any time from the PC. You may upload the contents of the trace bufferto the PC for further analysis at any time. fuzzyTECH automatically converts thetrace buffer into ASCII format readable by the File Recorder. The Trace functionis only supported by fuzzyTECH Editions with Online or RTRCD debug mode(refer to Table 4 in Section 9.4).

FTL Format fuzzyTECH uses the hardware-independent FTL format (Fuzzy TechnologyLanguage) to store fuzzy logic systems. If you manually edit an FTL file thatwas generated by fuzzyTECH, make sure to erase the line containing “SHELL =DEMO”. This forces a complete consistency check when opening the FTL file.

Data Formats fuzzyTECH uses ASCII format types for input and output values for multiplepurposes. The different file extensions classify the usage of the file:*.PTN Files generated by the Pattern Generator*.TRC Files uploaded from a target hardware trace*.OUT Files generated by the Batch Mode*.IN Files recorded from a real process*.EXP, *.DAT Files for NeuroFuzzy training and FuzzyCluster

Refer to Section 3.1.3.4 for more information.

Other Simulations Some fuzzyTECH editions contain additional simulation examples. Thesesimulations may be started directly by double-clicking their respective icons.Some of the simulations also allow a manual control of the process. To control aprocess simulation with fuzzyTECH, you must start fuzzyTECH by double-clicking the fuzzyTECH icon. The *.FTL file containing the fuzzy logic control-ler for the respective process simulation must then be opened within fuzzyTECH.Files with the “FTL” extension indicate a complete fuzzy logic project. Only oneprocess simulation may be started at the same time to avoid conflicts. Note: Theinstallation procedure has created a separate subdirectory for each processsimulation in the …\SAMPLES\ subdirectory. Each of these subdirectoriescontains the SIMULATE.EXE file with the process simulation and the *.FTLfile with the description of the fuzzy logic controller to be loaded by fuzzyTECH.

Page 30: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

30

The animated Steam Generator Drum simulation demonstrates fuzzylogic control using the fuzzyTECH software package and thefuzzyTECH Runtime DLL. Open this simulation from the Start menu(“Start/Programs/fuzzyTECH/Examples/Simulations/..”). The steamgenerator simulation is indicated by the right icon:

Steam Generator DrumSimulation This simulated application uses fuzzy logic control for the start-up of a steam

generator in a power plant. In most power plants, this start-up procedure isexecuted manually by operators. Manual start-up is used because of the largenumber of process variables involved, their interdependencies, and their non-linear relationships that render the use of conventional automation techniquesimpossible. As in many similar applications, fuzzy logic makes an automatedsolution possible because human operator experience can be put directly into asolution.

The simulation involves two fuzzy logic control modules. One employs a fuzzy-enhanced PID type single variable control loop for the steam pressure, the otherimplements a multi-variable supervisory control strategy that involves bothcontinuous and discrete control decisions.

The window of the Steam Generator Simulation displays graphically the processof putting a steam generator drum into operation. To start the simulation with thefuzzy logic controllers, press the [Start] button in the simulation window. Thisstarts the fuzzyTECH Runtime DLL, opens the START.FTR and PRESS.FTRfuzzy logic controllers, and initiates the start-up procedure of the steamgenerator. The simulation does not provide for manual operation.

The topics standing on the left side of the following pages guide you step-by-stepthrough the use of this simulation.

Page 31: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

31

Steam GeneratorOperation A steam generator drum is the central component of a power plant. It is

connected to heat exchanger pipes that transfer heat from the furnace. It is alsoconnected to a throttle valve, which delivers steam to the turbines that drive theelectric generators. Because the water capacity of the heat exchanger pipes muchexceeds the water capacity of the drum, starting the pump and the heat-upprocedure itself changes the water level in the drum strongly. The drum shallnever be empty because this would yield air into the heat exchanger pipes and ifthe drum runs full, the water must be drained. Because the water used has beenpurified, draining water is expensive.

Figure 16: Steam Generator Drum Simulation Window

Fuzzy Logic Start-upControl The start-up procedure of the steam generator drum involves both continuous

command variables, such as the command value set points for the Feed Valveand the Drain Valve, as well as discrete control variables, such as the Pump Onand Fire On signals. The first fuzzy logic controller (START) generates the fourcommand variables above from a number of input variables: level of water in thedrum (WaterLevel), its time derivative (dt_Level), the current pressure in thesteam generator drum (Pressure), and feed-back signals indicating fire andcirculation pump condition (FireOn, PumpOn). The second fuzzy logic controller(PRESS) stabilizes the pressure of the steam leaving for the turbines. It uses twoinput variables: pressure error (delta_Press) and its time derivative (dt_Pressure).The output of the PRESS controller (SteamValve) increases or decreases theangle of the steam valve opening. Note that this implies integration over time ofthe output of the controller.

Page 32: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

32

The next step gives you a brief overview on the fuzzyTECH Runtime DLL.The fuzzyTECHRuntime DLL The fuzzyTECH Runtime DLL is a stand-alone executable software that can be

embedded into most other software packages. It does not provide any means ofmodifying or monitoring a running fuzzy logic system; it only computes theoutput variables of the fuzzy logic system based on its inputs. The fuzzyTECHRuntime DLL is available in different executable formats, such as Windows 16-bit and 32-bit DLL component. For some software packages and process controlsystems such as InTouch, FactoryLink, or SIMULINK, specialized "ready-to-use" Runtime Module are available, too. All fuzzyTECH Runtime DLLs canopen any fuzzy logic system that follows the *.FTR file format.

While you may use the FTRCU interface to let fuzzyTECH itself compute theoutputs of a fuzzy logic system, in some cases, the Runtime Module is the betterchoice:• The fuzzyTECH Runtime DLL is much smaller than the complete

fuzzyTECH development system. For example, FTRUN32.DLL is less than100KB of size.

• The Runtime DLL is much faster than the complete fuzzyTECH developmentsystem. For example, on an i486 PC, a large fuzzy logic system computes inabout 1/10th of a millisecond.

• The Runtime DLL is free. If you are a licensed user of the fuzzyTECHProfessional or Online Edition, you can distribute the Runtime DLL withyour fuzzy logic system.

• One Runtime DLL can be called as a server by multiple client softwareprograms. Each client program can use multiple instances of different fuzzylogic systems at the same time.

A fuzzy logic system that is currently opened by the Runtime DLL can be linkedto the complete fuzzyTECH development system for monitoring, debugging, andoptimization. fuzzyTECH and the Runtime DLL can run on the same PC or ontwo different PCs connected by a network system. All system settings for thefuzzyTECH Runtime DLL are to find in its FTRUN.INI file. A detailed technicaldescription of the fuzzyTECH Runtime DLL and its integration is located in theHelp file FTRUN.HLP located in the ..\RUNTIME\FTRUN\ subdirectory.

The next step shows you how to configure the online connection link betweenfuzzyTECH and its Runtime DLL on the same PC.

Configuring anOnline Connection The following instructions give you a step-by-step guidance at configuring an

online connection between fuzzyTECH and a fuzzy runtime system. Thisexample uses as fuzzy runtime system the Steam Generator Drum Simulation,the fuzzyTECH Runtime DLL (FTRUN32.DLL), and the two files START.FTRand PRESS.FTR, both generated by fuzzyTECH.

Page 33: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

33

Start a fuzzyTECH edition that supports online debugging. Please note thatonline modifications are impossible with a fuzzyTECH Demo edition or thefuzzyTECH Viewer. No fuzzy system should be loaded in the fuzzyTECH ProjectEditor. Open the Online Wizard by clicking the Treeview entry OnlineConnections by the right mouse key and choosing the option Online Wizard inthe pop-up menu.

Figure 17: Online Wizard: Question concerning the fuzzy runtime system

The Online Wizard raises some questions you should check before setting-up theonline connection. As for the Steam Generator Drum Simulation, the results ofthis verification are as follows:1. The Steam Generator Drum Simulation runs on the same PC as fuzzyTECH.

For this reason, DDE is the most appropriate communication channel.2. DDE should be chosen as default communication channel for the Runtime

DLL. This can be verified in the “fuzzyTECH Runtime DLL Info” windowthat opens together with the simulation’s window at starting the SteamGenerator Drum simulation. If DDE is not chosen as online communicationchannel, change this setting of the fuzzyTECH Runtime DLL in itsconfiguration file FTRUN32.INI. This file is stored in the Windowsdirectory, e.g. C:\WINDOWS. In the paragraph [FTRUN], go to thecommand COMMCHANNEL and set it to COMMCHANNEL=DDE. Afterthe communication channel was changed, restart the Steam Generator DrumSimulation.

3. The files (or fuzzy systems) START.FTR and PRESS.FTR were generatedby a fuzzyTECH code generator with the option Online Code enabled. Thisrequirement is fulfilled, provided that you haven’t changed the files afterfuzzyTECH was installed.

Page 34: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

34

Figure 18: Online Wizard: Choosing an online communicatin channel infuzzyTECH

For fuzzyTECH, DDE has to be chosen as communication channel as well. Thiscan be done by choosing FTDDE.DLL in the list of Current Settings in theOnline Wizard. After DDE was set as communication channel both forfuzzyTECH and the fuzzyTECH Runtime DLL, click the [Next>] button in theOnline Wizard to go to its next page and initiate the online connection.

Figure 19: Online Wizard: Report

Now fuzzyTECH was successfully linked with the fuzzy runtime system. Thefuzzy systems START and PRESS are listed with their so-calles time stampsbelow the entry "Online Connections" in fuzzyTECH’s Treeview window.Additionally, the system loaded in the fuzzyTECH’s Project Editor has been

Page 35: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

35

entered in the Treeview, too. If, for many reasons, the online connection couldnot be set up, the Online Wizard appears with a negative report page. The OnlineWizard calls on you to get rid of possible errors and to try it again.

Figure 20: Online Wizard: Mismatch of fuzzy systems

If one of the fuzzy systems START or PRESS running on the fuzzy runtimesystem is to debug online, it has to be loaded into fuzzyTECH’s Project Editorfirst. In the Online Wizard, choose the option "Open System". The option"Download" is not available as long as no fuzzy system is loaded intofuzzyTECH’s Project Editor.

Figure 21: Online Wizard: Open a fuzzy system

Page 36: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

36

There are two possibilities to open a fuzzy system that corresponds with one ofthe systems on the fuzzy runtime system: either the right FTL file is stored on adata medium or the system is opened from the fuzzy runtime system. The OnlineWizard lists all systems that can be opened on the fuzzy runtime system. In thecase of the Steam Generator Drum Simulation, the both fuzzy systems STARTand PRESS are listed. Choose the one of the systems in the list of the OnlineWizard and click the [Next>] button to open its next page.

Figure 22: Online Wizard: Start online debug mode

The Online Wizard’s next page is opened and, simultaneously, the fuzzy systemselected before is loaded into fuzzyTECH’s Project Editor. It correspondscompletely with one of the fuzzy systems on the fuzzy runtime system, which isproven by the identical time stamps displayed in the Treeview. The entry"untitled" below the Treeview entry Online Connections, fuzzyTECH’s ProjectEditor has been replaced by the time stamp. Simultaneously, the fuzzy system’sname is displayed in the title line of the Treeview. The correspondence of thesystems is indicated by the bitmap . This page of the Online Wizard offers thetwo online debug modes Monitor and Monitor&Modify. Choose the Monitordebug mode that allows to access the fuzzy runtime system only in read mode,i.e. the fuzzy runtime system cannot be modified. As soon as the Monitor debugmode is active, fuzzyTECH calls cyclically (asynchronously) the runtime systemfor the latest values of input and output variables and displays these in all openfuzzyTECH editors.

The online communication uses master-slave operations. All requests areinitiated by fuzzyTECH. Thus, if no link is enabled, the controller is able tooperate without the development system. For security purpose, all telegrams aretransferred via handshake. If no message appears or a telegram is only partlyreceived at the target, the development system and the online debugger will sleep

Page 37: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

37

but let the controller work. Every message completely received at the target isacknowledged by the online debugger. This acknowledgment must reach thedevelopment hardware in a time period shorter than the time out intervaldetermined in the Timeout field in the dialog Online Timing (Figure 73) inTools/Project Options. Otherwise, a message appears and the Online Connectionis terminated.

The Fuzzy LogicControl Strategy Click [Start] button (or the [Stop], the [Reset], and the [Start] button if the

simulation is already running) in the Steam Generator Drum Visualizationwindow to run the start-up procedure again from the beginning. You can followthe actions of the fuzzy logic controllers in the Steam Generator Simulationwindow:• Filling of the steam generator drum.• When stable, start circulation.• When stable, lower water level and start fire (Fire starts with a delay).• Stabilize the water level while pressure builds up.• When pressure has been build up, control the steam pressure to the turbines.

The Steam Generator Drum Visualization Window has multiple elements thatvisualize each component of the process. However, the internal particulars of thefuzzy logic systems are not shown here. You need to start fuzzyTECH toremotely access the running system as set forth in Configuring an OnlineConnection. This remote access is described in the step Online Development withfuzzyTECH”.

Operating the power plant at a stable operating point does not provide anyspecial difficulty for conventional control engineering. To keep the operatingpoint constant, individual PID type controllers are used to keep each processvariable constant. However, automatic control of the start-up procedure is notthat straight forward since the inter-dependencies between the process variablesbecomes a very important factor that cannot be modeled using single loop PIDcontrollers. Thus, human operators control the start-up procedure manually byfollowing guidelines developed from experience, such as:• In most cases, the heat exchanger piping is only partially filled with water

before start-up. Hence, starting the circulation pump lowers the water level inthe drum and thus imposes a severe disturbance to the process.

• When the circulation and the drum water level are stable, the fire can bestarted in the furnace. Because this disturbance can cause the water level toabruptly raise to a potentially dangerous point, the water level is temporarilylowered prior to starting the fire.

The fuzzy logic implementation of the human operator control strategy usesthree fuzzy logic rule blocks: System State, Process Control, and Level Control.The system state estimation fuzzy rule block uses the four input variablesFireOn, Pressure, PumpOn, and WaterLevel to determine the current status ofthe start-up procedure. The linguistic variable Status uses the terms TankFill,

Page 38: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

38

StartPump, BoilerFill, StartFire, BuildPressure, and Operating. Notice that this isan intermediate linguistic variable that does not have membership functionsassociated with its terms. The variable Status is only used within the fuzzy logicsystem as an input to the other two fuzzy rule blocks.

Based on the system state estimation of the first fuzzy rule block, the secondfuzzy rule block controls the two discrete output signals of the fuzzy logicsystem, StartFire and StartPump. The third fuzzy rule block, Process Control,implements the trickiest part of the start-up procedure, the water level control.Based on the system state estimation of the first fuzzy rule block as well as themeasured water level and its time derivative, the third fuzzy rule blockdetermines the set values of both the feed and drain water valve. The totalnumber of rules in the third fuzzy rule block is 34.

Continuous Operationof the Power Plant As the start-up procedure is executed, the power plant reaches a stable operating

point where the fuzzy logic controller START.FTL stabilizes the water level inthe steam generator drum and pressure steadily increases. During this stableoperation after the pressure has been built up in the drum, the second fuzzy logiccontroller PRESS.FTL implements a fuzzy-PI type control strategy to controlsteam flow. The structure of a fuzzy-PI control element is commonly used inindustrial applications. It consists of a fuzzy logic system using the error(delta_press) and its time derivative (dt_Pressure) as inputs and outputs anincrement/decrement command for the valve position. Notice that the actualfuzzy logic control strategy implements a PD-type controller. The overallbehavior is PI-type however, because the output is used to increment ordecrement the command variable.

The structure of the fuzzy logic controller PRESS.FTL shows three moreinterfaces in fuzzyTECH that are not connected to any other objects infuzzyTECH. Two of these interfaces (SteamFlow and Pressure) are onlyvisualized in fuzzyTECH, the third (SetPressure) allows the user/developer tomodify/force the set point of the steam pressure controller remotely fromfuzzyTECH. Display and Force type interfaces/variables in fuzzyTECH are usefulwhen developing a fuzzy logic system because these variables can be used in alleditors, analyzers and the trace functions of fuzzyTECH just like any otherlinguistic variable.

After you have evaluated the two fuzzy logic controllers, you can start the OnlineDevelopment with fuzzyTECH to analyze and modify the fuzzy logic systems ondifferent platforms "on the fly".

Online Developmentwith fuzzyTECH An online development with fuzzyTECH requires the complete correspondence

of the fuzzy system loaded in fuzzyTECH’s Project Editor with the fuzzy systemrunning on the fuzzy runtime system. The Online Wizard has helped you to opensuch a fuzzy system on the fuzzy runtime system (as described in the stepConfigure the Online Connection) and to switch into Monitor debug mode.

Page 39: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

39

Remember that in Monitor debug mode it was only possible to visualize thefuzzy logic inference, but impossible to change the fuzzy system. Activate nowthe Monitor&Modify online debug mode to modify this fuzzy system. Eachmodification carried out on the fuzzy system by means of the fuzzyTECH editorsis forwarded directly to the fuzzy runtime system.

To demonstrate the effect of modifications on the Steam Generator DrumSimulation, try the following operations in Monitor&Modify debug mode (notavailable with the fuzzyTECH Demo):• Run the simulation until it has reached a stable operating point.• Open fuzzyTECH and arrange your desktop in a way that you can view both

the simulation window and Monitor&Modify debug mode. Establish anonline connection between both applications, open the fuzzy controllerSTART, and activate the Monitor&Modify online debug mode.

• In fuzzyTECH, open the Spreadsheet Rule Editor of the Process Control ruleblock. Change the rule "IF Status=Operating THEN StartPump=True" into"IF Status=Operating THEN StartPump=False".

• This causes the circulation pump to halt operation (notice that it takes a whilefor the water circulation to stop due to the inertia of the circulation pump).

• When the circulation pump stops, the water circulation is interrupted. Thisleads to an overheating of the steam generator and a reduced fire supply. Afire-shut down occurs immediately (alarm message), and the system slowsdown the steam generator.

• Now change the THEN part of the rule mentioned above back to"StartPump=True". The fuzzy logic start-up strategy tries to re-establishoperation.

• This restart of the circulation pump causes a complete emptying of the drum,because the previous overheat condition almost completely drove the waterout of the heat exchanger’s tubes.

• After this has been done, the fuzzy logic controller re-establishes stableoperation.

Switching off the Monitor&Modify debug mode now calls automatically theOnline Wizard (Figure 23), since the fuzzy system was modified in the course ofonline debugging.

The Online Wizard offers now the possibility to save the changed system or re-establish the system with its previous data (i.e. to regain the state of the systemthat it had before it was subject to online debugging). Another possibility is, thatyou synchronize manually your fuzzy system yourself. Since you haven’t changethe system in this example (you just changed a rule and then undid the change),choose the option Restore System on this page of the Online Wizard. After thisoption was chosen, the Online Wizard informs you on its next page about thesteps fuzzyTECH performs to follow this command.

Page 40: ft531manual

Inform Software Corporation Chapter 2: Online Debugging the Steam Generator Drum Simulation

40

Figure 23: Online Wizard: Leave online debug mode

Figure 24: Online Wizard: Restore the fuzzy system

fuzzyTECH replaces the fuzzy system currently opened in the Project Editor withthe "original" system. This original system is stored as FTL file, its location isdisplayed in the Online Wizard. At last, fuzzyTECH overwrites the fuzzy systemon the fuzzy runtime system with the original file. Click the [Next>] button tosee how fuzzyTECH executes all steps. Close the Online Wizard and open theother controller PRESS.FTL by clicking the entry PRESS - xx:xx:xx/xx/xxxxbelow Online Connections in the Treeview with the right mouse key andchoosing the option Open in the pop-up menu. Now you can analyze the thePRESS controller in the same way as the START controller.

Page 41: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

41

For example, carry out the following actions:• Activate the Monitor&Modify debug mode.• Open a 3D Plot for the variables: delta_Pressure, dt_Pressure, and

SteamValve. click the toolbar symbols and , to avoid a continousrepainting of the 3D plot and the arrows pointing to the variable values. Clickmultifoldly the symbol to rotate the 3D plot till it appears similar topicture below. Click the toolbar symbol to start tracing and restart theSteam Generator Drum Simulation. After the START controller has finishedthe start-up procedure of the steam generator, the PRESS controller takesover the control of the steam flow. As soon as the controller is active, thevalues for delta_Press and dt_Pressure are traced cyclically in the 3D Plot asgreen transfer curve.

• The Watch:Monitor&Modify debug mode window in fuzzyTECH lists theSetPressure variable (type: Force) and its current value. Select the Forcevariable SetPressure and set its value to "50" in the "Value:" field of thewatch window’s toolbar. As you can see in the window of the SteamGenerator Drum Simulation, this modification has a great effect on thepressure.

Figure 25: 3D-Plot of PRESS Controller (Repaint disabled, Trace enabled)

Page 42: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

42

This chapter describes the major steps involved in the design of fuzzy logicbased systems. In this part, the different possibilities of customizing fuzzyTECHand viewing options are briefly introduced.

The first section of this chapter shows how easy fuzzy system design is by usingthe Fuzzy Design Wizard.

The second section deepens your already gained knowledge of fuzzy logic andfuzzyTECH to a degree that enables you to create fuzzy systems by yourself. Thesystem design is explained by following such development steps, as:• Getting familiar with the structure and the objects of a fuzzy system.• Defining the system by defining text objects, linguistic variables,

membership functions, and rule blocks.• Formulating fuzzy rules for the fuzzy system.

The third section explains fuzzyTECH’s different optimization options toimprove the fuzzy system’s behavior. Learn, how• to optimize the system applying debug procedures,• to estimate system performance using process data or generated data, and• to verify the system’s behavior using fuzzyTECH analyzer tools.

The fourth and last section of this chapter introduces fuzzyTECH tools fordocumentation and revision control. The Project Information Dialog lets youenter project information, such as the author of the project, date of last projectchange, comments, etc. A documentation of the project loaded in fuzzyTECH isgenerated automatically as RTF file within a few minutes by using fuzzyTECH’sDocumentation Generator. fuzzyTECH’s Revision Control System allows you toload, save and delete project files related to its revision state. The revisioncontrol saves all important development steps as a complete revision history torewind to earlier development stages. Using fuzzyTECH’s Revision ControlSystem for system design documentation is thus a prerequisite for ISO-9000compliant system development.

Page 43: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

43

Customizing thefuzzyTECH Shell The fuzzyTECH shell can be customized in many ways. Open the fuzzyTECH

Preferences dialog (Figure 26) from the main menu “Tools/fuzzyTECHPreferences”. This dialog consists of the tabbed dialogs General, Save, TextEditors, Watch Window, Matrix Rule Editor and Serial Interface. The settingsmade in these dialogs are valid for all fuzzy systems you create or load infuzzyTECH, i.e. they are not system-specific.

Figure 26: The fuzzyTECH Preferences Dialog Lets You Customize fuzzyTECHAccording to Your Personal Preferences

fuzzyTECHPreferences: General

General Settings

Recent Used File List:By activating this option, the number entered here is the number of the mostrecently used files that are shown at the end of the “Files” entry of the mainmenu.

Quick Help Window Active:By activating this option, the Quick Help Window will be displayed afterfuzzyTECH has been started.

Enable Confirm Dialogs:When enabled, this option ensures that a confirmation dialog is shown for anyaction that changes a fuzzy logic system. Experienced designers should disablethis option to accelerate the design process.

Page 44: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

44

Open Matrix Rule Editor by Double-clicking Rule BlockDouble-clicking a rule block opens the Matrix Rule Editor instead of theSpreadsheet Rule Editor (default setting).

File Format

Commented File Format:fuzzyTECH supports two different file formats. Here you can choose between afile format with or without comments.

fuzzyTECHPreferences: Save

Save Options

Automatic Project Backup:fuzzyTECH saves the current system in a separate ...\BACKUP directory atregular intervals as specified by the time period. Back-up files of fuzzy systemsare saved automatically with the respective system’s name and the file extension*.FT! in this directory.

Save Window Configuration:If the “Save Window Configuration” option in the fuzzyTECH Preferencesdialog Save is enabled, fuzzyTECH saves the positions and sizes of all windows,as well as the configuration of all open analyzers, in a *.CFG file whenever yousave the *.FTL file. The functions “Open...” and “Save As...” in the main menuFile also let you save and open *.CFG files under a different project name. Thisallows you to have multiple configurations for the same project.

Prompt for Project Information:The dialog Project Information is automatically displayed to enter generalinformation about the current project after the instruction had been given to saveit.

fuzzyTECHPreferences: Text Editors

Text Editor:Lets you specify a preferred editor to view data and project files.

Word Processor:Lets you specify the word processor for documentation.

fuzzyTECHPreferences: Watch Window

Watch Window

Open Iconized:The Watch: Debug <Mode> Window is active in any debug mode. It alwaysdisplays the crisp values of all input and output variables of the system. Enablingthis option always minimizes the Watch Window any time you start the debugmode. If you have low video resolution, you can use this option to save screenspace and computing time.

Page 45: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

45

Use ColorsEnable or disable this option to show input, output and intermediate variables inthe Watch Window colored or uncolored.

Show Intermediate VariablesAll intermediate variables are listed in the Watch Window.

Edit DDE Input VariablesChoosing this option, a DDE linked input variable can be edited additionally inthe Watch Window.

Digits No. of Digits after Decimal:For some values, such as in the Watch Window or in the display of definitionpoints in the Variable Editor, the number of decimal places can be determined inthe edit field of this option.

fuzzyTECHPreferences: Matrix Rule Editor

Matrix RuleEditor

Advanced Display in Matrix ItemsAdditional information can be displayed in the matrix items. If this check box isenabled, the number of rules defined in the item or overlayed by "don't care"rules can be seen in the upper left corner of each matrix item.

Minimum Size of Matrix ItemsThe size of the matrix items corresponds to the window size of the Matrix RuleEditor. However, the size of the items cannot be smaller then the mimimum sizeof matrix items (in pixel ) entered in this edit field.

Maximum Size of Matrix ItemsThe size of the matrix items corresponds to the window size of the Matrix RuleEditor. However, the matrix items can be streched only up to the maximum sizeof matrix items (in pixel) entered in this edit field.

Display Options of Matrix Items

This field contains different display options for the matrix items. The MatrixRule Editor shows its matrix items at opening according to the preferred displayoption. Once the Matrix Editor is open, it can be switched between differentdisplay options using the symbols of its toolbar. The following display optionsare available:

Gray ScaleThe name of the output term of the strongest rule is displayed abbreviated (firsttwo letters of term name) in the middle of a matrix item. In design mode, acomplete plausible rule (Degree of Support (DoS) =1) is indicated by a white cellbackground. A dark gray background points to a complete implausible rule

Page 46: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

46

(DoS=0). Brighter gray tones indicate a DoS value within the interval [0,1]. If norule at all is defined for a matrix item, it appears with a black background. Indebug mode, the toolbar symbols [Input Aggregation] or [Composition withDegree of Support] can be chosen instead of the symbol [Degree of Support],which is the default setting. Then gray tones display then the firing degree of therule.

Term ColorsThe output term of the strongest rule is displayed for each matrix item. Thecolor of a matrix item corresponds to the color assigned to the output term in theVariable Editor.

False ColorsThe output term of the strongest rule is displayed for each matrix item in falsecolors. The false colors scale goes from bright green to dark green for positiveterms and from bright red to dark red for negative terms. The color tone relates tothe position of the term in the term list of the Variable Editor. The firstpositive/negative term of this list is bright green/red, the last term is darkgreen/red.

fuzzyTECHPreferences: Serial Interface

The serial interface of the Online/RTRCD or Serial Link connection isconfigured in this dialog. Click the [Help] button in this dialog to open thefuzzyTECH Help to read a description of the dialog’s options.

Customization of theViewing options Most viewing options can be set and changed in main menu View (Figure 27).

You may, for instance, hide toolbars or the statusbar to use the extra space toview more of the window or to save screen space on low resolution monitors.

Figure 27: The Main Menu View Contains Various Options that Allow You toConfigure fuzzyTECH According to the Requirements of Your Development PC

and Your Personal Preferences.

Toolbars: The Toolbar is a set of buttons bound to commonly fuzzyTECH commands toprovide quick access. Toolbars can be defined for the fuzzyTECH windows listedin the pop-up menu that opens if you choose the option Toolbars in the Viewmain menu. Here you can decide whether you want to see or hide the toolbar.

Page 47: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

47

Toolbars can be made visible or invisible either by choosing the Show All or theShow None option or by separate selection. A check mark beside the menu entryindicates that the toolbar in the respective window is visible.

Statusbar: Enabling or disabling this option lets you see (or hide) the statusbar. A checkmark beside the command indicates that the statusbar is visible. The Statusbar isthe gray area at the bottom of the main window of fuzzyTECH that displaysinformation about the currently selected command, the current system state orabout an operation in progress.

Zoom ProjectEditor In the fuzzyTECH main window, the display of the Project Editor can be

magnified or reduced. Zoom it to 75%, 50% and back to 100% (default setting).

Gridlines: In the Variable Editor and the Time Plot window, the gridlines can be switchedon and off. The resolution of the gridlines is determined automatically.

Term ListBox: Term List Boxes in the Variable Editor can be made visible or invisible by

choosing the Show All or the Show None option.PlotBackground: Use this option for screen display of the Time Plot and the 3D Plot to turn the

black background color to white.

Lines: Use the option Thick for high resolution monitors to increase the line thicknessin the windows of the Variable Editor and the Time Plot.

ObjectComments: Shows the written comments of every object in the form of a tool tip, when the

mouse is placed directly on the object.

Treeview: Only Shows the Treeview window. To hide and show the Treeview window,click the [Treeview] symbol in the main toolbar. Clicking the keys [Alt] + 0(zero) you can switch from any window to the Treeview.

3.1. First steps

Make now your first steps at designing a fuzzy system. At first a short overviewof the following contents:

System Structure The Fuzzy Design Wizard (FDW) supports quick generation of a structuredsystem. For inexperienced designers, the FDW provides a step-by-step guidancethrough all fundamental design steps. Experienced designers can design a systemprototype in just minutes. Instead of creating a new system, the FDW can also beused for adding a supplementary system to an already existing system.

Page 48: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

48

System Definition Section 3.1.2 presents the basic steps involved in the definition of an initial fuzzylogic system prototype using fuzzyTECH: set up of the system’s structure,definition of the linguistic variables, membership functions, rule blocks, text, andthe formulation of the fuzzy logic rule base.

Off-lineOptimization Once an initial prototype is set up, the system structure is further refined using

the numerous analyzer features for off-line optimization. Interactive debugging,which is used to analyze the system’s reaction to specific situations, can be usedto verify system behavior in abnormal situations. Depending on the type ofapplication, either pre-recorded process data or pattern-generator created datasets may be used for optimization. Within off-line optimization, fuzzyTECHoffers a number of analyzers for system verification. Also, a mathematicalsimulation of the process or window’s application software can be linked tofuzzyTECH.

OnlineOptimization Online optimization allows a system to be visualized and modified in real-time

on the running process. The control processor (e.g., an embedded controller) isconnected to the development PC via a link (e.g., a serial cable). This allows thevisualization of the entire inference flow, like in the Interactive mode, except thatit is done in real-time. Most system parameters can also be modified in real-time,thus allowing “on-the-fly” system optimization without halting the process. Inmost closed-loop applications, online optimization features speed up thedevelopment cycle by magnitudes.

fuzzyTECH analyzers are described in Section 3.1.3.5. Refer to Section 3.1.3.6for more details on online optimization. After the system has been optimized andverified, it can be implemented on various hardware platforms. An overview offuzzyTECH-supported implementation alternatives is given in Section 6.

➔ Read the following sections carefully and follow the (➔) sign in the order of its appearance.It guides you through the design of a fuzzy logic system from scratch.

3.1.1. Rapid Application Development with theFuzzy Design Wizard

The Fuzzy Design Wizard (FDW) supports quick and step-by-step generation ofa system prototype. For inexperienced designers, the FDW provides a step-by-step guidance through all fundamental design steps. Experienced designers candesign a system prototype in just minutes.

Page 49: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

49

The basic idea of the FDW is to propose default values for all design decisions.This minimizes the input required for generating a fuzzy logic system prototype.If you specify a sample data file, the FDW automatically determines defaultparameters for many design decisions from the data. With these features, theFDW is well suited to create the “empty” fuzzy logic system that NeuroFuzzytraining requires.(refer to Section 4.1.1).

Dialog Sequence The FDW activates a sequence of dialogs that guide you through the creation ofa complete fuzzy logic prototype. The FDW can also be used to create a newcomponent for an existing fuzzy project. Each window contains a few of theseveral required design steps. For each step, reasonable defaults are displayedwhen entering the dialog. The defaults can be accepted or changed. Note that youcan overwrite later all of the default parameters if desired. The sequence ofdialogs is as follows:• Welcome Dialog,• Number of Variables Dialog,• Define Variables Dialogs for each linguistic input variable,• Define Variables Dialogs for each linguistic output variable,• Define Defuzzification Method Dialog for each defined output variable,• Define Rule Blocks Dialog.

➔ Call the FDW by either selecting “File/Fuzzy Design Wizard...” in the main menu or byclicking the respective button in the main toolbar. Follow the instructions given on thefollowing pages.

Control Buttons The [Help], [Cancel], [Previous], [Next] and [End] buttons are located at thebottom of each FDW window. The [Next] button always takes you to the nextwindow. The [Previous] button always brings you back to the previous window.By stepping back and forth in the FDW windows, you can reverse any designdecision you make. The [End] button forces the FDW to generate the fuzzy logicsystem with the current specifications. Since the FDW proposes default valuesfor every design decision, the [End] button can be pressed in any FDW window.The FDW also ends when the [Next] button is pressed in the last FDW dialog.Then, the a confirmation dialog (Figure 32) appears before the actual system isgenerated.

In the first FDW window (Figure 28), specify:• Whether the fuzzy logic system to be created shall be added to the currently

opened fuzzy logic system or whether you want to create a new system.• Whether a sample data file exists that can be analyzed by the FDW. By

Specifying a Sample Data File, the FDW automatically extracts design data.The FDW uses information such as variable names, as well as the intervaland the distribution of the values, to propose default variables in later FDWwindows.

Page 50: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

50

Figure 28: Welcome Dialog of the Fuzzy Design Wizard

➔ Enable the check box, “Create New System” (see Figure 28). Press the [Enter] key or click the[Next>] button to open the next FDW dialog (Figure 29).

Figure 29: In the Second FDW Window, You Specify the Number of Input,Output and Intermediate Variables and Their Term Numbers.

In the Dialog Number of Variables you determine the number of input,intermediate and output variables as well as the number of terms for each ofthem. The number of terms can be changed for each variable in the followingFDW dialogs.

Page 51: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

51

➔ Accept the suggested default settings and click the [Next>] button to open the next FDWdialog (Figure 30).

Figure 30: The FDW Opens This Dialog for Each Variable to be Created.

The next FDW dialog Define Variable defines three linguistic variables (three isdefault setting) of the system. Define the first input variable: give it a name orleave the proposed default name, accept the proposed default range from 0 to 1,and choose the term names out of the pull-down list.

➔ Accept the settings proposed by the FDW and step to the next FDW dialog. The dialog fordefining the next variable opens. This is continued as long as there are input, intermediate andoutput variables of the system to be defined. After all variable have been defined, the nextFDW dialog Define Defuzzification opens. This dialog helps to define the defuzzificationmethod for the output variable. Accept the proposed default by clicking the [Next] button orpressing the [Return] key.

The next FDW window defines the rule blocks (Figure 31). To keep the systemstructure as simple as possible, just define only one rule block. Enabling thecheck box, “Create Rule Base”, lets the FDW generate a complete rule set foreach rule block. For each combination of terms, a rule is generated. As Degree-of-Support (DoS), either random values (“Random Value”) or a constant value(“User Defined Value”) is assigned. The FDW proposes the generation of a ruleset where all rules have a DoS of 0. Since the DoS is the degree of membership arule has in the set of totally true rules, this is equivalent to a set of completelyfalse rules. Hence, the generated rule set contains no information. The reason forcreating a complete, but totally false rule set is that the NeuroFuzzy training canonly start with an existing rule set.

Page 52: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

52

Figure 31: The Last FDW Window Specifies Whether andHow the FDW Generates Rule Blocks.

➔ Accept the proposed default values of the FDW and either click the [Next] button or press the[Return] key. Since this is the final window of the FDW, this is equivalent to pressing the[End] button. After pressing [Next], the Confirmation dialog (Figure 32) appears.

Figure 32: Before the Fuzzy Design Wizard Generates the System, ThisConfirmation Dialog Is Displayed.

Confirming this dialog or pressing [End] generates the system shown in Fig. 33.Take this simple fuzzy project as basis for the further design steps of thefollowing sections.

Figure 33: Structure of the System Generated By the FDW.

Page 53: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

53

3.1.2. System Definition

System definition is a fundamental step for setting up a fuzzy logic system withfuzzyTECH. After a system prototype has been generated using the Fuzzy DesignWizard, it is edited and adopted to the system. This section describes the objectsof a system as well as the ways to define and configure them.

3.1.2.1. Structure of a Fuzzy Logic System

The initial system structure is defined by the rule “vocabulary”, which includesthe input and output variables with their linguistic terms. In addition to thelinguistic variables, a preliminary rule set must also be created for a first systemprototype. For complex systems, a structure of rule blocks, linguistic variables,and text blocks (as optional objects) can be designed. System structure isdisplayed graphically in the Treeview and Project Editor window. In the ProjectEditor, information flow between rule blocks and linguistic variables is indicatedby the lines connecting the different objects. All objects are listed with their sub-groups in a hierarchical order in the Treeview. Three object types are used in thewindow:• Text: Text is an (optional) object used to make a fuzzy logic system structure

more transparent and describe the system structure. Text objects have nocomputational influence and can be inserted at any place in the worksheet indifferent colors and font sizes.

• Variables: Each input or output variable of the system is linked with aninterface. Interfaces are displayed as small boxes showing the variable’sname and an icon representing the chosen computation method. Inputinterfaces show the icon on the left side and output interfaces on the right.The total number of variables in a project depends on the fuzzyTECH Edition.Please refer to Section 9.4, Table 1 for an overview. Intermediate Variablesare not linked with an interface and occur thus only in the rule block theybelong to.

• Rule Blocks: In fuzzyTECH, individual rules are confined into rule blocks tobuild the system structure: Each rule block contains the rules for a set ofvariables. The rule blocks of a system contain the entire fuzzy inference step.The number of rule blocks that can be defined in a project depends on thefuzzyTECH Edition. Please refer to Section 9.4 for an overview.

3.1.2.2. Editing Objects

Using the Keyboard fuzzyTECH can be used with a mouse or keyboard. The [Ctrl][F6] keys let youswitch the focus between the windows of the main window. Within a window,the [Tab] key selects different groups. Use the arrow keys to move within a

Page 54: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

54

group and the [Return] / [Enter] key to activate an object. An object can also beactivated with the [Space] bar. Switch from any window to the Treeview by theshortcut [Alt] + [0] (zero). Select an object in the Treeview and press thefunction key [F2] to rename it. Some objects, such as definition points in theLinguistic Variable Editor or the objects in the Project Editor, may be movedwithin the window. In order to arrange these objects with the keyboard, firstselect or activate the object to be moved using the [Tab] key, and move it withthe arrow keys. The [Enter ]key releases the object at the desired position.

Using the Mouse Objects can also be moved using the mouse. Simply drag and drop objects usingthe left mouse button. Holding the [Shift] key before dragging the objectprovides positioning assistance: the direction in which the object was firstdragged is fixed. Different cursor shapes indicate the movement mode. Clickingon any object with the left mouse button highlights the respective object.Double-clicking an object opens the editor for this object. Double-clicking left arule block activates the Spreadsheet Rule Editor for this rule block

Pop-up Menu of theProject Editor Pop-up menus open by clicking the right mouse button in a fuzzyTECH window

or the function key [F9] or the keys [Shift][F10]. Most of the fuzzyTECHwindows use pop-up menus, e.g. Treeview, Project Editor, Variable Editor,Transfer Plot, 3D Plot, Time Plot, Revision Control, Spreadsheet Rule Editor,Matrix Rule Editor, and Watch Window.

Figure 34: Project Editor Pop-up Menu

Pop-up menus provide quick access to functions that let you change theproperties of the highlighted object or create new objects. Note that in the ProjectEditor or Treeview, different pop-up menus open according to the highlightedobject. The following shortcuts (see Figure 34) call fuzzyTECH’s differentwizards to create a new object and expedite system design:[Ctrl][V] Linguistic Variables Wizard[Ctrl][R] Rule Block Wizard,[Ctrl][X] Text Properties Dialog.

Properties Dialogs The only exception here is the Text Properties dialog, which is a “Wizard” and a“Properties Dialog” at the same time. While you can create new objects only byusing Wizards, you can edit or change the properties of the generated objects byso-called “Properties” dialogs. Open such a Properties dialog by highlighting therespective object in the Project Editor or Treeview, clicking right to choose theoption “Properties” in the pop-up menu.

Page 55: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

55

Another way is to highlight the object and to click the symbol [Properties] infuzzyTECH’s main toolbar. In addition to typical Properties dialogs (forvariables, rule blocks and text), there is another Properties dialog, the TermProperties dialog for editing the terms of a linguistic variable.

Editors Besides Properties dialogs that function as editors, there are some fuzzyTECHwindows that function as editor, too. Use the Matrix Rule Editor or SpreadsheetRule Editor to edit rule blocks or the Variable Editor for linguistic variables. Allare accessible through the pop-up menu of the respective object. Or by double-clicking a variable or a rule block to open the Variable Editor or the SpreadsheetRule Editor.

Deleting Objects To delete an object in the Treeview or Project Editor, highlight it and press the[Del] key. Another way is, to highlight it, open its pop-up menu by clicking itright and choosing the option Delete. Then a dialog appears, asking you toconfirm your intention in order to avoid objects to be deleted unintentionally.

Undo Function fuzzyTECH provides a multi-stage UNDO function. You can undo most actionsby pressing the keys [Alt] + [←] (Backspace) or selecting “Edit/Undo” from themain menu.

3.1.2.3. Definition of Text Objects

Text is an (optional) object used to make a fuzzy logic system structure moretransparent and describe the system structure. Text objects have nocomputational influence and can be inserted at any place in the worksheet indifferent colors and font sizes. Create new text objects or edit them by using theText Properties dialog (Figure 35).

Figure 35: Text Properties Dialog

Page 56: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

56

Each new text is listed in alphabetical sequence of its first letter in the Treeview.In the Treeview, rename a text object by right-mouse clicking it to open its pop-up menu and selecting the Rename option.

➔ Create text to document your fuzzy logic system by clicking on the main part of the windowwith the right mouse button and selecting [New Text...] from the Project Editor’s pop-up menu.Enter the text to appear in the “Text:” field, plus specify font size and color of the text byclicking the [Font] button in the Text Properties dialog. Confirm the settings and leave thisdialog by clicking the [OK] button. Create then other text as comment for each object in yoursystem.

After closing this dialog by clicking the [OK] button, the new text has to bepositioned in the Project Editor Window by clicking there on the appropriatedplace. Text objects can be copied into the Project Editor and Treeview byselecting it in one of both windows, opening its pop-up menu and choosing theoption Duplicate.

Figure 36: Text Blocks Explaining the Objects of the Fuzzy System

3.1.2.4. Defining Linguistic Variables

Linguistic variables are components of fuzzy logic systems that “transform” real,crisp values into linguistic values. Supposing you are a GP and you take apatient’s temperature. You assign his temperature to such categories like: “veryhigh temperature ” (fever), “high temperature”, normal temperature”, or “lowtemperature”. These expressions or different values are called “linguistic terms”of a linguistic variable (e.g. temperature). Refer to this case study in Example 1(page 152) of Section 5.1.2 for theoretical background.

Page 57: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

57

➔ Start the design of your fuzzy logic system from scratch by defining linguistic variables.(Create at first only one linguistic variable and add it to the system generated in Section 0.)Open the Treeview’s or Project Editor’s pop-up menu by pressing the [F9] key or clicking withthe right mouse key and choose the option New Variable.

Linguistic VariablesWizard This function opens the first dialog of the Linguistic Variables Wizard

(Figure 37), which can also be opened by clicking the [Variables] symbol infuzzyTECH’s main toolbar. Define name, type, and computational method for thevariable in this first dialog “Define Linguistic Variable”. fuzzyTECH uses a pre-defined variable definition to prototype the variable. At this place it may bementioned that all dialogs are explained in fuzzyTECH’s help system in detail.

Figure 37: Define Linguistic Variable Dialog

Type The type of the variable (input, output or intermediate) is determined in thisfield. Depending on the chosen variable type, different computation methods arelisted in the field Method. Each input and output variable is automaticallygenerated with an input or output interface (indicated as small frame or box).Each interface can only contain one linguistic variable. For details on fuzzy inputvariables and fuzzy output variables, refer to Chapter 5.

An intermediate variable passes information from one rule block to another infuzzified form (e.g. as vector of the firing degrees of an intermediate variable'ssingle terms). Therefore, intermediate variables can only be linked with a ruleblock, but not with an interface. Intermediate variables are never subject tofuzzification or defuzzification. That's why the intermediate variable's values are"only" linguistic (fuzzy) values and membership functions of variable terms donot play any role for it.

Page 58: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

58

Method In this field, a fuzzification method is chosen for a system input and adefuzzification method for a system output. Compute MBF for fuzzification andCoM for defuzzification is the standard approach. Compute MBF efficientlycomputes the membership degrees of the terms of the input variables from crispinput values. CoM is a high performance defuzzification method that computes acrisp set value by compromising between multiple firing outputs. The methodslisted in this field may vary in dependence from your fuzzyTECH Edition (referto Section 9.4).

Input Interfaces Input interfaces are displayed in the Project Editor as boxes. In each box, thelinguistic variable is printed on the right side and the fuzzification method isshown as an icon on the left side.

Figure 38: Different Fuzzification Methods

In Figure 38, the first interface box uses the “Compute MBF“ fuzzificationmethod and the second interface box uses the “Look up MBF“ fuzzificationmethod. The later computes fuzzification at compilation time and stores theMBFs as look-up tables in the run-time code. This consumes significantly morememory than the former but yields a faster performance, especially when non-Standard MBFs are used. When no fuzzification is used, a bar graph iconappears. This allows a “fuzzy” input or customized fuzzification methods.

Output Interfaces Output interfaces are displayed as boxes, in which the linguistic variable name isprinted on the left side and the defuzzification method is shown as an icon on theright side. The first interface box in Figure 39 shows the Center-of-Maximum(CoM) method, the second shows the Mean-of-Maximum (MoM) method andthe third shows the Center-of-Area (CoA) method.

Figure 39: Different Defuzzification Methods

Page 59: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

59

The Center-of-Area method is sometimes called Center-of-Gravity (CoG). Thelast interface box shows the hyperdefuzzification method Hyper CoM.Defuzzification can also be omitted to allow a “fuzzy” output or to usecustomized defuzzification methods.

Visualization Interfaces fuzzyTECH also allows the connection of process variables to interfaces that arenot used for the fuzzy calculation.

An interface type similar to the input interfaces isselected by the “Display” radio button. Like inputinterfaces, the Display interface reads and displays theassigned process variable value.

The Force interface is handled similar to outputinterfaces. Instead of values calculated by the fuzzycomputation, the values to be forced can be entered inthe appropriate Watch Window.

➔ Enter a name for the variable and confirm all other default settings by clicking the [Next>]button. This opens the next dialog of the Linguistic Variables Wizard “Base Variable Range”.

This dialog (see Figure 40) of the Linguistic Variables Wizard's lets you specifyrange, default value, and name of the base variable. The fields “Minimum” and“Maximum” let you specify the universe of the base variable. Tworepresentations exist in fuzzyTECH: Shell Values and Code Values. The basevariable’s unit, entered in the field Unit, serves only the purposes of displayingthe unit of the base variable in the variable editor.

Figure 40: Linguistic Variables Wizard: Base Variable Range

Page 60: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

60

Base Variable A Base Variable describes the basis (i.e. the crisp value) of a linguistic variable.Two different kinds of representation exist for the variable range: the Shellrepresentation and the Code representation. The Shell representation is used forall editors and debugging tools during development, while the Coderepresentation is used in the generated code (assembler, C, ...). In all fuzzyTECHEditions that support floating point resolution for fuzzy logic inference, the Shellrepresentation may alternatively be chosen for the generated code.

Shell Values vs.Code Values Take the input variable “Angle” of the crane controller for example. The range of

this linguistic variable is the interval from -90 to +90 degrees. However, inhardware implementation, the angle of the load is measured by an incrementalsensor with an output in the interval from 240 to 1400. The necessary conversioncan be automatically made through fuzzyTECH by entering the range [-90°,+90°] for Shell values and the range [240, 1400] for Code values. The Shellvalues are used for all editors and analyzers within fuzzyTECH, as well as for thedebug modes File Recorder and Batch. The Code values are only used togenerate the C or assembler code. If you want the Shell and the Coderepresentation to be equal, just enter the same range. Use the respective buttonsto set the Code Values to their minimum or maximum values.

Code Range The minimum and maximum of the code value interval depend on the data typeselected in “Tools/Project Options/Global Options”:

Data Type Minimum Maximum8 Bit Integer 0 25516 Bit Integer 0 65 535

Double Precision -1.7E+308 1.7E+308

If you have selected “Double” as “Base Variable Data Type” in the ProjectOptions/Global dialog to activate this dialog, the same values are used in thegenerated code. However, the use of double resolution float variables is ofprohibitive computational effort for most microcontrollers and other real-timeprocess controllers. Also, many compilers used with these target hardwareplatforms cannot provide libraries for this computation. Hence, the column“Code Values” lets you specify integer values for the minimum and themaximum of the variable in the generated code. The possible range for theseinteger values depends on the base variable data type. Assuming you want toimplement the crane controller on a 16-bit microcontroller. Your distance sensordelivers values from 822 to 3222 for a distance of -10 and 30 yards respectively.If you specify 822 and 3222 as code values, fuzzyTECH automatically convertsthese values into the shell values used for display in all editors and analyzers.

The reason for this automatic range conversion is that the code generators offuzzyTECH can tie in the range conversion with the fuzzification code. Thissaves both on conversion code, as well as computing steps, and makes the codeproduced more efficient. If you do not need this automatic range conversion,

Page 61: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

61

click the [Minimum] and [Maximum] buttons to achieve maximum integerresolution. If no rule for this variable fires and it is used in an output interface,then the “Default” field lets you specify a default value that is output by thefuzzy logic system. The field “Base Variable Unit” lets you specify a unit stringfor the base variable. This string is used for display purposes only.

Default Value If for any output variable, no rule fires as a result of the fuzzy inference, thedefault value is used for output. For input variables, this value has no meaning.The default value must be within the range of the Min. and Max. Shell values.

➔ Confirm all default settings by clicking the [Next>] key to open the next dialog “MBFDefinition” of the Linguistic Variables Wizard (Figure 41).

MBF Definition The degree, to which a crisp value belongs to a fuzzy set, is determined by afunction, the so-called membership function (MBF). Membership functions areexplained in more detail in Section 3.1.2.5 and Section 5.2.1.

Figure 41: Linguistic Variables Wizard: Definition of Membership Functions(MBF Definition)

This dialog (Figure 41) of the Linguistic Variables Wizard lets you visuallydefine the membership functions of the linguistic variable from a holistic view,and choose term names from several default name sets. According to the selectednumber of terms, different name sets are provided in the drop-down list. Use thehigh shoulder option to generate standard variables that are used in inputinterfaces, and use the low shoulder option for variables used in outputinterfaces. A symmetrical or non-symmetrical approach can be appropriatelyselected according to the respective application.

Page 62: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

62

➔ Choose High Shoulder for generating a default variable for an system input, or choose LowShoulder for an system output. Choose a symmetrical or asymmetrical non-linearity andconfirm all other default settings by clicking the [Next>] key to open the next LinguisticVariables Wizard dialog “Comment for Variable”.

Comments for Variable This dialog enables you to comment on the variable definition. The comment isdisplayed as a tool tip whenever the mouse pointer rests over the variable namein the Treeview or Project Editor. This comment is also taken for the automaticdocument generation by the Documentation Generator (see Section 3.1.4.2). Ifyou have entered an abbreviation as variable name (e.g. var1), you can explain itin the upper field of the dialog. The abbreviation with its explanation is thenincluded in the List of Abbreviations that is part of the automatic projectdocumentation.

Figure 42: Comment the New Linguistic Variable

➔ Enter a comment for this variable. Click then [End] or [Next>] and in the followingconfirmation dialog [Yes] to return from the Linguistic Variables Wizard to the Project Editor.Double-click a variable interface in the Project Editor to open its Variable Editor. In theVariable Editor, click right to open its pop-up menu.

Variable Editor Linguistic values (also called terms or labels) associated with a linguisticvariable (for “Distance” they could be far, medium, close, zero or neg_close).The Variable Editor (Figure 43) allows the graphic definition of each term’smembership functions.

Page 63: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

63

Figure 43: Variable Editor of the New Variable with Pop-up Menu.

Clicking the [Listbox] button displays a list of all terms defined for theassociated linguistic variable at the left side of the Variable Editor window. Onthe right side, the linguistic variable’s membership functions are plotted. Theterm names are displayed over the peaks of the functions. In order to select aterm, click on the term name in the listbox or above the plot area. If the listbox ishidden, terms can be also be highlighted by clicking the Variable Editor’s toolbarbutton [Next Term] . The name of a selected term is displayed in boldcharacters over the membership function plot area and its definition points areindicated by squares.

Sort Terms Terms are listed in the Variable Editor window’s list box according to theirposition. They can be sorted by clicking the toolbar button [Sort Terms] . Firstof all, positive terms are listed, then negative terms. Within the list of thepositive and negative terms of a variable, terms are sorted according to themaximum of their membership function. In order to help you visuallydifferentiate among the terms, assign them different colors using the [Color...]option. Note that not all colors can be displayed on certain video adapters.

➔ Click on the toolbar button [Base Variable] . This activates the Variable Properties: BaseVariable dialog (Figure 44).

Variable Properties:Base Variable This dialog is used to change the range of the base variable defined in the

Linguistic Variable Wizard’s dialog “Base Variable Range”. A base variable isthe range of value of a crisp variable that is represented by the linguistic variable.The upper part of this dialog is analogous to the Linguistic Variable Wizarddialog “Base Variable Range”.(see page 60), except the lower part GridResolution. That’s why the same dialog is opened if the Variable Editor’s toolbarsymbol [Grid] is clicked. The function of the Grid symbol and all the othersymbols of the Variable Editor’s toolbar is explained in Section 3.1.2.5.

Page 64: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

64

Figure 44: Variable Properties: Base Variable Dialog. This figure displays the“Temperature” case study and the range of value, for which a linguistic variable

“Temperature” would be valid.

➔ Leave the Variable Properties: Base Variable dialog by clicking [OK].

3.1.2.5. Defining Membership Functions

Definition of Terms Defining a linguistic variable also includes the definition of its possible linguisticvalues (terms), ranges of value, and membership functions. The degree ofmembership, i.e. the degree, to which a crisp value belongs to a linguistic value(term) of the linguistic variable, is computed by means of membership functions.This membership degree is represented by a value in the range of 1.0 and 0.0. Amembership degree of 0.0 means no membership at all, a degree of 1.0 - absolutemembership.

A value, lying beyond the defined range, obtains the membership degree of theterm’s definition point that is situated at the leftmost or rightmost side of theVariables Editor. It is considered as an absolute member of the respective term’sfuzzy set (µ=1). For example, if a value of 35 Yards would be entered for thevariable Distance (see Figure 45), it would be assigned to the term far with amembership degree µ=1.

Page 65: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

65

Figure 45: Defining a Standard MBF for the Term “zero”.

In some applications, the value that characterizes a term best is not a specificnumber, but an interval. For example, any distance within ±2 yards from thetarget point could be considered zero and would be best represented as a Pi-shaped MBF. Figure 46 shows an example of this.

Figure 46: Definition of a Pi-type MBF for the Term “zero”.

➔ The variables, generated by the Variables Wizard, contains already three default terms. Tocreate a new term, choose the option New Term from the Variable Editor’s pop-up menu orclick its [New Term] toolbar button .

Term Properties This calls the Term Properties dialog (Figure 47) that can also be opened bydouble-clicking a term’s name in the Variable Editor or in the Treeview. Use thisdialog to generate new terms or to change the properties of already existingterms, such as the name of the term, its color, sequence of terms and functiontypes.

Page 66: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

66

The name of a term is displayed in the field Name of this dialog. Term namescan be changed either there or in the Treeview by clicking the term name withthe right mouse key and choosing the option Rename from the pop-up menu (orjust press [F2]. Note that the term’s name, if contained in the generated code, hasto consist of alphabetical letters (and underscores) only and should not containany empty spaces at all. Terms can be visually differentiated by assigningdifferent colors to each of them via the [Color] key.

Figure 47: The Term Properties Dialog Lets You Specify aCharacteristic Features of a Term.

Shapes of Terms Specify a term’s membership function type in the Term Properties dialog’sShape field. (Refer to Section 5.1 for a comparison between differentmembership function types.) fuzzyTECH uses point definition of membershipfunctions. To connect these definition points, fuzzyTECH supports linear shapes(L-Shapes) and S-shapes. You can select between these types using therespective radio buttons. For S-shape membership function definition, you canalso specify the asymmetry factor in the range from 0 to 1.

MCU Editions support only L-Shaped (Linear Shape) membership functions ofStandard MBF type. For standard MBFs, straight lines are used to connect thedefinition points of a term (i.e. its maximum and minimum). See Figure 45 forthe definition of the term zero.

➔ Close the Term Properties dialog by clicking [OK] to return to the Variables Editor.

Point Definition ofMembership Functions For each new term, a default membership function of Lambda type is created.

Standard MBFs are defined by specifying their definition points. Each point canhave a degree of membership of either 0 or 1 (refer to Section 5.1 for details onStandard MBF’s). A term’s definition points are drawn as small rectangles: ahighlighted rectangle ( ) indicates a selected point, and an empty rectangle( ) shows a deselected point. A highlighted point’s coordinates are shown inthe lower left part of the Variable Editor. Point coordinates can also be directly

Page 67: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

67

entered by entering the value followed by pressing the [↵] key. For a variablewith multiple terms, the membership functions of all terms are displayed. Inorder to select a term in the Variable Editor, click on the term name in the listboxor above the plot area.

The definition points of membership functions can be freely positioned anddragged. The definition points of the membership function of the selected termappear as small squares in the plot area. You may highlight individual definitionpoints with mouse click and then drag them. A highlighted definition point isindicated by a filled square. Above the plot area, the term names are displayed.Each name is assigned to the “peak area” of the defined membership function.

Double-click on an empty space in the plot area to create a new definition pointfor the selected term. In order to delete a definition point, select it byhighlighting the point with a mouse click and then press the [Del] key. Theconfirmation dialogs that pops up any time you clear a system component can beavoided by disabling the “Enable Confirm Dialogs” option in Tools/fuzzyTECHPreferences/General.

Operate onMultiple Points Assistance with MBF definition tuning is provided by allowing multiple point

editing, i.e. more than one point can be selected at the same time. Highlight themost left point and depress the [Ctrl] key. While pressing the key, fuzzyTECHlets you select additional points. As long as you hold the key, you can move thecomplete set of selected points. Using the [Shift] key selects a complete range ofpoints. With this feature, sections of the MBF defined by multiple definitionpoints can be dragged. Note that the left and right most points can only be movedvertically. If the most left or right point is contained in a highlighted set ofpoints, the whole set can only be moved only vertically. This ensures thedefinition of a term over the complete universe of discourse.

➔ Create two new terms for the variable generated in Section 3.1.2.4 by using the TermProperties dialog. Refer to the case study in Example 1 (page 152): Rename this variable into“Temperature”. Change the variable’s name by clicking it right in the Treeview and choosingthe pop-up menu’s Rename option. Change now the term names and call them as follows: low,normal, above_normal, fever, strong_fever. Set the definition points of the “Temperature”variable’s five terms according to their names: low, normal, above_normal, fever, strong_feverto the following maxima: 35, 36.7, 37, 38, 41 (base variable’s unit: °C Degree of Celsius).

When defining terms, proceed in the following steps:1.) Find the numerical values or range of values that best characterize each term

of a linguistic variable. Since this is a “prototype” value, it should have amembership degree of 1 in the fuzzy set describing the term.

2.) Once the values having a membership degree of 1 have been defined, thecorresponding values with a membership degree of 0 should be defined.

3.) After all values with membership degrees of 0 and 1 have been defined,intermediate values can be defined.

Page 68: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

68

Grid Function The Variable Editor provides a grid function to ease the placement of definitionpoints. Use the base variable grid to divide the base variable range into intervalsthat allow an easy positioning of definition points. Select [Grid...] in the VariableEditor’s pop-up menu or click the toolbar button [Grid] . This opens the dialogVariable Properties: Base Variable.

The grid resolutions for the base variable (horizontal axis variable) andmembership degree (vertical axis) can be chosen independently. Enter the value“0.1” for “Membership”. This allows the membership degree of definition pointsto be set at values of 0, 0.1, 0.2, etc.. Enable the check box “Snap to Grid” andclose the dialog box by clicking [OK]. If you now drag definition points, onlygrid positions are considered. The fields “x” and “y” show the coordinates of thenearest grid position to the current mouse cursor position while no definitionpoint is highlighted. If one definition point is highlighted, the “x” and “y” fieldsshow its position. You can now also enter new coordinates for this point in thefields. If more than one definition point is highlighted, the fields show thecoordinates of the definition point which the mouse cursor is over.

If you do not want to use a mouse, you can also highlight definition points by the[Tab] and [Space] keys. Then use the cursor keys to move the definition pointand the [Return] key to place it.

Please note that the gridlines of the Variable Editor’s plot area can be hidden orshown by the Gridlines function choseable in the View main menu. Note thatthis option does not correspond to the grid resolution set in the VariableProperties: Base Variable.

➔ Analogous to the Fever sample, define the range of the base variable for “Temperature” according toFigure 44. In the field Grid Resolution, enter “0.5” in the Base field. This sets the grid resolution inintervals of 0.5, resulting in 14 possible values for “Temperature” (7 °C total difference / 0.5resolution = 14 intervals).

Converting toStandard MBFs The Linguistic Variable editor also can convert any membership function to a

Standard MBF to expedite the design of MBFs. Standard MBFs are supported, ifthe vertikal grid is set to 1 (for the membership) and the option “Snap to Grid” isaktivated. For Standard MBFs, two membership functions are converted into onewith a fixed overlap (for every given value of the base variable, exactly twomembership degrees are not equal to zero).

Simply define only the typical values for all terms of a linguistic variable(Section 5.1), such as:• the maximum point of all Lambda-type default membership functions (the

inner MBFs of input, all MBF of output variables),• the right upper point for a Z-type default membership function (the furthest

left MBF of the input variables) and

Page 69: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

69

• the upper-left point for an S-type default membership function (the furthestright MBF of input variables).

The toolbar button [Convert to Standard MBFs] in the Variable Editorconverts the term definitions to Standard MBFs, i.e. all other points are setautomatically. You may use the converter function at any time during systemdesign.

Figure 48 shows the linguistic variable “Temperature” with its terms low,normal, above_normal, fever, strong_fever” and the typical values of (35, 36.7,37, 38, 41) after conversion into Standard MBFs.

Figure 48: Defining the “Temperature” Variable: The Maximums ofthe MBFs Are Set to the Typical Value for Each Term.

Inverse Terms fuzzyTECH supports the definition of inverse terms to negate linguistic values(terms). For instance, an inverser term could be called not far and used to definerules with negated linguistic statements (like IF “Distance” = not far). See alsoSection 3.1.2.7.

Inverse terms are created by clicking the Variable Editor’s toolbar symbol [NewInverse Term...] or this option from the Variable Editor’s pop-up menu. Thisgenerates a new term (µ') with the inverse properties of the original term’smembership function (µ), i.e. the term that was selected in the Variable Editor’sterm list before. The inverse membership function of a term is computed with:µ'(x) = 1-µ(x). fuzzyTECH uses a separate term for the negation. The negation isnot computed during runtime to allow a higher degree of flexibility duringoptimization. Optimization is mostly necessary due to the fact that the relationµ'(x) = 1-µ(x) does not always apply to the optimized system.

Inverse terms have the following characteristics:• They are listed with a negation sign (¬) before the term name. The inverse

term’s name is (beside the negation sign) identical to the name of the term,from which it has been generated.

Page 70: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

70

• They are virtual, i.e. their membership functions are not displayedgraphically.

• Due to their virtuality, they cannot be edited directly. If the term, from whichan inverse term was generated is edited, then all changes made with this‘original’ term are transferred synchronously to its inverse term. Inverseterms can, however, be deleted separately.

➔ Create an inverse term. Choose a term in the Variable Editor’s term list, from which you wantto generate an inverse term. Then click the toolbar symbol [New Inverse Term] . Inverseterms are always listed at the end of the term list, after the “non-inverted” terms. The propertiesof an inverse term can only be changed by changing the properties of the term, from which itwas generated (original term). Open the dialog Term Properties by double-clicking its originalterm in the Variable Editor, choose another color for it and close the dialog by clicking [OK].The term list shows that the color was changed for its inverse term synchronously. Select theinverse term in the term list and press the [Del] key. This has no effect on its original term.Delete the “Temperature” variable by selecting it in the Treeview or in the Project Editor andpressing the [Del] key. In the Treeview, you wont be successful as long as the Variable Editorof this variable is open.

3.1.2.6. Defining Rule Blocks

In fuzzyTECH individual rules are confined into rule blocks to build the systemstructure. A rule block holds the inference with the production rules and connectssystem outputs to system inputs. The number of rule blocks that can be definedin a project depends on the fuzzyTECH Edition (refer to Section 9.4).

Rule Blocks The symbol for a rule block displayed in the Project Editor consists of twovariable columns and two operator boxes. The left column shows the variablesused in the precondition of fuzzy rules. The right column shows the variablesused for the conclusion of fuzzy rules. The upper box displays the ConditionAggregation Operator. The lower box shows the Result Aggregation Operator.

Figure 49: Rule Block in the Project Editor.

➔ Delete the rule block generated by the Fuzzy Design Wizard in Section 0 (see Figure 33).Create a new rule block for your fuzzy logic system by selecting the option [New RuleBlock...] in the Project Editor's pop-up menu.

Page 71: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

71

Rule Block Wizard This invokes the Rule Block Wizard (Figure 50) which gives comprehensivehelp at designing a new rule block. The Rule Block Wizard can also be called byclicking the symbol [Rule Block] in the main toolbar or the shortcut [Ctrl] + [R].This wizard consists of a sequence of four dialogs. In its first dialog, variablescan be assigned to the rule block as inputs or outputs and a name can be enteredfor the rule block.

Figure 50: Rule Block Wizard: Define Rule Block Configuration

➔ Select a variable in the Variables list and assign it correspondingly to the rule blocks Input orOutput list using the [>Input>] or [>Output>] key. After input and output variables have beenselected, click [Next>], to go to the next dialog “Define Rule Block Operators” (Figure 51).

The fuzzy operators for the new rule block are defined in this dialog. They areused for the fuzzy inference of this rule block which involves threecomputational steps: aggregation (or input aggregation), composition, and resultaggregation. As for input and result aggregation, different fuzzy operators can bechosen. The default operator is Min for aggregation, and Max for resultaggregation. The default operator for composition, the second step of the fuzzyinference, is the PROD operator.

Aggregation The aggregation operator is used to combine the different preconditions of acondition (figure 12). Some fuzzyTECH Editions (refer to Section 9.4) supportthree operator families, all of which have been successfully applied in fuzzylogic applications:

Page 72: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

72

Min-MaxMin-Avg

GAMMA

The mathematical properties of these operator families are explained in Section5.2 and Section 3.1.2.7.

Figure 51: Rule Block Wizard: Define Rule Block Operators

➔ Select the aggregation operator family in the Operator field of this dialog. Use the scroll bar orthe edit field to enter a parameter for this operator family.

The resulting operator for some parameter values may be a familiar operator,such as:- Min-Max with a parameter of 0 ⇒ minimum operator (Min)- Min-Max with a parameter of 1 ⇒ maximum operator (Max)- GAMMA with a parameter of 0 ⇒ product operator (PROD)In MCU Editions, only the Min-Max operator with a parameter of either 0 (Min)or 1 (Max) is supported, representing the logical AND or the OR operation.

Composition The composition operator is used to combine the degree to which the entireprecondition (left hand side) of a rule is fulfilled with the Degree of Support. Thefuzzy operator for composition is the PROD operator. You cannot chooseanother operator for composition; fuzzyTECH uses the PROD operator as adefault and does not support other operators for the composition.

Page 73: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

73

Result Aggregation The result aggregation operator combines the results of rules, i.e. theirconclusions (THEN-parts), to show the degree to which identical terms of alinguistic variable are valid. fuzzyTECH supports two methods for resultaggregation: the Max (Maximum) and BSUM (Bounded Sum) method. The Maxmethod selects the rule with the maximum firing degree of all rules matching tothe term. The Bsum uses a bounded sum. Thus, all firing degrees are summed byusing a bound of one. Note that BSUM result aggregation is different fromBSUM MoM and BSUM CoA. The bounds are zero and one. The resultaggregation operator can be switched between Max and BSum.

➔ Accept all default settings in this dialog and click the [Next>] button to open the Rule Wizard’snext dialog “Define Variable Influence”.

Figure 52: Rule Block Wizard: Define Variable Influence

The input variable’s influence on an output variable can be determined in thisdialog. Deactivate the check box “<INPUTVARIABLE> has an influence on<OUTPUTVARIABLE>” in the middle of this dialog, if an input variable shallnot influence the output variable. This input variable is then contained in the ruleblock. It has, however, no influence on the inference. This dialog opens for eachvariable assigned to the rule block.

➔ Accept all default settings in this dialog and click the [Next>] button to open this dialog for thenext input, output or intermediate variable. If you have determined the influence of allvariables, clicking the Next>] button opens the Rule Wizard’s next dialog “Comment for RuleBlock”.

Page 74: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

74

A comment for the rule block can be entered into the Rule Block Wizard’scomment dialog. This comment is shown as tool tip comment, as well as at thegeneration of a documentation.

Figure 53: Rule Block Wizard: Comments for Rule Block

➔ Clicking [Next>] or [End] opens a confirmation dialog. Answer [Yes] to generate a rule blockthat appears in the Project Editor Window as such a rule block icon as illustrated in Figure 49.This rule block icon can be positioned anywhere in the window.

Figure 54: Rule Block Properties: Operators Dialog

Page 75: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

75

Rule Block Properties Once a rule block has been generated, its properties can be changed using theRule Block Properties dialog (Figure 54). To open it, select a rule block either inthe Treeview or in the Project Editor and choose [Properties...] in the pop-upmenu or click the [Properties] symbol in the main toolbar.

3.1.2.7. Formulation of Fuzzy Rules

Rule Design When first starting with fuzzy technology, use rules with a Degree of Support ofonly 0 or 1. If there is a need for individual weighting of rules during optimiza-tion, use degrees of support between 0 and 1. At the end of the total inferenceprocess, all system output variables are associated with a fuzzy value. In thefollowing, the Crane Simulation sample of Chapter 1 is used to demonstrate thefollowing degrees of support (DoS) assigned to the linguistic variable Power:

Example

The linguistic result for “Power”:neg_high degree of support = 0.00neg_medium degree of support = 0.00zero degree of support = 0.00pos_medium degree of support = 1.00pos_high degree of support = 0.00

Rule Definition Actual system behavior is defined in the individual rules of the fuzzy system.Prototype an appropriate set of rules by first creating rules that representunambiguous controller strategies at specific operating points. From there,construct your rule set by working backwards step-by-step until the most detailedrule is defined.

Example

The operation point:

“If the crane has reached the target point and the load is not oscillating, nopower should be applied to the motor”

can be formulated as a fuzzy logic production rule:

IF “Distance” = zero AND “Angle” = zero THEN “Power” = zero.

Once one unequivocal rule set has been established, more detailed cranebehavior can easily be defined. For example, if the load is oscillating slightly atthe target point, the following rule could be defined:

Page 76: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

76

Example

IF “Distance” = zero AND “Angle” = pos_small THEN “Power” = neg_med

Rule Editors fuzzyTECH supports different rule editors: the Spreadsheet Rule Editor and theMatrix Rule Editor, as well as textual input in FTL syntax from any ASCII editorsuch as MS Windows Notepad.

➔ Enter your production rules in either the Spreadsheet Rule Editor or the Matrix Editor(create at least one rule). At first, open the Spreadsheet Rule Editor by double-clicking a ruleblock in the Project Editor or a rule block’s name in the Treeview.

Another way to open the Spreadsheet Rule Editor is to highlight a rule block inthe Project Editor or Treeview, clicking right to activate its pop-up menu, andchoosing the option Spreadsheet Rule Editor.

Spreadsheet RuleEditor Window The Spreadsheet Rule Editor (Figure 55) represents the rule (of a rule block) as

rows in a spreadsheet. It has a toolbar, the functions of which are explained inthe fuzzyTECH Help. Below the toolbar is the head of the spreadsheet, the [IF]and [THEN] fields, with the rule blocks’ input and output variables. A column isassigned to each input variable, showing its terms. A DoS column is assigned toeach output variable, containing the degree, to which a rule is supported (Degreeof Support = DoS) or, to put it another way, the rule’s weight.

Figure 55: Rule Block Properties: Operators Dialog

The first gray column displays the row number to count the rules. Each row inthe Spreadsheet Editor represents one (or more) fuzzy logic rule(s), with itsinputs (conditions) on the left side and its outputs (consequences) on the right

Page 77: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

77

side. A row of the Spreadsheet Rule Editor contains more than one fuzzy rule, ifthe rule block has more than one outputs.

Input and output variable columns are separated by a thicker line. Input variablesare headed by the IF field, but output variables and DoS values with the THENfield. The IF field contains all inputs of the rule block in variable columns, eachcell of which can represent a term of the input variable. Each output of the ruleblock, however, is assigned a seperate THEN field that can contain up to threecolumns: an output variable column, the DoS values belonging to it in a DoScolumn, and a Statistics column (min - # - max). The latter appears only, if theStatistics Analyzer is enabled in the Analyzer main menu.

Each cell of the DoS column (Degree of Support) indicates an individual ruleweight. The cells of variable columns contain only the terms used for the rule. Ifa term of an output variable is negative (Hyper CoM defuzzification method), itsname appears in red letters. In the spreadsheet, negative terms are listed afterpositive terms.

Complete andIncomplete Rules To formulate rules in fuzzyTECH, it is important to know, which rules are

regarded as complete or incomplete in fuzzyTECH. A fuzzy rule is regarded asincomplete (invalid), if either the IF, DoS, or THEN part is lacking. Incompleterules are deleted automatically when closing the rule editores. In fuzzyTECH, afuzzy rule is regarded as complete (valid), if it has at least one entry in its IF,DoS, or THEN part.

Don’t Care Rules If a rule has more than one conditions (= input variables of the IF part) and onecondition of them has no influence on the consequence (= output variable of theTHEN part), then it is possible to ignore this condition (input variable) for therespective rule. This is then a so-called “don’t care rule” and means that theresult of the THEN part does not depend from all its conditions in its IF part. Asensible usage of don’t care rules can help to reduce the amount of rules to aconsiderable degree.

FAM Rules (DoS) An individual weight may be applied to each rule as shown in the DoS column(Degree of Support). A rule with a degree of support of 0 is functionally equal toa non-existent rule. For some design steps, the definition of a rule with a DoS of0 can be useful. For example, an advantage of rules with a DoS of 0 is, that theyare already part of the total amount of rules, but have no influence on the fuzzysystem. They are regarded as complete and will not be cleared when closing therule editor. Thus an active rule can temporarily be deactivated by setting its DoSvalue to zero and may later be re-used. FAM rules are explained in detail laterfor the Matrix Rule Editor (refer to page 80).

Edit Rules To edit a rule, click once with the right mouse the part (cell) of the rule to bechanged. This activates pop up menus listing the possible values (term names)for the current variable.

Page 78: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

78

Create andDelete Rules New rules may be defined by filling one of the Spreadsheet Rule Editor’sempty

rows. According to the technical restrictions of your fuzzyTECH Edition (refer toTable 1 of Section 9.4), a new empty row will automatically be created for eachnew entered rule. To insert a new empty row between the other rows, click righta row number (first gray column) to select a row, and choose Insert Row fromthe pop-up to insert the new row above the selected row. Another possibility tocreate rules is to use the Rule Block Wizard (Section 3.1.2.6).

Delete rules by making them incomplete: either delete their inputs or theiroutputs or their DoS values to make them invalid. When closing the rule editor,all incomplete rules are automatically deleted. Rules with a Degree of Support of0.0 are regarded as non-active, complete rules and are not automatically erasedwhen the rule editor is closed. Another, easier way for deleting is to highlight arule by clicking its row number, and pressing the [Del] key. Or click right therow number, and choose Delete Row in the pop-up menu.

➔ Duplicate the rule block in the fuzzy system of the Container Crane (CRANE.FTL). Open theSpreadsheet Rule Editor for this new rule block and clear its rules by using its toolbar symbol

[Delete All Rules]. Generate new rules with the Wizard by deftermining the input variables’influence on the output variable. Confirm the rule definition in the last dialog. The Rule BlockWizard generates then all rules automatically with a DoS of 1.0. Now change some rules andtheir degrees of support.

Sort Rules The Spreadsheet Rule Editor features various sort options to organize large rulebases. Click its toolbar symbol [Sort Rules] to open the Sort Rules dialog.Choose an option according to which the rules of a rule block shall be sorted.The sequence of rules in Figure 11 is the result of sorting the rules containing thevariable Distance according to the maximum of its MBFs (terms). Open theVariable Editor of Distance to compare the sequence of terms.

Rule BlockUtilities In the Spreadsheet Rule Editor, the design of rule bases can be facilitated by the

utility functions of the Rule Block Utilities dialog. Click with the right mousekey a gray field below the toolbar to open the Spreadsheet Rule Editor’s pop-upmenu. Choose the Rule Block Utilities option to open a dialog with the followingfunctions:• “Delete all Rules”.• “Alpha Cut” deletes all rules with a DoS lower than the value specified in the

group “DoS Value”.• “Set all DoS” forces the rule weights to the value specified in the group

“DoS Value”.• “Create Full Rule Block” deletes all existing rules and creates a rule for each

combination of variable terms. Thus, for each possible combination of ruleblock input variable terms, a rule is generated for all output variable terms.The weights of the generated rules are specified in the group “DoS Value”.

Page 79: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

79

• “Create Partial Rule Block” only creates a rule for each combination of inputvariable terms. You have to specify the output variable terms for each rulemanually. The rules for which you do not specify an output term areincomplete and are erased when you close the Spreadsheet Rule Editor. Theweights of the generated rules are specified in the group “DoS Value”.

Figure 56: Reducing the Rule Set By Using the Alpha-Cut Utility.

Fuzzy Operators The inference process of any rule consists of input aggregation, composition, andresult aggregation. For input aggregation and result aggregation, different fuzzyoperators can be chosen. For composition, the fuzzy operator is the PRODoperator. It is fixed and cannot be changed. Fuzzy operators can be chosen andparameterized in the Rule Block Properties dialog (Figure 54).

There are different ways to activate this dialog:1. Double-click the operators in the edges of a rule block symbol in the Project

Editor:

2. Choose the “Properties” option in the pop-up menu of a rule block.3. Click the [Fuzzy Operators] button in the toolbar of the Spreadsheet Rule

Editor.4. Click the [Fuzzy Operators] button in the toolbar of the Matrix Rule Editor.

Dynamic Inference If a debug mode is enabled, the Spreadsheet Editor lets you dynamically tracerules. The degree to which any of the rules fire is displayed graphically to allowvisualization of the information flow in the system. In any debug mode, theSpreadsheet Rule Editor displays two small boxes for every rule and outputvariable located left and right of the Degree of Support value. The height of theblack bar in the boxes indicates the aggregation (left bar) and composition (rightbar) results.

Page 80: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

80

Visualization of Rules The firing degree of a rule can be visualized in a Time Plot. First, the respectiverule has to be added to a Time Plot. Click into the DoS column of theSpreadsheet Rule Editor to open a pop-up menu at the end of which a Time Plotmenu is displayed. This menu lists all open Time Plots. Choose the one to whichyou want to add the rule by clicking it. The added rule is then displayed in therespective Time Plot in the list Plot Items.

➔ After you have changed its rules and generated new ones, delete the duplicated rule block toobtain the previous (original) structure of the Container Crane project (CRANE.FTL). Switchto the Matrix Rule Editor by clicking the Spreadsheet Rule Editor’s toolbar symbol [MatrixEditor]. This editor can also be called by selecting a rule block in the Project Editor, openingits pop-up menu, and choosing the Matrix Rule Editor option. Or simply by double-clicking arule block, provided that the option “Open Matrix Rule Editor by Double-clicking Rule Block”is activated in Tools/fuzzyTECH Preferences/General.

Matrix Rule Editor The Matrix Rule Editor (Figure 57) displays and edits rule blocks as matrixes.Compared to the Spreadsheet Rule Editor, the Matrix Rule Editor has extendedfunctions. When designing complex rule bases, the Matrix Rule Editor allows abetter survey of the rule block and helps to find rule inconsistency and rule gapsdue to its graphical display of matrix items. The Matrix Rule Editor windowconsists of a toolbar, an IF field and a THEN field, and one or more rulematrices. The number of rule matrices depends from the number of the ruleblock’s outputs.

Figure 57: Matrix Rule Editor with FAM Rules

IF / THEN Field The variables that a rule block contains as its inputs and outputs are displayed atthe left side of the Matrix Rule Editor, either in the IF field or in the THEN field.In the IF field, all input variables are listed, in the THEN - all output variables.All terms of a variable can be chosen in the variable’s term list box. If a term listbox of an input variable is of grayish color, it indicates that the term of thisvariable is displayed in the rule matrix. The empty entry in input variables’termlist boxes is used to define “don't care” rules.

Page 81: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

81

If a term of an output variable is selected in the output variable’s term list box,the corresponding rule matrix displays all those items highlighted that use thisterm.

Rule Matrix Two input variables or an input variable and an output variable can be displayedin the rule matrix. In both cases, the Matrix Rule Editor is displayed in adifferent way. The buttons appear in a gray color, if variables are alreadydisplayed in the rule matrix or if the selected combination is not allowed. Next tothe variable's name are two buttons for selecting variables for display in the rulematrix. The left button assigns the terms of the selected variable to the rows ofthe rule matrix. The right button assigns the terms of the selected variable to therule matrix columns. The axes of a matrix can be swapped by clicking thetoolbar symbol [Swap Row and Columns]. One or more rule matrixes aredisplayed at the editor's right side. Each rule matrix contains a matrix item (cellor field) for all combinations of the selected variable's terms. Each matrix itemmaps one or more fuzzy rule. Black items indicate non-defined rules, all otheritems - defined rules. Each item comprises rules with the same IF part. Thismeans, that each matrix item displays the output term of the strongest rule. Ifmore than one rule were defined for a matrix item, the matrix item displays thestrongest rule as well. Additionally, in the viewing option [Display Degree ofSupport] (default setting), one or more *** signs indicate that this itemscontains more than one rule. If a matrix cell contains a defined rule, it isdisplayed as tool tip that pops up if the mouse pointer rests over this cell.

➔ After you have opened the Matrix Rule Editor, you see a red-bordered matrix cell. Read forthis cell the names of terms, standing on the horizontal and vertical axis of the matrix. Comparethem with the names of terms in the IF and THEN field. Then click further matrix cells, readthe terms’ names for each highlighted cell and watch the changing display in the term lists ofthe IF and THEN field. You see that the term lists of the IF and THEN field display always therule selected in the matrix (red-bordered matrix cell). Now hold the [Ctrl] key down whileselecting more matrix cells. ). Now hold the [Shift] key down, while clicking the upper leftmatrix cell and then the lowest right matrix cell. All matrix cell lying between the cells thatwere clicked on are selected. These two kinds of multiple selection can be useful for ruleediting.

FAM Rules If a unique consequence for a given combination of input variables cannot befound, FAM rules can be used to express ambiguities.

Example:

Consider the following rule to be represented in a fuzzy logic system:

IF “Distance” = close AND “Angle” = zeroTHEN “Power” = mostly zero but somewhat pos_medium

Page 82: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

82

One approach is to define a new term as “mostly zero but somewhatpos_medium.” This approach, however, would result in an excessive amount ofterms and membership functions. Moreover, system structure would becomeunnecessarily complex and difficult to survey. Using FAM, this ambiguity canbe expressed in rules. Figure 58 displays a possible representation of the rule ofthe Example above. Within the matrix, a white field represents a completelyplausible rule (100% true) and a black field represents a totally implausible rule(100% false). Gray shades indicate partial plausibility. The degree to which arule is valid or plausible is described by the so-called degree of support (DoS),here often referred to as “rule weight”, too. Adding an individual weight to eachrule extends the concept of “on/off” rules to a representation in which rulesthemselves are “fuzzy.” This allows for the rule base to be fine-tuned duringoptimization. Since the mapping of the input of the rules to the output is nowitself fuzzy, this concept is often referred to as a “Fuzzy Associative Map“(FAM).

Figure 58: Taking ambiguities into consideration by using FAMs: One rule isfully supported (DoS=1.0) and thus always true, the other is only partially

supported (DoS=0.5) and does thus not always apply.

Rule Definition In the Matrix Rule Editor, use the mouse and/or pop-up menus to define a fuzzyrule and its weight (DoS).

Create Rules Double-clicking a black matrix cell (i.e. a cell that contains no fuzzy rule) createsa new rule with a DoS of 1.0. The term displayed in the term list box of thecorresponding output variable is chosen to be the output term (and thus ruleconsequence). Alternatively to this method, a new rule can also be generated byright-clicking its corresponding matrix cell to open a pop-up menu. Choosing aterm from it inserts a new rule with a DoS value of 1.0. To add further rules to amatrix cell, choose the Add option from its pop-up menu.

Change Rules A rule can only be changed by changing its DoS value. If, for instance, theTHEN part of an existing rule shall be changed, choosing a new output termgenerates automatically a new rule in addition to the previous one. To change the

Page 83: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

83

DoS of a rule, click with the right mouse key the respective cell to open its pop-up menu, and choose its output term in it. This opens a side pop-up, from whicha DoS value ranging from 1.0 to 0.0 can be chosen as rule weight. This side pop-up contains also the option 0..1 that helps to assign a more exactly value.

Delete Rules Double-clicking a matrix item that represents a rule deletes this rule. If a matrixcell contains more than one rule, this deletes only the strongest rule (i.e. the rulewith the highest DoS). Then again the rule with highest degree of support isdisplays with its abbreviated term name (this applies only to Gray Scale Mode).

Rules can also be deleted using pop-up menus. Click a matrix cell that contains arule with the right mouse key and choose the option Delete All from the pop-upmenu to clear all rules. Or choose the output term of a rule and click Delete inthe next side pop-up menu, if only one rule (i.e. the rule with the specified outputterm) shall be deleted.

➔ Duplicate the rule block of the Container Crane Simulation. Add the following rule:IF “Angle” = neg_big AND “Distance” = far THEN “Power” = neg_high. Assign a DoS of 0.1 to this rule. Add further rules (with “Power” = zero and “Power” =pos_high) with higher DoS to the same matrix cells. You see that in Gray Scale Mode, thematrix cells display the strongest rule by showing an abbreviation of its output term’s name.Read the three defined rules in the tool tip. Double-click the matrix cell that contains the threerules, look which term’s name it displays now and read the tool tip again. You see that the“strongest” rule (i.e. the rule with the highest DoS) was deleted. Switch now into the viewingmode [Display Term Colors] , open the Variable Editor for “Power”, and compare the termcolors. In the Matrix Rule Editor, click the (down) arrow of the term list box in the THENfield, and select each output term. Rules containing the selected output term appear in thematrix as highlighted, red-bordered matrix cells. The rule containing the output term neg_highcannot be displayed in the respective matrix cell due to stronger rules, but can be found thisway.

Viewing Modes andDisplay Options The viewing mode Display Gray Scale is the default setting and shows the

DoS values in the matrices. If a matrix cell contains more than one fuzzy rule,only the strongest rule (i.e. the rule with the highest DoS) is displayed with theabbreviated name of its output term in a matrix cell. Rules can also be displayedwith the term colors of their output terms and false colors. Refer to thefuzzyTECH Online Help for an explanation of the Matrix Rule Editor’s toolbarbuttons.If fuzzyTECH runs in a debug mode, different display options can be chosen forthe Gray Scale Mode in the Matrix Rule Editor. They refer to the computation offuzzy rules (fuzzy inference). The inference process of each rule consists of twophases: aggregation and composition. Aggregation refers to evaluating theconditons of each rule (its inputs), while composition refers to the evaluation ofthe rule consequences (its outputs). The following options can be displayed inthe matrix cells:

Page 84: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

84

• Input Aggregation, i.e. the degree to which a rule’s (input) conditions arefulfilled, or

• Degree of Support, i.e. the degree to which a rule is supported (rule weight),or

• Composition with Degree of Support, i.e. the degree to which a rule that firesis fulfilled.

If the option Advanced Display of Matrix Items is enabled inTools/Preferences/Matrix Rule Editor, additional information are displayed inthe matrix items, e.g. a small number in the upper left corner of a matrix itemindicating the total number of rules defined for this item, including don’t carerules, too.

➔ Select the matrix cells applying multiple selection (Shift key) and delete all rules. Formulatethe rules as shown in Figure 58. Activate the option Advanced Display of Matrix Items inTools/Preferences/ Matrix Rule Editor. Put then the Distance variable again on the x-axis usingthe button next to the term list box. As the number in the upper left edge shows, the tworules have been assigned to one matrix cell.

Don’t Care Rules in theMatrix Rule Editor “Don't care” rules are displayed as matrix items behind a small gray line at the

right and lower side of the rule matrix. Don’t care rules can be defined, editedand deleted in a rule matrix as well. The influence of don’t care rules interfereswith rules that are nearly identically formulated. They differ from each other inso far, that the regular rules use a term instead of the “don’t care variable”.Generally, the purpose of don’t care rules is to replace a series of completelydefined rules.

In the Matrix Rule Editor, those rules interfered by a “don’t care rule” areindicated by a bar that stretches over the affected matrix items. If “gray scale” ischosen as viewing option (default setting), then the name of the chosen term ofthe output variable is displayed within the bar. The entire matrix is marked, ifboth variables displayed in the matrix are chosen to be “don’t care” variables.

➔ Define now the following rules by clicking the corresponding matrix cell: IF “Distance” = close THEN “Power” = pos_high WITH 0.9IF “Angle” = zero THEN “Power” = pos_medium WITH 0.5For the first rule, the input variable Angle has no influence on the output variable Power. Forthe second rule, the input variable Distance has no influence on Power. Don’t care rules canoverlap FAM rules. Overlapped rules are indicated by the Advanced Display of Matrix Itemsas well as bars, overlying the respective matrix rows or columns (Figure 59).

Page 85: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

85

Figure 59: Don’t Care Rules Overlapping a FAM Rule

The Matrix Rule Editor allows to define swap definitions or overlappingdefinitions, having both don’t care rules and completely defined rules for thesame range. Don’t care rules are then displayed in the background, but appear inthe foreground as soon as the matrix item assigned to the don’t care rule isselected. However, it is recommended to avoid swap definitions, since they themake the system more complex than necessary.

➔ You want to set both variables in the rule matrix as “don’t care”. However, a don’t care rule isonly valid, if it has at least one condition in its IF part. Since the currently loaded fuzzy systemContainer Crane (CRANE.FTL) contains only two input, you have to generate a further inputvariable. Assign the new variable as input to the rule block using the Rule Block Propertiesdialog. To re-establish the rule display as depicted in Figure 59, choose the no-name entry(empty space) in the term list box of the new variable to define it as “don’t care”. This steponly serves the restoration of the initial situation. Choose a term in the new variable’s term listbox to remove the output variable Power from Angle and Distance’s sphere of influence. Nowdefine the input variables Angle and Distance as “don’t care” by clicking the right lower matrixcell. This highlights all matrix cells, and the term list boxes of Angle and Distance display noname.

3.1.3. Optimization and Debugging

System optimization is usually required to achieve the desired systemperformance. Now, after you have learnt to set up a fuzzy system, the nextdevelopment step is to optimize and test this system. Because the optimizationstrategy varies with each type of application, fuzzyTECH offers different debugmodes. When switching from design mode in debug mode, fuzzyTECH simulates

Page 86: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

86

the developed fuzzy system. All editors display the entire inference processgraphically. The effects of modifications made in debug mode are immediatelydisplayed.

Not all modifications to the fuzzy logic system are possible in all debug modes.For example, you cannot modify the system structure in the Project Editor andyou cannot create new variable or terms. However, you may modify any existingmembership functions and create new definition points. Also, rules within anexisting Rule Block can be added, modified or deleted.

All debug modes are mutually exclusive. The Debug menu (Figure 60) is onlyactive, if a project has been defined or loaded. Within the Debug menu, theactive debug mode is indicated by a check mark (b). You may switch from anydebug mode to another at any time.

Figure 60: The Different Debug Modes Are Mutually Exclusive.

Off-line vs. Online The appropriate optimization tools for your fuzzy system depend on whetherthey are to be used on a running process in real-time on target hardware (onlinedevelopment), or whether they run on the development workstation/PC (off-linedevelopment). The online optimization technique is a unique fuzzyTECH featurein which development, debugging, and visualization features are available whilethe process is under the control of the fuzzy system.

Off-line debug modes use the internal computation kernel in fuzzyTECH tocompute the results of a fuzzy project. Online debugging is based on generatedcode compiled for the target system. Both enable an interactive systemdevelopment. Online modifications require access to system parameters in theimplemented code. These changes must be restricted to a protected protocol.Thus, not all design parameters can be changed on the fly. In the off-line modes,the internal computation kernel supports all fuzzyTECH visualization featuresand editors. This allows you to review all fuzzy design steps, but modifying thebasic structure of the fuzzy project is impossible.

Page 87: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

87

3.1.3.1. Off-line Debug Modes

Interactive Lets you check systems response to manually entered input data. The InteractiveDebug Mode shows the reaction of the system to the input values that you set.All editors and analyzers of fuzzyTECH graphically show the information flow.When you modify any elements of the fuzzy logic system, you can see the effectof the changes instantly. This allows quick “if-then” analysis.

Serial Link Lets you connect a controller running in fuzzyTECH to a process running onseparate hardware ( refer to Section 6.2.3). The Serial Link Debug Mode allowsfuzzyTECH to operate over a serial interface. The settings for communicationsmust be set in the Serial Interface dialog that you access via “Tools/fuzzyTECHPreferences/Serial Interface”. In Serial Debug Mode, fuzzyTECH acts as slave tothe process or simulation connected at the serial interface of your PC.

After activation of Serial Debug Mode, fuzzyTECH waits for the process orsimulation to write all input values of the fuzzy logic system to the serialinterface. When all input values are received, fuzzyTECH computes the outputvalues and writes them back to the serial interface. Then, fuzzyTECH waits forthe next input. The communication format is ASCII: ASC(31) is used asdelimiter between values; ASC(0) is used to indicate end of transmission.

File Recorder Lets you process data from a file and display the inference process graphically(refer to Section 3.1.3.4). The File Recorder lets you use input data stored in filesas input to the fuzzy logic system. These input data files may stem from processmonitoring, the fuzzyTECH Pattern Generator, or real-time traces.

Batch Lets you process data from an input file to an output file without displaying theinference process (refer to Section 3.1.3.4). The generated output file containsthe values of input variables as well as output variables.

RCU The Remote Control Unit (RCU) allows you to dynamically link fuzzyTECH toapplication software or to software simulations of the process to be controlled.RCU can be used to integrate fuzzyTECH into standard windows applicationsoftware. This mode is automatically activated, if fuzzyTECH is used ascomputation server by other applications that use RCU (refer to Section 6.2.1).

3.1.3.2. Online Debug Modes

Monitorand Monitor&Modify Lets you connect online to a controller running on a separate target system.

Online monitoring and modifications are possible; traces can be configured,started, and uploaded. fuzzyTECH Editions equipped with RTRCD support thegeneration of C code that can be modified remotely from the development PC

Page 88: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

88

while running on the target hardware. The development PC is connected to thetarget hardware (process controller, PLC, micro-controller board) by a serialcable, a field bus, a common file system or a similar communication medium.“Monitor” establishes communication with the target hardware and lets youvisualize the entire information flow of the fuzzy logic system in real time.“Monitor&Modify” lets you modify the running system in addition to allowingvisualization of information flow.

For microcontroller implementations, RTRCD delivers a reduced functionalityversion of the fuzzyTECH Editions with Online mode. An unlicensed fuzzyTECHEdition runs only in demo mode and supports only the Monitor debug mode.

3.1.3.3. Switching into Debug Mode

Switching fuzzyTECH from design mode into debug mode opens a WatchWindow (Figure 61) that is displayed as long as a debug mode is active. Theonly exeption is the Batch debug mode that runs without displaying the WatchWindow. If a debug mode is chosen in the main Debug menu, the chosen modeis displayed in the title bar of the Watch Window, in the Status bar and in theTreeview. Leave a debug mode by either closing the Watch Window or clickingthis debug mode in the Debug menu again.

Watch Window The Watch Window always displays the input/output values of all systemvariables. In the Interactive debug mode, the field Value may also be used formanual input. Note that minimizing the Debug dialog speeds up the display inmost debug modes. Simply close this window or deselect the active debug modeover the Debug pull-down as shown in Figure 60. Use the Watch Windowstoolbar to call different functions to modify the Watch Window’s appearance.Click the symbol [Intermediate Variables] to show the list of all intermediatesvariables of the project. If the project does not contain any intermediatevariables, this symbol appears in gray color and is deactivated. More WatchWindow settings can be selected or deselected in “Tools/ fuzzyTECHPreferences/Watch-Window”.

Figure 61: The Watch Window Shows All I/O Variables and Their Values.

Page 89: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

89

No Rule Firing If in any debug mode, no rule for the current combination of input values fires anoutput variable, then the value of this linguistic output variable is set to itsdefault value. This situation is indicated by setting the default value into braces,for instance (0.0000), displayed on the right side of the output variable for whichno rule has fired.

➔ Switch into Interactive debug mode by selecting “Debug/Interactive” or click the symbol [Interactive] in fuzzyTECH’s main toolbar.

Start InteractiveDebugging When the Interactive debug mode is started, a check of your system structure is

performed. If errors occur, an Error List window is activated. The WatchWindow appears only if no errors could be detected.

➔ Specify input values for the actual system. Review the system behaviors by visualizing theentire fuzzy inference in the fuzzyTECH editors.

In debug mode, all design editors such as the Variable Editor and theSpreadsheet Rule Editor graphically display the entire inference process. Asystem can also be designed in this debug mode. This accelerates developmenttime because the effects of design changes are now visualized immediately. Theeffects of membership function or rule modifications made in this mode areimmediately displayed. Though most of the system can be designed inInteractive debug mode, some restrictions do apply. Structural changes to thesystem – such as adding or deleting new linguistic variables or rule blocks – areimpossible.

3.1.3.4. Test System Performance Using Data

fuzzyTECH allows you to test the fuzzy system’s behavior with data. The mostsignificant data is recorded process data. Testing the fuzzy system with processdata requires preprocessed data.

Performance Evaluationwith Generated Data Process data normally does not cover the complete operational range of the

process. fuzzyTECH’s Pattern Generator may be used to produce sets of inputdata in a file for later use with the File Recorder and Batch Debug mode.

➔ Close now your currently loaded system in fuzzyTECH (“File/Close”). Load the ProjectCRANE.FTL in fuzzyTECH (“File/Open/…/Samples/Control/Crane”). fuzzyTECH features aPattern Generator to create sample patterns that cover the control space. Select “File/PatternGenerator” to activate the Pattern Generator, as shown in Figure 62.

Page 90: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

90

Figure 62: The Pattern Generator Creates Test Input Data Sets for the CurrentFuzzy Logic System

Creating Sample Patterns Every input variable of the system is listed in the list box at the top by name,range (from; to), and the step width for the pattern to be generated. The upperand lower margins of the pattern’s interval are specified in the “From” and “To”edit field, while the resolution (size of the steps is specified in the “Step” field.To change any of these values, select the respective value in the fields “From:”,“To:”, and “Step:” and change it. The option, “Margins: On”, ensures that theminimum and maximum values are part of the pattern in all instances.fuzzyTECH computes and displays the resulting number of patterns as “Numberof Records” and the disk space required to save these patterns as “Disk Space”.Click on the [Generate..] button to create the pattern. fuzzyTECH proposes thatyou accept the file name. The file extension *.PTN is appended to indicate apattern generated with fuzzyTECH. Close the Pattern Generator by pressing the[Close] button. You can view the generated pattern using the “File/View File...”option.

Margins If you specify an interval for a variable that is not a multiple of the step size, theupper margin (the value specified in the “From” field) is included in the pattern.You may however suppress this by selecting the “Margins - off” setting in thePattern Generator window (Figure 62). If, for example, you specified “From: 0”,“To: 10”, and “Step: 3” for a variable, then the pattern would comprise thevalues 0, 3, 6, and 9, if the margin option is set to off or the values 0, 3, 6, 9, and10 if the margin option is set to on.

Disk Space Generating complex patterns may result in large data files. The field “Number ofRecords:” shows the computed number of records which would be generatedwith the current settings. On this basis, the field “Disk Space (KB):” indicates anestimation of the disk space required for this data file (Figure 62). Click on the[Generate…] button to start the generation of the pattern. If the pattern consistsof more than 10000 records, a warning box lets you confirm the action.

Page 91: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

91

File Format The file format in which the pattern data is generated is equivalent to thefuzzyTECH file format (Section 9.3). fuzzyTECH supports two formats: a fileformat with comments and one without. The format, used for data generation,has to be chosen in Tools/fuzzyTECH Preferences/General.

The file format with comments contains:• a comment in the first line• all variable names, for which values are output, in the second line• a comment in the third line• from the fourth line on data starting with a “pattern name” (e.g. consecutive

number, time), followed by variable values (one value for each variable),separated by blanks or tabs.

The file format without comments uses:• a # sign in the first line, followed by the name of the variable, for which

values are output• from the second line on data with the variables’ values (one value for each

variable), separated by blanks or tabs.

File Names The file extension *.PTN shows, that the data of the file are pattern data.Generally, you are free to choose both input and output file names. As defaults,fuzzyTECH uses the following conventions:• The file names are the same as the FTL file name of the actual project.• Input files containing real data are identified by the .IN extension.• Input files containing data sets generated by fuzzyTECH’s pattern generator

are identified by the .PTN extension.• Input files containing trace records from the fuzzyTECH Trace Analyzer are

identified by the .TRC extension.• Output files from the Batch mode are identified by the .OUT extension.• Sample files for the NeuroFuzzy module are identified by the .EXP

extension.• Files containing data to be clustered are identified by the *.DAT extension.

➔ Start the generation of sample data by clicking the key [Generate…]. Accept the suggestedname of the file. Choose the directory into which the pattern data is to be saved. Then click the[Save] key and in the following window [File Recorder].

The suggested file extension for the generated pattern is *.PTN. During thegeneration of the pattern, a dialog shows the progress and lets you interrupt theprocess by clicking on the stop button.

File Recorder Mode The File Recorder Mode allows pre-recorded sample data to be used forinteractive development. The File Recorder has all the functions of theInteractive mode except that sample data, rather than manually entered data, areused as input values. The File Recorder uses the same data file format as the

Page 92: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

92

Batch mode, but instead of creating an output file, the entire processing of thesample data is visualized graphically.

Figure 63: The File Recorder Lets You Navigate Through Sample Data Files.

The File Recorder window lets you navigate through the pattern data. As long asfuzzyTECH is in File Recorder debug mode, the File Recorder dialog is always atthe top of all open windows to allow constant access to its controls. Informationabout the sample data file and the current record can be read below the VCR-likebuttons. The File Recorder window is always at the top of any other fuzzyTECHwindow. The File Control group contains a scroll bar and “VCR-like” buttons forbrowsing trough the input data file.

➔ Now press the button in the File Recorder window.

fuzzyTECH now processes all patterns in the files from the first record to the last.If you change the direction in which you browse through the records in the file, avertical red line is plotted in the Time Plot. If you change anything in the fuzzylogic system, such as membership functions or rules, a vertical yellow lineindicates the change in the Time Plot. The current record name is shown as“Record:” in cases where a record name is specified in the file. For example,real-time traces that are uploaded from a target hardware always store atimestamp as the record name. By moving the scroll bar, you may directly accessany record. In order to change the file, click on the [Read File...] button (Figure63) and specify a new file name for the sample data. Other sample data that havenot been generated by fuzzyTECH’s Pattern Generator have to be converted intoa fuzzyTECH data format to make them readable. Refer to the fuzzyTECH Helpsystem and search in the Index for the keyword “Data Format”.

➔ In the File Recorder window, click to close the File Recorder. Now start the Batch debugmode (Debug/Batch). In the window “Read Input From...” open the input file CRANE.PTN.fuzzyTECH suggests as name for the output file CRANE.OUT. Accept this proposal byclicking [Save]. Now you can view the generated file by clicking the [View] key.

Batch Debug Mode If you want to get the results of the fuzzy logic inference on file as well, you mayuse the Batch Mode. The Batch Mode does not display the fuzzy logic inferencein all editors, but generates an output file that contains the computed outputvalues in addition to the input values. The output file contains all input variables,

Page 93: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

93

the result for the computed output variables and a column “–flags–”. Thiscolumn indicates output variables for which no rule has fired (see Chapter 6 fordetails on the “–flags–” return variable). The Batch mode overwrites the data linewith the variable names.

➔ Activate the Batch Mode by “Debug/Batch”. A prompt for the input and output file namesappears., specify the input data file “CRANE.PTN” and click [OK]. fuzzyTECH suggests“CRANE.OUT” as the name of the output file. Accept this name by clicking [OK]. You canview the result file “CRANE.OUT” by “File/View File...”.

During processing, the inference flow is not displayed. You may interrupt theBatch mode by pressing [Stop] on the Batch Mode Message box that is displayedwhile computing great amounts of sample data.

File Recorder versusBatch The difference between the debug modes File Recorder and Batch is that the File

Recorder writes the output values not into a file as the Batch mode does, butdisplays them graphically. The File Recorder mode enables you to connect yoursystem to pre-recorded sample data files for analysis. Batch mode processes fileswith input data and generates a result file for further processing with othersoftware. In File Recorder mode, the number of records in a file is limited; inBatch mode this number is unlimited.

If your fuzzy system is already installed within your process or a simulation, thefuzzyTECH Trace Analyzer allows you to trace the process at the interfaces ofthe fuzzy controller (see Section 3.1.3.5). If the preprocessing is not yetdetermined, the fuzzyTECH DIAdem Module lets you apply signal conditioningand statistical methods to the data. Contact us (see 9.5) and ask for DIAdem.

3.1.3.5. fuzzyTECH Analyzers

fuzzyTECH’s analyzers can be used in any debug mode; only the Batch Debugmode does not support system visualization and analyzers. Open as manyanalyzers as you like. If no debug mode is activated, the [Analyzer] menu infuzzyTECH’s main menu is disabled. Leaving a debug mode closes all activeanalyzers. fuzzyTECH offers the following analyzer tools to verify a fuzzysystem’s behavior:

Transfer Plot Lets you analyze the static input/output characteristic of a fuzzy logic system asa color plot, showing cross-sections for the current operating point.

3D Plot Lets you analyze the static input/output characteristic of a fuzzy logic system asa scaleable, rotational 3D Plot.

Time Plot Lets you analyze the time response characteristic of a fuzzy logic system.

Page 94: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

94

Rule Analyzer Lets you analyze which rules had influence on the value of an output or anintermediate variable.

Statistics Lets you control the use of fuzzy rules by a statistics column in the SpreadsheetRule Editor.

Trace Lets you trace the dynamic input/output characteristic of a fuzzy logic system.The traced data can be saved. The File Recorder Debug mode allows you toreplay, step through, visualize and analyze the trace.

Figure 64: Different Analyzers Can Be Activated in the Analyzer Menu.

Save Window Positions The configurations and positions of all open analyzer windows are saved if theoption Save Window Configuration is enabled (Tools/fuzzyTECH Preferences/Save). fuzzyTECH uses a .CFG project file to save the project configuration evenwhen you exit fuzzyTECH.

➔ Activate a debug mode and open the Transfer Plot Analyzer either by clicking its symbol infuzzyTECH’s main toolbar or the entry New Transfer Plot in the Analyzer menu.

Figure 65: Transfer Plot Analyzer Window

Transfer Plot Analyzer The Transfer Plot (Figure 65) shows a cut in the control space. Two inputvariables and one output variable are always shown in this graph. In a fuzzysystem with more than two input variables, the non-selected variables possess agiven value, which is either defined (in Interactive debug mode) or determinedby the linked process or data file (in other debug modes). The two input variables

Page 95: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

95

are shown on the horizontal and vertical axis, and the value of the output variableis displayed as the color of the area spanned by the input variables. The color baron the lower part of the window shows the color-value relation. The resolution ofthe Transfer Plot can be specified in the rightmost list box “Step Width [%]:”.The Transfer Plot can be controlled via its own toolbar.

Cross Sections For a given control state, two cross section views – vertical and horizontal – ofthe transfer characteristic are also displayed above and to the right side of theTransfer Plot. In the upper left part of Figure 65, the output value “Power” isdisplayed over the variation of the input variable “Angle”. All other inputvariables remain the same.

Control Areas notCovered by Fuzzy Rules The plot only paints colored values in regions where the result is evaluated by

fuzzy rules. If no rule covers an operation point, a default value is used forcomputation and the plot shows a black colored area. The completeness of afuzzy system’s rule base is sometimes difficult to verify. A rule base can becomplete in two ways: within the entire control space or within the control spaceactually used by the system. While the entire control space can be studied usingthe Transfer Plot or 3D Plot analyzer, the control space actually used dependsupon the process itself. By using the File Recorder Mode, combined with theTransfer Plot Analyzer in the Trace mode, control space operating points aredisplayed within the Transfer and the 3D Plot. This helps to pinpoint the processstates for which no rules were defined and to distinguish superfluous rules.

If a fuzzy system contains rule blocks structured similar to Figure 66 (upperpart), it is recommended to transform intermediate variables into output variablesto visualize all rules of each rule block. Open the pop-up menu of theintermediate variable in the Treeview and choose the Properties option totransform it into an output variable. Thus an interface is assigned to theintermediate variables acting as output for one rule block. Now it can be selectedfor display in a Transfer Plot.

Figure 66: Transforming an intermediate variable into an output variable tovisualize a rule base

Page 96: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

96

➔ Load the Crane Control Project CRANE.FTL (“File/Open/…/Samples/Control/Crane/..”.Activate the Interactive debug mode, open the Transfer Plot and click the [Trace] button .Start the Crane Control Simulation (from the Program groups of the MS Start menu), click the[Fuzzy] key in the simulation window, and watch the tracing in the Transfer Plot. After tracingwill have been finished, click the [Reset] key in the simulation window.

Trace Transfer Plot Selecting the [Trace] button switches the Transfer Plot to the Trace TransferPlot and back. Rather than just the actual operating point, the Trace function inTransfer Plot draws a history of all operational states since Trace was started. Inorder to reset the trace, select the [Reset] button from the toolbar. Note thatthe cross-sections are not displayed in the Trace Transfer Plot mode.

Figure 67: Trace Transfer Plot

➔ Open the 3D Plot Analyzer (Figure 68) either by clicking its symbol in fuzzyTECH’s maintoolbar or its entry in the Analyzer main menu. Cross-check the fuzzy rule base of the cranecontroller by displaying the transfer characteristic of all rule blocks with the option [HidePlot Drawing] enabled. Rotate or flip the plot to display hidden plot parts.

3D Plot You can display the cut in the control space as a 3D picture. The 3D Plot has itsown toolbar. Use the rightmost drop down list box (the arrow-down buttondisplays the list of the possible resolutions) to change the resolution of the 3DPlot. A high resolution can result in slow response times of the plot, dependingon the video and computing performance of your PC. Use the 3D Plot’s toolbarto change the plot’s viewing options, to choose the variables to be plotted and tocall the Trace function. You can select variables for display in the plot by usingthe drop down list boxes (below the 3D Plot’s toolbar) displaying variablenames.

Rotate the Plot The four arrow buttons on the left side of the toolbar rotate the plotin all directions. A double click on an arrow button starts a (continuous) rotation;the [Stop] button or the [ESC] key stops rotation. The button [Vertical] flips the 3D Plot for better visibility.

Page 97: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

97

Figure 68: 3D Plot

Repaint and BackgroundPaint in Dynamic Plots If the output variable selected for the 3D Plot depends on more than the two

inputs displayed, the control surface dynamically depends on these variables. Ifthe [Repaint] button is pressed, the 3D Plot is repainted every time one ofthese other input variables changes to reflect the change in the control surfaceshape. Note that this only results in a smooth display if you have a PC with veryhigh video and computing performance. You can enhance this effect by enablingthe background paint mode [Hide Plot Drawing]. This creates the picture inthe background and dumps it to the screen.

Trace inTrace 3D Plot Analogous to Trace Transfer Plot, Trace 3D Plot is an option that plots current

operation states dynamically in the plot of the transfer characteristic. You mayswitch to this option using the 3D Plot’s toolbar or pop-up menu.

➔ Start the Trace function by clicking the [Trace] symbol. Now re-start the Crane Simulation(reset it, if necessary) by clicking the [Fuzzy] key in the window of the simulation. The tracing(indicated by a green line) starts with the initial situation of the crane (Angle=0, Distance=22)and proceeds to the final position of the crane (Angle=0, Distance=0).

Time Plot fuzzyTECH provides Time Plots to evaluate the time response. You may defineup to 10 Time Plots in each fuzzyTECH session. Each Time Plot is uniquelyidentified by a number in its title bar. Refer also to the paragraph Analyzing TimeResponse (Chapter 1, page 15), in which detailed instructions are given forhandling this analyzer.

➔ In order to open a new Time Plot, select Analyzer/New Time Plot... in fuzzyTECH’s mainmenu. This opens a Time Plot window without any plot items (see Figure 6 of Chapter 1).

Customizing Time Plots Each Time Plot has its own toolbar that can be disabled to save screen space.You may set the resolution of the time axis in the toolbar’s drop list to customizethe Time Plot. Also, the buttons and in the toolbar let you change thezoom. You may use the [Freeze] button in the toolbar to freeze the display.

Page 98: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

98

Use the [List Box] symbol from the toolbar to hide the Plot Items to savescreen space. The [Reset] button clears the plot area. Click the button [Configuration] to add or delete elements from the Time Plot.

➔ Click the [Configuration] symbol in the Time Plot’s toolbar or the option “Time PlotConfig…” in the pop-up menu of the Time Plot.

That invokes the Time Plot Configuration dialog (Figure 69) that consists of thethree tabbed dialogs Variables, Terms, and Rules. The dialog “Terms” containsthe terms of all linguistic variables. The dialog “Rules” lets you select individualrules for display. Use the Variables dialog for choosing variables for display inTime Plot. Another way to insert input and output variables into a Time Plot isclicking the toolbar buttons [Add Input/Output Variables] or .

Figure 69: The Time Plot Configuration Dialog Lets You SpecifyLinguistic Variables, Terms, and Rules for Display in the Time Plot.

The two left list boxes of the “Variables” dialog display elements that you canselect for display. The right list box titled “Variables in Time Plot” shows theelements currently selected for this Time Plot. For the crane controller the“Variables” dialog shows the three input and output variables “Angle”,“Distance”, and “Power” in alphanumeric sequence.

➔ Double-click all three of these variables to move them into the list box “Variables in TimePlot”. Just double-click on the highlighted variable or use the [Add] button to move variablesfrom the left list box to the right one. You can delete inserted variables by selecting them viamouse click and pressing the [Remove] button. After you have selected the three linguisticvariables for display, click on the [OK] button to close this window.

On the right side of the Time Plot window, a list box shows now all selected PlotItems. The left part of the window displays the plot area. A scale for the elementhighlighted in the Plot Item list box is displayed on the left border of the plot

Page 99: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

99

area. A dotted white horizontal line in the plot area shows the zero line if it is inthe displayed range.

➔ Change to the crane simulation window and start the simulation with the [Fuzzy] button. Younow see that the Time Plot window plots the value of all three control variables over time(Figure 70).

The blue line (Power) starts with medium positive Power. After the containersways slightly back (red line declines), the fuzzy logic controller increases themotor power (blue line increases). When the sway becomes too large (red linedeep down), the fuzzy logic controller reduces motor power (blue line declines).After reducing the sway (red line comes back up), the fuzzy logic controllerincreases the motor power again. The constantly declining green line (Distance)shows the progress toward the target.

Figure 70: The Time Plot Lets You Analyze Input and OutputVariables, As Well As Rule Firing Degrees Over Time.

Time Plot of RuleFiring Degrees You may also plot the firing degrees of individual rules.

➔ Open a new Time Plot by selecting Analyzer/New Time Plot... in fuzzyTECH’s main menu.Then double-click on the “RB1” entry in the “Rule Block:” list box. Follow now theinstructions given below.

RB1 is the name of the one and only rule block of the container crane controller.The list box “Plot Item:” now displays the entry “RB1.1.1”. The first numberafter the point identifies the number of the rule in the respective rule block; thesecond number is the output variable of the rule block to be plotted. Hence,“RB1.1.1” identifies the first rule in rule block RB1 and the first output variableof the rule. Next, select the second rule for display. Enter “2” in the field “Rule:”and double-click on the entry “RB1” in the “Rule Block:” list box. After pressing[OK] a second Time Plot opens that plots the firing degrees of the first two rules.Start the crane simulation again and you observe that initially the first rule fires,then the second one. When a rule is highlighted in the “Plot Item:” list box of theTime Plot, the respective rule is shown abbreviated under the plot area. You maymix any combination of linguistic variables, terms and rules in a Time Plot.

Page 100: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

100

The Spreadsheet Rule Editor represents a second and much easier possibility toadd rules to the Time Plot. Invoke the Spreadsheet Rule Editor by clicking on therule block in the window of the project editor. Click then into the DoS column toopen a pop-up menu at the end of which is a Time Plot menu. This menu lists allopen Time Plots. Choose the one to which you want to add the rule by clickingit. The added rule is then displayed in the respective Time Plot in the list PlotItems.

➔ Open a new Rule Analyzer either by clicking its symbol in fuzzyTECH’s main toolbar or theentry New Rule Analyzer in the Analyzer main menu.

Rule Analyzer Use the Rule Analyzer to point out for the last computation step, which rules hadinfluence on the value of the selected variable (Power). The Rule Analyzer canbe configured by its toolbar. By selecting the symbol the rules are sorted bythe aggregation values. By selecting the symbol the rules are sorted by theresult aggregation values. For each term those rules are listed that meet thefollowing conditions:

• The aggregation value of the IF part of the rule is > 0.• The THEN part of the rule contains this term.

➔ Set the value of the variable “Angle” to 38.5 and the value of the variable “Distance” to 8. TheRule Analyzer lists the following rules:

Figure71: Rule Analyzer for Output Variable “Power”

➔ To further examine the rule base, activate the Statistics Analyzer by selectingAnalyzer\Statistics from the main menu, or clicking the [Statistics] button in fuzzyTECH’smain toolbar.

Statistics Analyzer In contrast to Time Plot, Transfer Plot, and 3D Plot, the Statistics Analyzer doesnot occupy its own windows. Rather, it adds a new column [min-#-max] to eachSpreadsheet Editor. The Statistics column appears within the THEN part of theSpreadsheet Rule Editor. For each rule, two bars show the minimum and

Page 101: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

101

maximum firing degrees. The number between the bars counts how often a rulefires with a DoS greater than zero. The frequency a rule fires can either bedisplayed as count absolute of the cycles or relative to the determined period.Click the Spreadsheet Rule Editor’s toolbar button [Show Absolute Statistics]or [Show Relative Statistics] to display the frequency a rule fires in absoluteor relative values. Reset the statistics counter to zero by clicking the toolbarbutton [Reset statistics counter].

You can turn the Statistics analyzer off by deselecting Analyzer/Statistics infuzzyTECH’s main menu or by clicking the [Statistics] toolbar button infuzzyTECH’s main toolbar.

Trace Analyzer The trace function lets you trace the dynamic behavior of a fuzzy system duringruntime. While computing a fuzzy system, the input and output values of eachcomputation cycle are written into a special data buffer. The contents of this databuffer can be written into a file using one of the fuzzyTECH data formats. Theadvantage of such a trace lies in the possibility to analyze the dynamic behaviorof the fuzzy system at any time later. The debug mode File Recorder isespecially suitable for such a task, since it allow to repeat traced data in single-steps and “what-if” analyses can be made. Therefore, the Spreadsheet RuleEditor and 3D Plot can be opened additionally.

The Trace option lets you configure a trace buffer on the target hardware or inthe internal computation kernel of fuzzyTECH. A trace buffer must be assignedto your fuzzy controller to enable the Trace Analyzer. Select “Tools/ProjectOptions/Code Generator”. The Code Generator dialog can not be accessed whena debug mode is open. In the Settings field, choose the option Online Code, thenthe option Trace in the field Online Code and the buffer size.

Close Analyzer Click the system icon of a analyzer window to close an analyzer. If you leavethe debug mode, all analyzer windows are automatically closed.

3.1.3.6. Online Optimization

Although the resulting system may work well using the process data or thesimulation, the performance of the fuzzy controller on the real system varies inmost control applications. This is due to various reasons. When real process datahas been used, feed-back of the control actions is not taken into consideration.When using a simulation, model-based simulations are almost alwaysapproximations or simplifications of the actual system’s behavior. In this case,the Online Debug modes or the RTRCD (Real Time Remote Control Debug)modes are the appropriate tools. These debug modes allow the user to “take alook” at the inputs and outputs of a fuzzy system on a fuzzy runtime system andto modify the fuzzy system during runtime.

Page 102: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

102

Fuzzy Runtime System A fuzzy runtime system consists of the following components:1. Client: A client can either be a user-written program or a standard program

(e.g. MS Excel) that is used for computing a fuzzy system. The clientprovides the input values for the fuzzy system, initiates computation, andcalls for the output values for further processing.

2. fuzzyTECH Runtime Library: fuzzyTECH provides different runtime librariescontaining fuzzy algorithms, e.g. fuzzyTECH Runtime DLL, fuzzyTECHRuntime Control, fuzzyTECH C Runtime Library, fuzzyTECH AssemblerRuntime Library, fuzzyTECH COBOL Runtime Library, ...etc.

3. Fuzzy System: A fuzzy system can be at least one file generated by one offuzzyTECH’s code generators, containing specific data of the fuzzy system(rules, membership functions, etc.).

During Online/RTRCD optimization a communication channel connects thefuzzyTECH development system on the PC with the target hardware. Dependingon your fuzzyTECH edition this communication channel can be e.g. a serial cableor a PC network (see below for details).

Figure 72: Online Development, using a communication channel to connect theDevelopment System and the Target System.

The Online Edition enables you to do online optimization with all targetplatforms. The Professional Editions enable you to carry out online optimizationonly on Windows platforms. RTRCD optimization is possible on an MCU-platform for most MCU-Editions or on a S5/S7 platform for the IA-S5/7 Edition.

Monitor The Monitor debug mode can exclusively be used to monitor the running fuzzysystem on the target without modifying it. In this mode, the fuzzification, ruleevaluation and defuzzification are visualized. The communication can also beused for Tracing. All trace data are recorded as real time data on the fuzzyruntime system. It is, however, impossible to change the fuzzy system.

Monitor&Modify In RTRCD Monitor&Modify debug mode the following changes are possible:• Modify the Degree of Support (DoS) of each rule.

Page 103: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

103

• Modify the result term of each rule.• Modify the position of the definition points of each term.• Add / delete term definition points.

In addition to the above mentioned changes, the Online Monitor&Modify debugmode allows the following changes:• Modify the properties of a variable’s term (S-Shape / L-Shape).• Modify the output defuzzification method (CoA, CoM, ...).• Download a modified fuzzy system from the development PC onto the target

platform.• Upload the FTL code of the running system from the target platform onto

the development PC.

Communication Channels Several different communication channels can be used to establish an online linkbetween fuzzyTECH and a fuzzy application on a target system. TheMCU/RTRCD-Editions only allow a serial interface as communication channel.The serial interface allows communications with the target hardware. The dialogfor the Serial Interface Configuration is opened via “Tools/fuzzyTECHPreferences/Serial Interface”. The IA-S5 Edition uses a serial cable with PGinterface.

In addition to the serial link, the following communication channels are availablefor editions with Online/RTRCD mode:• Serial Interface: If this channel is chosen the serial interface is used for online

communication. By means of the [Setup] button, the dialog for theconfiguration of the Serial Interface is opened. This communication channelis available in Online/RTRCD Editions.

• Shared File System: If this channel is chosen fuzzyTECH uses a set of filesfor online communication. The files are passed via a directory on a filesystem that may be shared by fuzzyTECH and the target system application.Note: The shared file system directory must be an exclusive resource that canonly be used by one instance of fuzzyTECH and one target system applicationat the same time. Therefore, fuzzyTECH protects the directory against accessfrom other instances of fuzzyTECH by creating an empty file namedFTOMLOCK. The target system application protects the directory againstaccess from any other target system application with an empty file namedFTOSLOCK. This communication channel is only available in the OnlineEdition.

• ...\FTDDE.DLL: If this channel is chosen fuzzyTECH uses MS WindowsDDE for online communication. This is the best communication channel for aFTRUN based fuzzy runtime system running on the same PC as fuzzyTECH.The [Setup] button is deselected and appears therefore in a grayish colorbecause there is nothing to setup for DDE.

• ...\FTTCPIP.DLL: If this channel is chosen fuzzyTECH uses a networksupporting the TCP/IP protocol for online communication. This channel

Page 104: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

104

should be chosen, if two PCs are connected to such a network and PC1 isrunning fuzzyTECH and PC2 is running a FTRUN based fuzzy runtimesystem. The [Setup] button lets you specify either the host name or the IP-address of PC2.

• ...\FTIPX.DLL: If this channel is chosen fuzzyTECH uses a network foronline communication. The network, e.g. Novell Netware/Intranetware, mustsupport the IPX/SPX protocol. This channel should be chosen, if two PCs areconnected to such a network and PC1 is running fuzzyTECH and PC2 isrunning a FTRUN based fuzzy runtime system. The [Setup] button lets youspecify the network address of PC2. It consists of the three values Network,Node and Socket. The appropriate values for PC2 are shown in the FTRUNinformation window as a string with the following scheme: Online: IPX/SPXon <Network>.<Node>.<Socket>.

• ..\FTSDI.DLL: This communication channel is only available for thefuzzyTECH MCU-HC11/12 Edition. It should be used for RTRCDcommunication, if your M68HC12 target system has a Background DebugMode (BDM) connector for a Serial Debug Interface (SDI). If this channel ischosen fuzzyTECH uses the MMDS1632 protocol on the serial interface. The[Setup] button lets you specify serial port number, baud rate and the addressof the BDM communication buffer on target.

• Sucosoft S40: Only available for IA-S40 Edition.• ..\FTOCC.DLL: To enable non-standard communication channels

fuzzyTECH supports the integration of one or more user-implementedfuzzyTECH Online Communication Channel DLLs. If this channel is chosenfuzzyTECH uses an empty prototype of such a DLL. The source code of thissample is located at ..\USEREXT\FTOCC\SRC and can be used as basis forimplementing new communication channels.

Online Timing The period of time, in which online information are requested, is defined in theSettings field of the Online Timing dialog (see Figure 73) in Tools/ProjectOptions. As the calculations from the target hardware are visualized in thefuzzyTECH editors, a time period for the update of the editors has to be defined.The Refresh Time determines the time interval after which the currentoperational status is requested.

If the update of the windows update time is lower than the defined refresh time,the refresh time determines the request frequency. An error message occurs if noresponse from the target is stated after the determined timeout value ([Time Out]field). The Time Out parameter determines the time interval in which a responsehas to be obtained from the target system. A message box appears, if this timeinterval is exceeded, and the online connection is terminated.

Page 105: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

105

Figure 73: Define the Time Behavior of the Online Connection in the DialogProject Options/Online Timing.

Necessary Steps Follow these steps to optimize a fuzzy system with the Online/RTRCD debugmode Monitor&Modify:1. Choose the option Online Code from Tools/Project Options/Code Generator

and generate code.2. Start your generated system on the target hardware. Refer to Chapter 6 for

details on implementation.3. In fuzzyTECH, start the Online Wizard by clicking entry Online Connections

in the Treeview with the right mouse key and choosing the option OnlineWizard in the pop-up menu. Follow the instructions of the Online Wizard.Refer to the paragraph Configuring an Online Connection of Chapter 2 toread about the sequence of dialogs the Online Wizards guides you through.

5. Optimize the rules and membership functions using fuzzyTECH’s analyzers.6. After optimization, when you leave the debug mode, the Online Wizard

appears again. Follow its further instructions.

After the fuzzy system was optimized, compile the code again without theOnline Code option enabled (see step 1 above), and integrate it within the finalsystem. This compacts the code, since all code optimization features are disabledwhen generating online code.

Project Identification A condition for the Online/RTRCD optimization to work is, that the FTL projectin fuzzyTECH and the fuzzy runtime system must match each other. They matchonly, if the code of the fuzzy system on the runtime system was generated fromthe FTL project in fuzzyTECH. A project identification timestamp is used onboth sides to verify this. These timestamps are displayed behind the names of thesystems in the Treeview. If these timestamps differ from each other,Online/RTRCD debugging cannot be started.

Page 106: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

106

TerminatingOnline Debugging If a fuzzy system was modified during an online session, the Online Wizards

opens when leaving the Online/RTRCD debug mode. The Online Wizard offersthe user to save his system, to restore the original system, or to let himsynchronize the system himself manually. Synchronizing the system is necessaryin order to allow a later re-connection to the runtime system.

Interrupts whileOnline Debugging If the Online/RTRCD debug mode is interrupted due to communication errors

(e.g. interrupting the power supply for your PC or unplugging thecommunication cable), the fuzzy system loaded in fuzzyTECH and the system onthe runtime system may not be synchronous any more. If an interrupt occurs,follow the instructions of the Online Wizard.

Co-ordinationg OnlineCommunication The online communication uses master-slave operations. All requests are

initiated by fuzzyTECH. Thus, if no link is enabled, the controller is able tooperate without the development system. For security purpose, all telegrams aretransferred via handshake. If no message appears or a telegram is only partlyreceived at the target, the development system and the online debugger will sleepbut let the controller work. Every message completely received at the target isacknowledged by the online debugger. This acknowledgment must reach thedevelopment hardware in a time period shorter than the time out intervaldetermined in the Timeout field in the dialog Online Timing (Figure 73) inTools/Project Options. Otherwise, a message appears and the Online Connectionis terminated.

Password Protection To allow only qualified personal to modify the fuzzy system on the targetthrough Online /RTRCD mode you can protect the access to the Online /RTRCDmode with a password. Choose the option Password Protection from Tools/Project Options/Code Generator and generate the code. You will have to definethe password when you generate code. The password has always to be enteredwhen Online/RTRCD debug mode is started. The password must consist of fivecharacters at least. To change the password, click the respective system’s namein the Treeview with the right mouse key and choose the Change Passwordoption from the pop-up menu.

Open Fuzzy System onRuntime System (Upload) Upload is an additional feature of fuzzyTECH editions provided with online

debugging functions (refer to Table 4, Section 9.4). To activate this feature,select the option Compress FTL from “Tools/Project Options/Code Generator”before code generation is started. This way the generated code includes acompressed copy of the current fuzzy system (FTL file). Later this system can bere-loaded with the help of the Online Wizard, provided that fuzzyTECH and theruntime system are connected via a communication channel. Upload may bespecially useful, if the matching FTL file does not exist any more.

Page 107: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

107

Overwrite Fuzzy Systemon Runtime System(Download) Download is a feature that makes it possible to modify a fuzzy system off-line

and then download the modified system onto the target system. This requires thatthe fuzzy system loaded in fuzzyTECH’s Project Editor and the fuzzy system onthe runtime system match in significant parameters (number of inputs/outputs,data type, storage space...). Downloading can be carried out with the help of theOnline Wizard, if fuzzyTECH and the runtime system are connected to eachother via a communication channel. The download option is especially useful formodifications of the system’s structure (additional intermediate variables,additional terms, and additional rule blocks), since such modifications cannot becarried out in the debug mode Monitor&Modify.

Fast Processes Some processes are too fast to be optimized on-the-fly. In such cases, the TraceAnalyzer should be used for system analysis. After starting the Trance Analyzer,the fuzzy system traces (stores) the values of its input and output variables in realtime for a defined time interval. Via a communication channel, this data can laterbe transferred from fuzzyTECH and stored in a file for further off-line analysis.

3.1.3.7. Connecting fuzzyTECH to other Applications

Diverse interfaces are supported in fuzzyTECH to link fuzzyTECH with otherapplications, e.g. process simulations. All interfaces described in this section usethe internal computation kernel in fuzzyTECH to compute the results of a fuzzyproject. This allows a complete system visualization in all editors and analyzersof fuzzyTECH as well as an interactive system development. fuzzyTECHsupports the following interfaces:

RCU By remote control and via FTRCUxx.DLL, the Remote Control Unit (RCU)allows an application to use fuzzyTECH as data server and for fuzzycomputations. fuzzyTECH is completely controlled by this application.fuzzyTECH activates a special debug mode, that cannot be influenced by theuser. RCU links are explained in detail in Section 6.2.1.

RCU delivers functions to• check whether fuzzyTECH has been started ,• start, minimize, maximize and terminate fuzzyTECH,• check whether a determined project is loaded,• load a project,• check whether a debug mode is enabled,• switch into debug mode,• set values of input variables,• triggers a fuzzy computation, and• return the defuzzified result of specified output variables.

Page 108: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

108

Figure 74: Link fuzzyTECH With an Application Software Using RCU.

DDE DDE is another way to connect fuzzyTECH with MS Windows applications. Fordata exchange with other applications via DDE, fuzzyTECH can function both asserver and client. We recommend to use this interface together with theInteractive debug mode. DDE links are explained in detail in Section 6.2.1.

The DDE link allows you to:• receive data from another application in fuzzyTECH,• make data in fuzzyTECH available for other applications.

Figure 75: Link fuzzyTECH Using DDE.

Serial Link Another application can exchange data with fuzzyTECH using the serial interfaceand the Serial Link Protocol. Serial Links are explained in detail in Section 6.2.3.

3.1.4. fuzzyTECH Documentation and RevisionControl System

fuzzyTECH provides different tools that let you document and commented onyour entire project. The Project Information tabbed dialog displays the lateststate of your project. fuzzyTECH’s Revision Control System lets you save eachdevelopment step for revision and project control. fuzzyTECH’s DocumentationGenerator creates automatically a documentation of your entire project.

Copy/Print Window fuzzyTECH allows the capture of all editor windows to the clipboard or to awindow’s printer to allow graphical documentation of your fuzzy system. [File][Copy Window...] and [File] [Print Window...] let you either capture thecomplete fuzzyTECH screen or just the currently activated window. Note that infuzzyTECH, some windows are never displayed in the background.

Page 109: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

109

3.1.4.1. Project Information

➔ Choose the item “Project Information...” from the File main menu or from the pop-up menu ofthe Treeview window.

This activates the tabbed dialog Project Information (Figure 76). Its Generalpage is used to enter such project-related information as the name of the project,author’s name, the date of creation and last change. Moreover, furtherinformation on the current project are displayed, such as the total number ofinput/output/intermediate variables, rule blocks, text objects, terms and rules.

The project name can also be changed at any time later on this page and may bedifferent to the file name. A project name can be up to 16 characters long andmay not contain any spaces. The default project name is the same as the FTLfile.

Figure 76: Refer to the Project Information Dialog For Information About theCurrent State of Project

Enter project-related comments on the Comment page of this dialogs. Thesecomments are added automatically to a documentation generated byfuzzyTECH’s Documentation Generator.

Page 110: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

110

3.1.4.2. Documentation Generator

➔ Choose the item “Documentation...” from the File main menu or click the symbol[Documentation] in the main toolbar to open the Documentation Generator dialog.

In this dialog (Figure 77), the textual and graphical documentation of thecurrently loaded fuzzyTECH project will be configured. This documentation ismaintained in form of a report and saved in RTF format. Thus it can beprocessed further with another text processor. Clicking the [Generate…] keystarts the automatic project documentation according to your settings. Refer tothe fuzzyTECH Help system for a detailed description of this dialog.

Figure 77: fuzzyTECH’s Documentation Generator

3.1.4.3. Revision Control System

Like most design software, fuzzyTECH stores all information on a system underdevelopment in a file. In the case of fuzzyTECH this is an ASCII format file inFTL syntax with the suffix *.FTL. Optionally, fuzzyTECH stores the informationon editor and analyzer configurations in a *.CFG file that is an ASCII format filefollowing the same syntax rules as most MS Windows *.INI files. While this isthe standard way to handle project files in software development, themodifications to a system under design must often be documented. This is a mustfor developers who are obliged to document system modifications in an ISO9000

Page 111: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

111

compliant fashion. In software engineering, such documentation is handled by aRevision Control System. The objectives of a Revision Control System are to:• Ensure that only the appropriate persons can conduct modifications,• Document the modifications and the related comments of the developer, and• Allow the user to scroll back to an earlier stage in development.

Such Revision Control Systems are available from a large number of vendors,and you can integrate fuzzyTECH and its FTL files as source files with anycommercial Revision Control System. However, Revision Control Systems arepowerful and complicated tools, and if you do not already use one that has beenset up, you can use the integrated Revision Control System of fuzzyTECH.Because of its tight integration with fuzzyTECH, revision control becomes aneasy task, plus the overhead cost required to work with a revision control systemis easily recovered the first time you decide to revert to an earlier stage ofdevelopment.

fuzzyTECH’sRevision Control System fuzzyTECH’s Revision Control System (RCS) uses *.REV files to store multiple

*.FTL files, plus additional information describing the modifications fromprevious development stages. Each development stage is represented by its*.FTL file. In brief, a *.REV file contains the sequence of *.FTL files of adevelopment project. You can store each *.FTL file that represents a specificstage of development in the *.REV file and reclaim each *.FTL file from it later.The RCS uses a compressed and encrypted format for *.REV files. Hence, evena large number of *.FTL files can be stored in a *.REV file in a compact fashion.The RCS enforces password encryption to ensure that only appropriate personscan modify revisions of the fuzzy logic system.

Work with ExistingREV Files Open the existing file CREDIT.REV contained in the subdirectory

…\SAMPLES\BUSINESS\CREDIT\..., to become familiar with the RCS. Youcan either select File/Open from the main menu bar and set Filetype to RevisionFile (*.REV), or select File/Revision Control… from the main menu bar andclick on the [Open REV...] button. Both ways open the Revision Control dialog(Figure 78).

Password Protection The RCS enforces the use of passwords to protect the REV file fromunauthorized viewing and editing. For CREDIT.REV, the password is “fuzzy”.You can change the password of an opened *.REV file by selecting the[Password...] button from the Revision Control dialog.

Working with Revisions The list box in this dialog reports all revisions of *.FTL files that are stored inthe *.REV file. In CREDIT.REV, five stages of CREDITx.FTL, are stored. Thefirst column of the list box shows the project name, which is the original name ofthe *.FTL file. The sequence of the listed projects is the chronological sequencein which revisions have been stored in the RCS. It cannot be changed. TheDate/Time column shows when the *.FTL file was added to the *.REV file. TheAuthor and Comments columns show who developed the revision and what was

Page 112: ft531manual

Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

112

changed with respect to the previous revision. The column Comments showsonly the first part of the first line of the comments. You may look at thecomments in detail by clicking right on the revision’s name in the first graycolumn to open a pop-up menu and choosing there the [Comment...] item. Youcannot modify the columns Name, Date/Time, Author, and Comments of anexisting revision.

Figure 78: The Revision Control Dialog Lists All Stages ofa Fuzzy System Development.

Retrieving FTL Filesfrom REV files If you want to view or modify a revision, you need to log out this revision from

the RCS. First, select the revision in the list box, then press again the right mousekey and select the option [Check Out] in the pop-up menu. Because an *.FTLfile with the same name exists, the RCS lets you now specify a new file name.Then, the revision is automatically opened with fuzzyTECH. You can store thefile during development as any other *.FTL file.

Storing FTL Filesin a REV File When a new stage in development is reached that you would like to document

and store in the RCS, you have to open the respective *.FTL file withfuzzyTECH. Then, open the Revision Control dialog again by selectingFile/Revision Control from the main menu bar. If you have restarted fuzzyTECHsince the last time you opened the *.REV file, you have to open it again byclicking on the [Open REV...] button. Click on the button [Check In] to store thecurrent *.FTL file as new revision. This opens a dialog (Figure 79) that lets youspecify the author’s name and describe the modifications made.

In order to create a new file, just click the [New REV...] button in the RevisionControl dialog and specify a password for this *.REV file. Make sure that younote the password, as there is no way to access a *.REV file without thispassword. The password can only consist of standard alphanumeric charactersand must be at least five (5) characters long.

Page 113: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

113

Figure 79: When You Store a Revision in the RCS, You Specifythe Author’s Name and Describe the Modifications

Printing a CompleteDevelopment History Click on the [History...] button to print a complete development history that

covers all revisions. This delivers all the revision information plus all commentsinto a single text file that can be edited, printed, or integrated into otherdocuments.

Compact File Format Note that the binary *.REV file format is much more compact than the textual*.FTL format. While the five CREDITx.FTL files together use more than 50 KBof disk space, the CREDIT.REV file that contains all of them in condensedformat uses less than 10 KB of disk space. You can also use the *.REV fileformat, which stores only one *.FTL file, if you either need a more compactrepresentation than *.FTL or if you want to protect the *.FTL file from beingread by unauthorized persons.

Page 114: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

114

The composition of this chapter is analogous to Chapter 1. First, familiarizeyourself with NeuroFuzzy design by using samples and development tools.Second, design your own NeuroFuzzy system with the aid of the NeuroFuzzyGlass Sensor Simulation.

4.1. First steps

Make your first steps with NeuroFuzzy design by following the instructionsgiven in the next two sections. The first section walks you through the generationof a fuzzy XOR system from a sample data file. In the section which follows, thegenerated system (the XOR example) is then trained with the NeuroFuzzyModule.

If your fuzzyTECH Edition does not include a NeuroFuzzy Module, you maywish to skip this section. As an exercise, you can also train other logicalfunctions (OR, AND, NOR, NAND, NOT) later. A more detailed explanation ofthe development steps using the simulation of a real world classification problemis given in Chapter 5.

4.1.1. Generating a Fuzzy XOR System by theFuzzy Design Wizard

The Fuzzy Design Wizard (FDW) supports quick generation of a systemprototype (see Section 0, too). The FDW is well suited to create an “empty”fuzzy logic system that NeuroFuzzy training requires. Now you will generate afuzzy XOR system by the FDW and train this system in the next sections.

Page 115: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

115

➔ Close your current project in fuzzyTECH (“File/Close”). Open the FDW by either selecting“File/Fuzzy Design Wizard...” in the main menu or by clicking the respective button in themain toolbar. Follow then the instructions given below.

In the first FDW window enable the check boxes “Create New System” and“Use a Data File”. Clicking the [Next] button opens the file specification dialogRead Project Information From…. Select the “XOR.EXP” file from thesubdirectory “...\SAMPLES\NEUROFUZ\XOR”. After you have done that, thenext FDW dialog opens.

In the FDW dialog Numbers of Variables you specify number of input, output,and intermediate variables as well as their number of terms. You may change thenumber of terms for individual linguistic variables later. By analyzing the file“XOR.EXP”, the FDW discovered that the system to be created requires twoinput and one output variables. Due to the simple structure of the training data,the FDW does not propose intermediate variables. Move to the next FDWwindow by clicking the [Next] button or pressing the [Return] key.

The following three FDW windows specify the three linguistic variables of thesystem. The first of these FDW windows defines the first input variable, “InputA”. By analyzing the sample data set, the FDW has set the range for the variablefrom 0 to 1. The FDW has also determined that only 0 and 1 values are specifiedfor all variables and proposes the term names “false” and “true”. You maychoose other term names from the drop list box or overwrite the term number.For now, accept the default settings proposed by the FDW and move to the nextFDW window.

The next FDW window defines the next input variable, “Input_B”. Accept theproposed defaults and step to the next FDW window that defines the outputvariable. For the output variable, the FDW proposes the range -1 to 2. Thisresults from considering the possibility that a later shift of the membershipfunctions out of the range 0 to 1 could be necessary. Accept the default valuesproposed by the FDW and step to the next FDW window.

This FDW window defines the defuzzification method for the output variable.Accept the proposed default by clicking the [Next] button or pressing the[Return] key. The next FDW window defines the rule blocks. Due to thesimplicity of the training data, the FDW proposes just one rule block. Enablingthe check box, “Create Rule Base”, lets the FDW generate a complete rule set foreach rule block. For each combination of terms, a rule is generated. As Degree-of-Support (DoS), either random values (“Random Value”) or a constant value(“User Defined Value”) is assigned.

The FDW proposes the generation of a rule set where all rules have a DoS of 0.Since the DoS is the degree of membership a rule has in the set of totally truerules, this is equivalent to a set of completely false rules. Hence, the generated

Page 116: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

116

rule set contains no information. The reason for creating a complete, but totallyfalse rule set is that the NeuroFuzzy training can only start with an existing ruleset. Accept the proposed default values of the FDW and either click the [Next]button or press the [Return] key. Since this is the final window of the FDW, thisis equivalent to pressing the [End] button. After pressing [Next], a Confirmationdialog appears. Confirming the dialog or pressing [End] generates the system asshown in Figure 80.

Figure 80: Structure of the System Generated By the FDW for the File XOR.EXP.

4.1.2. NeuroFuzzy Training of Fuzzy Systems:The XOR Example

This section describes how to use the fuzzyTECH NeuroFuzzy Module to trainthe exclusive or (XOR) example.

Development Stepswith NeuroFuzzy The development of a solution using the fuzzyTECH NeuroFuzzy Module

consists of the following steps:1. Obtain training data, cluster if necessary2. Create an “empty” fuzzy logic system3. Enter all existing knowledge in the solution4. Open the components of the fuzzy logic system to be trained5. Configure the NeuroFuzzy Module6. Train with the sample data7. Evaluate system performance8. Manual optimization9. Implementation as “pure” fuzzy logic system

Obtain Training Data The training data for the XOR example is easy to obtain as a decision table forthe digital (Boolean) XOR. In practical applications, finding a representative setof sample data can be the hardest part of the design.

Page 117: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

117

➔ Start fuzzyTECH and select “File/View File...” in the main menu, choose “Example Data File(*.EXP)” as the “File Type”, and select the file “XOR.EXP” in the list box. This file is locatedin the subdirectory “...\SAMPLES \NEUROFUZ\XOR…”.

Training Data The editor window shows the contents of the file (Figure 81). The first and thirdrow of the file contain comments, while the second row specifies the names ofthe linguistic variables “Input_A”, “Input_B” and “Output”. The actual datarecords start with Row 4.

Figure 81: Contents of the File XOR.EXP.

Note that the file may not contain any empty rows. The data record rows startwith the record names “sample1” … “sample4”, plus the values of the two inputvariables and one output variable follow. The values must follow the IEEEformat for float values. You may use any ASCII editor to generate a training datafile. Also, most spreadsheet, data base, or data acquisition software systems cangenerate the training data files.

Create an “Empty”Fuzzy Logic System Since the training data already exists, the next step is the creation of an “empty”

fuzzy logic system using the Fuzzy Design Wizard. You may have alreadycompleted this step in the previous section.

Open Componentsfor Learning fuzzyTECH allows you to open specific components of the fuzzy logic system to

be modified by the NeuroFuzzy training. For the XOR example, you may openall rules and the output variable for training.

➔ First, open a Variable Editor window for the variable “Output” with a double-click on thevariable name in the Treeview window. Click on the [Learn MBFs] button in the toolbar ofthe Variable Editor to open all membership functions for learning.

If you only want to partially open the membership functions, open the pop-upmenu by clicking right somewhere in the Variable Editor and select the “Learnall MBFs” option. This opens the dialog shown in Figure 82 where you canspecify the range in which the NeuroFuzzy Module may modify the membershipfunctions. An “L:” appears left of the respective term name in the Term list boxof the Variable Editor to indicate membership functions opened for learning.

Page 118: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

118

Figure 82: Open the Membership Functions for Learning.

➔ Next, open the Spreadsheet Rule Editor for the Rule Block. The Fuzzy Design Wizard hasalready opened all rules for learning, indicated by the gray background of the DoS values.Click the [Learn MBFs] button to open or close all rules for learning. Here, you can enterthe interval in which the NeuroFuzzy Module may alter the DoS of the rules. Click on the DoSvalue in the Spreadsheet Rule Editor and select [Learn...] to open and close individual rules.Since the Fuzzy Design Wizard already opened all rules for learning, you do not need to adjustany further settings here. Now open the NeuroFuzzy Configuration dialog either by clickingthe respective button in the main toolbar or by selecting “Tools/Neuro/Configuration...” in themain menu.

Configuring theNeuroFuzzy Module In this step you specify the learning method and set parameters for it. The upper

left list box “Learn Methods:” of the NeuroFuzzy Configuration dialog (Figure83) shows all available training algorithms. The NeuroFuzzy Module of afuzzyTECH Edition in Demo mode only supports one basic algorithm: the“Random Method”. You may also code your own training algorithm by using theelements provided by the NeuroFuzzy Module and listing them in the “LearnMethods:” list box.

Figure 83: The Neuro Configuration Dialog Lets You Select a Learning Methodand Set Parameters For It.

Page 119: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

119

The group “Learn Parameters:” lets you set parameters for the algorithm. Leavethese parameters at the proposed default values for the training of the XORexample. The group “Stop Conditions:” lets you specify when the trainingshould automatically terminate. The three conditions are alternately used. Forinstance, if you enable “Max. Steps:” with a value of 100 and “Max. Dev.:” witha value of 0.1, the training stops after 100 training cycles or when the maximumerror is lower than 10%, whichever occurs first. If you do not select any stopcondition, you must stop training manually. The group, “Selection Mode:”, letsyou specify the sequence in which the samples are selected for training:“Sequential” always follows the sequence in the sample data file, while“Random” selects an arbitrary sequence. Whenever the sample data is sorted insome way, you should select “Random”.

➔ Since the XOR contains sorted samples, select Random as Selection Mode, make sure all otheroptions are specified as shown in Figure 83, and leave the dialog by clicking [OK].

Training and Analysis In order to make the training algorithm as computationally efficient as possible,you may not modify any of the fuzzyTECH windows during training. Optionally,all modifications made by the NeuroFuzzy Module can be visualized in theopened fuzzyTECH editors and analyzers. Therefore you should configure andarrange all fuzzyTECH editors and analyzers before you start training. Figure 84shows a window configuration that works well when training the XOR example.

➔ Activate the Interactive Debug mode, minimize the Watch Window, open the 3D Plot, activatethe “Repaint” option in the 3D Plot then position the windows similar to Figure 84.

Figure 84: Possible Window Configuration for Learning.

Page 120: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

120

The 3D Plot initially does not show any transfer surface since plotting issuppressed for areas where no rule fires. You can enforce plotting the transfersurface by setting the DoS values of all rules to 0.01.

➔ In the Spreadsheet Rule Editor, open its pop-up menu and choose the option Rule BlockUtilities from it. Select “Set all DoS” and “User Defined” and enter a value of 0.01 in the valuefield. When you click [OK], all rules fire to a very small degree and the 3D Plot draws atransfer surface.

Since no training has taken place thus far, the output value is a constant 0.5 forall combinations of the input values.

➔ Initiate the training by either clicking the [NeuroFuzzy Training] button on the main toolbar orselecting “Tools/Neuro/Learning...” from the main menu. Choose the file “XOR.EXP” fortraining. This opens the Learn Control dialog that lets you supervise and guide the trainingprogress.

Learn Control Dialog The learn control dialog is controlled via its toolbar where you find buttons tostart and stop training, and to process single training steps. Twobuttons control the Plot area: an error plot and an error statistic areavailable. A list of samples that continue to produce a significant error isgenerated by the button and is displayed in the bottom section of the dialog.In order to verify the training results during interrupted training, determinesthe current system’s state. enables the update of all windows shown infuzzyTECH. The Neuro Configuration dialog can be re-activated by the button.

➔ Terminate the training procedure and exit the Learn Control dialog by the [Exit] button.

Plot Area The plot area enables the display of a NeuroFuzzy error plot, a NeuroFuzzy errorstatistic or both. The error plot shows the training history of the maximumdeviation (Max. deviation) and the average deviation (Avg. deviation). Thestatistic plot classifies the deviations of all samples. The number of samplesfitting into each deviation class is displayed.

Deviation Values The group “Deviation Values:” displays the values of the current errors relativeto the selected error condition thresholds. The group, “Status:”, next to thisdialog on the right side, displays various types of information: number of the

Page 121: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

121

current sample, number of training cycles, and the iteration timer value. Theiteration timer value shows the computing time the last training cycle required totrain all samples of the data set. If you disable the [Update All Windows] button,this value declines.

Update All Windows Enabling the button causes the NeuroFuzzy Module to update the contents ofall opened editors and analyzers in fuzzyTECH for each training example. Enablethis option to interactively watch the training progress. Note that enabling thisoption slows down the training process considerably.

➔ Now click to initiate training.

Training the XOR The training either stops when one of the stop conditions is satisfied or the button is clicked. When you stop training and close the Learn Control dialog,you may manually change the fuzzy logic system and conduct various analyses.You may continue training at any time from the current setup by selecting“Tools/Neuro/Learning...” from the main menu, or by clicking the [NeuroFuzzyTraining] button in the main toolbar. The last configuration of the NeuroFuzzyModule is stored until you close fuzzyTECH.

Output and Target Values The list box “Output - Target - Computed:” displays a row for each outputvariable under training. The left item in each row is the name of the outputvariable, the middle item displays the desired output value (from the sample),and the right item is the value computed by the current fuzzy logic system undertraining. This list box is only updated in single-step mode. This function, forexample, allows you to determine which samples are causing any significantremaining error. Next, initiate Training by pressing the [Start] button. Becausethe NeuroFuzzy Module only generates fuzzy logic systems that are easy tocomprehend, it only operates with Standard MBFs. Therefore, all membershipfunctions are converted to Standard MBFs at each initiation of the training. Ifyou have followed all of these steps, you should now be able to monitor thetraining in the windows of fuzzyTECH. The NeuroFuzzy Module modifies theDoS of the rules and moves the membership functions of the output variable.The 3D Plot shows how this affects the transfer surface.

Figure 85 shows the transfer surface after training. The input combinations (0,0),(0,1), (1,0), and (1,1) from the sample data file are well-represented with thetrained fuzzy logic system. Between these points, the resulting fuzzy logicsystem performs a continuous approximation.

Page 122: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

122

Figure 85: Learning Results in the 3D-Plot.

You may use the File Recorder Debug mode to step through the samples in the“XOR.EXP” file. Try to train other logical functions as an exercise. Oneinteresting exercise is to present conflicting data to the NeuroFuzzy Module.Add the following row to the file “XOR.EXP” using a text editor:

sample5 1 1 1

Make sure that there is no space character between “sample” and “5”. This datais in complete conflict with sample4. If you restart the training with thismodified example file, you see that the error remains high. This is due to the factthat no adaptive system would be able to solve a conflict in the training data.

Since the learning method selected tries to minimize the average quadratic error,the transfer surface looks similar to Figure 86 after some training cycles. If youwant to eliminate rules that only have a small influence on the system aftertraining, you can use the “alpha cut” function from the Rule Block Utilitiesdialog.

End of Tools Overview This ends the fuzzyTECH development tools overview. The following sectionsguide you through a more in-depth exploration of fuzzy logic, NeuroFuzzytechnology and fuzzyTECH.

Page 123: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

123

Figure 86: Result of Learning With Conflicting Data.

4.2. NeuroFuzzy System Design

Fuzzy Logic Fuzzy Logic is a technology that enhances model-based system designs by usingboth intuition and engineering heuristics. As a result, elements of everydaylanguage are used to represent desired system behavior, thus circumventing theneed for rigorous mathematical modeling. This provides an efficient way ofdesigning, optimizing, and maintaining highly complex systems and results inrobust and fault-tolerant systems.

Sample Data In many control applications and in most sensor applications, classificationcriteria are expressed by linguistic knowledge and expertise is often representedby sample data. This is also typical for decision support problems, diagnosis orpattern recognition applications, and data analysis systems. Such data is usuallycollected from one or two sources: a running system using a functioningcontroller or from a development engineer, who creates realistic example data.NeuroFuzzy technology allows for the automated generation of fuzzy logicsystems based on this training data.

NeuroFuzzy The NeuroFuzzy Module combines the advantages of fuzzy systems – thetransparent representation of knowledge and the ability to cope withuncertainties – with the advantages of neural nets: the ability to learn. In order to

Page 124: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

124

successfully design a system by utilizing NeuroFuzzy technology, you requireboth a brief introduction to the basics of adaptive systems, and knowledge ofhow to use the NeuroFuzzy Module. If you are not familiar with NeuroFuzzytechnology, please first read the Fuzzy Primer in Chapter 5 of this manual. Thissection is intended to show the NeuroFuzzy development using the fuzzyTECHNeuroFuzzy Module for deriving a classification system. Typical applicationsfor such a classification system are the recognition of objects that are separatedby color (e.g. recycling glass, containers, or paper) or the quality control of paintjobs (e.g. car painting).

Recycling GlassClassification Collecting and recycling glass is one of the leading processes guiding us towards

ecological waste management. Although glass itself is collected separately, glassof different colors and items made of different materials must be sorted andseparated to gain a sufficient quality of recyclable raw material. In glassrecycling plants, the bottles are sorted into containers that later are meltedtogether and processed in a batch process to new glass. In this process, it isessential that the bottles be sorted into the containers in a mix that yields thedesired glass color when melted and processed. Because different customers ofthe produced glass require different colors and the mix of incoming bottleschanges, no clear definitions can be set with reasonable effort for the sorting ofthe bottles. Rather human operators sort the bottles manually, using theexperience in which mix of bottles will result in the desired color of theproduced glass.

To automate this labor extensive task, an intelligent sensor has been designedthat "learns" from the human operators and then applies the learned knowledgeto do the sorting automatically. In its training phase, the sensor and the humanoperator analyze all bottles in parallel. The sensor records the color differencesignals from a color-sensing element and stores them together with the containernumber the human operator choose for this bottle. Most of the glass articles areproduced either in white, red or green glass with a small fraction of blue andothers. In order to classify bottles and pieces, an amorphous RGB color sensor isused for data record. The sensor is amplified and the hardware calibrated. Therecord of data results in three values showing the differences between fractions:RedGreen, GreenBlue and BlueRed. An A/D converter allows the reading of thesensor values.

Classifier Simulation The Glass Sensor simulation is a simplified version of a real world application ina glass recycling plant. This animated simulation demonstrates the use ofNeuroFuzzy technologies to generate an entire fuzzy logic system solely fromsample data. The simulation was reduced to just four containers for didacticpurposes.

The classifier hardware was implemented as a simulation under MSWindows. The simulation can be opened by clicking the right icon inthe fuzzyTECH program group.

Page 125: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

125

This simulation allows recording the sensor outputs as digital values representingthe three measured colors. Depending on the calculated result, the sample bottleis dropped into one of the containers. In order to use sensor data in real worldapplications, signal conditioning procedures increase the quality of the data. Thedata delivered from the simulation does not require preprocessing. Signalconditioning routines, like statistical analysis and filters, can easily be tested andimplemented by using the fuzzyTECH DataAnalyzer Module. The simulation canbe used to further implement a fuzzy system in fuzzyTECH as a color classifier.

Applying NeuroFuzzy The classification problem requires an adaptive approach. First, the solutionmust include the ability to learn additional color classes. Second, describing theclassification criteria within fuzzy rules is not very efficient. However, recordingsample data assigned with the desired classification is simple. The simulationincludes the option to record data to a file. Within the simulation, the correctglass type is always determined. Thus, the correct glass type is always assignedto the sample data.

Development Steps The system uses three color data as input variables: “RedGreen”, “GreenBlue”and “BlueRed”, and computes the glass type as output variable “Type”. “Type”assigns the four terms green, red, white, and blue to numerical values calculatedby using the defuzzification procedure: 1 represents a red bottle, 2 a green, 3 awhite, and 4 a blue bottle.

Step 1:Record sample data Neural and NeuroFuzzy learning procedures depend on the number and sequence

of sample data. But how much of and in which sequence should the pattern databe recorded?

Quality of Sample Data When you use training data recorded from a real process, chances are that manydata sets are redundant. Use of training data sets with redundant recordslengthens training significantly. Even more critical, if most of the data recordsdescribe the same condition, they have a much greater impact on the solution.

For example, if you want to design a controller for a continuous process, 95% ofyour recorded training data may describe the steady state and only 5% of the datadescribes other conditions. Using this data results in a controller that excels inthe steady state but performs poorly in the other conditions. Training data thatstems from a real process should be clustered before it is used in NeuroFuzzytraining to avoid this situation.

The NeuroFuzzy Module provides a clustering function that features standardclustering methods as well as fuzzy clustering methods. For the examples usedwith the attached software, no clustering is required. Hence, clustering will notbe treated any further here.

Page 126: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

126

Figure 87: Glass Classification Simulation

➔ Start the simulation by clicking on the NeuroFuzzy sensor simulation icon in thefuzzyTECH program group. In the simulation window (see Figure 87), start the record mode byclicking the [Record] button. Every [Step] records a sample. Generate a sample file with 12samples. Click the [Stop] button to terminate the record mode. The data is saved in the fileNFSENSOR.EXP in the …\SAMPLES\NEUROFUZ\NFSENSOR directory (Figure 88). Usethe notepad editor or the “File/View File” option to display the sensor data.

How many samples? This question is one of the most important in every NeuroFuzzy development. Asystem can be no better than the quality of the data presented. Within thefollowing development, we work with only the 12 samples. The simulation canof course be used later to record files containing up to 50 samples. In order toinvestigate the influence of the number of sample data, these data can be used inlater training steps to gain a more sophisticated classifier.

Step 2: Create a System The NeuroFuzzy Module can only train an existing fuzzy logic system. Hence,the “empty” structure of the fuzzy logic system must be defined before trainingcan start. This structure consists of linguistic variables, terms, membershipfunctions, rule blocks, rules, and interfaces. fuzzyTECH supports development ofan “empty” structure with the Fuzzy Design Wizard (FDW). The FDW allowsthe setup of a fuzzy prototype in minutes. Also, the FDW can extract informationfrom sample data files. The use of the FDW was already explained in detail inSection 4.1.1.

Page 127: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

127

Figure 88: Sample Data Recorded With the Simulation

➔ Start the FDW by using the [Design Wizard] button in the main window toolbar or use theoption “File/Fuzzy Design Wizard”. Enable the check box “Use a data file” and press the[Next>] button. In the dialog “Read Project Information From…”, select the fileNFSENSOR.EXP.

This lets the FDW read the sample data file. The FDW extracts from the file:• the number of variables,• the names of the variables,• the data range of each variable.

The FDW selects defaults for the fuzzy prototype. Some assumptions:• all except the last variable are input; the last variable represents an output,• all inputs can be represented by three terms,• the output(s) can be represented by five terms,• default names are used for the terms,• CoM defuzzification is used for the outputs,• all variables are inferred via a single rule block, and• a complete rule base is created by using a DoS of 0 for all rules.

In the given application, all assumptions can be used, except the definition of theoutput variable. Because of the fact that the classifier uses four color types, anoutput variable with four terms results in a better match for the sample data.

➔ The following FDW dialog helps to define a variable and is repeated as many times as there areinput and output variables to be defined. Change the number of terms for the output variablefrom 5 to 4. Press the [Next>] button to step through the following FDW design steps, definedefuzzification method and rule blocks, and generate the system by confirming the last FDWdialog.

Page 128: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

128

Base Variable Range ofOutput Variables Looking at the variable “TYPE”, you find the four terms “low, medium_low,

medium_high, high” and a base variable range of [0...5]. At first glance, thisdefinition seems to be inappropriate when compared to “Type” data using valuesbetween 1 and 4. The FDW uses equidistant terms in all Lambda style.Defuzzified values always result in-between or on the maxima of the Lambdaterms. Thus, all existing output values must be larger than or equal to thesmallest term maximum and less than or equal to the largest. This means largerthan or equal to 1 and smaller than or equal to 4 in the given example.

Defuzzification Methodsand NeuroFuzzy By choosing CoM defuzzification, the FDW assumes the use of compromise

defuzzification. For the NeuroFuzzy approach, this assumption is mandatory.NeuroFuzzy training uses error gradients to determine a direction ofoptimization. The system response to small parameter changes is evaluated todetermine the gradients. Non compromising defuzzification methods do not reactto small changes. Thus, only compromising methods can be used for training.

Using a GeneratedRule Base As a default, the FDW creates a complete rule base starting with a DoS of 0 for

all rules. Rules with a DoS of 0 do not influence the computation of a fuzzysystem, but they can be used for NeuroFuzzy training. This approach lets theNeuroFuzzy training affect only the set of rules that influence system behaviorwithin the given sample data. All other rules are not changed and can be deletedlater. In addition, rules generated by the FDW are automatically open fortraining.

Step 3: Enter Knowledge In this step you enter all existing knowledge on the solution into the fuzzy logicsystem. The NeuroFuzzy Module uses this so-called “a-priori” knowledge as astarting point for the training. The access to the “empty” system allows you tofind a system configuration where training results can be explained. Selectvariable and term names in such a way that resulting fuzzy rules representcontrol, decision, or classification strategies.

➔ Change the term names of the variable “Type” to “green”, “red”, “white”, and “blue”.

For more complex systems, even the set up of an arbitrary rule base implements“a-priori” knowledge. The fact that existing knowledge can easily be used is abig advantage of the NeuroFuzzy approach over a neural net solution. If noknowledge of the solution exists, skip Step 3. The NeuroFuzzy Module extractsthe necessary information solely from the sample data in this case. Note: even ifall information required to build the solution is already contained in the trainingdata, entering existing knowledge expedites the training. If the training data is ofpoor quality, using existing knowledge to help the NeuroFuzzy Module may bethe only way to come up with a solution at all.

Page 129: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

129

Step 4: Open Components The NeuroFuzzy Module training paradigm is highly structured. You can defineexactly which components of the system shall be modified by the NeuroFuzzyModule. For linguistic variables, you can open specific terms for training, andfor rule blocks, you can open the individual rules for training.

➔ Within the sensor application, the FDW generated a rule base with all rules open for training. Ifyou manually created a rule block in the Project Editor, activate the spreadsheet editor and usethe [Utilities] dialog to create a complete rule base. The spreadsheet editor also contains a[Learn DoS] button that allows you to open all rules for training.

NeuroFuzzy training allows you to partially train systems. Within more complexapplications, often the main part of the NeuroFuzzy system is implemented in theconventional fuzzy logic approach derived from human expertise. NeuroFuzzytraining can be used to complete this knowledge for areas where not enoughexpertise exists, or this expertise can easily be derived from data.

Step 5:Configure Training In order to configure the NeuroFuzzy Module, you specify a learning method

and its parameters in the Neuro Configuration dialog (Figure 89).

Figure 89: The Neuro Configuration Dialog

➔ Activate the Neuro Configuration dialog by selecting “Tools/Neuro/Configuration” or clickingthe [Neuro Configuration] button in the main window toolbar. Select the “Random Method”for training. Use “Random” as the selection mode and use the default learning parameter.

This is the default configuration and results in the first NeuroFuzzy prototypeapproach for most applications. If the training does not converge, theconfiguration can be changed within the training procedure.

Page 130: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

130

Hints to SelectLearn Parameter Learning parameters allow for a better control of learning methods. Details

concerning the learning methods are explained in the NeuroFuzzy section of theprimer chapter of this manual. The learning parameter, Step Width (DoS),determines the maximum amount that a fuzzy rule is changed within a singletraining iteration. Due to the normalized notation of the DoS, the Step Width(DoS) can use values between 0 and 1. Step Width (Term) determines thechanges implemented in the positions of terms. Terms are shifted along theirbase variable axes. Because base variable ranges are not normalized, the StepWidth (Terms) is noted as a percentage of the complete base variable range.Normally, one starts a training procedure using large training steps; lateroptimizations are better performed with smaller step widths.

Winner Neurons Winner neurons determine the basic training strategy: Winner Neurons: 1 meansthat in every training iteration only one rule - the winner in competition to allother rules - is changed. Thus, using this configuration lets the NeuroFuzzytraining work in a fashion similar to approaches known as “CompetitiveLearning." Within most NeuroFuzzy training ventures, this approach was foundto be the most successful.

Stop Conditions Max. Steps (Maximum of Steps), Avg. Dev. (Average Deviation) and Max. Dev.(Maximum Deviation) determine a defined termination point for the training.Termination can occur after a determined number of iterations or when thederived solution fulfills the error criteria. The average or the error of the worstsample can be used as the determining criteria. Note: the first criterion to be metalways terminates training. For classification applications, the error of singlesample is more of interest than the average error. Even when all samples exceptone are perfectly trained, the failed sample may cause a malfunction that can notbe compensated.

➔ Disable the Avg. Dev. stop condition and enable the Max. Dev. stop condition.

Max. Dev. Stop Condition The dedicated use of the Max. Dev. stop condition also allows you to increasethe learning performance of the training. An error threshold is defined for whichtraining computation is skipped for all samples that produce errors under thedefined limit. Thus, only the samples still “bad enough” are used for furthertraining of the system. The more samples found which produce errors below thethreshold, the faster the training computations are executed.

Dynamic Stop Condition[From] [To] The best training performance is achieved when the fuzzy system’s behavior is

close to the given objectives. The idea of a dynamic stop condition is to achievethis situation during all training iterations. Hence, when system error is largeduring the first iterations, use a very high threshold entered in the [From] field. Ifthe system reaches this threshold, we can lower it step by step until we reach thefinal objective entered in the [To] field.

Page 131: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

131

How to use theDynamic Factor The value in the [Factor] field is used to determine the next threshold when the

current threshold is fulfilled by all samples. The factor is multiplied with thecurrent threshold; thus, the factor chosen must be between 0 and 1. A factor of 1fixes the threshold to the [From] value; a factor of 0 completes the training intwo steps: one using the [From] and the second using the [To] threshold. Valuesbetween 0 and 1 control the dynamic threshold steps. Values close to 1 result intraining only the worst samples.A lower factor determines larger threshold steps and thus results in more samplesaffected within the iterations. A factor close to one results in shorter computationtimes per iteration but probably more iterations.

➔ Confirm the training configuration by pressing [OK] and save the project (the NeuroConfiguration is stored in the current FTL project file).

Step 6: Training The training procedure changes the open parameters of the fuzzy system. Thus,interactive changes are prohibited during training. The NeuroFuzzy module letsyou control the training via a dialog and allows the full visualization of the fuzzycomputation during the training. In order to view fuzzyTECH editors andanalyzers during training, you must open and position them on the screen beforethe Learn Control window is opened.

➔ Open the “Type” Variable Editor and the Spreadsheet Rule Editor. Locate the windows on thescreen. Enable the Interactive debug mode and setup a Transfer Plot or a 3D Plot analyzer.

The Time plot and the Trace Analyzer are not of interest during optimization,because these analyzers usually display or record time dependent systembehavior. During training, computing sequences are completely determined bythe sample sequence.

Sample Data NeuroFuzzy training optimizes a fuzzy system by comparing sample data withthe computed output of the fuzzy system. Thus, the training is based on sampledata. For each training session, a sample data file must be selected. Multiplesample data files can only be used sequentially.

➔ Activate the Learn Control window by selecting “Tools/Neuro/Learning” in the main menu orselect the [Neuro Learning] button in the main window toolbar. In the file selector boxwhich follows, load the file NFSENSOR.EXP from the directory…\SAMPLES\NEUROFUZ\NFSENSOR.

MBF-Conversion If you have opened terms of the linguistic variables for learning, these variablesare automatically converted to standard variables. If you do not confirm theconversion, MBF training is disabled.

Page 132: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

132

Training Control The toolbar contains buttons to start and stop training, or process singletraining steps . The following two buttons control the plot area: [Error Plot] and [Error Statistic] . The [Show Error List] button computes a list of thecurrent sample errors to be displayed in the list box at the bottom of the window.The [Perform] button verifies the current system state by computing themaximum and average errors. The [Update] button updates all windows openin fuzzyTECH. Further, the Neuro configuration can be changed via the button[Neuro Configuration] and the training can be terminated clicking the [Exit]button . The button furthest right accesses help.

➔ Execute a single training step by selecting the [Step] button in the toolbar. If [Update] (in thetoolbar) is disabled, enable the link to the fuzzyTECH Watch window by selecting this buttonand then selecting [Step] again. When the training steps are successfully computed, press[Start] to train your system.

Training Steps A single training step:• selects the next sample by the selected sample sequence,• loads the sample and displays its number,• determines the winner neurons,• updates the winner neuron,• updates all windows open in fuzzyTECH (if Update enabled),• displays sample error, and• displays targeted and computed output of all output interfaces in the list box.

Iterations During a training session, the training of each sample must be repeated severaltimes in an iterative procedure. One training iteration is defined as a computingstep using one complete pass through the sample data. At the end of eachiteration:• a perform run is computed to determine the real errors,• the average error of all samples is computed and displayed,• the error plot and error statistics are updated,• the iteration counter is updated, and• an error list can be displayed in the list box by pressing the [Show Error List]

button.

Training Runs When the training is executed in a continuous run by using the [Start] button• samples are selected, loaded, and displayed automatically,• the winner neurons are determined and updated, and• the Watch Windows are updated (if update is enabled).

After each completed iteration:• a perform run is computed to determine the real errors,• the average error of all samples is computed and displayed, and• the error of the worst sample is determined and displayed.There is no access to the error list and the output values during training runs.

Page 133: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

133

Step 7: EvaluateSystem Performance After completion of the actual training, you can test the resulting fuzzy logic

system with all debug modes and analyzers of fuzzyTECH. If the result is notsatisfactory, you can repeat some development steps.

➔ Load the sample file in the file recorder ([Debug][File Recorder]) and in the file editor[File][View File]. View the training samples to verify that the system has learned the samplespresented (Figure 90).

Step 8:Final Optimization In contrast to neural nets, the result of NeuroFuzzy training is a fuzzy logic

system that you can directly optimize by hand. How to manually optimize thesystem depends greatly on the application. In closed-loop control applications,often online optimization using a real process or a simulation is very efficient. Indata analysis applications, a prototypical implementation of the training resultand further tests show whether and in what respect the solution needs furtheroptimization.

Figure 90: NeuroFuzzy Training of the Sensor

Reduce the Rule Set Usually, a rule set subjected to NeuroFuzzy training includes more rules thanrequired in the final system. Often the objective of the training is to findfunctionally redundant rules or unnecessary rules. The superfluous rules can bedeleted using the Rule Block utility (Figure 56).

Page 134: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

134

➔ Choose the Rule Block Utility option from the pop-up menu of the Spreadsheet Rule Editor. Inthe dialog, select the alpha cut utility, and enter a small value or zero in the user defined valuefield. Confirming the operation deletes all rules without a real purpose from the rule block.

Specific Optimizations Normally, the result of the first training run does not satisfy the system’sobjective. More specific training runs allow for an interactive approach usingmanual optimizations, as well as the ability to train partial systems. Also, thepositions of membership functions can be included in the training procedure. Forthe sensor application, the system setup takes into account that the output termsperfectly match the given color classes.

Using these MBFs for training results in a system where color classes can onlybe represented by combinations of rules. Thus, for the sensor, training only inputMBFs may enhance the system.

Open singleRules for Training The training methods can be further specified by selecting the fuzzy rules that

are open for training. Other rules that represent common knowledge or resultsfrom previous training can be modified in later training sessions. Thespreadsheet allows you to open rules independently.

Figure 91: Open Single Rules for Training.

Step 9: Implementation The result of NeuroFuzzy training is a “pure” fuzzy logic system that can beimplemented on microcontrollers, PC, workstations, PLC or industrialcontrollers.

➔ Start the NeuroFuzzy Glass Sensor Simulation. The [Record] button lets your system run andsample data. The [Fuzzy] button in the simulation’s window connects your developedNeuroFuzzy glass sensor simulation with fuzzyTECH. The sensor should work properly formost of the bottles. In order to enhance the performance of the sensor system, record a samplefile with more samples and repeat the development steps 6 to 9.

Page 135: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

135

4.2.1. Clustering with fuzzyTECH

This section guides you through a simple clustering example with theFuzzyCluster Module of fuzzyTECH. The example covers the basic steps it takesto use clustering techniques as a means of data reduction.An example of a simple mathematical function with one input and one output isused to illustrate the use of the clustering module:

OutputInput=

10

2

For input values ranging from 0 to 100 with a step width of 10, the input andoutput values are given in the file CLUSTER1.EXP located in the subdirectory…\SAMPLES\NEUROFUZ\CLUSTER\. The following figure shows thecontents of this file.

Figure 92: The File CLUSTER1.EXP Contains 11 Data Samples Describing aSimple Mathematical Function.

Training theCLUSTER1.EXP Data You can use the file CLUSTER1.EXP directly for NeuroFuzzy training. Start

fuzzyTECH, start the Fuzzy Design Wizard, enable “Use a data file”, and specifythe file CLUSTER1.EXP. Because of the simple structure of the sample data file,the Fuzzy Design Wizard proposes three (3) terms per input and five (5) termsper output variable. Overwrite both values with “7” to create seven (7) termseach for input and output variables. Overwrite the input variable range from theproposed [0;100] to [-15;115] and accept all other proposed values to generatethe project.

Page 136: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

136

Enable the Interactive debug mode and open a 3D Plot. Double-click on thebutton of the toolbar and click on the button to put the 3D Plot in a nearly“flat” perspective. Enable “Background Paint” in the 3D Plot. Then open the“View” pull down menu and set the “Plot Background” option to “White”. Openthe Neuro Configuration dialog, select “Learn Methods:” to “RandomMethod”and “Selection Mode:” to “Random”. In the group “Stop Conditions”, set thevalue of the “Avg. Dev..:” field to “2%”.

Leave all other options at default values and settings, and close the dialog.Initiate NeuroFuzzy training with the file CLUSTER1.EXP. Enable first the“Update” option in the Learn Control dialog by clicking on its toolbar button[Update], then start training. After a few iterations, the training should stop withan average error of less than 1% and show a result similar to Figure 93. Note, the“flat” portions of the curve are outside the training interval of [0;100].

Figure 93: NeuroFuzzy Training Result from the File CLUSTER1.EXP.

Data Reduction The small training test has shown that the 11 data points contained inCLUSTER1.EXP can be converted into fuzzy logic rules rather quickly by theNeuroFuzzy module. Now, what would happen if many more data points wereavailable? The file CLUSTER2.DAT for example contains 100 data pointsfollowing the same mathematical function as the data points contained inCLUSTER1.EXP. Figure 94 shows the location of the data points.

What would be the result, when this file would be used for NeuroFuzzy training?The fuzzy logic system trained contains seven (7) terms each for input andoutput. Hence, a significantly better representation of the mathematical functionas with the training data contained in CLUSTER1.EXP would almost beimpossible because of the granularity of the linguistic variables involved. Thus,using file CLUSTER2.DAT instead of CLUSTER1.EXP would only slow down

Page 137: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

137

the training process, but most likely does not deliver a better result. Note, with asmall problem such as used here for illustration, the NeuroFuzzy module stilldelivers reasonable results, but if problems get more complex, using large datafiles can result in prohibitive computational effort.

Figure 94: The File CLUSTER2.DAT Contains 100 Data Samples Describingthe Mathematical Function.

Clustering Data For these reasons, the data contained in CLUSTER2.DAT should be clustered totypicals before used for NeuroFuzzy training. Start fuzzyTECH’s clusteringfunction by selecting “Tools/Cluster/IsodataCluster...” from the main menu offuzzyTECH. Specify the file CLUSTER2.DAT in the “Cluster Data from…”dialog (…\SAMPLES\NEUROFUZ\CLUSTER). This opens the IsodataClusterConfiguration dialog.

Figure 95: The Isodata Cluster Configuration Dialog Lets You Specify Range,Accuracy, and Usage of Each Variable.

Page 138: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

138

The Isodata Cluster Configuration dialog contains a large list box that lists eachvariable contained in the file. In each row of the list box, the variable’s position,its name, its minimum and maximum, its accuracy and its usage are shown. Inorder to change these values, select the variable in the list box and enter the newvalues in the edit fields above the list box. Modify the accuracy of both variablesto 11.75%. Press the [Start] button to start clustering.

At the same time clustering is starting a Cluster Progress dialog (Figure 96) isopened, which informs about the current status of the clustering.

Figure 96: The Cluster Progress Dialog Displays the Status of the Clustering.

If you want to use other programs you need to interrupt clustering by pressingthe [Esc] key on the keyboard. This opens another control dialog that lets youcontinue, end, or reset clustering. While this dialog is open, you can work withother programs.

0

20

40

60

80

100

0 20 40 60 80 100

Figure 97: The Output File of the Clustering Step, CLUSTER2.EXPContains Only the Typical Points of File CLUSTER2.DAT.

Page 139: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

139

After clustering is completed, the “Write Typicals to…” dialog opens. Store thetypicals under the name CLUSTER2.EXP in the subdirectory…\SAMPLES\NEUROFUZ\CLUSTER\ and confirm the following dialog, ifyou wish to view the file. The previous figure shows the 16 data points thatIsodataCluster computed as typicals from the CLUSTER2.DAT file. The 16typicals can now be used for NeuroFuzzy training to be converted into fuzzylogic rules.

RemovingRedundant Data A different case is contained in the file CLUSTER3.DAT. This file contains 100

data points as well. However, most data points are located very closely to thedata point (50, 25). All these data points can be replaced by a single typical usinga clustering method, because a single data point is sufficient for the NeuroFuzzytraining.

0

20

40

60

80

100

0 20 40 60 80 100

Figure 98: The File CLUSTER3.DAT Contains 100 Data Points Of Which Most Points Are Redundant.

If you cluster the file CLUSTER3.DAT with an accuracy of 3% for all variables,the IsodataCluster removes most redundant data points. However, the accuracyof 3% was not large enough to remove all redundancy. If you cluster the fileCLUSTER3.DAT with an accuracy of 7% for all variables, IsodataClusterremoves all redundant data points. Determining the best accuracy setting forIsodataCluster may require a few test cycles.

Page 140: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

140

0

20

40

60

80

100

0 20 40 60 80 100

Figure 99: IsodataCluster Has Removed Most of the Redundant Data Points.

0

20

40

60

80

100

0 20 40 60 80 100

Figure 100: With an Accuracy Setting of 7%, IsodataCluster Removes AllRedundant Data Points.

Resolving Conflicts The FuzzyCluster Module can resolve conflicts during clustering if the “CheckData Consistency” option is enabled in the IsodataCluster Configuration dialog.Use the file CLUSTER6.DAT that contains the same samples as fileCLUSTER2.DAT plus two conflicting data points. The following figureillustrates the contents of file CLUSTER6.DAT.

Page 141: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

141

0

20

40

60

80

100

0 20 40 60 80 100

Figure 101: The File CLUSTER6.DAT Contains the Same Samples asCLUSTER2.DAT, Plus Two Conflicting Data Points.

Activate “Tools/Cluster/IsodataCluster...” from the main menu, select the fileCLUSTER6.DAT, enable at first the “Check Data Consistency” option in theIsodataCluster Configuration dialog, and set then the Accuracy of the inputvariable to 2% and Accuracy of the output variable to 7%. When you startclustering, the Resolve Data Discrepancy dialog opens (Figure 102).

Figure 102: The Resolve Data Discrepancy Dialog Opensfor Every Detected Pair of Conflicting Data Points.

The Resolve Data Discrepancy dialog opens for every conflicting pair of datapoints. The dialog shows the detected conflict between data points #24 and #103.While the input variable values are close enough for being clustered in the sametypical, the outputs differ greatly from each other.

The buttons of the right side of the dialog show the options for resolving theconflict. The upper two buttons let you select just one of the data points, causingthe clustering function to remove the other one from the data point set. If youselect one of these options, the other data point is automatically written to a Skipfile. The button [Use Both] leaves the conflicting pair of data points in the set,

Page 142: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

142

whereas the button [Use Neither] removes both data points. The button [SkipAll] removes all conflicting data points that will be found while clustering,which results in suppressing the automatic call for the Resolve Data Discrepancydialog. The button [Cancel] causes the clustering function to the further use of allconflicting data points. [Cancel] is similar to having not enabled the “Check DataConsistency” option in the IsodataCluster Configuration dialog at all.

Now select [Use #24] because data point #103 is wrong. The FuzzyClustermodule now prompts you for a file and location to which to write the data pointsremoved from the data sample while solving conflicts. Accept the proposedfilename and location. The Resolve Data Discrepancy dialog opens again anddisplays the discrepancy between data points #85 and #102. Select [Use #85]because data point #102 is wrong. Then, clustering proceeds as in the examplesfrom before.

Displaying Sample FileContents with fuzzyTECH Note, although fuzzyTECH is not a general-purpose graphics software, you can

display the contents of the files CLUSTER1.EXP to CLUSTER6.DAT with the3D Plot analyzer. Just open the file DUMMY.FTL contained in the subdirectory…\SAMPLES\NEUROFUZ\CLUSTER\ that contains two input variables namedInput and Output and the output variable DummyOut.

Figure 103: The 3D Plot Analyzer of fuzzyTECH Can Be Used to Plotthe Contents of the File CLUSTER1.EXP to CLUSTER6.DAT Using the

DUMMY.FTL Project.

Next, start the File Recorder debug mode, open CLUSTER6.DAT and open a 3DPlot. Enable [Trace] in 3D Plot, click on the and double-click on the button of the toolbar to put the 3D Plot into a nearly flat perspective. Then startbrowsing the file CLUSTER6.DAT by clicking the button in the File Controlfield of the File Recorder Window.

Page 143: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

143

The graph shown in Figure 103 can also be visualized in MS Excel (open the*.DAT or *.EXP file in Excel, which imports it into a table, highlight thecolumns Input and Output, select “Insert/Chart” and select a scatter type of thediagram). All graphs shown in this section about IsodataClustering have beenmade this way.

FuzzyClustering In the previous section with the square function, an academic example ofclustering & training was used to show the usage of IsodataCluster computation.The following example shows the fuzzy clustering approach by using real, rawdata for the design of a fuzzy logic system. Such raw data first needs to beclustered to create a training data set of typicals. This data set is then used forNeuroFuzzy training to create a fuzzy logic system. The raw data sample file iscontained in the file CREDIT4.DAT found in the directory…\SAMPLES\BUSINESS\CREDIT that can be accessed via“Tools/Cluster/FuzzyCluster”. It contains 500 data points. Because of the largenumber of data points, they can hardly be plotted in a transparent fashion.

Configuration Because the variables Continuity, Inc_Exp, and Liquidity have differentinterpretations, since as to how similar data points differ, select“Tools/Cluster/FuzzyCluster…” from the main menu bar. The “Fuzzy ClusterConfiguration” dialog looks similar to the “Isodata Cluster Configuration”dialog. However, the distance measure between two data points is defined byfuzzy logic membership functions rather than by an accuracy measure.

Figure 104: The Fuzzy Cluster Configuration Dialog Lets You DefineMembership Functions to Express the Similarity Between Two Data Points.

All membership functions are defined by the two parameters Delta and Epsilon.Epsilon describes the distance under which two values for the variable areconsidered to be completely similar and Delta describes the distance abovewhich two values for the variable are considered to be completely dissimilar. For

Page 144: ft531manual

Inform Software Corporation Chapter 4: NeuroFuzzy Design

144

the variable Inc_Exp, enter a Delta of 5 and an Epsilon of 3. The resultingmembership function is shown in the Membership Function Fuzzy Clusteringgroup of the Configuration dialog. For the variable Continuity, enter a Delta of10 and an Epsilon of 5. The resulting membership function is:

For the variable Liquidity, enter both a Delta and an Epsilon of 3. The resultingmembership function is:

This type of membership function does not allow any “fuzziness”: the interval inwhich two values of Liquidity are considered similar is as crisp as withIsodataCluster. Define a Delta of 5 and an Epsilon of 3 for the variable Inc_Exp.

Fuzzy Clustering Start FuzzyCluster by clicking the [Start] button in the “FuzzyClusterConfiguration” dialog. On a Pentium™100 class PC running Windows95™,FuzzyCluster reduces the 500 sample data file to 72 typicals. Store the typicalsas CREDIT4.EXP, open the file CREDIT1.FTL in fuzzyTECH, and train thefuzzy logic system using the RandomMethod with Selection Mode: Random. Ifyou have the 3D Plot open with Background Paint and Trace enabled, you canfollow the NeuroFuzzy Module approximating the typicals by modifying therules. Note, the NeuroFuzzy Module only reaches an average error in the orderof 10%. This is due to the fact that real world data was used; it still containsinconsistencies or typicals that cannot be represented by just three (3) terms perinput variable. You can repeat FuzzyCluster with the following settings for Deltaand Epsilon to use an even smaller set of typicals:

Variable Delta EpsilonInc_Exp 10 5Continuity 20 10Liquidity 5 5

This setting assumes that the variable Continuity stems from a calculation of thebalance fluctuation of the applicant. Thus, the information this variable deliversto the assessment is rather “fuzzy,” and the membership function has beenwidened. Also, the membership functions for Inc_Exp and Liquidity are definedwider. When you use FuzzyCluster with these settings, the generated set oftypicals contains 26 data points.

Page 145: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

145

Clustering of LargeData Files Note, you can use the FuzzyCluster Module both from within fuzzyTECH as well

as stand-alone. FuzzyCluster can be called as a separate executable file located inthe directory in which you installed fuzzyTECH. Simply call CLUSTER.EXEfrom the file manager or install it in a program group. When installed in aprogram group, FuzzyCluster shows its icon:

Because FuzzyCluster is a separate program, multi-tasking operating systemscan run it in the background. When called directly, FuzzyCluster starts with itsown main window. This window, however, does not contain new functions; itprimarily lets you select the clustering method and activate the online helpsystem for FuzzyCluster.

Page 146: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

146

Fuzzy logic is an innovative technology that allows a description of the desiredsystem behavior by using everyday spoken language. Applications range fromconsumer electronic goods and household appliances to auto electronics, processengineering, and industrial automation solutions. Many successful applicationsare achieved not by conventional mathematical modeling, but with fuzzy logicand its everyday language. Fuzzy logic “fills” ambiguous descriptors such aspermanent, light, or above average with crisp mathematical models so they canbe understood by computers.

Boolean Logic Logic is known as the most precise of all sciences and theoretical disciplines.Most of modern science and mathematics – not to mention the foundation ofmodern computers – is based upon its principles of precision. Despite theadvantages of its accuracy, classical Boolean Logic has a major drawback: itcannot reproduce human thought patterns.

A Natural Logic Fuzzy logic is a continuous logic patterned after the approximate reasoning ofhuman beings. As a theoretical mathematical discipline, fuzzy logic is designedto react to continuously changing variables and challenge traditional logic by notbeing restricted to the conventional binary computer values of 0 and 1. Instead, itallows for partial and multi-valued truths. This discipline is especiallyadvantageous for problems that cannot be easily represented by mathematicalmodeling because data is either unavailable, incomplete, or the process is toocomplex.

The real-world language used in fuzzy control allows programmers toincorporate the ambiguous, approximate nature of human logic into computers.The use of linguistic modeling – instead of mathematical modeling – greatlyenhances system transparency and modification potential. It leads to quickdevelopment cycles, easy programming and accurate control.

Page 147: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

147

5.1. Fuzzy Logic

The first section of this chapter gives a short history of fuzzy logic. If you are notinterested in the history of fuzzy logic, skip this section and go on to Section5.1.2 and its introduction to the basic concepts of fuzzy logic or Section 5.1.3about the use of fuzzy logic in system design.

5.1.1. History

The first publication on fuzzy logic, which also coined its name, dates back to1965. It was written in the U.S. by Lotfi Zadeh, Professor of Systems Theory atthe University of California, Berkeley. From there, the history of fuzzy logicfollows the pattern of a number recent technologies: invented in the U.S.,engineered in Europe, and mass-marketed in Japan.

First Applications The first industrial applications of fuzzy logic were completed after 1970 inEurope. At Queen Mary College in London, England, Ebrahim Mamdani usedfuzzy logic to control a steam generator that he could not get under control withconventional techniques. At the RWTH University of Aachen, Germany, Hans-Jürgen Zimmermann used fuzzy logic for decision support systems. Otherindustrial applications, such as the control of a cement kiln, followed as a resultof this initial work, but fuzzy logic could not get broad acceptance in industry.The few applications that used fuzzy logic hid the fact by circumscribing fuzzylogic with terms such as “multi-valued logic“ or “continuous logic.”

Starting around 1980, fuzzy logic gained more momentum in decision supportand data analysis applications in Europe. Many of the more advanced fuzzy logictechnologies were developed in application and research projects. Mostdevelopments were triggered by empirical research regarding how well fuzzylogic models the human decision and evaluation processes.

Fuzzy Logic in Japan Inspired by the initial European fuzzy logic applications, the first Japanesecompanies started to use fuzzy logic in control engineering after 1980. Due tothe poor computational performance of the first fuzzy logic algorithms onstandard hardware, most applications looked into dedicated fuzzy logichardware. Some of the first fuzzy logic applications were a water treatment plantby Fuji Electric in 1983 and a subway system by Hitachi which was openedin 1987. The initial applications raised much interest in Japan, and there were anumber of factors contributing as to why fuzzy logic took off in that country.First, Japanese engineers start with a simple solution and later tweak the mostout of this system. Fuzzy logic supports the generation of a fast prototype and

Page 148: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

148

incremental optimization. Second, a fuzzy logic system always remains plain andsimple to understand. The “intelligence” of a system is not buried in differentialequations or source code. Since Japanese engineers generally develop systems ina team where everybody desires to understand the underlying behavior of thesystem, fuzzy logic delivered a more transparent means of system design. Also,due to the nature of their culture, Japanese Engineers are not preoccupied withBoolean logic. Nor does their language portray a negative connotation of theword “fuzzy.”

Technological factors were only part of the reason why fuzzy logic came to beused so broadly in such a short time. Another reason is that the Japanesegovernment joined forces with their large corporations to set up technologytransfer programs. After the IFSA’s (International Fuzzy Systems Association’s)Japanese chapter was founded in 1985 to support fuzzy research, several newindustry support circles were created:- Japan Society for Fuzzy Theory and Systems (SOFT),- Biomedical Fuzzy Systems Association (BMFSA),- Laboratory for International Fuzzy Engineering Research (LIFE),- Fuzzy Logic Systems Institute Iizuka (FLSI),- Center for Promotion of Fuzzy Logic at TITech.

As a result, fuzzy logic is now used in practically every application area forintelligent control or data processing. Photo and video cameras use fuzzy logic toput the expertise of photographers in their control. Mitsubishi announced theworld’s first car in which every control system is based on fuzzy logic whilemost other Japanese car manufacturers use fuzzy logic in at least some of theircomponents. In factory automation, Omron Corporation claims more than 350patents. Fuzzy logic control also optimizes many chemical and biologicalprocesses.

Fuzzy Logic in Europe In the late 80’s, major European corporations realized that they had almost lostanother key technology to the Japanese. They started a major effort in promotingfuzzy logic in their applications. Since then, more than 200 successful fuzzylogic mass market products have been launched in Europe. Additionally, anuncounted number of industrial automation and process control applications havesuccessfully used fuzzy logic. The fuzzy logic enhanced products include homeappliances that realize major savings in energy and water consumption with noadded production costs, as well as many automotive applications. The industrialautomation applications include chemical and biological process control,machinery equipment control and intelligent sensors.

Due to the large commercial success of these applications, fuzzy logic is nowconsidered a “standard” design technique and has gained broad acceptance in theengineering community. One of the supporting factors was the advent ofadvanced fuzzy logic software design tools that support all development stagesof a fuzzy logic design. Some of the fuzzy logic design tool software houses

Page 149: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

149

teamed up with major semiconductor and industrial automation equipmentmanufacturers to provide a seamless development environment for most targethardware platforms.

Fuzzy Logic in the U.S. Now that fuzzy logic has made the trip from the U.S. to Japan via Europe, it’scoming back to the U.S. the same way. Recently, fuzzy logic has attracted a lotof attention in the U.S., especially among companies who are in heavycompetition with both Asia and Europe. However, many argue whether thisuphill battle can be won. Some would argue yes, as there are many factors infavor of the U.S. First, many applications completed in Japan involve products inindustries which U.S. manufacturers do not compete with the Japanese. Sincebasically no major U.S. entertainment electronics manufacturer is left on theworld market, the use of fuzzy logic in camcorders, cameras, and hi-fi equipmentis a competitive factor mainly between Japanese corporations. In Europe, mostapplications are in industrial automation, mostly due to their very high cost oflabor. In other application areas, such as automotive engineering, the U.S. facestough competition from both Europe and Japan.

This leaves some market segments open for U.S. corporations. For instance,fuzzy logic has proven to be an excellent tool for building decision supportsystems, memory cache, and hard disk controllers as well as compressionalgorithms for speech and video. Also, telecommunications applications such asecho cancellation, network routing, and speech recognition benefit from fuzzylogic. Combine this with the U.S. manufacturers’ muscle in communicationequipment, office automation, and computer software, and you can see a fairchance that the U.S. can benefit from fuzzy logic technologies. Another factor isthe strong research background in neural net technologies in the U.S. All fuzzylogic experts agree that the clever combination of neural network technologiesand fuzzy logic is the next logical step in developing the technology further.

5.1.2. Types of Uncertainty

This section introduces the basic principles of fuzzy logic. Reading this section isessential to understanding how fuzzy logic systems work. Advanced fuzzy logictechnologies are treated in Section 5.1.3.

Mathematical Principlesof Uncertainty Many mathematical disciplines deal with the description of uncertainties, such as

probability theory, information theory, and fuzzy set theory. It is mostconvenient to classify these by the type of uncertainty they treat. In this section,we consider only two types of uncertainty, stochastic and lexical uncertainty.

Stochastic Uncertainty Stochastic uncertainty deals with the uncertainty toward the occurrence of acertain event. Consider Statement 1:

Page 150: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

150

Statement 1:The probability of hitting the target is 0.8

The event itself – hitting the target – is well defined. Close shave, no cigar. Theuncertainty in this statement is whether the target is hit or not. This uncertainty isquantified by a degree of probability. In the case of Statement 1, the probabilityis 0.8. Statements like this can be processed and combined with other statementsusing stochastic methods, such as the Bayesian calculus of conditionalprobability.

Lexical Uncertainty A different type of uncertainty lies in human languages, the so-called lexicaluncertainty. This type of uncertainty deals with the imprecision that is inherent inmost words humans use to evaluate concepts and derive conclusions. Considerwords such as “tall men”, “hot days”, or “stable currencies”, for which there areno exact definitions. Whether a man is considered “tall” hinges on many factors.A child has a different concept of a “tall” man than an adult. Also, the contextand the background of a person making an evaluation plays a role. Even for onesingle person, an exact definition on whether a man is considered “tall” does notexist. No law in existence determines the threshold above which a man isconceived as “tall.” This would not make sense anyhow, because a law thatdefines all men taller than 6’ 4” to be “tall” would imply that a man of 6’ 3” isnot tall at all. The science that deals with the way humans evaluate concepts andderive decisions is psycholinguistics. It has been proven that humans use wordsas “subjective categories” to classify qualities such as “height” or “temperature.”Using these subjective categories, elements of the real world are evaluated by thedegree to which they satisfy the criteria. Even though most concepts used are notprecisely defined, humans can use them for quite complex evaluations anddecisions that are based on many different factors. By using abstraction and bythinking in analogies, a few sentences can describe complex contexts that wouldbe very hard to model with mathematical precision. Consider Statement 2:

Statement 2:We will probably have a successful financial year

At first glance, Statement 2 is very similar to Statement 1. However, there aresignificant differences. First, the event itself is not clearly defined. For somecompanies, a successful financial year means that they deferred bankruptcy, forothers it means to have surpassed last years profit. For one company, there maybe no fixed threshold that exists to define whether a fiscal year is considered tobe successful or not. Hence, the concept of a “successful fiscal year” is asubjective category.

Page 151: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

151

Another difference lies in the definition of expressing probability. While inStatement 1, the probability is expressed in a mathematical sense, Statement 2does not quantify a probability. If someone expresses that a certain type ofairplane probably has problems, the actual probability can well be lower than10%, still justifying this judgment. If someone expresses that the food in acertain expensive restaurant is probably good, the actual probability can well behigher than 90%. Hence, the expression of probability in Statement 2 is aperceived probability rather than a mathematically defined probability as inStatement 1. In Statement 2, the expression of probability is also a subjectivecategory much like “tall men.”

ModelingLinguistic Uncertainty Statements using subjective categories, such as Statement 2, play a major role in

the decision making process of humans. Even though these statements do nothave quantitative contents, humans can use them successfully for complexevaluations. In many cases, the uncertainty that lies in the definition of the wordswe use adds a certain flexibility. Consider for illustration the annual wageincrease negotiations between unions and industry. Both want to achieve thesame goal: an appropriate wage increase. The problem starts when they have toexpress in percentage, what they mean by “appropriate.”

The flexibility that lies in the words and statements we employ is used widely inour society. In most western societies, the legal system consists of a certainnumber of laws that each describe a different situation. For example, one lawcould express that theft of a car should be punished with 2 years of prison.Another law could define diminished responsibility. For instance, the judge hasto decide in a court case the exact number of days in prison for a thief. The thiefstole a car while under the influence of a 0.1% blood alcohol level, plus he had abad childhood and his wife left him the day before. Since for each “real” case aspecific law does not exist, the judge must combine all applying laws to derive afair decision. This is only possible due to the flexibility in the definition of thewords and statements used in each law.

Fuzzy Logic asHuman Logic The basic idea is simple: in reality, you cannot define a rule for each possible

case. Exact rules (or laws) that cover a case perfectly can only be defined for afew distinct cases. These rules are discrete points in the continuum of possiblecases and humans approximate between them. Hence, for a given situation,humans combine rules that describe similar situations. This approximation ispossible due to the flexibility in the definition of the words that constitute therules. Likewise, abstraction and thinking in analogies are only rendered possibleby the flexibility of “human logic.”

A mathematical model is required to implement this human logic in engineeringsolutions. Fuzzy logic has been developed as such a mathematical model. Itallows representation of human decision and evaluation processes in algorithmicform. There are limits to what fuzzy logic can do. The full scope of humanthinking, fantasy, and creativity can not be mimicked with fuzzy logic. However,

Page 152: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

152

fuzzy logic can derive a solution for a given case out of rules that have beendefined for similar cases. So, if you can describe the desired performance of atechnical system for certain distinctive cases by rules, fuzzy logic can effectivelyput this knowledge into a solution.

Fuzzy Logic vs.Probability Theory Practitioners, especially those working extensively with probability theory, have

denied the usefulness of fuzzy logic in applications. They claim that all types ofuncertainty can be expressed with probability theory. Rather than embarking ona discussion of whether this is true, consider Example 1. If you find such astatement in a medical textbook and want to implement it in a system, it looksvery easy at first glance. Suppose you have a patient that suffers from strongfever, has no yellowish colored skin, but suffers from nausea. You can computethe probability for a hepatitis infection using Bayesian calculus.

Example 1:“Patients suffering from hepatitis show in 60% of all cases strong fever, in45% of all cases a yellowish colored skin, and in 30% of all cases nausea.”

Although this looks very easy, the problem starts when you have to define what a“strong fever” is. If you read medical books or ask doctors, you do not get anundisputed, single answer. Even if most doctors agree that if the threshold is atabout 102°F (39°C), this does not mean that a patient with temperature of101.9°F does not have a strong fever at all while another patient with atemperature of 102°F has a strong fever.

If a threshold for “strong fever” does exist, the reverse must also exist. Thisimplies that a very precisely measured body temperature results in a very precisediagnosis. If this was true, you could measure your body temperature up to thefifth significant figure and expect a doctor to tell you, based on this very preciseinformation, the disease from which you suffer. In reality, a doctor does not get acompetent diagnosis from the precision of a single parameter, but rather from theevaluation many symptom parameters. Here, the precision of each parameterdoes not, for the most part, infer the quality of the result. If the doctor asks youwhether you sweat at night, he is not interested in the precise amount but rather atendency.

As Example 1 illustrates, stochastic uncertainty and linguistic uncertainty are ofa different nature. Stochastic uncertainty deals with the uncertainty of whether acertain event will take place and probability theory lets you model this. Incontrast, lexical uncertainty deals with the uncertainty of the definition of theevent itself. Probability theory cannot be used to model this since thecombination of subjective categories in human decision making processes doesnot follow its axioms.

Page 153: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

153

A “fuzzy” Set How can you model linguistic uncertainty adequately? If a doctor does not havea precise threshold in mind when evaluating whether a patient suffers from“strong fever,” how does it work? Psycholinguistic research has shown that adoctor would compare the patient with two “prototypes.” On one side exists the“perfect” strong fever patient: pale, sweating, and with chills. On the other sideexists the “perfect” patient without a fever, who does not show any signs of feverat all. Comparing with these two extremes, a doctor evaluates where in-betweenthe two his patient ranks.

How can this be modeled mathematically? Consider set theory, where you wouldfirst define the set of all patients with strong fever. Then you define amathematical function that indicates for each patient whether he is a member ofthis set or not. In conventional math, this indicator function has to uniquelyidentify each patient as member or non-member of the set. Figure 105 gives anexample of the set of “patients with strong fever” (black area), where theindicator function defines “strong fever” as a temperature of higher than 102°F.

As pointed out before, a doctor instead evaluates the degree to which his patientmatches the prototype of a strong fever patient. Figure 106 gives an example of aset where certain elements can also be “more-or-less” members. The “shade ofgray” indicates the degree to which the body temperature belongs to the set ofstrong fever. This “shade of gray” that makes the black area in Figure 105 looksas if it is “fuzzy” led to the name “fuzzy logic.”

Figure 105: In Conventional Set Theory, the Set of “patient with strong fever” Is Defined Exactly By ≥ 102°F.

In Figure 106, each body temperature is associated with a certain degree towhich it matches the prototype for “strong fever.” This degree is called the“degree of membership” µSF (x) of the element x ∈ X to the set “strong fever”(SF). The body temperature is called a “base variable”, x, with the universe X.

Page 154: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

154

The range of µ is from 0 to 1, representing absolutely no membership to the setand complete membership respectively.

Figure 106: The “fuzzy” Set of “patient with strong fever” AlsoAllows Elements That Are “more-or-less” Members of the Set.

As a temperature of 94°F would have no membership at all, a temperature of110°F would have complete membership. Temperatures between are members ofthe set only to a certain degree (Example 2).

Example 2:µSF(94°F) = 0 µSF(100°F) = 0.1 µSF(106°F) = 0.9

µSF(96°F) = 0 µSF(102°F) = 0.35 µSF(108°F) = 1

µSF(98°F) = 0 µSF(104°F) = 0.65 µSF(110°F) = 1

The degree of membership can also be represented by a continuous function.Figure 107 plots such a membership function. Note: a temperature of 102°F anda temperature of 101.9°F are evaluated differently, but just slightly and notrelative to a crisp threshold. How to define membership functions for a certainapplication is handled in Section 3.1.2.1.

Note: Fuzzy sets are a true generalization of conventional sets. The cases µ=0 and µ=1of the conventional indicator function are just a special cases of the fuzzy set.The use of fuzzy sets defined by membership functions in logical expressions iscalled “fuzzy logic.” Here, the degree of membership in a set becomes the degreeof truth of a statement. For example, the expression, “the patient has a strongfever,” would be true to the degree of 0.65 for a temperature of 104°F.

Page 155: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

155

Figure 107: The Degree µSF(x) to Which a Temperature x Is

Considered to Belong to the Set of Patients With “Strong Fever” CanBe Expressed As A Continuous Function.

The primary building block of any fuzzy logic system is the “linguistic variable.”Here, multiple subjective categories describing the same context are combined.In the case of fever, not only strong fever, but also raised temperature, normaltemperature, and low temperature exist. These are called “linguistic terms” andrepresent the possible values of a linguistic variable. Figure 108 plots themembership functions of all terms of the linguistic variable “fever” into the samegraph.

Figure 108: A Linguistic Variable Translates Real Values Into Linguistic Values.

This linguistic variable now allows the translation of a measured bodytemperature, given in Fahrenheit, into its linguistic description. For example, abody temperature of 100°F would be evaluated as “pretty much raisedtemperature, and just slightly high fever.” How to use this technology inengineering system design is handled in the next section.

5.1.3. Fuzzy Logic Technologies

In the past 30 years, a great number of methods using fuzzy sets have beendeveloped. This book is restricted to the so-called “rule based” fuzzy logictechnologies. Nearly all recent fuzzy logic applications are based on thismethodology. This section gives a brief introduction to the basic technology ofrule based fuzzy logic systems using a case study in container crane control. Adetailed description of the fuzzy logic design methodology is given inChapter 3.

Page 156: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

156

Case Study:Container Crane Control Container cranes are used to load and unload containers onto and from ships in

most harbors. They pick up single containers with flexible cables that aremounted to the crane head. The crane head moves on a horizontal track. When acontainer is picked up and the crane head starts to move, the container begins tosway (Figure 109). While sway is no problem during transportation, a swayingcontainer cannot be released.

Two trivial ways to solve this problem exist. One is to position the crane headexactly over the target position, then wait until the sway dampens to anacceptable level. On a calm day, this will eventually happen, but it takes far toomuch time. A container ship needs to be loaded and unloaded in a minimumamount of time for cost reasons. The other trivial option is to pick up thecontainer and move it so slow that no sway ever occurs. Again, this may work ona calm day, but it takes far too much time. An alternative is to build containercranes with additional cables to fix the position of the container during operation.Very few cranes make use of this technique due to the much higher cost of thesolution.

Figure 109: Since the Container Is Linked to the Crane Head With a FlexibleCable, the Container Starts to Sway When the Crane Moves. The Fuzzy Logic

Controller Compensates For This Sway Using the Human Operator’sExperience (Screen Shot Of the Software Simulation).

For these reasons, most container cranes use a continuous speed control for thecrane motor under the direction of a human operator. The operator has tosimultaneously compensate for the sway while ensuring the target position isreached in a minimum amount of time. This task is not easy, but a skilledoperator is capable of achieving acceptable results.

Page 157: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

157

Control ModelAlternatives Many engineers have tried in the past to automate this control task. They have

attempted:• Linear PID control,• Model-based control, and• Fuzzy logic control.

Conventional PID (Proportional-Integral-Differential) control was not successfulbecause the control task is non-linear. Sway minimization is important onlywhen the container is close to the target. Other engineers have tried to derive amathematical model of the crane to use in a model-based controller. This resultsin a fifth-degree differential equation to describe the mechanical behavior.

Although in theory this should work, it does not. The reasons for this are:• The crane motor behavior is by far not as linear as assumed in the model,• The crane head moves with friction, and• Disturbances such as wind gusts cannot be included in the model.

Linguistic ControlStrategy On the other hand, a human operator is capable of controlling a crane without

differential equations. The operator does not even use a cable length sensor thatany model-based solution would require. Once he has picked up the container,the operator starts the crane with medium motor power to see how the containersways. Depending on the reaction, he adjusts motor power to get the container alittle behind the crane head. In this position, maximum speed can be reachedwith minimum sway.

Getting closer to the target position, the operator reduces motor power or evenapplies negative power to brake. As the crane gets very close and power isfurther reduced or reversed, the container gets a little ahead of the crane headuntil the container has almost reached target position. Finally, the motor power isincreased so that the crane head is over the target position and sway is zero. Nodifferential equations are required for this operation, and disturbances and non-linearities are compensated by the operator’s observance of the container’sposition.

The analysis of the operator’s actions reveals that he uses some “rules of thumb”to describe his control strategy:1. Start with medium power.2. If you have started and you are still far away from the target, adjust the motor

power so that the container gets a little behind the crane head.3. If you are closer to the target, reduce speed so the container gets a little ahead

of the crane head.4. When the container is over the target and the sway is zero, stop the motor.

Page 158: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

158

Implementing a LinguisticControl Strategy Sensors for the crane head position (“Distance”) and the angle of the container

sway (“Angle”) are employed to automate the control of this crane. Using theseinputs to describe the current condition of the crane, the five rules of thumb canbe translated to an “if-then” format. Note that rule 3 has been translated into tworules to fit the if-then format.

1. IF Distance = far AND Angle = zero THEN Power = pos_medium2. IF Distance = far AND Angle = neg_small THEN Power = pos_high3. IF Distance = close AND Angle = neg_small THEN Power =pos_medium

IF Distance = medium AND Angle = neg_big THEN Power = pos_medium4. IF Distance = zero AND Angle = zero THEN Power = zeroIf-then rules always describe the reaction to a certain situation as:

IF <situation> THEN <action>

In the case of the container crane, each situation is identified by two conditions.The first condition describes the value of Distance, the second the value ofAngle. The conditions are combined by AND, representing the fact that bothconditions have to be valid for the respective situation.

Fuzzy Logic Once you have set up a set of rules describing the desired behavior of a system,the question becomes: how can you implement these rules? First, consider usinga programming language to code the “if-then” rules. The problem with thismethod is that you have to define the words that the conditions of the rules use.However, exact definitions for these words do not exist. This is the same as withthe definition of “strong fever” discussed in the previous section. This is thereason you can use fuzzy logic to implement a linguistic control strategy. Thefollowing shows you step by step, how to design a controller using fuzzy logictechniques.

Structure of a Fuzzy LogicCrane Controller Figure 110 shows the complete structure of a fuzzy logic controller. First, all

sensor signals must be translated into linguistic variables. For example, ameasured distance of 12 yards may be translated into the linguistic value “stillmedium, just slightly far.” This step is called “fuzzification,” as it uses fuzzy setsfor translating real variable values into linguistic variable values.

Once all input variable values are translated into the respective linguistic variablevalues, the so-called “fuzzy inference“ step evaluates the set of if-then rules thatdefine system behavior. The result of this is again a linguistic value for theoutput linguistic variable. For example, the linguistic result for Power could be“a little less than medium.” The so-called “defuzzification” step translates thislinguistic result into a real value that represents the power setting of the motor inkilowatts.

Page 159: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

159

Figure 110: Structure of a Fuzzy Logic Controller For the Container Crane. TheFuzzy Logic System Consists of Three Steps: Fuzzification, Fuzzy Inference, and

Defuzzification.

Fuzzification usingLinguistic Variables Linguistic variables have to be defined for all variables used in the if-then rules.

As described in Section 5.2, possible values of a linguistic variable are calledterms or labels. For the crane controller, the terms are:

Example 3:Linguistic Variable Possible Values (Terms)1. Distance ∈ {neg_close, zero, close, medium, far}2. Angle ∈ {neg_big, neg_small, zero, pos_small, pos_big }3. Power ∈ {neg_high, neg_medium, zero, pos_medium, pos_high}

For every linguistic variable, each term is defined by its membership function.Figures 111 and 112 show the definitions for the two input variables.

Figure 111: Linguistic Variable: “Distance” Between Crane Head and TargetPosition

Page 160: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

160

Figure 112: Linguistic Variable: “Angle” of the Container to the Crane Head

Consider a possible situation for the crane where the Distance of the crane headto the target position is 12 yards and the Angle of the container is -30°. Example4 shows how the fuzzification is computed for this case.

Example 4:

A Distance of 12 yards is a member of the fuzzy sets for the terms:neg_close to the degree of 0.00zero to the degree of 0.00close to the degree of 0.00medium to the degree of 0.83far to the degree of 0.17

An Angle of -30° is member of the fuzzy sets for the terms:neg_big to the degree of 0.4neg_small to the degree of 0.6zero to the degree of 0.0pos_small to the degree of 0.0pos_big to the degree of 0.0

Fuzzy-Inferenceusing If-Then Rules Now that all input variables have been converted to linguistic variable values, the

fuzzy inference step can identify the rules that apply to the current situation andcompute the value of the output linguistic variable. Example 5 shows a subset ofthree rules for illustration:

Page 161: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

161

Example 5:Rule 1: IF Distance = medium AND Angle = neg_small

THEN Power = pos_highRule 2: IF Distance = medium AND Angle = neg_big

THEN Power = pos_mediumRule 3: IF Distance = far AND Angle = neg_small

THEN Power = pos_high

The computation of the fuzzy inference consists of three components:• Aggregation: computation of the IF part of the rules. This step computes the

support of the rule relative to the conditions.• Composition: computation of the THEN part of the rules. This step computes

the degree of truth for the rule.• Result Aggregation: After the degrees of truth for the rules are computed, this

step determines which rules will contribute to the deffuzzified result

Aggregation The IF part of Rule 1 combines the two conditions “Distance = medium” and“Angle = neg_small.” The IF part defines whether the rule is valid in the currentsituation or not. In conventional logic, the combination of the two conditions canbe computed by the Boolean AND as shown in the following table:

A B A∧B

0 0 00 1 01 0 01 1 1

In the case of fuzzy logic, the Boolean AND cannot be used as it cannot copewith conditions that are more-or-less true. Hence, new operators had to bedefined for fuzzy logic to represent logical connectives such as AND, OR, andNOT. The first set of operators that has been proposed is given in Example 6.These three operators are used in the majority of today’s fuzzy logicapplications.

Example 6:AND: µ(A∧B) = min{ µ(A), µ(B) }OR: µ(A∨B) = max{ µ(A), µ(B) }NOT: µ(¬A) = 1 - µ(A)

f you use the min operator to represent the logical AND, the IF parts of the rulesof Example 5 using values from Example 4 can be computed as shown inExample 7. The results are the degrees of truth of the IF parts and thus indicatehow adequate each rule is for the current situation.

Page 162: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

162

Example 7:Rule 1: min{ 0,83; 0.6} = 0.6Rule 2: min{ 0.83; 0.4 } = 0.4Rule 3: min{ 0.17; 0.6} = 0.17

Each rule defines an action to be taken in the THEN part. The degree to whichthe action is valid is given by the adequacy of the rule to the current situation.This adequacy is computed by the aggregation as the degree of truth of the IFpart. Therefore, Rule 1 results dictate the action “Power = pos_high” to thedegree 0.6; Rule 2 dictates the action “Power = pos_medium” to the degree 0.4;and Rule 3 dictates the action “Power = pos_high” to the degree 0.17.

Composition In many cases the degree of truth of the IF part is considered the degree of truthof the rule, however, in some cases it is advantageous to let the rules themselvesbe fuzzy. In the composition step, the degree of truth of the IF part of the rule ismultiplied by a weighting factor. This factor represents the weight of the rule inrelation to the other rules in the system. The use of weights is the most common,simple and transparent implementation of more general concepts such as FuzzyAssociative Memories or the Compositional Rule of Inference. In this examplefuzzy logic inference, a weight of 1.0 is multiplied with the aggregation result inthe composition step. In fuzzyTECH this weight factor is referred to as the DoSof the rule and may take values in the interval [0, 1].

Result Aggregation As both Rules 1 and 3 result in the same action but with a different degree oftruth, these results must be combined before the defuzzification step. In a fuzzylogic rule base, rules are defined alternatively: either Rule 1 is true, OR Rule 2 istrue, OR Rule 3 is true, OR ... Using the fuzzy logic operators as listed in theexample, the OR can be represented mathematically by the max operator. Thefinal result of the fuzzy logic inference for the linguistic variable Power is shownin Example 8.

Example 8:For the linguistic variable Power, the fuzzy inference result is:neg_high to the degree of 0.0neg_medium to the degree of 0.0zero to the degree of 0.0pos_medium to the degree of 0.4pos_high to the degree of 0.6 ( = max {0.6; 0.17} )

This fuzzy inference method (Example 8) is sometimes called Max/Min orMax/PROD inference. Advanced inference methods and fuzzy logic operatorsare discussed in the following section. Experience with the optimization of fuzzylogic systems has shown that it can be necessary to associate weights to each

Page 163: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

163

rule. In Section 3.1.2.7 you find how if-then rules and weights can be defined fora given application.

Defuzzification UsingLinguistic Variables At the end of the fuzzy inference, the result for Power is given as the value of a

linguistic variable. In order to use it to set the motor power, it has to be translatedinto a real value. This step is called defuzzification. The relation betweenlinguistic values and corresponding real values is always given by themembership function definitions. Figure 113 plots the membership functions forthe linguistic variable “Power”.

Figure 113: Linguistic Variable “Power”.

The result of the fuzzy inference given in Example 8 is both fuzzy andambiguous since two different actions have non-zero truth degrees. How can twoconflicting actions that are defined in fuzzy sets be combined to a “crisp” real-valued output for motor power? Consider how humans solve the problem ofcombining two fuzzy and conflicting actions in Example 9.

Example 9:Consider yourself in an apartment house at 11 p.m. You would like to listento some music such as Wagner or Nirvana, music that requires some volumeto be fun. On the other hand, your neighbors have already suffered quite a bitfrom your recent music sessions. When you set the volume on your stereo,you must combine these two conflicting and fuzzy goals into a crisp value,as only such a value can be set with the volume knob of your stereo. In orderto find a volume that compromises the two goals, you could turn on themusic and tune the volume until you balanced out the two goals.

Page 164: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

164

As fuzzy logic mimics the human decision and evaluation process, a gooddefuzzification method should also approximate this approach. Mostdefuzzification methods use a two step approach. In the first step, a “typical”value is computed for each term in the linguistic variable. In the second step, the“best compromise” is determined by “balancing” out the results.

“Typical” Values The most common approach to compute the typical values of each term is to findthe maximum of the respective membership function. If the membership functionhas a maximizing interval, the median of the maximizing set is chosen. For thelinguistic variable Power as shown in Figure 113, the computation of the typicalvalues is illustrated in Figure 114. Here, the gray arrows point to the horizontalposition of the typical values.

Figure 114: In the First Step of Defuzzification, the Typical Value For EachTerm Is Computed As the Maximum of the Respective Membership Function.

Best Compromise In the second step, the best compromising crisp value for the linguistic result iscomputed. Figure 115 illustrates this step. A “weight” proportional to the degreeto which the action is true is placed at the horizontal position of the typicalvalues. The weights are shown as the heights of the black arrows over the grayarrows. The compromise crisp value is then determined by balancing the weights“on a pen tip.” In the example, the position that balances the fuzzy inferenceresult is at the position of 10 kilowatts. This value is considered the bestcompromise and is outputted to the motor.

This method of defuzzification is called “Center-of-Maximum“ and is identicalto the “Center-of-Gravity“ method using singleton membership functions. Thesedefuzzification methods are used in most fuzzy logic implementations. Otherdefuzzification methods are introduced and compared in Section 0.

Page 165: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

165

Figure 115: By Balancing Out the Conflicting Results, a Crisp Result Is Found.

5.2. Computing Fuzzy Systems

Fuzzy logic recognizes the advantages of approximate logic. In most real-worldsituations, a precise answer does not necessarily provide the optimal solution.For example, for the expression 10/3, the answer about 3 often suffices.Computing a more precise answer, 3.33, may in some cases be both superfluousand time-consuming. Fuzzy logic expands the strict true/false classifications oftraditional logic and incorporates values such as mostly true and totally wrong. Itaccommodates the anomalies of human thought patterns by allowing a situationto be more or less true in one case and not in another.

Linguistic Concepts Fuzzy logic systems are also rule-based but they use different concepts torepresent the linguistic elements of the rules. Technical quantities, represented bylinguistic variables, allow expressions to be more or less true in one or evenmultiple sets. Linguistic rules are formed using operators that represent alinguistic AND and OR. Finally, a computation of the applicability of the rulesthemselves – represented by a linguistic IF...THEN expression – is performed.This step is called fuzzy inference. In control applications, specializedfuzzification and defuzzification methods link the entire system to the process.

Fuzzy Control In control applications, fuzzy logic is used to devise a control strategy usingevery day spoken language. The goal of any control strategy is to obtain adesired output, like crane motor power, from given inputs such as crane positionor load angle. Because cranes cannot interpret linguistic concepts, two-waytranslations between crisp values and linguistic concepts are necessary. Thus, afuzzy logic process controller is created in three steps:

Fuzzification Crisp input values are translated into linguistic concepts, which are representedby fuzzy sets. These concepts are called linguistic variables. Degrees ofmembership for all input values are assigned.

Page 166: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

166

Example: To what extent is 60 Yards considered far?

Fuzzy Rule Inference IF...THEN rules that define the relationship between the linguistic variables aredefined. These rules determine the course of action the controller must follow.Example: If “Distance” is far THEN “Power” is pos_high.

Defuzzification The result of the fuzzy inference is retranslated from a linguistic concept to acrisp output value.

Example: “Power” pos_medium equals a physical value of 10 KW.

The different options to compute these 3 steps are explained in the followingsections of this chapter.

5.2.1. Fuzzification

Linguistic Variable In fuzzy logic, the different values for a given linguistic variable representconcepts, not numbers. Linguistic values (also called terms or labels) associatedwith a linguistic variable “Distance” could be neg_big, neg_small, zero,pos_small, pos_big. Each linguistic term is represented by a specific fuzzy set;even approximate descriptions like extremely close and very far are possible.

Linguistic Terms A technical quantity like “Distance” is measured as a crisp value, like 20 yards.The degree to which the crisp value belongs to a set is represented by a valuebetween 0 and 1. This value is called the degree of membership. Degree ofmembership equal to zero means that a value definitely does not belong to a set,while a degree of membership equal to 1 reflects absolute membership. Degreeof membership values between 0 and 1 represent partial membership, thusallowing for computations that are partly true and nearly false – a task which isimpossible using conventional logic. In fuzzy logic, a degree of membership isusually normalized in the interval [0; 1] and denoted with the symbol µ.

Membership Function The degree to which crisp values belong to a given fuzzy set is represented by afunction known as a membership function (MBF). Typically, technical quantitiesare represented on the horizontal axis of the function and membership degrees onthe vertical. The technical quantity is called the base variable and represents theuniverse of discourse.

Page 167: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

167

Figure 116: Membership Functions for “Distance”.

Standard MBFs Although scientific publications have suggested many different types ofmembership functions for fuzzy logic, standard membership functions are usedin most practical applications. Standard membership function types are Z,Lambda, Pi and S.

Figure 117: Standard Membership Function Types.

All of these can be mathematically represented as piecewise linear functions. Themembership degree of a base variable value as given by its piecewise linearmembership function is computed as follows:

1. The membership function is defined as a set of points P(xi, µi) with:i= 1...n , x1 ≤ xi ≤ xn and µi ∈ [0,1].[x1 ... xn ] is the base variable range.

The current operational value is X ∈ [x1 ... xn ]

2. Evaluate the valid base variable interval with:xk ≤ X ≤ xk+1

3. Compute the membership degree by:µ = µi + (X-xi)*(µ i+1 -µi ) / (xi+1 -xi )

Fast Computationof MBFs For microcontrollers without fast multiplication and division capabilities, some

fuzzyTECH Editions (see Table 2 of Section 9.4) offer an approximation of thismethod called Fast Computation of MBF, which can be selected in the dialogProject Options: Global.

Page 168: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

168

Figure 118: Standard Membership Function DefinitionWith Two Points and Two Slope Values.

The method uses only two definition points and two fixed integer slope values toreduce code size and computing effort (Figure 118). The method computes amembership degree by:

1. The membership function is defined with the points:Point 1 at µ = 0: x1,Slope Up: s1,Point 3 at µ = 1: x2,Slope Down: s2,

with: xi,si: integer.

2. The current operation value is X, integer.Membership degrees are noted as integer in 0...Imax..

3. Evaluate the valid case with:case1: X ≤ x1

case2: x1 ≤X ≤ x2

case3: x2 ≤ X

4. Compute the membership degree for:case 1: µ =0case 2: µ = min (Imax., (X - x1) * s1 )case 3: µ = max (0, Imax - (X - x2) * s2 )

Note! If Fast Computation of MBF is enabled, the Linguistic Variable editor infuzzyTECH automatically modifies the MBF to a feasible definition by movingany defined membership function point to the closest appropriate value.Definition points 1 and 3 can be positioned as desired – restricted only by theresolution of the base variable. However, definition points 2 and 4 can only bepositioned so that the resulting slope can be represented by integer numbers.

Look up MBF onStandard MCUs Using look up tables for fuzzification results in faster, but much larger code

sizes. The relative gain in speed is low for the most 16-bit and the powerful 8-bitmicrocontrollers. On the other hand, due to the large ROM requirement for lookup tables, only microcontrollers which can address external ROM would benefit

Page 169: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

169

from this option. Hence, using look up tables for fuzzification is only supportedby the MCU-51Edition. The MCU-51 allows Look up MBF, Compute MBF, andFast Fuzzification with Standard MBF Types.

S-Shaped MBFs S-shaped MBFs are not available for all fuzzyTECH editions (refer to Table 2 ofSection 9.4). Scientific studies based on psycholinguistic research about thehuman classification of continuous variables propose an alternative to these fourstandard MBFs. From these studies, four axioms relating to membershipfunctions were derived:

1. µ(x) is continuous over X:No infinitesimally small change of the base variable can result in a stepin the membership degree.

2. d(µ(x)) / dx is continuous over X:No infinitesimally small change of the base variable can result in a stepin the derivative of the membership degree.

3. d²(µ(x)) / dx² is continuous over X:No infinitesimally small change of the base variable can result in a stepin the second derivative of the membership degree.

4. µ(x): minµ (maxx (d²(µ(x)) / dx²)):

The maximum of the second derivative over the universe of the basevariable has to be minimal for the definition of µ(x).

µ is the degree of membership; µ(x) the membership function; X the universe ofthe base variable, and x is an element of X.

Research has proven that only one family of functions satisfies all four axioms:the interpolative cubic spline function, or S-shaped MBF. In this case, only theintervals of the base variable with µ(x)=0 and µ(x)=1 need to be defined. S-shaped MBFs should be designed similarly to standard MBFs only theinterpolation is S-shaped, rather than linear. In fuzzyTECH, S-shape membershipfunctions permit the specification of an asymmetry parameter, the “shape”parameter. This allows for context-sensitive adaptation.

Figure 119 shows an example of a symmetrical S-shape membership function infuzzyTECH. Note, S-shape membership functions require more run-time codeand computation time when they are not stored as look-up tables. S-shapemembership functions are not supported by all fuzzyTECH Editions.

Page 170: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

170

Figure 119: S-shaped Membership Functions (Symmetrical).

Arbitrary MBFs While the majority of applications use standard MBFs (not S-shaped), somemembership function derivation methods and adaptation techniques do requiremore general functions. For the most simple design methodology of these MBFtypes and for the most efficient run-time code representation, arbitrarymembership functions should be approximated as piecewise linear functions.

Figure 120: Definition of Arbitrary MBFs

Handling in fuzzyTECH All standard MBF types can be represented with up to four (4) definition points.The fuzzification algorithm of the fuzzyTECH MCU-Editions uses these fourpoint definitions for all types of Standard MBFs to optimize code size and speed.The fuzzyTECH Professional and Online Editions also allow MBF definitionsusing linear shapes with more than four definition points rather than usingdifferent interpolation procedures. In these Editions, the optimizing codegenerator always picks the most effective algorithm. For example, if you areonly using Standard MBFs, the Professional and Online Editions use the samealgorithm as the MCU Editions.

Note: the Linguistic Variable editor in fuzzyTECH enforces the use of feasibleshape definitions. Once the membership degrees of all terms have beenevaluated, the controller strategy can be computed within the fuzzy logicinference.

Page 171: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

171

5.2.2. Fuzzy Rule Inference

Most fuzzy logic based systems use production rules to represent therelationships among the linguistic variables and to derive actions from sensorinputs. Production rules consist of a precondition (IF-part) and a consequence(THEN-part). The IF-part can consist of more than one precondition linkedtogether by linguistic conjunctions like AND and OR.

Fuzzy Rule Inference The computation of fuzzy rules is called fuzzy rule inference. The inference is acalculus consisting of the steps: aggregation, composition and, if necessary,result aggregation. The first step of the fuzzy inference, aggregation, determinesthe degree to which the complete IF part of the rule is fulfilled. Special fuzzyoperators are used to aggregate the degrees of support of the variouspreconditions.

Computation of the IF part of a fuzzy rule

• Aggregation of i terms (i condition parts) of linguistic variables.• Use minimum operator for AND aggregation.• Use maximum operator for OR aggregation.

AND: µIF = mini (µi )OR: µIF = maxi (µi )

Compensatory Operators Using the conjunction AND for the minimum and OR for the maximum is oftenappropriate in small control applications. Sometimes other kinds of operators areneeded to signify the relationship of the different parts of the conditions. Whileall fuzzyTECH Editions support Min and MAX operators, some editions alsosupport compensatory operator families (refer to Table 3 of Section 9.4):

Computation of the IF part of a fuzzy rule

• Aggregation of i terms (i condition parts) of linguistic variables.• Use one of the three families of operators.• Use the compensation parameter λ or γ.

Min-Max: µIF = λ * mini (µi ) + (1-λ) * maxi (µi)

Min-Avg: µIF = λ * mini (µi ) + (1-λ) * nΣ (µi) / i

i=0

GAMMA: µIF = (n∏ (µi ))

1-γ* (1-

n∏ (1-µi))

γ

i=0 i=0

Page 172: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

172

MAX-MIN Inference The second calculation step of each production rule (composition) uses thesupport of the precondition to calculate the support of the consequence. Instandard MAX-Min or MAX-PROD (sometimes called MAX-DOT) inferencemethods, the consequence of a rule is considered equally as true as the condition.

FAM Inference Using standard MAX-Min/MAX-PROD methods, rule base optimization oftenconsists of arbitrary rule addition and deletion. This method can result in aclumsy trial-and-error approach, since the individual importance of a rule can beexpressed only as a 0 or 1. For this reason, most fuzzyTECH Editions support anadvanced inference method, the Fuzzy Associative Map inference, or FAM.With FAM, each rule is assigned a Degree of Support representing the individualimportance of the rule. Rules themselves can be “fuzzy” – meaning, with asupport between 0 and 1.

The support of a consequence is calculated by linking the support of the entirecondition with the Degree of Support by a composition operator. Usually, theproduct operator is used as the composition operator because then the Degree ofSupport reflects rule “significance.”

Computation of the THEN part of a fuzzy rule:

• Combination of the IF part with the Degree of Support.• Use the product operator to represent rule significance.

µTHEN = µIF * DoS

Result Aggregation Finally, if more than one rule produces the same consequence, an operation mustaggregate the results of these rules. A result aggregation step determines themaximum degree of support for each consequences which is used for all furtherprocessing.

BSUM vs. MAX For the Result Aggregation, you may either select the MAX operator or theBSUM (Bounded SUM) operator. The computation is defined as:

Result aggregation of rules having the same consequence:

• Aggregation of the results of the rules.• Use the maximum or BSUM operator.

MAX result aggregation: µRESULT = maxi ( µ THEN,RLUE i )BSUM result aggregation: µRESULT = min ( 1, Σ (µ THEN,RLUE i ))

Page 173: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

173

5.2.3. Defuzzification

The result produced from the evaluation of fuzzy rules is, of course, fuzzy. In theprevious example, the result could be linguistically expressed as “mostlypos_small but also “slightly zero.” Naturally, a crane motor cannot interpretsuch a linguistic command. Membership functions are used to retranslate thefuzzy output into a crisp value. This translation is known as defuzzification andcan be performed using several methods.

CoM Defuzzification Because more than one output term can be evaluated as valid, the defuzzificationmethod must compromise between the different results. The Center-of-Maximum Method (CoM) does this by computing a crisp output as a weightedaverage of the term membership maxima, weighted by the inference results.Figure 121 illustrates CoM defuzzification for the linguistic variable “Power.”The locations of the individual term membership maxima are indicated by thegray arrows and the inference result is shown by the height of the black bar inthe arrows.

Figure 121: Defuzzification With Center-of-Maximum

CoM-Defuzzification:• Calculates the crisp output value Y.• Uses Center of Maximum (CoM) method.• Compromises between the aggregated results of the different terms J of a

linguistic output variable• Based on the Maximum YJ of the each term J.

ΣJ (µ RESULT,TERM i * Y J)Y = = 18.1 KW.

ΣJ µ RESULT,TERM , J

Page 174: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

174

MoM Defuzzification Some fuzzyTECH Editions support other defuzzification methods as well (referto Table 3 of Section 9.4). The Mean-of-Maximum Method (MoM), for example,computes a system output only for the term with the highest resulting degree ofsupport. If the maximum is not unique (like in a Pi-shaped MBF), the mean ofthe maximizing interval is computed. Figure 122 illustrates the MoMdefuzzification procedure.

MoM-Defuzzification:

• Calculates the crisp output value Y.• Uses Mean of Maximum (MoM) method.• Evaluates the most significant of the different terms J of a linguistic

output variable• Based on the Maximum YJ of the each term J.

Y = YJ (µ RESULT,TERM ,MAX)

Figure 122: Mean-of-Maximum Defuzzification

CoA Defuzzification Center-of-Area (CoA), sometimes also called Center-of-Gravity (CoG), is themost frequently used defuzzification method in fuzzy systems. This computationmethod is not available for all fuzzyTECH Editions (refer to Table 3 of Section9.4). With singleton membership functions, CoA and CoM defuzzification areidentical. Most CoA implementations are only approximations since they neglectoverlapping and can be represented with the CoM defuzzification method.

The CoA defuzzification supported by fuzzyTECH is not an approximation as ituses numerical integration for the computation of the areas. Althoughspecification of the number of iterations used for numerical integration ispossible, the real CoA defuzzification is much slower than an approximated CoAdefuzzification, i.e., CoM, because it is computed during runtime. Figure 123illustrates the CoA defuzzification process.

Page 175: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

175

Figure 123: Defuzzification With Center-of-Area

Comparisons While the CoM and CoA defuzzification methods result in the “best compromisesolution,” MoM results in the “most plausible solution.” In control applications,CoM is most commonly used because the output value represents the bestcompromise of all inferred results. MoM is often used in pattern recognition andclassification applications as a plausible solution is most appropriate. Scientificliterature has suggested many other defuzzification strategies that have rarelybeen used in industrial applications.

Hyper CoMDefuzzification The Hyper CoM defuzzification method (Figure 124) is available as add-on

module for some fuzzyTECH Editions (refer to Table 4 of Section 9.4). In manyapplications, not only positive experience in the form of recommendations is ofimportance, but also negative experience in the form of warnings andprohibitions. In order to avoid undesirable operating situations (especially in theinterest of safety) or unacceptable product qualities, for protecting facilities andcutting costs it is essential to adhere strictly to certain prohibitions or to giveappropriate heed to certain warnings. Using conventional type fuzzy controllers,it is - in principle – possible to reproduce previously known transfercharacteristics at will. However, these cannot be used to observe warnings orprohibitions in a systematic or transparent manner as a means of generatingfavorable transfer characteristics.

Figure 124: The Hyper CoM defuzzification method

Page 176: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

176

The Kiendl two-way fuzzy controller structure permits the exploitation of bothpositive and negative fuzzy rules. These two separate rule sets produce twomembership functions µ +(u) and µ -(u), which – in respect of each possibleoutput value – indicate to what degree the value is recommended or not,expressing the latter as warning. A hyperdefuzzification strategy weighs theserecommendations and warnings against each other and computes a membershipfunctions µ (u). The hyperdefuzzification method Hyper CoM then computes theoptimum based output value from this function.

5.3. NeuroFuzzy Technologies

If you wish to enhance fuzzy logic systems with learning capabilities, you canintegrate neural net technologies. The combination of fuzzy logic and neural nettechnology is called “NeuroFuzzy” and combines the advantages of the twotechnologies. Section 5.3.1 introduces the basic principles of neural nets, andSection 5.3.2 presents the combination of neural nets with fuzzy logic.

5.3.1. Basics of Adaptive Systems

For much of the last century, scientists have been inspired by the concept ofimitating the human mind with computer systems. About 50 years ago,researchers created the first electronic hardware models of nerve cells. Sincethese first ventures, a large scientific community has grown dedicated to newmathematical models and training algorithms.

Connectionism Today, this branch of computer science – connectionism – has gainedconsiderable popularity. The research area focuses on the behavior of highlyparallel computer architectures, namely, artificial neural nets. These nets use anumber of simple computational units, called “neurons,” which each try toimitate the behavior of a single human brain cell.

How to Mimic HumanNerve Cells Researchers in the area of neural nets have analyzed various models of human

brain cells. The human brain contains about 1011 nerve cells with about 1014

connections to one another. Figure 125 shows the simplified scheme of such ahuman neuron. The cell itself contains a kernel surrounded by an electricalmembrane. Each neuron has an activation level that ranges between a maximumand a minimum. Thus, in contrast to Boolean logic, there are not just twopossible values or states which may exist .

Page 177: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

177

Activation of Neurons Synapses exist to increase or decrease the activation of this neuron as a result ofinputs from other neurons. These synapses carry an activation level from asending neuron to a receiving neuron. If the synapse is an excitatory one, theactivation level from the sending neuron increases the activation of the receivingneuron. If the synapse is an inhibitor, the activation from the sending neurondecreases the activation of the receiving neuron. Synapses not only differ bywhether they excite or inhibit the receiving neuron, but also by the weight ofeffect (synaptic strength). The output of each neuron is transferred by an axon,which ends in as many as 10,000 synapses influencing other neurons.

Figure 125: Simplified Schematic of a Human Neuron

Net Structure A neural net consists of a set of inter-connected identical units. Each unit may beseen as a simple processor aggregating information coming in from a number ofother units. Following the aggregation, the unit computes the output which ispassed via connections to another unit. Some units are connected to the outerworld on either the input or output side. Information is first given to the systemvia the input units. It is then processed through the net and read from the outputunits.

Simple MathematicalModel of a Neuron Based on this simple neuron model, various mathematical models exist.

Figure 126 shows the most common one. The behavior of a single neuron isdetermined by the following functions:

Propagation Function First, the propagation function combines all inputs, xi that stem from the sending

neurons. The means of combination is primarily a weighted sum, for which theweight, wi, represents the synaptic strength. Excitor synapses have positive

weights; inhibitor synapses have negative weights. An offset (bias) Θ is added tothe weighted sum to express the background activation level of the neuron.

Activation Function The result of the propagation function is now used to compute the activation ofthe neuron with the so-called activation function. Different types of functions areused for this – sigmoid functions are the most common.

Page 178: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

178

Figure 126: Basic Structure of an Artificial Neuron

Output Function Sometimes, the calculated result generated by the activation function is thenfurther processed by another output function. This allows an additional filteringof the output information of every unit.

Can Neural NetsCopy Human Thinking? This is the simple neuron model that underlies most of today’s neural net

applications. Note: this model is only a very simple approximation of reality.You cannot exactly model even one single human neuron. It is beyond thecurrent ability of humans to model. Hence, any application based on this simpleneuron model is unable to exactly copy the human brain. This model is rather an“inspiration” by nature than a “copy” of it. However, many successfulapplications using this technique prove the benefit of neural nets based on thesimple neuron model.

Feedforward Nets For many applications, a determined net computation is as important as adetermined time behavior. Net architectures that allow for cyclic structures in-between units compute output values depending on the inner activation of theneurons. Even if the input does not change, the outputs may vary until thecomputation inside the net reaches a stable state. Nets in which units are onlyunidirectionally connected do not show this behavior. They are calledFeedforward Nets. Nets other than the feedforward type are of less practicalimportance.

Neural Net Objectives The objective of a neural net is to process information in a manner that has beenpreviously trained into the net. Training uses either sample data sets of inputsand corresponding outputs, or a teacher who rates the performance of the neural

Page 179: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

179

net. The neural nets use “learning algorithms” to accomplish the desired training.Upon creation, a neural net is dumb and does not reflect any behavior. Thelearning algorithm then modifies the individual neurons of the net and the weightof their connections in such a way that the behavior of the net reflects the desiredone. The “knowledge” learned by the net is usually represented by the strengthof the connections linking the units and sometimes also by the configuration ofthe units themselves.

Pavlov’s Dogs So, how do you teach a neural net? Basically, the method is similar to that usedwith Pavlov’s dogs. More than hundred years ago, the researcher Pavlovexperimented with dogs. When he showed the dogs food, the dogs salivated. Hethen installed a bell in the dogs’ cages. When he rang the bell, the dogs did notsalivate, as they saw no link between the bell and the food. He then trained thedogs to associate food with the sound of a bell by always letting the bell ringwhen he presented the dogs their food. After a while, the dogs also salivatedwhen just the bell rang and he presented no food.

Figure 127: Principle of Pavlov’s Dog Experiment. Before Learning, the DogsSalivated Only When Pavlov Showed Them Food, Ignoring the Bell. After, TheyLearnt That the Bell Is Linked to the Food, and the Dogs Salivated at the Mere

Ringing of the Bell.

Figure 127 shows how the simple neuron model can represent Pavlov’s dog.There are two input neurons, one representing the fact that the dog sees food andthe other one the fact that the bell rings. Both input neurons have links to theoutput neuron, called the synapses. The thickness of the line represents thesynapse weight. Before learning, the dog only reacts to the food and not the bell.Hence, the line from the left input neuron to the output neuron is thick, while theline from the right input neuron to the output neuron is very thin.

The HebbianLearning Rule Repeatedly letting the bell ring when food is presented creates an association

between the bell and the food. Hence, the right line also becomes thicker – thesynapse weight increases. From these experiments, a researcher by the name ofHebb deducted the following learning rule:

Page 180: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

180

Increase weight to an active input neuron if the output of this neuron shouldbe active.Decrease weight to an active input neuron, if the output of this neuronshould be inactive.

This rule, called the Hebbian Rule, is the father of all learning algorithms. Wemust focus a little more on the learning concepts to explain how this rule isapplied in today’s learning methods.

Supervised Learning If a given input pattern (e.g., a recognizable character) must be associated with aspecified output pattern (e.g., the set of all valid characters), we can superviseeach training step by comparing the computed and the desired results.

Unsupervised Learning If the task of our training procedure is to discover regularities within theenvironment – like categorizing properties of given input patterns – there areusually no specified output patterns or structures to supervise the trainingsuccess. This learning process is called unsupervised learning.

Training Phase andWorking Phase Neural net behavior is configured by altering the strength of the connections

linking the units. Supervised learning can be accomplished only by using sampledata completely separated from the process. Thus, a learning and working phasecan be distinguished.

Training Phase Developing a neural net solution means teaching the net a desired behavior. Thisis called the learning phase. Either sample data sets or a “teacher” can be used inthis step. A teacher is either a mathematical function or a person that rates thequality of the neural net performance. Since neural nets are mostly used forcomplex applications where no adequate mathematical models exist and ratingthe performance of a neural net is difficult in most applications, most are trainedwith sample data.

Figure 128: Training and Working Phase for Supervised Learning

Page 181: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

181

Working Phase After the completion of learning, the neural net is ready to enter the workingphase. As a result of the training, when the input values match one of the trainingsamples, the neural net outputs values nearly equal to those of the sample datasets. For input values in-between sample data input values, it approximatesoutput values. In the working phase, the behavior of the neural net isdeterministic. Thus, each possible combination of input values always producesthe same output value. During the working phase, the neural net does not learn.This is important in most technical applications to ensure that the system neverdrifts towards hazardous behavior.

Learn Methods Today, the most often used neural net learning algorithms are applied infeedforward nets using supervised training procedures. A well-known method,the idea of which is essential to NeuroFuzzy systems, is the delta rule. Moresophisticated approaches, e.g., the error backpropagation method, were derivedbecause the delta rule can only be applied to nets with a single neuron layer.

Delta Rule andError Backpropagation The basic idea of this method is to compare the result computed by the current

neural network with the target output value from the sample pattern. For training,the deviation between these values is used to update the net. The training occursin the following steps:

Select Sample A sample must be selected from a sample data base. For thetraining to succeed, a well-defined data base must be constructed,as well as a specific policy to determine the sequence of samplesapplied to the training algorithm.

Compute Network The network is fed with input data (forward propagation), and theresult of the net’s computation is retrieved at its output units.

Compare Result By comparing the calculated result with the sample output given ,a deviation is computed.

Change Net Weights The weights of the connections are now modified using thecomputed error. Various methods can be used for this task. Thedelta rule uses Hebb’s learning rule to derive a simplemathematical formula. The formula computes new values for theweights of the trainable layer by expressing Hebb´s rule using aproduct of the current weight’s activation and current error. Thisproduct is partially added to each weight.

Back Propagation If a net consists of more than one layer, the error can not directly be assigned tothe weights. Thus, net weights are changed by starting from the output neurons,stepping backwards through the net up to the input units.

Page 182: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

182

Iteration The algorithm repeats these steps with every data set until the average error isreduced to less than a pre-defined threshold. Note: this iterative approach cannever reduce the error for all data sets to zero because in most applications, thedata sets are somewhat ambiguous. Error Backpropagation is only used forsupervised learning.

Various Methods Based on this idea, several learning mechanisms are developed according to thediverse application fields, net structures, and neuron models. All trainingmethods must be properly configured to succeed. Focusing on the supervisedlearning procedures, only a few parameters are common:

Learning Rate The output deviation produced by each sample input must be minimized by theneural training method. Thus, the objective of the problem is multi-dimensional.A training step decreasing the output deviation of one sample may increase theoutput deviation for the other sample cases. In order to converge on a solutionfor all sample cases, the training steps are repeated, and for each computation asmall descent step is performed. This step length can be adjusted with theLearning Rate as a global training parameter.

Updating Policy Standard or universal learning rates are not adequate for all net structures andtraining situations. If nets use different types of neuron models, individualadjustment of the learning rates is required. A random learning rate can find theway out of a local minimum if a given training method does not converge to anacceptable solution.

Winner Neurons Usually a distributed memory is used to train an Error BackpropagationNetwork. In this case, all activated neurons producing a deviation from thesample target value are updated. This of course can increase the error of othersamples, and a small learning rate must be chosen to protect former trainingresults. If local concepts are used, updating only the “best neurons” is a betterprotection for former training results. If only one neuron wins the competition,the method is called Competitive Learning. Nevertheless, both strategies cannotavoid increasing errors.

Termination Criteria Each iteration process needs termination criteria. The simplest criterion is to stopafter a fixed number of iteration steps. Most often, the remaining net error isconsidered when evaluating the termination condition. Here, the average oferrors due to the diverse sample data, as well as the maximum error of the worstsample, may be considered. In both cases, different strategies can be employedwhich drop samples for training if they produce results under the giventhreshold. However, training one sample and decreasing its error can increase theerror of other samples. Even though a sample generates an output result underthe error threshold, it must be still tested in following training steps. It isprobable that the sample error will increase with further iterations of the learningprocess and the sample must be trained again.

Page 183: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

183

Sample Sequencing Any given training step may have an effect on the results of any or all othertraining steps. Therefore, the choice and sequence of samples influences thetraining success. It is possible that the result of one training step, or a series oftraining steps, will undo the training of previous training steps and vice versa.The training can become stuck in an unending cycle, especially if, for example,there are only a few samples sequentially picked for training,

5.3.2. Combining Neural and Fuzzy

The key benefit of fuzzy logic is that it lets you describe desired system behaviorwith simple “if-then” relations. In many applications, this gets you a simplersolution with less design time. In addition, you can use all available engineeringknowledge to optimize the system performance directly. While this is certainlythe beauty of fuzzy logic, it is at the same time its major limitation. In manyapplications, knowledge that describes a desired system behavior is contained indata sets. Here, the designer must derive the “if-then” rules from the data setsmanually – a major effort for large data sets. When knowledge about the systemto be designed is contained in data sets, a neural net presents a solution since itcan train itself from the data. However, few commercial applications of neuralnets exist. This is in contrast to fuzzy logic solutions, which are very common inAsia and Europe.

The sparse use of neural nets in applications can be attributed to a number ofreasons. First, neural net solutions stand as a “black box.” You can neitherinterpret what drives a certain behavior, nor can you modify a neural netmanually to influence a certain behavior. Second, neural nets require prohibitivecomputational effort for most mass-market products. Third, selection of theappropriate net model and setting the parameters of the learning algorithm is stilla “black art” which requires extensive experience. Of the aforementionedreasons, the lack of an easy way to verify and optimize a neural net solution isprobably the major limitation.

Neural Nets Fuzzy LogicKnowledgeRepresentation

Implicit, the systemcannot be easily inter-preted or modified (-)

Explicit, verification andoptimization are easy andefficient (+++)

Trainability Trains itself by learningfrom data sets (+++)

None, you have to defineeverything explicitly (-)

Figure 129: Both Neural Nets and Fuzzy Logic Have Their Strengths andWeaknesses.

Page 184: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

184

In simple words, both neural nets and fuzzy logic provide powerful designtechniques that have individual strengths and weaknesses. Neural nets can learnfrom data sets, while fuzzy logic solutions are easy to verify and optimize. If youlook at these properties side by side (Figure 129), it becomes obvious that aclever combination of the two technologies delivers the best of both worlds.Combine the explicit knowledge representation of fuzzy logic with the learningpower of neural nets and you get NeuroFuzzy.

Training Fuzzy LogicSystems with NeuroFuzzy Many alternative ways of integrating neural nets and fuzzy logic have been

proposed in the scientific literature. However, very few have already beensuccessfully applied in industrial applications. Delta rule and error backpropagation algorithms have become the standard for most neural netimplementations. If the error back propagation algorithm is so powerful, why notuse it to train fuzzy logic systems, too? Alas, this is not straight forward. First ofall, fuzzy systems use different mechanisms for computation:• The input layer uses fuzzification.• The hidden layers use fuzzy inference.• The output layer uses defuzzification.

In each of the three computation mechanisms, we must find parameters that canbe used as “weights” in a neural training procedure. Second, the error backpropagation algorithm differentiates the transfer functions of the neurons todetermine the influence of each neuron. Here, the standard fuzzy logic inferencecannot be differentiated.

The Weights in aFuzzy System NeuroFuzzy development tools use expanded fuzzy logic inference methods to

solve the first problem. The most common approach is to use so-called FuzzyAssociative Maps (FAMs). A FAM is a fuzzy logic rule with an associatedweight. The second problem can be circumvented by implementing a modifiederror back propagation algorithm with fuzzy logic. For details, refer to thecomputation section of this chapter. As a user of NeuroFuzzy tools, you do notneed to worry about the details of the algorithm. Today’s NeuroFuzzy tools workas an “intelligent” assistant to help you with your design. They help you generateand optimize membership functions and rule bases from sample data. You canfind further remarks pertaining to design steps you may use with NeuroFuzzy inSection 4.2.

NeuroFuzzy vs. otherAdaptive Technologies Compared to other adaptive techniques, NeuroFuzzy has a number of

advantages:• Because you start with a pre-structured system, the degrees of freedom for

learning are limited. Experience dictates that in many applications, therepresentation of the input and output variables by membership functions andthe structure of the information flow in the system already contain much ofthe information that an unstructured neural net must derive from the sampledata sets.

Page 185: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

185

• You can use any knowledge you already have of the system right from thestart. In most applications, a few things are perfectly clear. By usingNeuroFuzzy, you can implement all this knowledge in the initial fuzzy logicsystem.

• You can exclude parts of the system from training. For example, this isnecessary in applications where some rules contain knowledge that isessential to the safe operation of a plant.

• You can always interpret the result or current stage of the system as itcontains self-explanatory fuzzy logic rules and linguistic variables.

• You can manually optimize the result of NeuroFuzzy training.• You can train the system interactively. After modification, you can start

training again with the same or other sample data sets.• The resulting fuzzy logic system is faster and more compact on most target

hardware platforms.

On the other hand, there are also disadvantages of NeuroFuzzy when comparedto other adaptive techniques:• There is much more experience with neural nets because extensive research

has been on going for 50 years. In contrast, NeuroFuzzy is still a “young”technology that developed from practitioners rather than researchers.

• NeuroFuzzy training features fewer degrees of freedom for the learningalgorithm when compared to a neural net.

In engineering, this is an advantage rather than a drawback. However, inapplications where no knowledge of the system’s structure exists, but massiveamounts of data are available, NeuroFuzzy may not deliver a solution at all.

5.4. Computing NeuroFuzzy Training

Neural Netswithout Neurons? In order to actually design a network, it is necessary to use a kind of knowledge

representation other than the “problem nonspecific” uniform neurons. Thefollowing concepts must be realized to apply neural training strategies toelements that represent “problem specific” neurons:• a directed information processing. The connections between the units must

use a feed forward structure, thus, allowing the system to be divided intolayers. System inputs are members of the input layer and system outputs aremembers of the output layer.

• The elements inside a layer are independent. Thus, all members of a layer canbe processed by parallel processors.

Page 186: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

186

Fuzzy Logic as Neurons Fuzzy logic systems can be used for knowledge representation in neural systemsbecause:• The fuzzification, computed by independent input variables, can represent the

input layer.• Fuzzy rules, computing the rule conclusions independently, can represent a

hidden layer. Arbitrary rules can be seen as multiple layers.• The defuzzification is also processed in independent elements, i.e., the output

variables.Fuzzy vs. Neural NetKnowledge Representation Thus structurally, fuzzy systems can easily be understood and calculated much

like a parallel structure. Storing knowledge in a fuzzy system, however, uses adifferent memory model than that which is used in neural nets:• Fuzzy systems store facts localized in “problem specific” elements.• Known a priori facts can be manually edited into the system, thus

accelerating the learning phase.• System behavior can be manually altered during the learning process.

Problems like the deadlock of iterations in a local optimum can be avoided,thus allowing further system optimization .

• A possible malfunction in the working phase cycle can be easily be explainedand, most likely, also corrected.

• Neural nets store facts distributed in the whole net.• Facts cannot be manually edited, system behavior cannot be manually

altered, and malfunctions in the working phase cannot be explained byobserving specific neurons.

Although fuzzy systems provide the advantages previously mentioned, anautomated training procedure applied to a NeuroFuzzy system does not alwaysimplement the knowledge in the most plausible way. Within fuzzy systems,desired responses can be expressed by using either one specific rule matched to arequired strategy, or by a combination of rules using perhaps a compromisedefuzzification method to obtain the same result. A training algorithm usuallysupervises only the deviation between computed and desired output values, notthe number of rules used to represent a given sample.

DeterminedTraining Results Thus, the advantages of representing knowledge in fuzzy systems can only be

maintained if the NeuroFuzzy training can be directed to dedicated trainingparameters and the modification of parameters does not disturb the transparencyof the elements used. The following chapters show how adaptive methods can beintegrated into fuzzy elements like linguistic variables and fuzzy rules.

Page 187: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

187

5.4.1. Learning Fuzzy Rules

The basic idea of all early NeuroFuzzy approaches is to set up a complete fuzzyrule base, not by entering the rules, but by presenting a set of training samplesand selecting the set of rules that represent the samples. For small systems, theapproach works adequately. When applied to the training of larger systems, theapproach shows disadvantages:• Without a rule base, it is difficult to set up the exact definitions of linguistic

variables such that rules can be selected which represent the given samples. Ifvariable definitions do not provide a good match to the given sampledistribution, the training may not converge.

• If rules can only be switched on or off, neural training procedures cannot beapplied. Neural training methods usually use error gradients to heuristicallyfind the best search direction. A gradient can not be calculated when discreterules are used.

FAM Rules In neural nets, the parameters affected by the training procedure are theconnection weights between the neurons. Looking at a fuzzy system usingarbitrary sets of fuzzy rules, the firing strength of each rule output connects thisrule with the precondition of the following rule block. Using the technology ofFuzzy Associative Maps (FAM), this connection can be weighted. This ruleplausibility can be used as the parameter to be calibrated in the neural training. Aneural training algorithm can calculate an error gradient by slightly changing ruleweights.

Restricted Training The result of using this approach in large systems can of course be a huge rulebase where most of the rules are assigned a local weight. The rules onlyrepresent sample patterns in combination with several other rules in order torestrict the number of rules used and to save a-priori knowledge that was enteredinto the system before training.

Training Data The training of a fuzzy system by changing fuzzy rules requires access to:• training samples• the computation of the current fuzzy system• a list of the open rule parameters• the gradients indicating whether changing a rule parameter increases or

decreases the error due to given sample• the parameters determining the learning method and configuration, the update

policy, break conditions, and sample sequencing strategies.

The NeuroFuzzy module allows access to the necessary data. Therefore,optimizing heuristics may be applied to adjust open system parameters and find asystem that fulfills the requirements of the given samples.

Page 188: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

188

How NeuroFuzzy Trainingis Accomplished The NeuroFuzzy module provides methods for supervised learning. The heuristic

methods employed combine the two learning steps of error backpropagation withthe idea of competitive learning. After a system output is computed by forwardpropagation, an output error is identified by comparing the system output withthe given sample output data.

Error Backpropagation This error is then used to determine the fuzzy rule most suited for influencingsystem behavior. Using the selected learning rule, the plausibility of the fuzzyrule is modified before the subsequent sample data set is read.

Learning Method The learning method is the computing heuristic that evaluates the winner neuronsfor the next update. In addition, a strategy can be implemented to apply aspecified step width to the updated parameter.

Training Iterations Updating a system parameter decreases the error for one sample, but mayincrease the error for all others. Thus, NeuroFuzzy uses an iterative computationto find the fuzzy system which best matches all given samples. In most cases, thesamples must be trained multiple times to reach a sufficient result. An iteration iscompleted each time all samples are used once for computation of an output.

Perform Training In order to monitor the system behavior relative to the results produced by allsamples, the perform computation command is executed after each completeiteration. The perform run may also be executed manually when the training isstepped one sample at a time or stopped during an iteration. The perform run alsochecks the break criteria of the training procedure. If the system fulfills all validcriteria, the training is terminated. The result is a pure fuzzy system to be used inthe working phase.

Configuration Parameter For NeuroFuzzy training, the learning methods must be configured similar toneural net training. The fuzzyTECH NeuroFuzzy Module allows the adjustmentof the following parameters:

Learning Rate The Learning Rate is a global training parameter which determines the stepwidth of each training step. The learning rate for DoS values is normalized as thevalues themselves in the interval [0...1]. In other words, the DoS learning ratedetermines the value that is added or subtracted to a winner DoS.

Learning Methodsin fuzzyTECH The NeuroFuzzy module allows standard methods (REAL_METHOD and

RANDOM_METHOD) and batch training procedures (BATCH_LEARN andBATCH_RANDOM). The first of each group uses the learning rate entered asconstant training steps, while the second uses randomly defined steps from theequally partitioned interval [0... learning. rate] for the update. If the training doesnot converge, the random learning rate can help to avoid local minimums.

Page 189: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

189

Standard/Batch Learning The standard methods perform an optimization step per sample. Batch methodscalculate errors and gradients for all samples and update the systems parametersafter each complete iteration. Standard methods provide a better computationperformance and batch methods a better convergence behavior. fuzzyTECH alsoallows you to include user defined methods by writing your own trainingmethods as a dynamic link library.

Winner Neurons Fuzzy Systems use local elements to represent knowledge. Only the winnerneurons are updated in order to keep a rule base transparent. The number ofwinners determines how many neurons are updated within each iteration step.Note that the more winner neurons are used, the less is the protection of trainingresults from former samples.

Stop Criteria:Number of Iterations fuzzyTECH allows for three termination criteria. The first criterion is to stop after

a fixed number of iteration steps. One iteration is defined as one complete passthrough the sample data. If the sample sequence is random, the iteration isdefined as complete after N sample data sets are trained, where N is the numberof samples in the sample file. Note: for random sequencing, samples can bedouble trained in one iteration while other samples are skipped.

Avg. Deviation The Avg. Deviation (Average Deviation) criterion is fulfilled if the average ofthe errors occurring during a complete iteration is less than a defined errorthreshold. The average error is computed by adding the errors for each sampledivided by the number of samples. Note: the last computed error is taken intoaccount for each sample. For efficiency purposes, the error is only computed ifthe sample is trained.

Max. Deviation The Max. Deviation criterion compares the error of the worst sample with anerror threshold. Samples under the threshold are skipped within the trainingprocedure. Training one sample can increase the error of other samples;therefore, the training results are automatically evaluated after every completeiteration. In order to evaluate the max deviation when the training is stopped,before an iteration is completed, or when you step through the trainingprocedure, a perform command is mandatory. Max deviation can also be used asa dynamic criterion.

Dynamic Break Condition The Max. Deviation criteria can be implicitly used to improve the trainingperformance of the NeuroFuzzy optimization. When using max deviation as thestop criterion, only the samples that continue to produce an error larger than thedefined threshold are trained. The max deviation threshold can be dynamicallyused to always evaluate only the samples producing the larger errors. Thethreshold starts at the [From] value and is reduced by the [Factor] value eachtime the threshold parameter is fulfilled. The training is stopped when thethreshold has reached the entered [To] value and all samples meet the designatedcriteria. Note: the [From] value must be larger than the [To] value and the[Factor] value must be less than 1.

Page 190: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

190

Sample Sequencing The sample data may be provided in sequential or random order. Randomsequencing takes the next sample from the equally partitioned set of all samples.User specified methods can be integrated through user defined dynamic linklibraries.

Interaction betweenFuzzy and NeuroFuzzy Fuzzy rules in a rule set may be edited at any time in order to reduce the time

required to complete the learning phase. All open fuzzy rules – predefined ornot– are modified during the learning process via their degrees of support. Thesemodifications are processed using sample data accessed from external files. Afterthe learning process is complete, the trained rule base can be displayed andedited in the fuzzyTECH Rule Editor. With a repeated call-up of the NeuroFuzzyModule, the optimization of the fuzzy system can be enhanced by switchingbetween interactive editing and sample learning processes.

5.4.2. Learning Fuzzification and Defuzzification

Fuzzy rules determine the central component of the information processing ofthe fuzzy system. Input and the output interfaces of the network that arerepresented by fuzzification and defuzzification routines must mimic the neuronsof input and output layer of the desired network. In neural nets, the weightsbetween the input and the first hidden layer, as well as the last hidden layer andthe output layer, determine the input/output behavior. In a fuzzy system theseparameters are found in the fuzzification and defuzzification routines and canthus be trained.

Training of theMembership Functions If all definition points of an arbitrary membership function are determined by an

automated training method, the result would most likely be chaotic term shapes.Fuzzy systems with chaotic membership functions lose their transparency.Therefore, fuzzyTECH allows only selected parameters within special standardvariables to be opened for training.

Figure 130: Standard Membership Functions Used for Input Interfaces:Z, Lambda, and S Form.

Page 191: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

191

Standard Variables Before training is started, the membership functions of all open terms areconverted to these standard types. Different types are chosen based on their useas input or output variables. Inputs are converted to Z-Lambda-...Lambda-Stypes (Figure 130). For output variables, all terms are converted to lambda typemembership functions (Figure 131). In addition, the standard variables arerestricted to shapes which allow an overlap of no more than two terms. Thisleads to a variable definition in which each term is determined by exactly oneparameter, the base value of the term’s maximum. As a result, each term mustintersect the base line at the maximum point of its neighbor on either side.

Figure 131: Standard MBF Used for Output Interfaces in All-Lambda-Type Forms.

Shifting StandardVariables The fuzzyTECH NeuroFuzzy module uses the single characteristic parameter of

the term of a variable for the term’s adaptation. A change of this parameterrepresents a horizontal shift of the term maximum. The base points of itsneighbor terms must also be changed to keep the membership function as astandard type during this shift. Figure 132 shows how terms of a variable areshifted when a parameter is changed by adaptation.

Figure 132: Shifting of Characteristic Base Values of Standard Variables.

Learning Methods The fuzzyTECH learning methods allow for training either fuzzy rules, terms orboth. The manner in which the fuzzyTECH NeuroFuzzy Module treats theparameters of the terms is similar to the modification of fuzzy rules. Therefore,the learning mechanism depicted in the previous section can also be applied toterm learning.

Page 192: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

192

Learning Rate Although fuzzy rules and membership functions are treated similarly by thelearning method, you can define differing learning rates for the two sets of openparameters. Both learning rates can be adjusted independently. DoS values arenormalized in the interval [0...1], while Base Values are represented as Shellvalues and can be changed according to a user defined interval inside the basevariable range. The learning rate for terms is entered as a percentage of the rangeinterval.

Restrictions Learning is not restricted to the output values of one output variable. Structureswith numerous variables, rule structures, and rule blocks are allowed. Oftenfuzzy systems do not have a one-to-one correspondence – meaning that the sameresults may be produced by different fuzzy systems. The convergence of thelearning procedure towards one specified solution can therefore not beguaranteed.

5.5. Data Clustering

NeuroFuzzy techniques, which you experimented with in the previous section,provide a powerful method for converting information contained in sample datainto fuzzy logic rules. The benefit of this is significant. In contrast to sample datafiles, fuzzy logic rules can be interpreted and optimized in a straightforwardmanner. However, in many cases the training data for the NeuroFuzzy learningmust be preprocessed. Such preprocessing is necessary for two reasons:• It removes redundant data.• It resolves conflicts in the data.

For instance, consider the case that you would like to derive a credit grantingpolicy from past data. In this past data, typically 98% of the cases cover standardcases, while only 2% of the cases cover more unusual cases. Since any trainingalgorithm treats each case with the same importance, it spends most of itsattention on the standard cases and very little on the unusual cases. If you usesuch sample data directly for training, it takes a long time for convergence andthe performance on the more unusual cases is likely to be low. Hence, removalof redundant data greatly improves the training result in this case. Also, you mayhave a certain degree of inconsistency in the cases because multiple creditexperts have processed the cases. These inconsistencies may be very hard to spotas credit experts may well agree in certain situations but may strongly disagree inothers. If you use inconsistent training data, the NeuroFuzzy module averagesbetween the inconsistencies to minimize total training error. For smallinconsistencies, this may be the right way to proceed, but if you have a fewstrong inconsistencies in the training data set, the training result may be poor. Itfollows the rule, “garbage in, garbage out,” and you should remove these stronginconsistencies before training.

Page 193: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

193

fuzzyTECH integrates the FuzzyCluster Module to help you with preprocessingof sample data. The functions contained in this module help you both inremoving redundant data and resolving strong inconsistencies in the data. TheFuzzyCluster Module contains two different clustering techniques: the industry-standard IsodataCluster and the FuzzyCluster approach. The following sectionintroduces the specifics of the FuzzyCluster approach.

FuzzyCluster In order to illustrate the function of a clustering algorithm, consider a data setusing a single input variable matched by data sets to a single output variable.

Removing Redundant Data Most data points group themselves with others into three clouds. These cloudsare called “clusters.” A single data point can replace each of the members ofsuch a cluster to reduce the number of data points. Such data points are referredto as “typicals.”

Input Variable

Output Variable

Figure 133: Sample Data Set Containing One Input and One Output Variable.

If only the three (3) typicals are used for the subsequent NeuroFuzzy training,the resulting rules could be:

With only three (3) typicals for training, the training time for the NeuroFuzzyModule would be much smaller than with the original sample data. Note, theleftmost cluster contains far fewer data points than the middle cluster. If thissample data had been used without preprocessing, this area would have gainedmore attention from the NeuroFuzzy algorithm, because the NeuroFuzzy trainingalgorithm treats each data sample with the same importance.

IF Input IS low THEN Output = lowIF Input IS medium THEN Output = lowIF Input IS high THEN Output = high

Page 194: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

194

Input Variable

Output Variable

Figure 134: The Data Points of the Example Can Be Grouped Into ThreeClusters. Each Cluster Is Represented By a “Typical” Data Point (Cross).

Resolving Conflicts The second objective of the data preprocessing step is to identify and solveconflicts between data points. In the example, a single data point cannot begrouped in a cluster. This data point is indicated by an arrow. It does not belongto the leftmost cluster, because the distance to the other data points of this clusteris too large. Thus, this data point conflicts with the other points, and the conflictshould be removed. Otherwise, the NeuroFuzzy training cannot later deduce aclear rule from the sample data.

Input Variable

Output Variable

Figure 135: If a Data Point is Too Far Away From the Cluster, It Is Considereda Conflict.

Page 195: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

195

Clustering Algorithm fuzzyTECH integrates both the standard IsodataCluster method, as well as theinnovative FuzzyCluster clustering method. Both methods are similar, exceptthat they use different distance measures for the determination of the distancesbetween data points. Also, fuzzyTECH’s integrates a data consistency checkwithin the clustering procedure.

Cluster Configuration Clustering means to combine “similar” data points into a single cluster. Theresult of the clustering is the set of typicals, where each typical denotes onecluster. Now, the question becomes: what is “similar”? The similarity of datapoints is specified by a so-called “accuracy” for each variable. Thus, “accuracy”is a vector. Its dimension is the total number of inputs plus outputs. Data pointsthat are confined within the same accuracy measure are considered to belong tothe same cluster.

Computing Distances andData Sample Reduction The first step of the clustering algorithm is to compute the geometric distances

between all the data points. Then, all data points that are closer to each other thanthe geometric length of the accuracy vector are marked and sorted. Starting withthe closest pair of data points, all “similar” pairs are combined. This results in anew data point and the two original data points are erased from the data set. Eachtime a new data point is inserted, the distances from this new data point to all theother ones must be re-computed.

Input Variable

Output Variable

A B

C

D

E

F

Figure 136: Example of a Set of Six (6) Data PointsWith Points Depicted In a 2-Dimensional Diagram.

Figure 136 shows an example of a set of six (6) data points. After all distancesare computed, the distance between AB was determined to be the shortest one.Hence, A and B are combined into a new data point X, and A and B areremoved.

Page 196: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

196

Input Variable

Output Variable

A B

C

D

E

F

X

Figure 137: Example of a Set of Six (6) Data Points; PointsA and B Are Combined into the New Data Point X.

Next, the distances from the new point X to all other points are computed. Next,the points D and E are closest to each other and thus combined to a new point Y.Points D and E are removed.

Input Variable

Output Variable

A B

C

D

E

F

X

Y

Figure 138: Example of a Set of Six (6) Data Points:A, B Clustered to X and D, E Clustered to Y.

After computing the distances to the new point Y, the two closest points now areX and C. X and C are combined into the new point Z. Since point X stemmedfrom a combination of two points and point C is only one point, the new point Zis located closer to X, because Z has to represent the original points A, B, and C.The position of Z is computed as the linear combination of X and C, weighted bythe number of original data points.

Page 197: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

197

Input Variable

Output Variable

A B

C

D

E

F

X

Y

Z

Figure 139: Example of a Set of Six (6) Data Points: A, BClustered to X; D, E Clustered to Y; and X, C Clustered to Z.

Now, no further combination of points can be made because the distancesbetween Z and Y, as well as Y and F, are no longer considered similar.Clustering halts and outputs data points Z, Y, and F as typicals.

Consistency Analysis If the “check consistency” option of fuzzyTECH’s clustering function is enabled,data points that are considered similar to the input variable values, but notsimilar to the output variable values, are marked and presented to the user forresolution of the conflict.

Input Variable

Output Variable

A

B

C

D

E

F

Figure 140: Example of a Set Containing Conflicting Data Points: Band C Use the Same Input Value Mapping on a Different Output.

Page 198: ft531manual

Inform Software Corporation Chapter 5: Fuzzy Primer

198

Data points D and E are considered to have similar input variable values.However, the corresponding output variable value is not similar. This puts thesetwo points in conflict with each other. Data points B and C are not consideredconflicting, because the respective output variable values are close enough to beconsidered similar. Data points A and B are not considered conflicting since theinput variable values are not close enough to be considered similar. fuzzyTECH’sclustering function brings these conflicts to the user’s attention. The user mustdecide if only one data point shall be used, or if both or neither point shall beused.

Fuzzy Clustering The clustering method, as discussed before, has proven to be useful in manyapplication areas. However, for many other applications, the fuzzy logicextension, dubbed “FuzzyCluster” showed to be a useful extension. FuzzyClusteruses a more sophisticated computation of the “similarity” of data points. First, itdoes not use a “threshold”-like definition for the IsodataCluster methodpresented. Second, it considers different similarity definitions for each variable.

FuzzyCluster associates each variable with a membership function that assesseshow similar two data points are, depending on the difference in value for thegiven variable. In contrast to IsodataCluster, first the similarity of two datapoints for each variable v is assessed as a degree of truth (µv). The distance dXY

between two points is then computed as the negative minimum of the similarities(dXY = - min v {µv}). The two points that have the lowest dXY are consideredclosest.

Epsilon Delta0

Difference

µ

Figure 141: FuzzyCluster Expresses the Similarity of Two Data PointsUsing a Membership Function.

The interpretation of Epsilon and Delta is as follows:• Epsilon is the largest difference in value of two data points that are still

considered to be completely similar.• Delta is the smallest difference in value of two data points that are considered

not to be similar at all.

Page 199: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

199

Advantages of Clusteringand FuzzyCluster Consider the following conclusions as a summary of the previous chapters:

• A fuzzy logic system can approximate any nonlinear multi-variable system.• The representation of a fuzzy logic system is linguistic rather than

mathematical.• Thus, human experience and experimental results can be used directly for

system design.• Typical samples can be converted into a fuzzy logic system with the

NeuroFuzzy module.• Real-world sample data can be converted into typicals using clustering

techniques.

Fuzzy Logic

Rules, Linguistic Variables

NeuroFuzzy

Clustering

#

I n p u

t

1 2 3 4 1

2 3

1 2 0 3 4

8 1 ß 2 3

Typicals

Raw Data

Human Expert

Typical Data

Real-World Data

Figure 142: The Combination of Fuzzy Logic, NeuroFuzzy, and ClusteringTechniques Provides a Complete Workbench for the Design of Intelligent

Systems.

Thus, the combination of multiple techniques, such as fuzzy logic, NeuroFuzzy,and clustering, constitutes a powerful tool box for the design of intelligentsystems. The previous figure shows the various types of system design thatcombinations of the different techniques allow you. Explicit knowledge ofdesired system behavior, such as decision policies, are inputted directly byhuman experts as fuzzy logic rules and linguistic variables. If typical data isavailable, the NeuroFuzzy module automatically converts it into rules andlinguistic variables of a fuzzy logic system. If only raw real-world data isavailable, fuzzyTECH’s clustering function resolves conflicts in the data andremove redundancies to generate the typicals.

Page 200: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

200

fuzzyTECH provides two different approaches how other applications cancompute fuzzy runtime systems.

Standalone Systems If you want to use your fuzzy logic project in a standalone fuzzy runtime systemyou should use the fuzzyTECH code generators. As result you will get sourcecodes that you may include in the software development project of your ownapplication. Your fuzzy runtime system will be very compact and fast. There isno limitation how many fuzzy logic systems can be used at the same time.Section 6.1 explains the details.

Client Server Systems If you want to use the fuzzyTECH Shell as server to compute fuzzy logic systemsfor your application, you should use one of fuzzyTECH’s standard interfaces forinterprocess communication with other applications. MS Windows standardinterfaces are supported as well as interfaces independent from the operatingsystem. This approach allows a complete fuzzy logic system visualization andon-the-fly changes. Section 6.2 explains the details.

6.1. Using fuzzyTECH Code Generators

Overview fuzzyTECH provides different code generators specialized for different targetplatforms. The generated code is royalty free. The computed results in the fuzzyruntime systems are the equivalent, they do not depend on the code generator.This overview should help you to find the optimal and most convenient solutionfor your problem.

Page 201: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

201

Figure 143: fuzzyTECH stand-alone Runtime Module as server for fuzzycomputations

ActiveX You can use the fuzzyTECH Runtime Control to integrate a fuzzy runtimesystem into an application running on a MS Windows operating system,provided that this application is able to function as ActiveX container (client).The fuzzyTECH Runtime Control is a so-called in-process ActiveX server thatallows to load and compute any fuzzy systems. The fuzzyTECH Runtime Controlis integrated into a client application in the same way as other controls, too.Section 6.1.1 explains the details.

FTRUN.DLL If you want to integrate a fuzzy runtime system into an application running on aMS Windows operating system you should use the fuzzyTECH runtime moduleFTRUN.DLL. It is easy to integrate into any software or programming languagethat supports the integration of DLLs and you do not need any compiler tools tocompile the fuzzy runtime system. Section 6.1.2 explains the details.

Page 202: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

202

MCUs DSPs PLCs fuzzyTECH provides optimized support for a wide range of target hardwareplatforms. For common microcontroller, DSP and PLC architectures, fuzzyTECHsupports the generation of hardware specific code, i.e., code that has beencarefully optimized to perform at its best on the chosen target hardware. Formost of the supported architectures, Inform has teamed up with manufacturers ofthe respective devices to ensure the most efficient implementation. Section 6.1.3explains the details.

C Code Other hardware platforms are supported by the generation of C source code thatcan be implemented on any existing target hardware platform supported by a Ccompiler. Various options allow the customization of fuzzyTECH’s C codegenerator to complement the C compiler and target hardware in use at best.Section 6.1.4 explains the details.

COBOL Code fuzzyTECH offers optimized support for COBOL mainframes. The COBOL codegenerator generates from a fuzzy system a *.COB file that contains COBOLsource code. COBOL-based user applications can use the fuzzyTECH COBOLRuntime Library together with this source code to compute a fuzzy system.Section 6.1.5 explains the details.

M Code fuzzyTECH provides optimized support for Simulation and mathematicalsoftware packages that use M-Code for system representation. Section 6.1.6explains the details.

Online/RTRCD Some code generators allow an online connection between the fuzzyTECH Shelland the fuzzy runtime system. The online connection lets the fuzzyTECH Shellvisualize the fuzzy runtime system. Even changes of the running system arepossible; the runtime system can be optimized during runtime without any timeconsuming re-compilations. Read the subsection that corresponds with youredition for more details.

6.1.1. fuzzyTECH Runtime Control (ActiveX)

Definition The fuzzyTECH Runtime Control is a so-called in-process ActiveX server thatcan load and compute any fuzzy systems. The fuzzyTECH Runtime Control isintegrated into a client application in the same way as other controls, too.

Availability The fuzzyTECH Runtime Control is only available for editions that are able togenerate FTR files (refer to Table 5 of Section 9.4).

Page 203: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

203

FTR Files The fuzzyTECH Runtime Control is independent from any fuzzy logic system.The code generator of fuzzyTECH stores the specific information of each fuzzylogic system in *.FTR files. This files contain binary data only in a compactformat that is optimized for the Control.

Online Module The fuzzyTECH Runtime Control includes the Online module. This supportsonline development with fuzzyTECH Editions that include the Online debugmode (refer to Table 4 of Section 9.4). The following communication channelsare support:• MS Windows DDE• TCP/IP• IPX/SPX• Serial Interface• Shared File Systems

Note that *.FTR file must be generated with the Online Code option(Tools/Project Options/Code Generator) to enable the Online Module.

Multiple Instances, Multi-Systems, Multi-Clients A client can use the Runtime Control for simultaneous computations of multiple

instances of the same fuzzy system. Moreover, the client can use many ofdifferent fuzzy systems at the same time, too. The fuzzyTECH Runtime Controlis multi-clientcapable, i.e. it can be used by many clients at the same time.

License You may add the fuzzyTECH Runtime Control to any other software includingsoftware written by yourself without royalty fees, if:• You are a registered user of one (or more) fuzzyTECH Edition(s) that can

generate FTR files (refer to Table 5 of Section 9.4).• You use only fuzzyTECH to generate the *.FTR file.

Integration Samples You find integration samples in the ..\RUNTIME\ACTIVEX\ sub-directory.Further useful information on how to use the fuzzyTECH Runtime Control youcan find in the Start Menu/Programs/fuzzyTECHxx/Help.

6.1.2. fuzzyTECH Runtime DLL (FTRUN.DLL)

Definition FTRUN is a stand-alone runtime module that allows the computation of arbitraryfuzzy logic systems. It is a MS Windows DLL and can be integrated into everyMS Windows application with a DLL interface. This may be standard softwareas well as user written software.

Page 204: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

204

Availability FTRUN is available only for editions that are able to generate FTR files (refer toTable 5 of Section 9.4).

FTR Files FTRUN is independent from any fuzzy logic system. The ‘code’ generator offuzzyTECH stores the specific information of each fuzzy logic system in *.FTRfiles. This files contain binary data only in a compact format that is optimized forFTRUN.

Online Module FTRUN includes the Online module. This supports online development withfuzzyTECH Editions that include the Online debug mode (refer to Table 4 ofSection 9.4). FTRUN supports the following communication channels:• MS Windows DDE• TCP/IP• IPX/SPX• Serial Interface• Shared File Systems

Note that *.FTR file must be generated with the Online Code option to enablethe Online Module.

Directory FTRUN is delivered in two versions. Both DLLs and a help system are located inthe directory …\RUNTIME\FTRUN:FTRUN.HLP MS Windows Help SystemFTRUN.DLL supports 16-bit applications for MS WindowsFTRUN32.DLL supports 32-bit applications for MS Windows.Note that the Online module of this DLL does not run under the Win32sExtension for MS Windows 3.1x.

Interface The interface between FTRUN and the client applications is the FTRUNapplication programmer’s interface (API). It consists of functions that1. open fuzzy logic systems (*.FTR files)2. close fuzzy logic systems3. set values to the fuzzy logic system4. get values from the fuzzy logic system

Multiple Instances, Multi-Client, Multi-Systems FTRUN is multi-system capable, i.e. one target software can use FTRUN to

compute multiple instances of the same fuzzy logic system as well as differentfuzzy logic systems at the same time. FTRUN is also multi-client capable, thatis, more than one target software can share a single FTRUN.

Overview An implementation of a fuzzy runtime system consists of at least three modules:1. One or more fuzzy system modules generated by the FTR code generator of

fuzzyTECH. Each *.FTR file contains the data for its specific fuzzy logicsystem in a compact binary format.

Page 205: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

205

2. The FTRUN DLL as fuzzy computation server that contains the FTRUNAPI, the Online module and basic fuzzy algorithms which are independentfrom any fuzzy system

3. One or more of your applications as clients that call the FTRUN API to usethe fuzzy logic system(s).

Figure 144 illustrates the hierarchy of these modules.

MS Windows

A.EXE B.EXE ... Z.EXE

FTRUNxx.DLLFTRUN API + Fuzzy Algorithms + Online Module

A1.FTR B1.FTR ... Z1.FTRA2.FTR B2.FTR ... .A3.FTR . ... .

.

.

.

.

.

.

...

...

...

.

.

.

Figure 144: Fuzzy Runtime Systems with FTRUN

License You may add FTRUN to any other software including software written byyourself without royalty fees, if:• You are a registered user of one (or more) fuzzyTECH Edition(s) that can

generate FTR files (refer to Table 5 of Section 9.4).• You use only fuzzyTECH to generate the *.FTR file for FTRUN.

Performance FTRUN uses the same efficient techniques for the fuzzy logic computation as theruntime systems implemented with the fuzzyTECH source code generators. Thus,the performance of FTRUN is comparable to that of the fuzzyTECH C codesolutions. Refer to the benchmarks published at www.fuzzytech.com. The DLL’sfile sizes are about 100 KB for the 32-Bit DLL and about 50 KB for the 16-BitDLL.

6.1.2.1. FTRUN API

FTRUN consists of a very small function interface that can be used by everysoftware with an interface to DLLs. The functions can be subdivided into threegroups:1. The standard functions will be sufficient to integrate any fuzzy logic system

that was generated as FTR module with the base variable data type Double.

Page 206: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

206

2. The integer functions must be used if the FTR module was generated with thebase variable data type 16 bit Unsigned Integer. In this case no floating pointarithmetic is used.

3. The advanced users functions can be used to integrate the i/o-mapping of thefuzzy systems dynamically at runtime. This allows the integration of any newfuzzy logic system without recompiling your application.

Here the functions are listed in C language syntax. For more details about thefunctions and their parameters please refer to the help system in the Windowsstart menu: Start/Programs/fuzzyTECHxx/Help/fuzzyTECH Runtime DLL(…\RUNTIME\FTRUN\FTRUN.HLP).

Standard Functions

BOOL ftrOpen (HINSTANCE hInstance, LPSTR lpszFile, LPHFTRUN lphftr);BOOL ftrClose (HFTRUN hftr);BOOL ftrSetShellValue (HFTRUN hftr, FTRIOI ioIndex, double ShellValue);BOOL ftrGetShellValue (HFTRUN hftr, FTRIOI ioIndex, double* lpShellValue, BOOL* lpNoHitFlag);BOOL ftrTrace (HFTRUN hftr, BOOL TraceOn);

Integer Functions

BOOL ftrSetCodeValue (HFTRUN hftr, FTRIOI ioIndex, FUZZY CodeValue);BOOL ftrGetCodeValue (HFTRUN hftr, FTRIOI ioIndex, LPFUZZY lpShellValue, BOOL* lpNoHitFlag);

Advanced Users Functions

UINT ftrGetInfo (HFTRUN hftr, UINT InfoTopic);BOOL ftrGetIONameByIndex(HFTRUN hftr, FTRIOI ioIndex, UINT ioNameBufSize, LPSTR lpIOName);BOOL ftrGetIORange (HFTRUN hftr, FTRIOI ioIndex, double* lpMinValue, double* lpMaxValue);

Usage ofStandard Functions Call ftrOpen to load a *.FTR file in the initialization phase of your

application. You get a specific project handle for this file. This project handleand an i/o-index must be used to perform i/o with the fuzzy system.Call ftrSetShellValue to set the input values of the fuzzy system.Call ftrGetShellValue to get the output values of the fuzzy system.Call ftrClose to free the resources locked by the fuzzy logic system, whenyou terminate your application.

Example The following ANSI C example opens a FTRUN project that supports the datatype double and performs fuzzy computations in a loop. The FTRUN project isclosed after the computation loop has been terminated.

Page 207: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

207

#include <windows.h>#include "ftrun.h"int WINAPI WinMain (HANDLE hInst, HANDLE PrevInstance, LPSTR CmdParam, int CmdShow){ HFTRUN hMyFtr; //FTRUN project handle FTRIOI ioiInA = 0, ioiInB = 1, ioiOutC = 2; //variable identification indices double InA = 42.0, InB = 3.1415, OutC; //project variables BOOL Continue, ok; Continue = ok = TRUE; //FTRUN init ok &= ftrOpen(hInst, "c:\\myprjs\\mysample.ftr", &hMyFtr); if (ok) { while (ok && Continue) { //FTRUN Computations ok &= ftrSetShellValue(hMyFtr, ioiInA, InA); ok &= ftrSetShellValue(hMyFtr, ioiInB, InB); ok &= ftrGetShellValue(hMyFtr, ioiOutC, &OutC, NULL); Continue = FALSE; } //FTRUN exit ftrClose(hMyFtr); }return ok;}

6.1.2.2. FTRUN Integration Using Software Development Tools

FTRUN is delivered with interfaces for the mostly used programming languages,such as C, Pascal and Basic. Please use a similar approach for other softwaretools with a DLL interface. If you have built a client application, you have tomake sure that the application has access to the FTRUN DLLs. The fuzzyTECHSetup installs the FTRUN DLLs in the MS Windows system directory,guaranteeing thus the access to both DLLs for every application. Alternatively,you may copy the DLLs either into the directory from which your application isstarted or into the current working directory.

Borland Delphi The directory …\RUNTIME\FTRUN\DELPHI contains the FTRUN interfaceand a integration sample for Borland Delphi. Please add the unit FTRUN32.PASto your project. This unit contains the function interface of FTRUN32.DLL inPascal syntax.

Microsoft Visual Basicand VBA The directory …\RUNTIME\FTRUN\VB contains the FTRUN interface and a

integration sample for Visual Basic. Please add the module FTRUN32.BAS toyour project. This module contains the function interface of FTRUN32.DLL in

Page 208: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

208

Visual Basic syntax. Use the same approach for VBA (Visual Basic forApplications), e.g. in MS Access or MS Excel.

Microsoft Visual C 32 Bit The directory …\RUNTIME\FTRUN\C contains the FTRUN interfaces for the32 bit C compiler of Microsoft. The header file …\INCLUDE\FTRUN.H exportsthe functions and data types for FTRUN32.DLL. Please link the file…\LIB\FTRUN32.LIB to your project.

Microsoft Visual C 16 Bit The directory …\RUNTIME\FTRUN\C contains the FTRUN interfaces and aintegration sample for the 16 bit C compiler of Microsoft (Vs. 1.52). The headerfile INCLUDE\FTRUN.H exports the functions and data types for FTRUN.DLL.Please link the file LIB\FTRUN.LIB to your project.

Wrapper-Classes:Overview The fuzzyTECH code generator for *.FTR files is able to generate additional files

containing a so-called wrapper class for either Visual C++, Visual Basic orVBA. The programming interface of the wrapper class are methods andproperties matching the very special fuzzy system the class was generated for.The class “hides” the more general FTRUN-API. Developers preferring objectoriented programming may prefer this approach. The class module does notcontain any data but only some calling interfaces to the FTRUN-API, i.e.: If youmodify the fuzzy system, you must exchange the class module and re-compileyour application in those cases only, when the number or data type of the i/ovariables has changed. If you change rules our membership functions only, it issufficient to generate a new *.FTR file and to restart the application afterwards.

Wrapper Classes forVisual Basic and VBA The fuzzyTECH code generator for *.FTR files is able to generate a so-called

class module with the file extension *.CLS. Add this class module to your VisualBasic or VBA project. Take care about the difference between a class moduleand a standard module! The class module exports a special data type for thefuzzy system starting with the prefix Ftr and ending with the name of the fuzzysystem, e.g. FtrTraffic or FtrCrane. You may declare variables of this datatype. Use the properties and methods of those variables to access the i/ovariables of the fuzzy system.

Wrapper Classes forVisual C++ The fuzzyTECH code generator for *.FTR files is able to generate a C++ Class.

The two additional files for this class are built from the following scheme:Ftr*.cpp and Ftr*.h. Add the class to your Visual C++ project. The classexports a special data type for the fuzzy system starting with the Prefix CFtr andending with the name of the fuzzy system, e.g. CFtrTraffic or CFtrCrane.You may declare variables of this data type. Use the properties and methods ofthose variables to access the i/o variables of the fuzzy system.

Page 209: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

209

6.1.2.3. FTRUN Integration in Standard Software

FTRUN can directly be tied into popular standard software products, such assimulation software packages, visualization software, process control software,soft-PLC software, and data acquisition packages.

The fuzzyTECH Setup installs all FTRUN based plug-in interfaces that areavailable for your fuzzyTECH Edition in the ..\RUNTIME\FTRUN\..subdirectory of your fuzzyTECH installation.

6.1.2.4. FTRUN Configuration

Initialization Files FTRUN configures itself with the settings in the initialization files FTRUN.INIor FTRUN32.INI. These files are located in the Windows directory, i.e.C:\WINDOWS. You may use any editor to change the initialization files.FTRUN creates a new initialization file with default settings, if the initializationfile does not exist or contains incorrect settings. The following features ofFTRUN can be configured:

1. The appearance of the FTRUN information window: It can be opened eitherin standard size or as icon.

2. Error Messages: FTRUN displays error messages if incorrect functionparameters are detected. This may be useful during the debugging phase ofyour application. Afterwards this option can be turned off.

3. Configuration of the Online Module• Communication Channel: Choose between:

- DDE- TCP/IP- IPX/SPX- Serial Interface- Shared File System

• Settings of the Communication Channels• Time interval between the calls to the Online Module

Please refer to the Windows help system RUNTIME\FTRUN\FTRUN.HLP formore details about the sections, entries and values in the initialization file.

Example[FTRUN]INFOWINDOW=1COMMCHANNEL=DDEONLINETICK=55QUIET=0

Page 210: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

210

[SERIAL]COM=1BAUD=19200

[SHAREDFILESYSTEM]SFSDIR=C:\TEMP\

[IPX]SOCKETADDRESS=2FFF

6.1.3. Hardware Specific Code

Hardware specific code generators are only supported by the fuzzyTECH MCUEditions and the fuzzyTECH IA Editions. Please refer to the subsection thatcorresponds to your edition.

6.1.3.1. MCU-ST6 Edition

The fuzzyTECH MCU-ST6 Edition uses a specialized library, the fuzzyTECHkernel FUZZYLIB.ST6. Since this kernel contains highly optimized assemblerfunctions, the generated code is efficient and compact enough to be implementedon an ST6 device.

Compatibility The fuzzyTECH MCU-ST6 Edition supports all ST62xx and ST63xx devices ofthe ST6 family.

Integration You need an ST6 assembler to integrate the fuzzy system. Inform recommendsusing the SGS-Thomson AST6.EXE assembler. You may also use an In-CircuitEmulator (ICE) for testing.

fuzzyTECH Kernel The fuzzyTECH MCU-ST6 Edition’s assembler code generator uses afuzzyTECH kernel that contains all fuzzy logic engine modules. The kernel is ahighly optimized assembler library.

Figure 145 illustrates the integration structure of the fuzzy logic system. Theuser’s system code with all periphery code, plus pre- and post processing ofinput and output data are all contained in the USER.ST6 source code file. Thiscode calls the fuzzy logic system as an assembler function contained inMYPROJ.ST6. MYPROJ.ST6 is generated by the fuzzyTECH MCU-ST6 Editionfrom MYPROJ.FTL. The source code in MYPROJ.ST6 uses the fuzzy inferenceengine modules contained in the kernel FUZZYLIB.ST6.

Page 211: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

211

Figure 145: Integration of the Fuzzy Logic System

Files The following files are necessary to integrate the fuzzy logic system with yourcode:

FUZZYLIB.ST6 The fuzzyTECH kernel for the ST6 Microcontroller family.This kernel contains modules for fuzzification,defuzzification and rule inference. The FUZZYLIB.ST6library file comes with the fuzzyTECH MCU-ST6 Editionand is located in the …\RUNTIME\ST6\LIB\SRCsubdirectory. If you are encountering any compatibilityproblems linking the kernel using linkers other than SGSThomson LST6 Version 3.0, please contact SGS-Thomson.

MYPROJ.ST6 The output file of the MCU-ST6 Edition. You have tocompile this file using a ST6 assembler, such asAST6.EXE. For example, type:AST6 -l -o MYPROJ.ST6to generate the file MYPROJ.OBJ.

MYPROJ.INC A file also generated by the MCU-ST6 Edition.MYPROJ.INC contains public variable definitions forfuzzy logic system functions. You have to include this filein USER.ST6.

USER.ST6 Your main program that contains all code of the pre- andpost processing of input and output data. Compile this fileusing an ST6 assembler, such as the AST6. For example,type: AST6 -l -o USER.ST6to generate the file USER.OBJ.

Build Procedure An example of the required building procedure is contained in the fileBUILD.BAT, contained in the …\RUNTIME\ST6\SAMPLES\MYPROJsubdirectory.

RAM Allocation The RAM segment for the fuzzy engine is automatically located for the labelftstart. The RAM segments can be moved in the entire, available addressrange by assigning a higher value to ftstart. Verify that the used RAM segmentdoes not exceed the address range.

Page 212: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

212

Calling the Fuzzy System Before the fuzzy system can be called-up from your main program, theinitialization routine must be called once:

call initmyproj

Example First, the input variables of the fuzzy system have to be assigned within thecontrol loop. For example, the values of the two input variables "Angle" and"Distance" would be assigned in the following way:

ldi lv0_Angle, 020hldi lv1_Distance, 080h

After reading in the input values, the fuzzy system can be executed by calling:

call myproj

After execution is completed, two variables have been assigned a value: theresult of the computation (output of the fuzzy logic system) and a state variable.Note, due to the limited internal RAM, the MCU-ST6 Edition only allows for 1output variable. In the example, the name of the output variable is:

lv2_Power

Return Value The state variable invalidflags indicates whether a rule has fired for thecurrent combination of input variables. The name for this state variable is fix. Ifinvalidflags is 0, the output value is the result of at least one of the definedfuzzy rules; if invalidflags is 1, the default value specified in the VariablesProperties: Base dialog is used as the output value.

Example The following shows an example of how to call the code generated by thefuzzyTECH MCU-ST6 Edition from within your program. If you design yourown project, you have to replace the string ’myproj’ with your project name, bothin the file names and in the function calls.

Example USER.ST6:

...

call initmyproj

...

loop:

...

ldi lv0_Angle, 020h

ldi lv1_Distance, 080h

call myproj

ld a, lv2_Power

...

ld a, invalidflags

Page 213: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

213

jnz no_fire

...

jp loop

no_fire:

...

jp loop

6.1.3.2. MCU-MP Edition

The fuzzyTECH MCU-MP Edition uses assembler routines as the fuzzyTECHkernel. These routines are delivered as source code. Since the kernel containsassembler functions highly optimized with regard to speed and size, thegenerated code is efficient and compact. In order to achieve maximumperformance on different processors, the MCU-MP Edition supports the 16C5x,16Cxx, and 17Cxx families with an 8-bit assembler library. In addition, a 16-bitlibrary is available for the 16Cxx and 17Cxx families. Banking is supported forall families. Due to the diverse capabilities of the devices, different functions areenabled by the MCU-MP Edition:

Device Resolutions Flag: Banking Flag: Family16C5x 8 bit 0 016C5x 8 bit 1 016Cxx 8 bit / 16 bit 0 116Cxx 8 bit / 16 bit 1 117Cxx 8 bit / 16 bit 0 217Cxx 8 bit / 16 bit 1 2

The flags „Banking“ and „Family“ are used by the fuzzy kernel routinesinternally, to optimize code and speed for the dedicated processor. They aregenerated by the fuzzyTECH code generator.

Integration With the MCU-MP Edition, you may call (16Cxx, 17Cxx) or include (16C5x)the fuzzy logic routine from assembler code. You need the MPASM assemblerto integrate the fuzzy system with the code of the entire system. You may alsouse an in-circuit emulator (ICE) for testing (optional).

fuzzyTECH Kernel The MCU-MP assembler code generator uses an optimized fuzzyTECH kernelthat contains the fuzzy inference engine modules.

Figure 146 shows the integration of the fuzzy logic system: all peripheryinterfaces and pre- and post processing of input and output data is contained inthe MYMAIN.ASM source code. This source code uses the fuzzy logic systemfunction as an assembler function contained in MYPROJ.ASM.

Page 214: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

214

Figure 146: Integration of the Fuzzy Logic System

Generated Code MYPROJ.ASM is generated by the fuzzyTECH MCU-MP Edition from yourproject stored as MYPROJ.FTL. MYPROJ.ASM uses the fuzzy logic modules.The subdirectories...\RUNTIME\MP16C5x\SAMPLES\MYPROJ,...\RUNTIME\MP16Cxx\SAMPLES\MYPROJ, and...\RUNTIME\MP17Cxx\SAMPLES\MYPROJ8

contain full examples with the project name MYPROJ using Input_1, Input_2 asthe input variables and Output as the output variable. An additional exampleshowing the use of the 16-bit library is located in the subdirectory:…\RUNTIME\MP17Cxx\SAMPLES\MYPROJ16.

Files The files necessary for integrating the fuzzy logic system with your code are:

ASM kernel: This kernel contains configurable modules for fuzzification,defuzzification and rule inference. The completefuzzyTECH kernel for each microcontroller family islocated in the subdirectories:…\RUNTIME\MP16C5x\SRC, or...\RUNTIME\MP16Cxx\SRC, or…\RUNTIME\MP17Cxx\SRC.

MYPROJ.ASM A file generated by the MCU-MP Edition, containing theconfiguration of the current fuzzy system. This file must becalled, included and assembled with the main program.

MYPROJ.VAR A file generated by the MCU-MP Edition, containing thedeclarations of all required variables. The file must beincluded in the user’s main program.

FTPUBDEC.VAR contains public variable definitions for the fuzzy logickernel.

FTPUBDEC.MAC contains public macros for the fuzzy logic kernel.

Page 215: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

215

FTMPxxxx.INC contains restrictions due to the selected controller family. Afile matching to the selected controller family (xxxx = 165xor 16xx or 17xx) must be located in the source directory.

MYMAIN.ASM This file contains your main program in assembler code and(see BUILD.BAT for MYPROJ) and has to be assembledby using the MPASM assembler.

Build Procedure Follow these steps in order to generate a fuzzy logic system and to integrate itwith your source code:1. Select the desired resolution (8- or 16-bit) in the Project Options: Global

dialog.2. Generate MYPROJ.ASM by selecting from the Tools pull down menu bar of

the fuzzyTECH MCU-MP Edition the option“Compile to/16C5x” or “Compile to/16C5x BANKED RAM” or“Compile to/16Cxx” or “Compile to/16Cxx BANKED RAM”“Compile to/17Cxx” or “Compile to/17Cxx BANKED RAM”,.

3. Write your main program MYMAIN.ASM, which includes and calls thefuzzy logic function and includes the generated project like shown in thesample.

4. Compile your main program file, for example by typing:MPASM MYMAIN.ASM.

BUILD.BAT Each of these building steps are contained in the BUILD.BAT file located in thesubdirectories :...\RUNTIME\MP16C5x\SAMPLES\MYPROJ,...\RUNTIME\MP16Cxx\SAMPLES\MYPROJ, and...\RUNTIME\MP17Cxx\SAMPLES\MYPROJ8

An example using the 16-bit kernel is found in the subdirectory

...\RUNTIME\MP17Cxx\SAMPLES\MYPROJ16.Using theFuzzy System The code in the file MYPROJ.ASM, generated by fuzzyTECH, provides two

assembler functions. One contains the entire fuzzy logic computation and theother an initialization routine:

myprojinitmyproj

The initmyproj function initializes the internal variables of the kernel andhas to be executed once before the fuzzy logic system function can be used.

TemporarilyUsed Variables The fuzzy kernel uses temporary variables of type BYTE. These variables can

also be used temporarily for other code when the fuzzy system is not computing.

Page 216: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

216

The variables are named VAR1, VAR2, ... The number of internal variables isdepicted in Section 9.4. All variables are declared in FTPUBDEC.VAR.

Banked RAM For the banked devices, the support of the bank RAM is completely managed bykernel routines. The usage of the kernel is identical to unbanked devices. If thefuzzy system fits completely on one RAM page, banking is not required and thekernel switches automatically during assembler time to the faster unbanked code.The start address of the fuzzy task must be located on the first page.

Paging Code Tables The tables generated for the 16C5x family must fit completely on one code pagebecause of table access via "RETLW".

RAM Allocation User defined variables can be appended to the RAM allocation of the fuzzysystem. For this purpose, the CBLOCK directive can be located directly afterthe RAM allocation for the fuzzy system, as shown in the given examples. Thisallows for dynamic RAM allocation by the user.

Limitations Due to the given capabilities of the supported devices, size limitations of thefuzzy systems to be created exist.

RAM: A RAM check for the RAM required by the fuzzy system isimplemented in the generated code. If the designed system requiresmore RAM than available in the device, the assembler will result in anerror. The required RAM can be reduced by using fewer terms or fewervariables.

ROM: The knowledge base of the fuzzy system is located in the ROM area; forthe device family 16C5x it starts from address 000. These devices usean RETLW instruction for table access. Thus, the system will use thefirst page. Note, the generated tables, the inference routine and thedefuzzification routine must fit on this first page. Therefore, thefuzzyTECH MP Edition uses only minimum aggregation, CoMdefuzzification and does not support FAM rules for the processors ofthe 5x family. If the system exceeds the first page, an error occurs atassembler time. In this case, fewer rules, fewer terms or variables mustbe implemented. Note that rules require the most ROM space.

Return Value The fuzzy logic system returns a value in INVALIDFLAGS. Each bit inINVALIDFLAGS represents one output variable, starting with the lowest orderbit and assigned in sequence to the output variables in alphanumeric order. Azero bit for a variable indicates that for this output variable, at least one rulefired. Hence, a return value of zero indicates that for every output variable atleast one rule fired. INVALIDFLAGS represents an 8-bit integer for thefuzzyTECH MCU-MP Edition.

Page 217: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

217

Example Return Value Consider a fuzzy logic system with the two output variables: A_Out and B_Out.For this system, the bits 1 and 0 of the return variable correspond to variableA_Out and B_Out. All higher bits are not used. Evaluated in a specific controlcycle, a return value of 2 now indicates that no rule for variable A-out fired andthat B_Out was evaluated by at least one of the defined fuzzy rules. A returnvalue of 0 would indicate that at least one rule for every output variable did fire.

8-bitvalue

INVALIDFLAGSrv=2

Variables inOutput Interface

OutputValue

MSB: 7 0 not used -6 0 not used -5 0 not used -4 0 not used -3 0 not used -2 0 not used -1 1 A_Out default-value

LSB: 0 0 B_Out calculated

Figure 147: Return Flags of a Return Value rv=2 For a System With Two OutputInterfaces

Example The following is an example of how to use the BUILD.BAT procedure for anassembler code main program. If you design your own project, you have toreplace 'myproj' with your project name, both in file names and in function calls.In this example, MYPROJ.FTL has two inputs and one output.

Page 218: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

218

Example MYMAIN.ASM for 16C5x (8-bit):;–----------------------------------------; USER MAIN FILE;------------------------------------------... INCLUDE "MYPROJ.VAR"... ORG CODE_STARTMYMAIN CALL INITMYPROJ...LOOP... MOVLW 0x00 MOVWF LV0_MYIN1 MOVLW 0xA0 MOVWF LV1_MYIN2... INCLUDE "MYPROJ.ASM" MOVF INVALIDFLAGS,W BTFSS _Z GOTO NO_FIRE...;FIRE MOVF LV2_MYOUT1,W... GOTO LOOPNO_FIRE ;CALL DEFAULTHANDLING GOTO LOOP;------------------------------------------; RESET VECTOR;------------------------------------------ ORG RESET_VECTOR GOTO MYMAIN

END

Page 219: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

219

Example MYMAIN.ASM for 16Cxx (8-bit):;------------------------------------------; USER MAIN FILE;------------------------------------------... INCLUDE "MYPROJ.VAR"... ORG CODE_STARTMYMAIN CALL INITMYPROJ...LOOP... MOVLW 0x00 MOVWF LV0_MYIN1 MOVLW 0xA0 MOVWF LV1_MYIN2... CALL MYPROJ MOVF INVALIDFLAGS,W BTFSS _Z GOTO NO_FIRE...;FIRE MOVF LV2_MYOUT1,W... GOTO LOOPNO_FIRE ;CALL DEFAULTHANDLING GOTO LOOP

INCLUDE "MYPROJ.ASM"

;------------------------------------------; RESET VECTOR;------------------------------------------ ORG RESET_VECTOR GOTO MYMAIN

END

Page 220: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

220

Example MYMAIN.ASM for 17Cxx (8-bit):;------------------------------------------; USER MAIN FILE;------------------------------------------... INCLUDE "MYPROJ.VAR"... ORG CODE_STARTMYMAIN CALL INITMYPROJ...LOOP... MOVLW 0x00 MOVWF LV0_MYIN1 MOVLW 0xA0 MOVWF LV1_MYIN2... CALL MYPROJ TSTFSZ INVALIDFLAGS GOTO NO_FIRE...;FIRE MOVFP LV2_MYOUT1,WREG... GOTO LOOPNO_FIRE ;CALL DEFAULTHANDLING GOTO LOOP

INCLUDE "MYPROJ.ASM"

;------------------------------------------; RESET VECTOR;------------------------------------------ ORG RESET_VECTOR GOTO MYMAIN

END

Page 221: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

221

Example MYMAIN.ASM for 17Cxx (16-bit):;------------------------------------------; USER MAIN FILE;------------------------------------------... INCLUDE "MYPROJ16.VAR" ORDER EQU MSB_LSB ;compatibility... ORG CODE_STARTMYMAIN CALL INITMYPROJ16...LOOP... MOVLW 0x00 MOVWF LV0_MYIN1 MOVLW 0x00 MOVWF LV0_MYIN1_LO

MOVLW 0xA0 MOVWF LV1_MYIN2 MOVLW 0xCD MOVWF LV1_MYIN2_LO... CALL MYPROJ16 TSTFSZ INVALIDFLAGS GOTO NO_FIRE...;FIRE MOVFP LV2_MYOUT1,Wreg MOVFP LV2_MYOUT1_LO,Wreg... GOTO LOOPNO_FIRE ;CALL DEFAULTHANDLING GOTO LOOP INCLUDE "MYPROJ16.ASM";------------------------------------------; RESET VECTOR;------------------------------------------ ORG RESET_VECTOR GOTO MYMAIN END

Page 222: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

222

6.1.3.3. MCU-51 Edition

The fuzzyTECH MCU-51 Edition includes the RTRCD module and generatesassembler source code for the entire 8051 family. You need thecompiler/assembler tool kit from BSO/TASKING, IAR, INTEL,KEIL/FRANKLIN or PLC to build an application for this family. Please contactInform’s technical support for support of other tool kits.

Overview An implementation of a fuzzy runtime system consists of at least three up to fourmodules:1. The fuzzy library FTxyz.LIB that stores the RTRCD module and the basic

fuzzy algorithms, which are independent from any fuzzy system.2. One or more fuzzy system modules generated by the assembler code

generator of fuzzyTECH. Each module contains code and data for its specificfuzzy logic system.

3. One or more of your own software modules either in C or assemblerlanguage for implementing the application that uses the fuzzy logic system.

4. A communication module that supports the serial interface of the 8051. Notethat this applies only, if you use the RTRCD option.

Figure 148 illustrates the hierarchy of these modules:

User Modules (*.C or *.A51)

FuzzyModule 1

*.A51

FuzzyModule 2

*.A51

. . . FuzzyModule N

*.A51

Fuzzy LibraryFTxyz.LIB:

Fuzzy Library FTxyz.LIB: RTRCD Module

Fuzzy Algorithms CommunicationModule:COMM.C

Figure 148: Fuzzy Runtime Systems and RTRCD for the 8051 family

6.1.3.3.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highlyoptimized for both speed and size. The location for the libraries isRUNTIME/51/LIB. Please refer to the table below to find the library thatmatches with your environment.

If you are using a different tool kit, please use general C sources.

Page 223: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

223

Library Name CPU MemoryMode

Tool KitManufacturer

Tool KitReleaseNumber

FT51I.LIB 8051 Intel 2.3FT51K.LIB 8051 Keil/Franklin 3.2 up to 4FT51K5.LIB 8051 Keil/Franklin 5.0 or moreFT517K.LIB 80517 Keil/Franklin 3.2 up to 4FT517K5.LIB 80517 Keil/Franklin 5.0 or moreFT251KS.LIB 80251 source Keil/Franklin 1.02 or moreFT251KB.LIB 80251 binary Keil/Franklin 1.02 or moreFT51TK.LIB 8051 BSO/Tasking 3.0 or moreFT517.LIB 80517 BSO/Tasking 3.0 or moreFT251TKS.LIB 80251 source BSO/Tasking 1.0 or moreFT251TKB.LIB 80251 binary BSO/Tasking 1.0 or moreFT51IAR.LIB 8051 IAR 5.12 or moreFT517IAR.LIB 80517 IAR 5.12 or moreFT251PS.LIB 80251 source PLC 2.01 or moreFT251PB.LIB 80251 binary PLC 2.01 or more

Note that fuzzyTECH does not support the RTRCD functionality for the tool kitof Intel.

6.1.3.3.2. RTRCD Communication Module

Most code of the RTRCD module is part of the fuzzy library. This does notinclude the communication module that access the serial interface. It is deliveredin C source code to allow changes of the settings. Please refer to the directory…\RUNTIME\51\LIB\SRC .

RS232 The routines handling the communication via the RS232 (V24) port are in aseparate module COMM.C.

Note that COMM.C uses interrupts both for transmitting and receiving data. Youmay have to change the interrupt priority, if you use more interrupts. Note thatthe declarations of the functions and variables defined in COMM.C are fixedinterfaces of the fuzzy library. Do not change these definitions.

6.1.3.3.3. Generating and Using the Assembler Module

Generate theAssembler Module This section shows how the assembler modules generated by fuzzyTECH can be

integrated into your own software modules. First select your tool kitManufacturer (BSO/TASKING, IAR, Intel, KEIL/Franklin or PLC) from themenu “Tools/MCU-Tool Kit” in the fuzzyTECH Shell. Select “8051...” or“80251...” from the “Tools/Compile to...” menu in the fuzzyTECH Shell to

Page 224: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

224

generate the current fuzzy logic project as assembler code. The code generatorcreates two files with the same name as the fuzzy system, one with the fileextension *.A51, the other one with the extension *.H. The *.A51 filecontains code, data and the external symbol definitions of the fuzzy logic system.The *.H file contains the export interface of this module for ANSI C language.Note that the name of each exported function or variable ends with the name ofthe fuzzy logic system. The generated modules use the project independent fuzzylogic algorithms of the fuzzy library.

Integration from C code The following enumeration gives an overview about the steps necessary tointegrate a fuzzy system module into the source code of your software module(s)in C language. For details please refer to the files …\RUNTIME\51\SAMPLES\MYPROJ51\MYMAIN.C or Example 7 at the end of this section.

1. Include C header files• Include the export header file(s) of the fuzzy system module(s).• Include the export header file of the RTRCD module.

2. Initialization during startup of your application• Initialize the RTRCD module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. Call the RTRCD communication (optional).5. Trace control allows you to start or stop the trace process with your own

logical expressions (only with RTRCD).Integration fromAssembler Code How to integrate a fuzzy system module into the source code of your software

module(s) in assembler language, please refer to the following files in thedirectory RUNTIME\51\SAMPLES\MYPROJ51.

MYMAINS.I CPU: 51 and 517; tool kit manufacturer: IntelMYMAIN.IAR CPU: 51 and 517; tool kit manufacturer: IARMYMAIN.K CPU: 51, 517, 251; tool kit manufacturer: KEIL/FRANKLINMYMAINS.P2 CPU: 251; tool kit manufacturer: PLCMYMAIN.TK CPU: 51 and 517; tool kit manufacturer: BSO/TASKINGMYMAIN.2TK CPU: 251; tool kit manufacturer: BSO/TASKING

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of RTRCD module have additionally to include the file RTRCD.H,which is located at RUNTIME\51\INCLUDE . It is recommended to include thefuzzy systems before the RTRCD.H file.

Page 225: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

225

Initialization Some initialization functions must be called only once during the startup of theapplication. Users of the RTRCD module have first to initialize the RTRCDmodule with the function initrtrcd() for C source code. It is important todo this before initializing any fuzzy system modules. Afterwards each fuzzysystem module must be initialized. The initialization function follows thescheme:

void init<Module Name>(void);

Fuzzy Computation:Parameter Passing The i/o-Interface to the fuzzy module uses global variables. These variables have

the data type FUZZY, which is 8 bit unsigned char. Their value range is definedby the code values in the Variables Properties: Base dialog. The *.A51 or the*.C file exports all input and output variables of the fuzzy logic system with thecorrect data type automatically. The *.H file contains the export interface to allinput and output variables of the fuzzy logic system for ANSI C language.Additionally the value ranges are printed as comments in the file with theextension *.H. The names of the exported variables are constant. They arederived from the names you have used in fuzzyTECH and follow this scheme forC source code:

<Variable Name>_<Module Name><Term Name>_<Variable Name>_<Module Name>

Fuzzy Computation:Function Prototype The function name for the fuzzy computation is the same as given for the fuzzy

logic system itself. For C language the function prototype follows the scheme:

void <Module Name>(void);Fuzzy Computation:Return Value The fuzzy logic system returns a value in INVALIDFLAGS. Each bit in

INVALIDFLAGS represents one output variable, starting with the lowest orderbit and assigned in sequence to the output variables in alphanumeric order. Azero bit for a variable indicates that for this output variable at least one rule fired.Hence, a return value of zero indicates that for every output variable, at least onerule fired. INVALIDFLAGS represents an 8-bit integer for the fuzzyTECHMCU-51 Edition.

ExampleReturn Value Consider a fuzzy logic system with the 2 output variables A_Out and B_Out. For

this system, the bits 1 and 0 of the return value correspond to variable A_Out andB_Out. All higher order bits are not used. A return value of 2 evaluated in aspecific control cycle now indicates that no rule for variable A_Out fired, andthat B_Out was evaluated by at least one of the defined fuzzy rules. A returnvalue of 0 would indicate that at least one rule for every output variable did fire.

Page 226: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

226

8-bitvalue

INVALIDFLAGSrv=2

Output Variables OutputValue

MSB: 7 0 not used -6 0 not used -5 0 not used -4 0 not used -3 0 not used -2 0 not used -1 1 A_Out default-value

LSB: 0 0 B_Out calculated

Figure 149: Return Flags of a Return Value 2 for a System With Two OutputInterfaces.

RTRCD Communication Add the following call to the RTRCD module in your C source code to supportthe communication mechanism.

#ifdef FT_RTRCDrtrcd(); /* call the RTRCD module */#endif

Note that you must call this function regularly and as often as necessary.Otherwise the RTRCD communication will run into a time-out. For example, ifyour application has a kind of main control loop, this would be the best place toinsert the function call.

Note that the function rtrcd()should not interrupt the computation of thefuzzy systems. This is important, in case you use a timer interrupt to call thisfunction.

Note that the function rtrcd()is programmed in such a way that it consumesas little time as possible. During an active online connection it copies themaximum number of 76 bytes and sends an answer to fuzzyTECH before itreturns. If no active online connection is running, the function returnsimmediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate codesupporting a trace buffer that records the input and output values of the fuzzysystem in real-time in your application. During an online connection the traceprocess is controlled by the Trace Control dialog. The dialog offers an option tostart or stop the trace process by external trigger events. Therefore the generatedcode exports two additional functions that control the trace process. Call thesefunctions in your source code to start or stop the trace at arbitrary logicalconditions.

Page 227: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

227

Note that once the Trace process has been started, multiple calls of the followingstart function are ignored. The same applies to the stop function.

void StartTrace<Module Name>(void);void StopTrace<Module Name>(void);

Code Sample The following listing of pseudo C code illustrates the usage of the generatedassembler module. It uses two fuzzy systems with the names MYPROJ1.FTLand MYPROJ2.FTL and supports the RTRCD module.

/* Example 7: MYMAIN.C RTRCD-51 */

/* real time remote cross debugging on multiple fuzzy projects (PIO) */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes and defs */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

Page 228: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

228

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_RTRCD

if(...) /* your logical condition */

StartTracemyproj2(); /* start trace process */

else

StopTracemyproj2(); /* stop trace process */

#endif

... /*...more outputs */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

6.1.3.3.4. Building an Executable File

Build Steps This section describes the compiling, assembling and linking process of allmodules that are part of the fuzzy runtime system. This section is a rather generaldescription and not a step-by-step guidance. It may be necessary to browse yourtool kit manual to realize the building steps. Please follow the enumerated stepsbelow if you implement a new application. If you add a fuzzy runtime system toan existing application please proceed analogously.

1. Verify, whether your compiler/assembler tool kit for the 8051 or 80251family is installed correctly.

2. Create a new project or makefile for your application.• Add your software module(s).• Add the fuzzy module(s).• Add the correct fuzzy library FTxyz.LIB with x is the family 8051, 80517 or 80251, y is the tool kit manufacturer: Intel, KEIL/FRANKLIN, BSO/TASKING,

IAR or PLC, z is the memory mode (binary/source) or the tool kit version 5 (only KEIL/

FRANKLIN).• For RTRCD add the communication module COMM.C with the included

file RUNTIME\51\INCLUDE\COMM.H• Add the directory RUNTIME\51\LIB to the compiler/assembler path of

your tool kit for the chosen library.• Add the directory RUNTIME\51\LIB\SRC to the compiler/assembler

path of your tool kit for the communication module.

Page 229: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

229

3. Build the application.• Compile/Assemble your own module(s).• Assemble the fuzzy module(s).• Assemble the communication module (RTRCD only).• Assemble the startup routine delivered with your tool kit or fuzzyTECH.• Locate all sections in your or the delivered linking directives.• Link all object files and libraries.• Convert to Intel HEX Format

4. Execute the application.

For more details, please refer to the samples in the next section.

Samples All building steps are summarized in the batch files:BUILDC.BAT for your software module, written in ANSI C, andBUILDASM.BAT for your software module, written in assembler.

For the tool kit of PLC, please refer to the file:BUILDPLC.TXT with all necessary building steps.

You find this files in the directory …\RUNTIME\51\SAMPLES\MYPROJ51.Generate the appropriate controller for your tool kit to use these batches.Please use a copy of these files as basis for your own application. Note that thesample can not give appropriate settings for your locator call. You have to adaptit due to your hardware. Please refer to the manual of your tool kit for moredetails about section locating.

TemporaryUsed Variables The fuzzy kernel uses temporary variables of the type BYTE. These variables

can also be used for other code. Therefore, an external declaration of thevariables must be accomplished. In the assembler, the variables are named_VAR1, _VAR2, etc. and the syntax of the declaration is (e.g. for _VAR1):

EXTRN DATA (_VAR1)

Coding in C, the variable names are var1, var2, ... the declaration syntax is (forexample, for var1):

extern BYTE data var1;

The number of internal variables available for sharing in the MCU-51 Edition isdepicted in Section 9.4.

Page 230: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

230

6.1.3.4. MCU-374 Edition

The fuzzyTECH MCU-374 Edition uses a specialized library, the fuzzyTECHkernel. Since this kernel contains highly optimized assembler functions, thegenerated code is much more efficient and compact compared to the C codelibrary described in Section 4.2. To achieve maximum performance withdifferent devices and compiler tool kits, the following kernels are delivered withthe MCU-374 Edition:

FT38.LIB Supports members of the 374 family with internal MUL / DIVinstructions for Mitsubishi tool kit.

FT38IAR.LIB Supports members of the 374 family with internal MUL / DIVinstructions for IAR tool kit.

Compatibility The fuzzyTECH MCU-374 Edition supports the entire Mitsubishi 374microcontroller family with internal MUL / DIV instructions.

Integration To integrate the fuzzy system with the code of the entire system, you need anAssembler. You may also use an in-circuit emulator (ICE) for test andintegration (optional). The assembler libraries FT38.LIB and FT38IAR.LIB areready compiled and archived. You do not need to create these libraries.

fuzzyTECH Kernel The MCU-374 code generator uses a fuzzyTECH kernel, containing the fuzzylogic engine modules. The kernel is a highly optimized assembler library. Figure150 shows the integration of the fuzzy logic system: all periphery interfaces, pre-and post processing of input and output data is contained in the MYMAIN.A74or MYMAIN.A31 source code. This source code calls the fuzzy logic systemfunction as an assembler function in MYPROJ.A74 for Mitsubishi orMYPROJ.A31 for IAR.

Figure 150: Integration of the Fuzzy Logic System

Generated Code MYPROJ.Axx is generated by the fuzzyTECH MCU-374 Edition from yourproject stored as MYPROJ.FTL. MYPROJ.Axx uses the fuzzy logic modulescontained in the kernel FT374.LIB. The file BUILD.BAT is located in the

Page 231: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

231

subdirectory ..\RUNTIME\374\SAMPLES\MYPROJ74\ contains a full examplewith the project name CRANE using Angle and Distance as input variables andPower as output. To support the appropriate tool kit optimal, you have to choosethe tool kit in the menu “Tools/MCU Toolkit” and generate the controller in themenu “Tools/Compile to/374...” for your tool kit. The code generator generatesan file with the extension *.A74 for the Mitsubishi tool kit and *.A31 for theIAR tool kit.

Files The files you need to integrate the fuzzy logic system with your code are:

FT38x.LIB The fuzzyTECH kernel for the 374 microcontroller family. Thiskernel contains configurable modules for fuzzification,defuzzification and rule inference. The FT38x.LIB files arelocated in the ..\RUNTIME\374\LIB\ subdirectory.

MYPROJ.Axx The file generated by the fuzzyTECH MCU-374 Edition. Youhave to assemble this file using an assembler for the 374microcontrollers to generate the file MYPROJ.OBJ.

MYPROJ.H Also generated by the MCU-374 Edition code generator.MYPROJ.H contains the function prototypes for the fuzzy logicfunctions and the inputs and outputs. If your main program is inC, you can include this file in your source file.

MYMAIN.AxxThis file contains an sample main program in assembler code.This code calls the fuzzy logic system as an assembler codefunction (see BUILD.BAT for CRANE project).

Alternative MYMAIN.C This file contains an sample main program in C code.

Build Procedure To generate a fuzzy logic system and to integrate it with your source code,follow these steps:1. Write your main program MYMAIN.C or MYMAIN.Axx that calls the fuzzy

logic function contained in the MYPROJ.Axx file. If your main program is inC, you have to declare the fuzzy functions and interfaces. This can be doneby including the generated file MYPROJ.H in your main program.

2. Generate the file MYPROJ.A74 for Mitsubishi or MYPROJ.A31 for IARtool kit by selecting [Compile to → 374...] from the [Tools] pull down menu.

3. Compile your main program file, for example by typing:ASM374 MYMAIN.Axx orC740 MYMAIN.C

to generate the file MYMAIN.OBJ.4. Assemble the MYPROJ.Axx file, for example by typing:

ASM374 MYPROJ.Axx to generate the file MYPROJ.OBJ.5. Link all files, for example by typing:

LINK374 MYMAIN MYPROJ FT374.LIB ?PAGE=????

Page 232: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

232

BUILD.BAT All these build steps are prepared in the batch file BUILD.BAT located in thesubdirectory ..\RUNTIME\374\SAMPLES\MYPROJ74\ for your appropriatetool kit.

Debugging withSerial Link A connection with the target system can be established via the serial link debug

feature of fuzzyTECH. An example of how to handle this debug feature is locatedin the subdirectory ..\SERLINK\374\SAMPLES\. The example batch fileBUILD.BAT is prepared for using the Mitsubishi or the IAR tool kit. For detailsconcerning the serial link debugging feature please refer to Section 6.2.3.

RAM Allocation The RAM and ROM segments of the fuzzy engine are automatically located bythe linker. RAM and ROM segments can be moved in the whole availableaddress range by linker commands. 6 bytes scratch RAM at the zero page areused internally by the fuzzy kernel routines. All other RAM, used for the kerneland fuzzy controller, can be freely located.

Calling theFuzzy System The code in the file MYPROJ.Axx, generated by fuzzyTECH, provides two

assembler code functions. One contains the entire fuzzy logic computation, theother an initialization routine:

myproj:initmyproj:

The initmyproj function initializes the internal variables of the kernel andhas to be executed once before the fuzzy logic system function can be used.

The myproj function is the fuzzy controller and can be called every loop. Thefuzzy function starts computing the input vector of the public global variablesand sets the output vector after computation before returning.

Multiple Fuzzy Controller You have to call the init routines of each controller once during initialization.You can call an fuzzy controller in the order you like. The labels which aregenerated for functions and variables are unique and cannot be mixed with otherprojects. The library will only be linked once.

TemporaryUsed Variables The fuzzy kernel uses temporary variables of type BYTE. These variables can

also be used for other code. Therefore, an external declaration of the variablesmust be proceeded. The variables on zero page are named _ZVAR1, _ZVAR2,... and the freely locatable variables are named _VAR1, _VAR2, ... .

The number of internal variables to share of the MCU-374 Edition is depicted inSection 9.4.

Page 233: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

233

Return Value The fuzzy logic function returns a value in variable INVALIDFLAGS. Each bitin INVALIDFLAGS represents one output variable, using the lower significantbits in alphabetic sequence. A zero bit for a variable indicates, that for this outputvariable at least one rule fired. Hence, a return value of zero indicates that forevery output variable at least one rule fired. INVALIDFLAGS represents a 8-bitinteger for the fuzzyTECH MCU-374 Edition.

8-bitvalue

FLAGSrv = 5

Variables inOutput Interface

OutputValue

MSB:7 0 not used -... ... ... ...4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 151: Flags of a return value 5 for a system with four output interfaces (8-bit FLAGS type).

Example Return Value Consider a fuzzy logic system with 4 output variables: A_Out, B_Out, C_Outand D_Out. For this system, the bits 3...0 of the return variable correspond tovariable A_Out .. D_Out. All higher bits are not used. A return value of 5evaluated in a specific control cycle now indicates, that no rule for both thesecond and the forth output variable did fire. A return value of 0 would indicate,that at least one rule for every output variable did fire.

Example Code Integration The following are examples of how to use the BUILD.BAT procedure, both foran assembler and an C code main program. If you design your own project, youhave to make sure, that the label myproj corresponds to the name of yourgenerated project, both in file names and in function calls. MYPROJ.FTL in thisexample has two inputs and two outputs.

Page 234: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

234

Example MYMAIN.A74: (Mitsubishi tool kit)

.EXT _crane

.EXT _initcrane

.EXT _lv0_Angle

.EXT _lv1_Distance

.EXT _lv2_Power

.EXT _invalidflags

...

.SECTION CODEmain:

JSR _initcrane ;One time initialisation...

LOOP:...LDA #$78STA _lv0_Angle ;Setting first inputLDA #$87STA _lv1_Distance ;Setting second input

JSR _crane ;call fuzzy function

LDA _invalidflagsBEQ FIRED ;Did a rule fired ?

;NO_FIRE: ; JSR DEFAULT_HANDLING ;No rule fire case

JMP READY

FIRED:LDA _lv2_Power ;Get computed output

READY:...JMP LOOP

Page 235: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

235

Example MYMAIN.A31: (IAR tool kit)

.EXT _crane

.EXT _initcrane

.EXT _lv0_Angle

.EXT _lv1_Distance

.EXT _lv2_Power

.EXT _invalidflags

...

.SECTION CODEmain:

JSR _initcrane ;One time initialisation...

LOOP:...LDA #$78STA NP:_lv0_Angle ;Setting first inputLDA #$87STA NP:_lv1_Distance ;Setting second input

JSR _crane ;call fuzzy function

LDA NP:_invalidflagsBEQ FIRED ;Did a rule fired ?

;NO_FIRE: ; JSR DEFAULT_HANDLING ;No rule fire case

JMP READY

FIRED:LDA NP:_lv2_Power ;Get computed output

READY:...JMP LOOP

Page 236: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

236

Example MYMAIN.C - Public IO:

#include "myproj.h"

...

void main( void ) {

initcrane(); /* called only once */

...

while( 1 ) {

...

Angle_crane = 210; /* Set first input */

Distance_crane = 30; /* Set second input */

crane(); /* call fuzzy function */

if( invalidflags ) /* Has a rule fired? */

; /*default handling routine();*/else

{

... = Power_crane; /* Get computed output */}

...

}

}

6.1.3.5. MCU-96 Edition

The fuzzyTECH MCU-96 Edition includes the RTRCD module and generates C

source code for the entire Intel MCS®-96 (80x96) family. You need either thecompiler tool kit from BSO/TASKING or INTEL to build an application for thisfamily. Please contact Inform’s technical support for support of other tool kits.

Overview An implementation of a fuzzy runtime system consists of at least three modules:1. The fuzzy library FT96x.LIB, that stores the RTRCD module and the basic

fuzzy algorithms which are independent from any fuzzy system.2. One or more fuzzy system modules generated by the assembler code

generator of fuzzyTECH. Each module contains code and data for its specificfuzzy logic system.

Page 237: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

237

3. One or more of your own software modules either in C or assemblerlanguage for implementing the application, that uses the fuzzy logic system.

4. A communication module that supports the serial interface of the 80x96.Note that this applies only, if you use the RTRCD option.

Figure 152 illustrates the hierarchy of these modules:

User Modules (*.C)

FuzzyModule 1

*.C

FuzzyModule 2

*.C

. . . FuzzyModule N

*.C

Fuzzy LibraryFT96x.LIB:

Fuzzy Library FT96x.LIB: RTRCD Module

Fuzzy Algorithms CommunicationModule:COMM.C

Figure 152: Fuzzy Runtime Systems and RTRCD for 80x96 Family

6.1.3.5.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highlyoptimized for both speed and size. The location for the libraries isRUNTIME/96/LIB. Please refer to the table below to find the library thatmatches with your environment.

Library Name CPU Tool KitManufacturer

Tool Kit ReleaseNumber

FT96.LIB 80x96 INTEL 1.3FT96TK.LIB 80x96 BSO/TASKING 3.0 or more

6.1.3.5.2. RTRCD Communication Module

Most code of the RTRCD module is part of the fuzzy library. This does notinclude the communication module that accesses the RS-232 serial interface. It isdelivered in assembler source code to allow changes of the settings. The filename of the communication module is COMM.C for the serial interface, pleaserefer to the following directory:RUNTIME\96\LIB\SRC

Note that the functions and variables defined in COMM.C are fixed interfaces ofthe fuzzy library. Do not change these definitions.

Page 238: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

238

6.1.3.5.3. Using the Generated C Module

Generate theC Module This section shows how the assembler modules generated by fuzzyTECH can be

integrated into your own software modules. Select “80x96...” from the menu“Tools/Compile to...” in the fuzzyTECH Shell to generate the current fuzzy logicproject as C code. The code generator creates two files with the same name asthe fuzzy system, one with the file extension *.C, the other one with theextension *.H. The *.C file contains code and data of the fuzzy logic system,the *.H file contains the export interface of this module for ANSI C language.Note that the name of each exported function or variable ends with the name ofthe fuzzy logic system. The generated modules use the project independent fuzzylogic algorithms of the fuzzy library.

Integration The following enumeration gives an overview about the steps necessary tointegrate a fuzzy system module into the source code of your software module(s)in C language. For details please refer to Example 7 at the end of this section.1. Include C header files

• Include the export interface(s) of the fuzzy system module(s).• Include the export interface of the RTRCD module.

2. Initialization during startup of your application• Initialize the RTRCD module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. Call the RTRCD communication (optional).5. Trace control allows you to start or stop the trace process with your own

logical expressions (only with RTRCD).

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of RTRCD module have additionally to include the file RTRCD.Hwhich is located at RUNTIME\96\INCLUDE. It’s recommended to include thefuzzy systems before the RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of theapplication. Users of the RTRCD module have first to initialize the RTRCDmodule with the function initrtrcd(). It’s important to do this beforeinitializing any fuzzy system modules. Afterwards each fuzzy system modulemust be initialized. The initialization function follows the scheme:void init<Module Name>(void);

Fuzzy Computation:Parameter Passing The i/o-Interface to the fuzzy module uses global variables. These variables have

the data type FUZZY, which is 16 bit unsigned integer. Their value range isdefined by the code values in the Variables Properties: Base dialog. If the [Public

Page 239: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

239

Input and Output] option in Tools/Project Options/Code Generator is enabled,the generated fuzzy logic system accepts its input and output variables as globalvariables. They are exported in the *.H file with the correct data typeautomatically. Additionally the value ranges are printed as comments. Thenames of the exported variables are constant. They are derived from the namesyou have used in fuzzyTECH and follow this scheme:

<Variable Name>_<Module Name><Term Name>_<Variable Name>_<Module Name>

Fuzzy Computation:Function Prototype The function name for the fuzzy computation is in any case the same as given for

the fuzzy logic system itself. Depending on the chosen parameter passing anddata type options the fuzzy computation function exported in the *.H file willhave different prototypes.

1. Global variables, all data types: FLAGS myproj1(void);2. Function parameters, data type FUZZY:

FLAGS myproj1(FUZZY in1, FUZZY in2, ..., FUZZY* out1, FUZZY* out2, ...);

If you use global variables the *.H file exports all input and output variables ofthe fuzzy logic system with the correct data type automatically. The names ofthese variables are constant. They are based on the names you have used infuzzyTECH and follow this scheme:

<Variable Name>_<Module Name><Term Name>_<Variable Name>_<Module Name>

If you use the function parameter interface, you have to declare variables in yoursource code. One variable for each input and each output of the fuzzy logic isrecommended. You are free to use any names for these variables, but their datatype has to be FUZZY. When calling the computation function, you have to placeyour variables at the correct position that matches the fuzzy logic system. In anycase the function needs first the inputs. They are in alphanumeric order sorted bythe variable names used in fuzzyTECH. The function expects call-by-referenceparameters after the inputs. This is one pointer for each output variable inalphanumeric order.

Fuzzy Computation:Return Value The computation function returns a value of type FLAGS with the fuzzy logic

inference control flags. Each bit in FLAGS represents one output variable,starting with the lowest order bit and assigned in sequence to the output variablesin alphanumeric order. A zero bit for a variable indicates that for this outputvariable at least one rule has fired. Hence, a return value of zero indicates thatfor every output variable at least one rule has fired. The data type for FLAGSrepresents a 16-bit integer for the fuzzyTECH Edition.

Page 240: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

240

ExampleReturn Value Consider a fuzzy logic system with four (4) output variables: A_Out, B_Out,

C_Out and D_Out. For this system, the bits 3...0 of the return variablecorrespond to variable A_Out .. D_Out. All higher order bits are not used. Areturn value of 5 evaluated in a specific control cycle now indicates that no rulehas fired for the second and the forth output variable.

16-bitvalue

FLAGSrv=5

Variables inOutput Interface

OutputValue

MSB:15 0 not used -14 0 not used -

... ... ...... 0 not used -

... ... ...4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 153: Return Flags of a Return Value 5 for a System With Four OutputInterfaces (16-bit FLAGS type)

RTRCD Communication Add the following call to the RTRCD module in your source code to support thecommunication mechanism.

#ifdef FT_RTRCDrtrcd(); /* call the RTRCD module */#endif

Note that you must call this function regularly and as often as possible.Otherwise the RTRCD communication will run into a time-out. For example, ifyour application has a kind of main control loop, this would be the best place toinsert the function call.

Note that the function rtrcd() should not interrupt the computation of thefuzzy systems. This is important, in case you use a timer interrupt to call thisfunction.

Note that the function rtrcd() is programmed in such a way that it consumesas little time as possible. During an active online connection it copies themaximum number of 76 bytes and sends an answer to fuzzyTECH before itreturns. If no active online connection is running, the function returnsimmediately.

Page 241: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

241

TemporaryUsed Variables The fuzzy kernel uses temporary variables of the type FUZZY, which is a word

data type in the MCU-96 Edition. These variables can also be temporarily usedfor other code. Therefore, the variables must be declared as external. Thevariable names are var1, var2,..., and the declaration syntax is (for the examplevar1):

extern FUZZY var1;

The number of internal variables available for sharing with the MCU-96 Editionis depicted in Section 9.4.

Code Sample The following listing of pseudo C code illustrates the usage of the generatedassembler module. It uses two fuzzy systems with the names MYPROJ1.FTLand MYPROJ2.FTL and supports the RTRCD module.

Page 242: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

242

/* Example 7: MYMAIN.C RTRCD-96; PUBLIC-I/O*/

/* real time remote cross debugging on multiple fuzzy projects (PIO) */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes and defs */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 243: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

243

/* Example 7: MYMAIN.C RTRCD-96; NO PUBLIC-I/O */

/* real time remote cross debugging on multiple fuzzy projects (PIO) */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes */

FUZZY myin1, myin2, myin3, myin4, …; /* input definition */

FUZZY myout1, myout2, myout3, myout4, …; /* output definition */

FLAGS rv;

... /* more definitions */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1 = ...; /* set input data ... */

myin2 = ...; /*...for fuzzy system 1 */

... /* more inputs */

rv=myproj1(myin1, myin2,…,

&myout1, myout2, …); /* call fuzzy system 1 */

... /* more code */

myin3 = ...; /* set input data ... */

myin4 = ...; /*...for fuzzy system 1 */

... /* more inputs */

rv=myproj2(myin3, myin4,…,

&myout3, myout4, …); /* call fuzzy system 2 */

... /*...more code */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 244: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

244

6.1.3.5.4. Building an Executable File

Build Steps This section describes the compiling, assembling and linking process of allmodules that are part of the fuzzy runtime system. Assuming you are firm inusing your tool kit and in adapting the locator instructions, that match with yourhardware, this section is a rather general description and not a step-by-stepguidance. It may be necessary to browse your tool kit manual to realize thebuilding steps.

Please follow the enumerated steps below if you implement a new application. Ifyou add a fuzzy runtime system to an existing application please proceedanalogously.1. Verify, whether your compiler/assembler tool kit for the 80x96 family is

installed correctly.2. Create a new project or makefile for your application.

• Add your software module(s).• Add the fuzzy module(s).• Add the correct fuzzy library FT96x.LIB with its tool kit manufacturer:

INTEL or BSO/TASKING.• Add the communication module COMM.C (RTRCD only) including the file

…\RUNTIME\96\INCLUDE\COMM.H• Add the directory …\RUNTIME\96\INCLUDE to the include file search

path of your compiler.• Add the directory …\RUNTIME\96\LIB to the library search path of your

tool kit.3. Build the application.

• Compile/Assemble your own module(s).• Assemble the fuzzy module(s).• Assemble the communication module (RTRCD only).• Assemble the startup routine delivered with your tool kit.• Link all object files and libraries. With some tools you have to include a

tool kit library in the command line.• Locate all sections.

4. Execute the application.For more details please refer to the samples in the next section.

Samples Complete samples illustrating the code integration are located in the directory:…\RUNTIME\96\SAMPLES\MYPROJ96.All building steps are summarized in the batch file: BUILD.BAT .Please use a copy of this file as basis for your own application. Note that thesample can not give appropriate settings for your locator call. You have to adaptit due to your hardware. Please refer to the manual of your tool kit for moredetails about section locating.

Page 245: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

245

RAM Allocation The RAM segment for the fuzzy engine is automatically located by the linker.RAM and ROM segments can be moved in the entire available address rangewith linker commands. If a fixed memory allocation is necessary, a linkercommand can be entered.

RAM Overflow If the linker issues the warning: "memory overflow in the register segment",recompile all sources using the directive REGCONSERVE:

6.1.3.6. MCU-166 Edition

The fuzzyTECH MCU-166 Edition includes the RTRCD module and generatesassembler source code for the entire 80C166/167/ST10 family. You need eitherthe compiler/assembler tool kit from BSO/Tasking or Keil/Franklin to build anapplication for this family. Please contact Inform’s technical support for supportof other tool kits.

Overview An implementation of a fuzzy runtime system consists of at least three modules:

1. The fuzzy library FT16xyz.LIB, that stores the RTRCD module and thebasic fuzzy algorithms which are independent from any fuzzy system.

2. One or more fuzzy system modules generated by the assembler codegenerator of fuzzyTECH. Each module contains code and data for its specificfuzzy logic system.

3. One or more of your own software modules either in C or assemblerlanguage for implementing the application, that uses the fuzzy logic system.

4. A communication module that supports the serial interface of the80C166/167. Note that this applies only, if you use the RTRCD option.

Figure 154 illustrates the hierarchy of these modules:

User Modules (*.C or *.A66)

FuzzyModule 1

*.A66

FuzzyModule 2

*.A66

. . . FuzzyModule N

*.A66

Fuzzy LibraryFT16xyz.LIB:

Fuzzy Library FT16xyz.LIB: RTRCD Module

Fuzzy Algorithms CommunicationModule:

SERIALx.A66

Figure 154: Fuzzy Runtime Systems and RTRCD for 80C166 Family

Page 246: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

246

6.1.3.6.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highlyoptimized for both speed and size. The location for the libraries isRUNTIME/166/LIB. Please refer to the table below to find the library thatmatches with your environment.

Library Name CPU MemoryModel

Tool KitManufacturer

Tool Kit ReleaseNumber

FT166TB.LIB 80C166 Tiny BSO/Tasking 4.0 or moreFT166TB3.LIB 80C166 Tiny BSO/Tasking 3.0FT166TK.LIB 80C166 Tiny Keil/Franklin 2.05 or moreFT167TB.LIB 80C167 Tiny BSO/Tasking 4.0 or moreFT167TK.LIB 80C167 Tiny Keil/Franklin 2.05 or more

6.1.3.6.2. RTRCD Communication Module

Most code of the RTRCD module is part of the fuzzy library. This does notinclude the communication module that accesses the serial interface. It isdelivered in assembler source code to allow changes of the settings. Note that the80C166 is equipped with two serial interfaces (S0 and S1). You have to decidewhich of both you want to use. The file name of the communication module iseither SERIAL0.A66 or SERIAL1.A66 for the serial interface S0 or S1. Tofind the module that matches to your environment, please refer to one of thefollowing directories:

…\RUNTIME\166\LIB\SOURCE.A66\TASKING…\RUNTIME\166\LIB\SOURCE.A66\KEIL…\RUNTIME\166\LIB\SOURCE.A67\TASKING…\RUNTIME\166\LIB\SOURCE.A67\KEIL

Note that SERIALx.A66 uses interrupts both for transmitting and receivingdata. You may have to change the interrupt priority, if you use more interrupts.Note that the functions and variables defined in SERIALx.A66 are fixedinterfaces of the fuzzy library. Do not change these definitions.

6.1.3.6.3. Using the Generated Assembler Module

Generate theAssembler Module This section shows how the assembler modules generated by fuzzyTECH can be

integrated into your own software modules. Select “80C166...” or “80C167...”from the menu “Tools/Compile to...” in the fuzzyTECH Shell to generate thecurrent fuzzy logic project as assembler code. The code generator creates twofiles with the same name as the fuzzy system, one with the file extension*.A66, the other one with the extension *.H. The *.A66 file contains code

Page 247: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

247

and data of the fuzzy logic system, the *.H file contains the export interface ofthis module for ANSI C language. Note that the name of each exported functionor variable ends with the name of the fuzzy logic system. The generatedassembler modules use the project independent fuzzy logic algorithms of thefuzzy library.

CPU Registers The generated assembler module dynamically allocates a local register bank onthe system stack (32 byte). Note, register R0 is never used by MCU-166generated code and R0 must hold the user stack pointer. The generated code doesnot use any special function registers (SFRs).

Integration You may either call the fuzzy logic module from C code or assembler code. Thefollowing enumeration gives an overview about the steps necessary to integrate afuzzy system module into the source code of your software module(s) in Clanguage. For details please refer to Example 7 at the end of this section.1. Include C header files

• Include the export interface(s) of the fuzzy system module(s).• Include the export interface of the RTRCD module.

2. Initialization during startup of your application• Initialize the RTRCD module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. Call the RTRCD communication.5. Trace control allows you to start or stop the trace process with your own

logical expressions.

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of RTRCD module have additionally to include the file RTRCD.Hwhich is located at …\RUNTIME\166\INCLUDE . It’s recommended to includethe fuzzy systems before the RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of theapplication. Users of the RTRCD module have first to initialize the RTRCDmodule with the function initrtrcd(). It’s important to do this beforeinitializing any fuzzy system modules. Afterwards each fuzzy system modulemust be initialized. The initialization function follows the scheme:

void init<Module Name>(void);

Fuzzy Computation:Parameter Passing The i/o-Interface to the fuzzy module uses global variables. These variables have

the data type FUZZY, which is 16 bit unsigned integer. Their value range isdefined by the code values in the Variables Properties: Base dialog. The *.H file

Page 248: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

248

contains the interface to all input and output variables of the fuzzy logic systemwith the correct data type. Additionally the value ranges are printed ascomments. The names of the exported variables are constant. They are derivedfrom the names you have used in fuzzyTECH and follow this scheme:

<Variable Name>_<Module Name><Term Name>_<Variable Name>_<Module Name>

Fuzzy Computation:Function Prototype The function name for the fuzzy computation is the same as given for the fuzzy

logic system itself. For C language the function prototype follows the scheme:

FLAGS <Module Name>(void);Fuzzy Computation:Return Value The computation function returns a value of type FLAGS with the fuzzy logic

inference control flags. Each bit in FLAGS represents one output variable,starting with the lowest order bit and assigned in sequence to the output variablesin alphanumeric order. A zero bit for a variable indicates that for this outputvariable at least one rule has fired. Hence, a return value of zero indicates that forevery output variable at least one rule has fired. The data type for FLAGSrepresents a 16-bit integer for the fuzzyTECH Edition.

ExampleReturn Value Consider a fuzzy logic system with four (4) output variables: A_Out, B_Out,

C_Out and D_Out. For this system, the bits 3...0 of the return variablecorrespond to variable A_Out .. D_Out. All higher order bits are not used. Areturn value of 5 evaluated in a specific control cycle now indicates that no rulehas fired for the second and the forth output variable.

16-bitvalue

FLAGSrv=5

Variables inOutput Interface

OutputValue

MSB:15 0 not used -14 0 not used -

... ... ...... 0 not used -

... ... ...4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 155: Return Flags of a Return Value 5 for a System With Four OutputInterfaces (16-bit FLAGS type)

Page 249: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

249

RTRCD Communication Add the following call to the RTRCD module in your source code to support thecommunication mechanism.

#ifdef FT_RTRCDrtrcd(); /* call the RTRCD module */#endif

Note that you must call this function regularly and as often as possible.Otherwise the RTRCD communication will run into a time-out. For example, ifyour application has a kind of main control loop, this would be the best place toinsert the function call.

Note that the function rtrcd() should not interrupt the computation of thefuzzy systems. This is important, in case you use a timer interrupt to call thisfunction.

Note that the function rtrcd() is programmed in such a way that it consumesas little time as possible. During an active online connection it copies themaximum number of 76 bytes and sends an answer to fuzzyTECH before itreturns. If no active online connection is running, the function returnsimmediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate codesupporting a trace buffer that records the input and output values of the fuzzysystem in real-time in your application. During an online connection the traceprocess is controlled by the Trace Control dialog. The dialog offers an option tostart or stop the trace process by external trigger events. Therefore the generatedassembler code exports two additional functions that control the trace process.Call these functions in your source code to start or stop the trace at arbitrarylogical conditions. Note that once the Trace process has been started, multiplecalls of the following start function and stop function are ignored:

void StartTrace<Module Name>(void);void StopTrace<Module Name>(void);

Code Sample The following listing of pseudo C code illustrates the usage of the generatedassembler module. It uses two fuzzy systems with the names MYPROJ1.FTLand MYPROJ2.FTL and supports the RTRCD module.

/* Example 7: MYMAIN.C RTRCD-166 *//* real time remote cross debugging on multiple fuzzy projects (PIO) */

#define TASKING /* define your tool kit... */

/* #define KEIL */ /* ...here */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

Page 250: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

250

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes and defs */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_RTRCD

if(...) /* your logical condition */

StartTracemyproj2(); /* start trace process */

else

StopTracemyproj2(); /* stop trace process */

#endif

... /*...more outputs */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 251: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

251

6.1.3.6.4. Building an Executable File

Build Steps This section describes the compiling, assembling and linking process of allmodules that are part of the fuzzy runtime system. Assuming you are firm inusing your tool kit and in adapting the locator instructions, that match with yourhardware, this section is a rather general description and not a step-by-stepguidance. It may be necessary to browse your tool kit manual to realize thebuilding steps.

Please follow the enumerated steps below if you implement a new application. Ifyou add a fuzzy runtime system to an existing application please proceedanalogously.

1. Verify, whether your compiler/assembler tool kit for the 80C166 family isinstalled correctly.

2. Create a new project or makefile for your application.• Add your software module(s).• Add the fuzzy module(s).• Add the correct fuzzy library FT16xyz.LIB with

x is the derivative of the 80C166 family: 6 or 7y is the memory model: tz is the tool kit manufacturer: b or k

• Add the communication module SERIALx.A66 (RTRCD only) withx is the number of the serial interface: 0 or 1.

• Add the directory …\RUNTIME\166\INCLUDE to the include filesearch path of your compiler.

• Add the directory …\RUNTIME\166\LIB to the library search path ofyour tool kit.

3. Build the application.• Compile/Assemble your own module(s).• Assemble the fuzzy module(s).• Assemble the communication module (RTRCD only).• Link all object files and libraries.• Locate all sections.• Convert to Intel Hex Format

4. Execute the application.For more details please refer to the samples in the next section.

Samples Complete samples illustrating the code integration are located in the directories:…\RUNTIME\166\SAMPLES\MYPROJ66 for 80C166…\RUNTIME\166\SAMPLES\MYPROJ67 for 80C167

All building steps are summarized in the batch files:MAKETASK.BAT for BSO/Tasking andMAKEKEIL.BAT for Keil/Franklin.

Page 252: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

252

Please use a copy of these files as basis for your own application. Note that thesample can not give appropriate settings for your locator call. You have to adaptit due to your hardware. Please refer to the manual of your tool kit for moredetails about section locating.

6.1.3.7. MCU-320 Edition

The fuzzyTECH MCU-320 Edition uses a specialized library, the fuzzyTECHkernel. For the C2X and C5X families, this kernel contains highly optimizedassembler functions. For the C3X and C4X families, this kernel is provided asC source code. This is due to the fact that for the C2X and C5X families, theassembler kernel is far more efficient compared to the C code solution, while theC3X and C4X families are capable of processing even the C kernel veryefficiently. For implementations on the C3X and C4X family, refer toSection 6.1. For the C2X and C5X families, the following assembler languagekernels are provided with the MCU-320 Edition:

FT320_50.LIB supports the entire TMS 320/5X family.FT320_25.LIB supports the entire TMS 320/2X family.

Integration You need a C compiler to integrate the fuzzy system with the code of the entiresystem. Inform recommends using TI’s development tools. You may also use anIn-Circuit Emulator (ICE) for testing and integration (optional). The assemblerkernel FT320_XX.LIB is already compiled and archived. You do not need tocreate this library.

fuzzyTECH Kernel As a C code generator, the MCU-320 code generator uses a fuzzyTECH kernelthat contains the fuzzy inference engine modules. Thus, the files generated are inC, and the kernel is a highly optimized assembler library.

Figure 156: Integration of the Fuzzy Logic System

Figure 156 shows the integration of the fuzzy logic system: all interfaces, plusthe pre- and post processing of input and output data are contained in theMYMAIN.C source code. This source code calls the fuzzy logic system functionas a C function. This function is contained in MYPROJ.C.

Page 253: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

253

Generated Code MYPROJ.C is generated by the fuzzyTECH MCU-320 Edition from your projectand stored as MYPROJ.FTL. MYPROJ.C uses the fuzzy logic modulescontained in the kernel FT320_XX.LIB. The file BUILD.BAT in thesubdirectory …\RUNTIME\320\SAMPLES\MYPROJ contains a completeexample of how to implement the CRANE project.

Files You need the following files to integrate a fuzzy logic system with your code:

FT320_XX.LIB The fuzzyTECH kernel for the TMS 320/XX digital signalprocessor family. This kernel contains configurable modulesfor fuzzification, rule inference and defuzzification. TheFT320_XX.LIB file comes with the fuzzyTECH MCU-320Edition in the ...\RUNTIME\320\LIB subdirectory.

FTLIBC.H This file contains the function prototypes of theFT320_XX.LIB. It is always included in MYPROJ.C. This filealso contains declarations of the configuration variables of theFT320_XX.LIB. The FTLIBC.H file comes with thefuzzyTECH MCU-320 Edition in the subdirectory...\RUNTIME\320\INCLUDE.

MYMAIN.C Your main program, containing all interfaces, plus pre- andpost processing of input and output data.

MYPROJ.C The output file of the MCU-320 Edition. You have to compilethis file using a TMS 320 compiler, such as the DSPCL. Forexample, type:DSPCL -v50 -ma -mx MYPROJ.C MYMAIN.C orDSPCL -v25 MYPROJ.C MYMAIN.Cto generate the file MYPROJ.OUT.

MYPROJ.H Also generated by the MCU-320 Edition. MYPROJ.H containsa function prototype for the fuzzy logic system function. Youhave to include this file in MYMAIN.C.

Build Procedure The following steps are required to generate and integrate a fuzzy logic system:1. Write your main program MYMAIN.C to call the function contained in the

MYPROJ.C file. Include the file MYPROJ.H in MYMAIN.C.2. Generate MYPROJ.C and MYPROJ.H by calling the menu bar item

“Tools/Compile to/TMS 320...” of the fuzzyTECH MCU-320 Edition.3. Compile and link your main program file with the fuzzy logic system by

typing:DSPCL -v50 -ma -mx MYPROJ.C MYMAIN.C -z LINK.CMD orDSPCL -v25 MYPROJ.C MYMAIN.C -z LINK.CMD

to generate the file CRANE.OUT.

Page 254: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

254

BUILD.BAT All these building steps are summarized in the file BUILD.BAT, which is foundin the subdirectory ...\RUNTIME\320\SAMPLES\MYPROJ for the CRANEproject. The generated code in the file MYPROJ.C contains two functions:

Initialization void initmyproj( void );

This initializes the internal variables of the kernel and has to be executed oncebefore the fuzzy logic system function can be called.

Calling the Fuzzy System,No Public IO FLAGS myproj( FUZZY in1, FUZZY in2, ..., FUZZY *out1,

FUZZY *out2, ... );

The fuzzy logic system function is called by the user code. First all input, then alloutput variables are listed as parameters. The sequence of variables isalphanumeric. The return value identifies output variables for which no rule hasfired.

Public IO If the [Public Input and Output] option in the dialog “Project Options/CodeGenerator” is enabled, the fuzzy logic system generated accepts its input andoutput variables as global variables. For the variable names, the name of thefuzzy logic project (same as *.FTL file name) is appended with an underscoreafter each variable name (low caps). For example, in MYPROJ.FTL with thevariables myin1, myin2,... , myout1, myout2,... the global variable names are:

myin1_myproj, myin2_myproj,... , myout1_myproj, myout2_myproj, ... .

Before calling the fuzzy logic inference, the global variables representing theinputs must be initialized.

Unique Function Call The fuzzy logic computation is started by calling the function:

FLAGS myproj( );

The function must be called by your program code, and it contains the entirefuzzy logic computation. In order to initialize this function, the file MYPROJ.Ccontains the same initialization function whether the [Public IO] option isenabled or disabled. The initialization function must be called once beforecalling the fuzzy logic system function. After this initialization, the fuzzy systemfunction does not need any further initialization.

Return Value The fuzzy logic system function returns a value of type FLAGS with the fuzzylogic inference control flags. Each bit in FLAGS represents one output variable,starting with the lowest order bit and assigned in sequence to the output variablesin alphanumeric order. A zero bit for a variable indicates that for this outputvariable at least one rule fired. Hence, a return value of zero indicates that forevery output variable at least one rule fired. The data type for FLAGS representsa 16-bit integer for the fuzzyTECH MCU-320 Edition.

Page 255: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

255

Example Return Value Consider a fuzzy logic system with four (4) output variables: A_Out, B_Out,C_Out and D_Out. For this system, the bits 3...0 of the return variablecorrespond to variable A_Out .. D_Out. All higher bits are not used. A returnvalue of 5 evaluated in a specific control cycle indicates that no rule for both thesecond and the forth output variable fired. A return value of 0 would indicatethat at least one rule for every output variable did fire (see Figure 157).

16-bitvalue

FLAGSrv=5

Variables inOutput Interface

OutputValue

MSB:15 0 not used -14 0 not used -

... ... ...... 0 not used -

... ... ...4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 157: Return Flags of a Return Value 5 for a System With Four OutputInterfaces (16-bit FLAGS type)

Example Integration The following examples show how to call the code generated by the fuzzyTECHMCU-320 Edition using public IO or a parameter transferred via a function call(no public IO) within your program. If you design your own project, you have toreplace 'myproj' with your project name both in the file names and in thefunction calls.

Page 256: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

256

Example MYMAIN.C - No public IO:

/*

fuzzyTECH MCU 320 Edition --- Example*/

#include "myproj.h"

/* including function prototypes */

void main()

{

FUZZY myin1, myin2,.., myout1,myout2,..;

FUZZY result;

FLAGS rv;

/* initialization, call only once */

initmyproj();

/* code to be used in a control loop */

myin1=...;

myin2=...; /* setting input data */

rv = myproj(myin1, myin2,...,

&myout1,myout2,..);

/* call fuzzy routines */

if( !rv ) {

... = myout1;

... = myout2; /* use outputs */

}

else {

/* default handling, no rules fire */;

}

}

Page 257: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

257

Example MYMAIN.C - Public IO:

/*

fuzzyTECH MCU 320 Edition --- Example*/

#include "myproj.h"

/* including function prototypes */

void main()

{

FLAGS rv;

initmyproj(); /* initialize variables */

/* call only once */

/* The following code can occur */

/* in a control loop */

myin1_myproj = ...;

myin2_myproj = ...;

/* setting input data */

rv = myproj();

/* call fuzzy routines */

if( !rv )

... = myout1_myproj;

... = myout2_myproj; /* use outputs */

else

/* default handling, no rules fire */;

}

Page 258: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

258

6.1.3.8. MCU-HC05/08 Edition

The fuzzyTECH MCU-HC05/08 Edition includes the RTRCD module for theHC08 and generates assembler source code for the entire M68HC05 andM68HC08 families. You need the compiler/assembler tool kit from COSMIC orHIWARE to build an application for this families. Please contact Inform’stechnical support for support of other tool kits.

Overview An implementation of a fuzzy runtime system consists of at least three up to fourmodules:1. The fuzzy library FTxyz.LIB, that stores the RTRCD module and the basic

fuzzy algorithms, which are independent from any fuzzy system.2. One or more fuzzy system modules generated by the assembler code

generator of fuzzyTECH. Each module contains code and data for its specificfuzzy logic system.

3. One or more of your own software modules either in C or assemblerlanguage for implementing the application, that uses the fuzzy logic system.

4. A communication module that supports the serial interface of the M68HC08.Note that this applies only, if you use the RTRCD option.

User Modules (*.C or *.S)

FuzzyModule 1

*.S

FuzzyModule 2

*.S

. . . Fuzzy ModuleN

*.S

Fuzzy LibraryFTxyz.LIB:

Fuzzy Library FTxyz.LIB: RTRCD Module

Fuzzy Algorithms CommunicationModule:

COMM.S orCOMM_BDM.S

Figure 158: Hierarchy of the Fuzzy Runtime Systems and RTRCD (only forM68HC08) for the M68HC05/08 families

6.1.3.8.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highlyoptimized for both speed and size. The location for the libraries is…\RUNTIME\MCUHC05\LIB or …\RUNTIME\MCUHC08\LIB. Please referto the table below to find the library that matches with your environment.If you are using a different tool kit, please use general C sources.

Page 259: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

259

Library Name CPU Tool KitManufacturer

Tool Kit Release Number

FT05COS.LIB M68HC05 COSMIC 4.0 or moreFT05HIW.LIB M68HC05 HIWARE 5.0 or moreFT08COS.LIB M68HC08 COSMIC 4.0 or moreFT08HIW.LIB M68HC08 HIWARE 5.0 or more

6.1.3.8.2. RTRCD Communication Module (only for M68HC08)

Most code of the RTRCD module is part of the fuzzy library. This does notinclude the communication modules that access the serial interface. They aredelivered in assembler source code to allow changes of the settings. Usually thisis necessary, since different types of microcontrollers store code, data, or theinterrupt table at a different place.

RS-232 /Serial Interface Routines handling the communication via the RS-232 port are in a separate

module COMM.S. Choose a port and baud rate by clicking the [Configuration]key in the Online Wizard dialog “Online Communication Channel” (see alsoTools/fuzzyTECH Preferences/Serial Interface). Note that COMM.S usesinterrupts both for transmitting and receiving data. You may have to change theinterrupt priority, if you use more interrupts. Note that the functions andvariables defined in COMM.S are fixed interfaces of the fuzzy library. Do notchange these definitions.

6.1.3.8.3. Using the Generated Assembler Module

Generate theAssembler Module This section shows how the assembler modules generated by fuzzyTECH can be

integrated into your own software modules. First select your tool kitManufacturer (COSMIC or HIWARE) from the menu “Tools/MCU-Tool Kit” inthe fuzzyTECH Shell. Select “HC05...” or “HC08...” from the menu“Tools/Compile to...” in the fuzzyTECH Shell to generate the current fuzzy logicproject as assembler code. The code generator creates two files with the samename as the fuzzy system, one with the file extension *.S, the other one with theextension *.H. The *.S file contains code, data and the external symboldefinitions of the fuzzy logic system. The *.H file contains the export interfaceof this module for ANSI C language. Note that the name of each exportedfunction or variable ends with the name of the fuzzy logic system. The generatedmodules use the project independent fuzzy logic algorithms of the fuzzy library.

Integration from C code The following enumeration gives an overview about the steps necessary tointegrate a fuzzy system module into the source code of your software module(s)in C language.

Page 260: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

260

1. Include C header files• Include the export interface(s) of the fuzzy system module(s).• Include the export interface of the RTRCD module.

2. Initialization during startup of your application• Initialize the RTRCD module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. Call the RTRCD communication (optional).5. Trace control allows you to start or stop the trace process with your own

logical expressions.

For details please refer to the files…\RUNTIME\MCUHC05\SAMPLES\MYPROJ05\MYMAIN.C,…\RUNTIME\MCUHC08\SAMPLES\MYPROJ08\MYMAIN.Cor the Example 7 at the end of this section.

Integration from Assembler How to integrate a fuzzy system module into the source code of your softwaremodule(s) in assembler language, please refer to the files…\RUNTIME\MCUHC05\SAMPLES\MYPROJ05\MYMAIN.S or…\RUNTIME\MCUHC08\SAMPLES\MYPROJ08\MYMAIN.S.

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of RTRCD module have additionally to include the file RTRCD.H,which is located at …\RUNTIME\MCUHC05\INCLUDE or RUNTIME\MCUHC08\INCLUDE. It is recommended to include the fuzzy systems beforethe RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of theapplication. Users of the RTRCD module have first to initialize the RTRCDmodule with the function initrtrcd() for C source code or JSR_initrtrcd for assembler source code. It is important to do this beforeinitializing any fuzzy system modules. Afterwards each fuzzy system modulemust be initialized. The initialization function follows the scheme:

void init<Module Name>(void); /* for ANSI C */XREF _init<Module Name> ;for assemblerJSR _init<Module Name> ;for assembler

Fuzzy Computation:Parameter Passing The i/o-Interface to the fuzzy module uses global variables. These variables have

the data type FUZZY, which is 8 bit unsigned char. Their value range is definedby the code values in the Base Variable dialog. The *.S or the *.C file exportsall input and output variables of the fuzzy logic system with the correct data type

Page 261: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

261

automatically. The *.H file contains the export interface to all input and outputvariables of the fuzzy logic system for ANSI C language. Additionally the valueranges are printed as comments in the files with the extension *.H and *.S. Thenames of the exported variables are constant. They are derived from the namesyou have used in fuzzyTECH and follow this scheme:

<Variable Name>_<Module Name> /*for ANSI C*/<Term Name>_<Variable Name>_<Module Name> /*for ANSI C*/_<Variable Name>_<Module Name> ;for assembler_<Term Name>_<Variable Name>_<Module Name>;

for assembler

Fuzzy Computation:Function Prototype The function name for the fuzzy computation is the same as given for the fuzzy

logic system itself. For C language the function prototype follows the scheme:

FLAGS <Module Name>(void);

In assembler language the function prototype follows the scheme

XREF _<Module Name>JSR_ <Module Name> with a return value in ACCUMULATOR B.

Fuzzy Computation:Return Value The computation function returns a value of type FLAGS (only C code) or in

ACCUMULATOR A (only assembler) with the fuzzy logic inference controlflags. Each bit in FLAGS or of ACCUMULATOR A represents one outputvariable, starting with the lowest order bit and assigned in sequence to the outputvariables in alphanumeric order. A zero bit for a variable indicates that for thisoutput variable at least one rule has fired. Hence, a return value of zero indicatesthat for every output variable at least one rule has fired. The data type for FLAGSrepresents an 8-bit unsigned char for the fuzzyTECH Edition MCU-HC05/08.

ExampleReturn Value Consider a fuzzy logic system with four (4) output variables: A_Out, B_Out,

C_Out and D_Out. For this system, the bits 3...0 of the return variablecorrespond to variable A_Out…D_Out. All higher order bits are not used. Areturn value of 5 evaluated in a specific control cycle now indicates that no rulehas fired for the second and the forth output variable.

Page 262: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

262

8-bitvalue

FLAGS orACCU B

rv=5

Variables inOutput Interface

OutputValue

MSB:7 0 not used -6 0 not used -5 0 not used -4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 159: Return Flags of a Return Value 5 for a System With Four OutputInterfaces (8-bit FLAGS type or ACCU A)

RTRCD Communication Add the following call to the RTRCD module in your C source code to supportthe communication mechanism.

#ifdef FT_RTRCDrtrcd(); /* call the RTRCD module */#endif

If your source code is written in assembler language add this call:

XREF _rtrcd ; declarationJSR _rtrcd ; call the RTRCD module

Note that you must call this function regularly and as often as possible.Otherwise the RTRCD communication will run into a time-out. For example, ifyour application has a kind of main control loop, this would be the best place toinsert the function call.

Note that the function rtrcd() or _rtrtcd should not interrupt thecomputation of the fuzzy systems. This is important, in case you use a timerinterrupt to call this function.

Note that the function rtrcd() or _rtrcd is programmed in such a way thatit consumes as little time as possible. During an active online connection itcopies the maximum number of 76 bytes and sends an answer to fuzzyTECHbefore it returns. If no active online connection is running, the function returnsimmediately.

Page 263: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

263

Trace Control(only M68HC08) If the RTRCD option is enabled, the fuzzyTECH MCU-HC05/08 Edition offers

the option to generate code supporting a trace buffer that records the input andoutput values of the fuzzy system in real-time in your application. During anonline connection the trace process is controlled by the Trace Control dialog.The dialog offers an option to start or stop the trace process by external triggerevents. Therefore the generated code exports two additional functions thatcontrol the trace process. Call these functions in your source code to start or stopthe trace at arbitrary logical conditions. Note that once the Trace process hasbeen started, multiple calls of the following start and stopp function are ignored.

The trace functions follow the scheme:

void StartTrace<Module Name>(void); /*for ANSI C*/StopTrace<Module Name>(void); /*for ANSI C*/XREF _StartTrace<Module Name> ;for assemblerXREF _StopTrace<Module Name> ;for assembler

JSR _StartTrace<Module Name> ;for assemblerJSR _StopTrace<Module Name> ;for assembler

Code Sample The following listing of pseudo C code illustrates the usage of the generatedassembler module. It uses two fuzzy systems with the names MYPROJ1.FTLand MYPROJ2.FTL and supports the RTRCD module.

/* Example 7: MYMAIN.C RTRCD-HC05/08 *//* real time remote cross debugging on multiple fuzzy projects (PIO) */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes and defs */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

Page 264: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

264

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_RTRCD

if(...) /* your logical condition */

StartTracemyproj2(); /* start trace process */

else

StopTracemyproj2(); /* stop trace process */

#endif

... /*...more outputs */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

6.1.3.8.4. Building an Executable File

Build Steps This section describes the compiling, assembling and linking process of allmodules that are part of the fuzzy runtime system. Assuming you are firm inusing your tool kit and in adapting the locator instructions, that match with yourhardware, this section is a rather general description and not a step-by-stepguidance. It may be necessary to browse your tool kit manual to realize thebuilding steps.

Please follow the enumerated steps below if you implement a new application. Ifyou add a fuzzy runtime system to an existing application please proceedanalogously.1. Verify, whether your compiler/assembler tool kit for the M68HC05 or

M68HC08 family is installed correctly.2. Create a new project or makefile for your application.

• Add your software module(s).• Add the fuzzy module(s).

Page 265: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

265

• Add the directory …\RUNTIME\MCUHC05\LIB orRUNTIME\MCUHC08\LIB with the corresponding fuzzy libraryFTxyz.LIB to the linking directive, with x is the family M68HC05 or M68HC08 y is the tool kit manufacturer: COSMIC, or HIWARE z (reserved for further options)

• For RTRCD, add the directory …\RUNTIME\MCUHC08\SRC\[tool kit]with the chosen communication module COMM.S.

3. Build the application.• Compile/Assemble your own module(s).• Assemble the fuzzy module(s).• Assemble the communication module (RTRCD only).• Assemble the startup routine.• Assemble the vector table for the M68HC08 with RTRCD, but verify

before assembling, that the given form for the structure of interruptaddresses corresponds to their microcontroller version.

• Locate all sections in your or the delivered linking directive and add thepaths of the object files and libraries. As for HIWARE, the C languageinterface ANSI.LIB has to be added.

• Link all object files and libraries.• Convert the binary file into Motorola S-RECORD format

4. Transfer the S-RECORD file to the target.5. Execute the application.For more details please refer to the samples in the next section.

Samples All building steps are summarized in the batch files:BUILD05.BAT for M68HC05 andBUILD08.BAT for M68HC08.

You find this files in the directory…\RUNTIME\MCUHC05\SAMPLES\MYPROJ05 or…\RUNTIME\MCUHC08\SAMPLES\MYPROJ08.

Generate the appropriate controller for your tool kit to use these batches. Pleaseuse a copy of these files as basis for your own application. Note that the samplecan not give appropriate settings for your locator call. You have to adapt it due toyour hardware. Please refer to the manual of your tool kit for more details aboutsection locating.

ZEROPAGE The fuzzyTECH library has been developed with variables on the Zeropage,since a very fast computation time is only granted by a short access time onglobal variables. To avoid the loss of memory space, these variables can be usedoutside the fuzzy controller as well.

Page 266: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

266

For the M68HC08, import the variables from the fuzzyTECH library as follows:XREF_var11 ;1 ByteXREF_var12 ;1 ByteXREF_var13 ;1 ByteXREF_var14 ;1 ByteXREF_var15 ;1 ByteXREF_var16 ;1 ByteXREF_var17 ;1 Byte

XREF_var21 ;2 ByteXREF_var22 ;2 ByteXREF_var23 ;2 ByteXREF_var24 ;2 Byte

For the M68HC05, import the variables from the fuzzyTECH library as follows:XREF_var1 ;1 ByteXREF_var2 ;1 Byte

***

XREF_var9 ;1 ByteXREF_var10 ;1 Byte

Restrictions The M68HC05 allows only 256 elements per rule block. Due to its 8-bitregisters, the M68HC05 data tables are restricted. For this reason, the generatedassembly code of a fuzzyTECH rule table cannot contain more than 256elements. This code is compressed and not to be mistaken with the number ofelements in the fuzzyTECH development shell. If you have more than 256elements and are thus not allowed to generate code, then comply this restrictionby splitting a large rule table into a few smaller ones. This can be done veryquick by using fuzzyTECH’s “Duplicate Rule Block” function.

The M68HC05 cannot generate assembly code, if the Online option is enabled. Ifso, please deactivate in the menu Tools/Project Options/Code Generator theoption Online Code, since the M68HC05 library has no RTRCD function.

The M68HC05 is multi-system incapable, i.e. it does not support multipleinstances (or multi-clients). Not more than one fuzzy project can be integratedwithin source code. This restriction allows the M68HC05 to process several ruletables.

Page 267: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

267

6.1.3.9. MCU-HC11/12 Edition

The fuzzyTECH MCU-HC11/12 Edition includes the RTRCD module andgenerates assembler source code for the entire M68HC11 and M68HC12families. You need the compiler/assembler tool kit from COSMIC, HIWARE,IAR or MOTOROLA to build an application for this family. Please contactInform’s technical support for support of other tool kits.

Overview An implementation of a fuzzy runtime system consists of at least three up to fourmodules:1. The fuzzy library FTxyz.LIB, that stores the RTRCD module and the basic

fuzzy algorithms, which are independent from any fuzzy system.2. One or more fuzzy system modules generated by the assembler code

generator of fuzzyTECH. Each module contains code and data for its specificfuzzy logic system.

3. One or more of your own software modules either in C or assemblerlanguage for implementing the application, that uses the fuzzy logic system.

4. A communication module that supports either the serial interface of theM68HC11 / M68HC12 or the SDI™ of the M68HC12. Note that this appliesonly, if you use the RTRCD option.

User Modules (*.C or *.S)

FuzzyModule 1

*.S

FuzzyModule 2

*.S

. . . Fuzzy ModuleN

*.S

Fuzzy LibraryFTxyz.LIB:

Fuzzy Library FTxyz.LIB: RTRCD Module

Fuzzy Algorithms CommunicationModule:

COMM.S orCOMM_BDM.S

Figure 160: Hierarchy of the Fuzzy Runtime Systems and RTRCD for M68HC11and M68HC12 families

6.1.3.9.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highlyoptimized for both speed and size. The location for the libraries is…\RUNTIME\HC11\LIB or …\RUNTIME\HC12\LIB . Please refer to thetable below to find the library that matches with your environment.If you are using a different tool kit, please use general C sources.

Page 268: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

268

Library Name CPU Tool KitManufacturer

Tool KitReleaseNumber

FT11COS.LIB M68HC11 COSMIC 4.0 or moreFT11HIW.LIB M68HC11 HIWARE 2.7 or moreFT11IAR.LIB M68HC11 IAR 4.11or moreFT11MOT.LIB M68HC11 MOTOROLA 5.0 or moreFT12COS.LIB M68HC12 COSMIC 4.0 or moreFT12HIW.LIB M68HC12 HIWARE 2.7 or moreFT12IAR.LIB M68HC12 IAR 2.1 or moreFT12MOT.LIB M68HC12 MOTOROLA 5.0 or more

6.1.3.9.2. RTRCD Communication Module

Most code of the RTRCD module is part of the fuzzy library. This does notinclude the communication modules that access the serial interface or the SDI™interface. They are delivered in assembler source code to allow changes of thesettings. Note that you can access the M68HC12 in two communication modes,either directly with the RS-232 / serial interface or indirectly with the SDI™interface / Background Debug Mode connector.

To find the module that matches to your environment, please refer to one of thefollowing directories:…\RUNTIME\HC11\SRC\[tool kit]…\RUNTIME\HC12\SRC\[tool kit]

SDI™ Interface /BDM Connector Routines handling the communication via the SDI™ interface (M68HC12 only)

are in a separate module COMM_BDM.S. In the Online Wizard dialog “OnlineCommunication Channel” in fuzzyTECH” select the channel ...\FTSDI.DLL...,click the [Configuration] key and update the starting address of thecommunication buffer on target. The communication buffer is called _BDM_Bufand is located in the file COMM_BDM.S. You can get the starting address out ofthe *.MAP file or the absolute listing of COMM_BDM.S. If this is not possible,because the source files are for example unknown, please insert the startingaddress of the RAM array on target into the Setup dialog. fuzzyTECH starts itssearch for the communication buffer from this address on. Further you mustverify a port and baud rate by clicking the [Configuration] key in fuzzyTECH’sOnline Wizard dialog “Online Communication Channel”.

RS-232 /Serial Interface Routines handling the communication via the RS-232 port are in a separate

module COMM.S. Choose a port and baud rate by clicking the the[Configuration] key in fuzzyTECH’s Online Wizard dialog “OnlineCommunication Channel”.

Page 269: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

269

Note that COMM.S uses interrupts both for transmitting and receiving data.You may have to change the interrupt priority, if you use more interrupts. Notethat the functions and variables defined in COMM.S and COMM_BDM.S arefixed interfaces of the fuzzy library. Do not change these definitions.

6.1.3.9.3. Using the Generated Assembler Module

Generate theAssembler Module This section shows how the assembler modules generated by fuzzyTECH can be

integrated into your own software modules. First select your tool kitManufacturer COSMIC, HIWARE or MOTOROLA from the menu“Tools/MCU-Tool Kit” in the fuzzyTECH Shell. Select “HC11...” or “HC12...”from the menu “Tools/Compile to...” in the fuzzyTECH Shell to generate thecurrent fuzzy logic project as assembler code. The code generator creates twofiles with the same name as the fuzzy system, one with the file extension *.S,the other one with the extension *.H. The *.S file contains code, data and theexternal symbol definitions of the fuzzy logic system. The *.H file contains theexport interface of this module for ANSI C language. For this reason no *.H filewill be generated for the tool kit of Motorola; a compiler is not available. Notethat the name of each exported function or variable ends with the name of thefuzzy logic system. The generated modules use the project independent fuzzylogic algorithms of the fuzzy library.

Integration from C code The following enumeration gives an overview about the steps necessary tointegrate a fuzzy system module into the source code of your software module(s)in C language.1. Include C header files

• Include the export interface(s) of the fuzzy system module(s).• Include the export interface of the RTRCD module.

2. Initialization during startup of your application• Initialize the RTRCD module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. Call the RTRCD communication (optional).5. Trace control allows you to start or stop the trace process with your own

logical expressions.

For details please refer to the files…\RUNTIME\HC11\SAMPLES\MYPROJ11\MYMAIN.C,…\RUNTIME\HC12\SAMPLES\MYPROJ12\MYMAIN.Cor the Example 7 at the end of this section.

Page 270: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

270

Integration from Assembler How to integrate a fuzzy system module into the source code of your softwaremodule(s) in assembler language, please refer to the files…\RUNTIME\HC11\SAMPLES\MYPROJ11\MYMAIN.S or…\RUNTIME\HC12\SAMPLES\MYPROJ12\MYMAIN.S.

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of RTRCD module have additionally to include the file RTRCD.H,which is located at …\RUNTIME\HC11\INCLUDE or RUNTIME\HC12\INCLUDE. It is recommended to include the fuzzy systems before the RTRCD.Hfile.

Initialization Some initialization functions must be called only once during the startup of theapplication. Users of the RTRCD module have first to initialize the RTRCDmodule with the function initrtrcd() for C source code or JSR_initrtrcd for assembler source code. It is important to do this beforeinitializing any fuzzy system modules. Afterwards each fuzzy system modulemust be initialized. The initialization function follows the scheme:

void init<Module Name>(void); /* for ANSI C */XREF _init<Module Name> ;for assemblerJSR _init<Module Name> ;for assembler

Fuzzy Computation:Parameter Passing The i/o-Interface to the fuzzy module uses global variables. These variables have

the data type FUZZY, which is 8 bit unsigned char. Their value range is definedby the code values in the Base Variable dialog. The *.S or the *.C file exportsall input and output variables of the fuzzy logic system with the correct data typeautomatically. The *.H file contains the export interface to all input and outputvariables of the fuzzy logic system for ANSI C language. Additionally the valueranges are printed as comments in the files with the extension *.H and *.S . Thenames of the exported variables are constant. They are derived from the namesyou have used in fuzzyTECH and follow this scheme:

<Variable Name>_<Module Name> /*for ANSI C*/<Term Name>_<Variable Name>_<Module Name> /*for ANSI C*/_<Variable Name>_<Module Name> ;for assembler_<Term Name>_<Variable Name>_<Module Name>;

for assembler

Fuzzy Computation:Function Prototype The function name for the fuzzy computation is the same as given for the fuzzy

logic system itself. For C language the function prototype follows the scheme:

FLAGS <Module Name>(void);

In assembler language the function prototype follows the scheme:

XREF _<Module Name>

Page 271: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

271

JSR_ <Module Name> with a return value in ACCUMULATOR B.Fuzzy Computation:Return Value The computation function returns a value of type FLAGS (only C code) or in

ACCUMULATOR B (only assembler) with the fuzzy logic inference control flags.Each bit in FLAGS or of ACCUMULATOR B represents one output variable,starting with the lowest order bit and assigned in sequence to the output variablesin alphanumeric order. A zero bit for a variable indicates that for this outputvariable at least one rule has fired. Hence, a return value of zero indicates thatfor every output variable at least one rule has fired. The data type for FLAGSrepresents an 8-bit unsigned char for the fuzzyTECH Edition MCU-HC11/12.

ExampleReturn Value Consider a fuzzy logic system with four (4) output variables: A_Out, B_Out,

C_Out and D_Out. For this system, the bits 3...0 of the return variablecorrespond to variable A_Out…D_Out. All higher order bits are not used. Areturn value of 5 evaluated in a specific control cycle now indicates that no rulehas fired for the second and the forth output variable.

8-bitvalue

FLAGS orACCU B

rv=5

Variables inOutput Interface

OutputValue

MSB:7 0 not used -6 0 not used -5 0 not used -4 0 not used -3 0 A_Out calculated2 1 B_Out default-value1 0 C_Out calculated

LSB: 0 1 D_Out default-value

Figure 161: Return Flags of a Return Value 5 for a System With Four OutputInterfaces (8-bit FLAGS type or ACCU B)

RTRCD Communication Add the following call to the RTRCD module in your C source code to supportthe communication mechanism.#ifdef FT_RTRCDrtrcd(); /* call the RTRCD module */#endif

If your source code is written in assembler language add this call:XREF _rtrcd ; declarationJSR _rtrcd ; call the RTRCD module

Note that you must call this function regularly and as often as possible.Otherwise the RTRCD communication will run into a time-out. For example, if

Page 272: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

272

your application has a kind of main control loop, this would be the best place toinsert the function call.

Note that the function rtrcd() or _rtrtcd should not interrupt thecomputation of the fuzzy systems. This is important, in case you use a timerinterrupt to call this function.

Note that the function rtrcd() or _rtrcd is programmed in such a way thatit consumes as little time as possible. During an active online connection itcopies the maximum number of 76 bytes and sends an answer to fuzzyTECHbefore it returns. If no active online connection is running, the function returnsimmediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate codesupporting a trace buffer that records the input and output values of the fuzzysystem in real-time in your application. During an online connection the traceprocess is controlled by the Trace Control dialog. The dialog offers an option tostart or stop the trace process by external trigger events. Therefore the generatedcode exports two additional functions that control the trace process. Call thesefunctions in your source code to start or stop the trace at arbitrary logicalconditions. Note that once the Trace process has been started, multiple calls ofthe following start and stopp function are ignored.

The trace functions follow the scheme:

void StartTrace<Module Name>(void); /*for ANSI C*/StopTrace<Module Name>(void); /*for ANSI C*/XREF _StartTrace<Module Name> ;for assemblerXREF _StopTrace<Module Name> ;for assembler

JSR _StartTrace<Module Name> ;for assemblerJSR _StopTrace<Module Name> ;for assembler

Code Sample The following listing of pseudo C code illustrates the usage of the generatedassembler module. It uses two fuzzy systems with the names MYPROJ1.FTLand MYPROJ2.FTL and supports the RTRCD module.

/* Example 7: MYMAIN.C RTRCD-HC11/12 *//* real time remote cross debugging on multiple fuzzy projects (PIO) */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_RTRCD

#include "rtrcd.h" /* include cross debugger */

#endif

... /* more includes and defs */

Page 273: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

273

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_RTRCD

initrtrcd(); /* initialize cross debugger */

#endif

initmyproj1(); /* initialize fuzzy system 1 */

initmyproj2(); /* initialize fuzzy system 2 */

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_RTRCD

if(...) /* your logical condition */

StartTracemyproj2(); /* start trace process */

else

StopTracemyproj2(); /* stop trace process */

#endif

... /*...more outputs */

#ifdef FT_RTRCD

rtrcd(); /* call cross debugger */

#endif

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 274: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

274

6.1.3.9.4. Building an Executable File

Build Steps This section describes the compiling, assembling and linking process of allmodules that are part of the fuzzy runtime system. Assuming you are firm inusing your tool kit and in adapting the locator instructions, that match with yourhardware, this section is a rather general description and not a step-by-stepguidance. It may be necessary to browse your tool kit manual to realize thebuilding steps.

Please follow the enumerated steps below if you implement a new application. Ifyou add a fuzzy runtime system to an existing application please proceedanalogously.1. Verify, whether your compiler/assembler tool kit for the M68HC11 or

M68HC12 family is installed correctly.2. Create a new project or makefile for your application.

• Add your software module(s).• Add the fuzzy module(s).• Add the directory …\RUNTIME\HC11\LIB or RUNTIME\HC12\LIB

with the corresponding fuzzy library FTxyz.LIB to the linkingdirective, with x is the family M68HC11 or M68HC12 y is the tool kit manufacturer: COSMIC, HIWARE, IAR or MOTOROLA z (reserved for further options)

• For RTRCD add the directory …\RUNTIME\HC11\SRC\[tool kit]or …\RUNTIME\HC12\SRC\[tool kit] with the chosen communicationmodule COMM.S or COMM_BDM.S (only HC12 with SDI).

3. Build the application.• Compile/Assemble your own module(s).• Assemble the fuzzy module(s).• Assemble the communication module (RTRCD only).• Assemble the startup routine delivered with your tool kit or fuzzyTECH.• Locate all sections in your or the delivered linking directive and add the

paths of the object files and libraries. HIWARE with M68HC12 only: add the C language interfaceANSIS.LIB

• Link all object files and libraries.• Convert the binary file into Motorola S-RECORD format

4. Transfer the S-RECORD file to the target.5. Execute the application.For more details please refer to the samples in the next section.

Samples All building steps are summarized in the batch files:BUILDC.BAT for your software module, written in ANSI C, andBUILDASM.BAT for your software module, written in assembler.

Page 275: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

275

You find this files in the directory …\RUNTIME\HC11\SAMPLES\MYPROJ11or …\RUNTIME\HC12\SAMPLES\MYPROJ12. Generate the appropriatecontroller for your tool kit to use these batches. Please use a copy of these filesas basis for your own application. Note that the sample can not give appropriatesettings for your locator call. You have to adapt it due to your hardware. Pleaserefer to the manual of your tool kit for more details about section locating.

6.1.3.10. IA-S5 Edition

The IA-S5 Edition allows for the implementation of a fuzzy controller in thefunction blocks of the SIEMENS S5 PLC. The devices supported by thefuzzyTECH IA-S5 Edition are:S5-95US5-100U CPU103S5-115U CPU 941-944, 945S5-135U CPU 928, 928B, 948, 948RS5 155U CPU 928, 946, 947, 948

Due to their their limited computing capabilities, the S5-90U device as wwell asthe S5-100U CPU 100, 102 and 922 are not supported.

S5D File All devices are supported by generating the fuzzy project as *.S5D code that canbe added to other PLC routines with all available programming tools.

I/O Mapping The I/O mapping between input and output interfaces of the fuzzy project andthe other tasks to be executed on the PLC is implemented via addresses enteredin the I/O-Mapping field in the Variables Properties/General dialog. fuzzyTECHchecks the plausibility of the addresses entered and highlights invalid characters.

Valid addresses are:MWxxx (MERKERWORT) with xxx from 0-255EWxxx (EINGANGSWORT) with xxx from 0-255AWxxx (AUSGANGSWORT) with xxx from 0-255PWxxx (PERPHERIEWORT) with xxx from 0-255Dbyyy:DWWxxx (DATENWORT in

DATENBAUSTEIN) with xxx and yyy from 0-255

In the Tools main menu, choose the entry “S5-Parameters” to open a specific IA-S5 Edition dialog that lets you enter the number of the first data and functionblock and the address of the first memory word (MERKERWORT: MW) that isused by fuzzy routines.

Page 276: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

276

Code Generation The option “Tools /Compile to/S5” lets you generate the *.S5D file. Before codegeneration, the system and all entries in I/O mapping and the S5 options arechecked for completeness and correctness. fuzzyTECH produces the followingfunction blocks within code generation that can be freely located in a validrange:

DB xxx data block containing tables for fuzzification anddefuzzification routines,xxx can be selected from 0 - 255 and is saved in the FTL file.

DB xxx+nRB every rule block in fuzzyTECH is represented by a separatedata block.

FB yyy function block containing routines for the I/O-handling of thefuzzy controller,yyy can be chosen from 0 - 255 and is saved in the FTL file.

FB yyy+4+m function blocks containing calculation routines, such as FLMS: fuzzification using standard membership functions,MinPROD: min-prod inference calculation,COM: center of maximum defuzzification,DIV32: a high resolution division routine, and, depending onthe device,MUL16: a multiplication routine. If MUL16 is required, onemore FB is generated. In this case, m is 1. For PLC’s withoutthe capability of 16-bit multiplying, m is 0.

FB yyy+2+c function blocks used to copy fuzzy values between the datablocks. If more than 1 rule block exists, additional copyfunction blocks are generated. c is the number of ruleblocksminus one (-1).

MW xxx - yyy 16 memory words (32 bytes) are used internally for the fuzzycalculations.

If the code generation is successfully completed, the number of generatedfunction and data blocks is displayed. The generated code file can now betransferred to the programming device of the PLC. Do not change any addressesin the generated code, since they may be used as well by other function blocks.

Call Fuzzy The fuzzy computation is executed by calling the first function block from theapplication program. The number of this function block is the number specifiedin the S5 option dialog. The activated function block initializes the loading ofthe input values specified in the I/O mapping of the input interfaces, executes allrequired fuzzy calculations, and writes the results to the addresses specified inthe I/O mapping field of the output interfaces. During fuzzy calculation, alarmswill be temporary deactivated. All calculations use a resolution of 15 bitunsigned integer (0..32767).

Fuzzy Computation The restrictions of the S5 devices allow only basic fuzzy computations. Thus,fuzzy systems implemented on the PLC S5 use for:

Page 277: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

277

fuzzification linear memberships in 4-point definition (standard MBF)inference minimum operator using FAM rulesdefuzzification center of maximum defuzzification.

Data Block Limit S5 devices are limited to 256 addresses to be indirectly addressed in a data block.Fuzzy systems generated by fuzzyTECH are therefore distributed on several datablocks. However, a block limitation may occur. A check is executed during codegeneration in fuzzyTECH. In addition, there are restrictions on the number ofinterfaces, rule blocks and rules:

inputs 32 input variables each using max. 5 termsoutputs 8 output variables each using max. 5 termsrule blocks 8 rule blocks each using max. 80 rules.

Cross Debugging A connection of your PC with the PG-interface (PROGRAMMIERGERAETE-SCHNITTSTELLE) of the PLC is required in order to use the real time remotecross debugging function of the fuzzyTECH IA-S5 Edition, which connectsfuzzyTECH to a fuzzy controller running on the S5 PLC during runtime. Use aserial cable containing a level converter for the connection. Note that fuzzyTECHuses the AG-Link module by DELTALOGIC GmbH with copyright.

RTRCD-Limitations Although the complete functionality of the fuzzyTECH real time remote crossdebugger is realized on the S5, the trace function is especially limited. Thenumber of trace steps is restricted by the remaining space in the first generatedfunction block.

Example

Example:

FB 20 BIB=NETZWERK 1

NAME :MAINLOOP0005 :L KH 10000007 :T MW 100 Set 1. crisp value0008 :0009 :L KH 3000000B :T MW 102 Set 2. crisp value000C :000D :SPA FB 30 Call fuzzy system000ENAME :CRANE000F :0010 :L MW 104 Get 1. crisp output0011 :T AW 32 Proceed output0012 :0013 :BE

Page 278: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

278

6.1.4. Portable C Code

The source codes generated by the fuzzyTECH C code generator are portable.Thus, fuzzy runtime systems can be implemented on any target platform forwhich a C compiler exists. Any code generated by fuzzyTECH can be usedroyalty-free. This applies also to the library, as long as it has not been modifiedand is part of a project that was generated by fuzzyTECH.

Overview An implementation of a fuzzy runtime system consists of at least three modules:1. A fuzzy library, that stores the basic fuzzy algorithms which are independent

from any fuzzy system.2. One or more fuzzy system modules generated by the C code generator of

fuzzyTECH. Each module contains code and data for its specific fuzzy logicsystem.

3. One or more of your own software modules for implementing the application,that uses the fuzzy logic system.

4. A communication module, that implements one of the communicationchannels supported by fuzzyTECH. Note that this applies only to thefuzzyTECH Online Edition. Even for this edition the usage of acommunication module is optional.

Figures 162 and 163 illustrate the hierarchy of these modules:

User Modules

FuzzyModule

1

FuzzyModule

2

. . . Fuzzy ModuleN

fuzzyTECH C Runtime Library: Fuzzy Algorithms

Figure 162: Fuzzy Runtime Systems in C Language

User Modules

FuzzyModule 1

FuzzyModule 2

. . . FuzzyModule N

fuzzyTECH CRuntime Library:

fuzzyTECH C Runtime Library: Online Module

Fuzzy Algorithms CommunicationModule

Figure 163: Fuzzy Runtime Systems And Online in C Language

Page 279: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

279

The steps to get an application to run and compute one or more fuzzy logicsystems are described in this section as follows: Section 6.1.4.1 explains thesteps to build your own fuzzy library. Section 6.1.4.2 describes the integration ofthe user interface of the fuzzy system modules into your own source codes.Users of the fuzzyTECH Online Edition may need to integrate a communicationmodule to support the online connection between the fuzzy runtime system andthe fuzzyTECH Shell. Refer to Section 6.1.4.3 for more details. Section 6.1.4.4describes the process of linking all modules together to get an applicationrunning.

6.1.4.1. Building the fuzzyTECH C Runtime Library

Build Your Own Library The library used by the C code generator is delivered as source code to keep theC Code based fuzzy runtime systems portable to any platform. Therefore youhave to create the binary form of the library yourself. Building your ownfuzzyTECH C Runtime Library allows you to use your favorite compiler withyour favorite compiler settings for your favorite target CPU.

Note: You can use any C compiler for any target CPU. Neither does thefuzzyTECH C Runtime Library need other libraries nor does it include files ofyour compiler.Note: The fuzzyTECH C Runtime Library has to be built for your personalenvironment only once. Afterwards, it can be used for all fuzzy runtime systemson this environment.

Directory You should locate your library in the directory …\RUNTIME/C/LIB . Allnecessary source codes for building the library can be found in the directory…\RUNTIME/C/LIB/SRC .

To do Due to the great number of different C compilers, this section is a rather generaldescription and not a step-by-step guidance. It may be necessary to browse yourcompiler manual to realize the building steps. The library consists of manymodules. You will find one C source file for each module.1. Important: Set the fuzzy library preprocessor definitions. Please refer to

Section 6.1.4.1.1 for details.2. Compile all *.C source files to *.OBJ binary object files.3. Move all *.OBJ files to the library.

Please refer to the manual of your compiler, if you are not firm with these steps.Note: You can use both the command line version and, if available, theintegrated development environment (IDE) of your compiler. For some compilertool kits the library manager may be a separate tool.

Compiler Settings Due to the great number of very different C compilers, this section can give onlysome general hints. Some compilers offer options for optimizing the library

Page 280: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

280

either for size or for speed. Note: Some compilers may support different memorymodels (small, medium, large, ...). Make sure that the fuzzy library was compiledfor the same memory model as your application to be linked with the fuzzylibrary. If you want to use different memory models you have to build separatelibraries for each memory model. Please refer to your compiler manual for moredetails.

Sample The batch file FTMAKE.BAT creates the fuzzy library for the PC based Ccompilers of Microsoft or Borland. It is based on the command line versions ofboth compilers. You may use this file as sample for adapting your compiler.

6.1.4.1.1. Preprocessor Definitions

What Is It? Preprocessor definitions are standard control elements in the C language to buildif-else-constructs that are evaluated at compile time. The same source code canthus be used for multiple purposes. C programmers generally use preprocessordefinitions together with the statements: #define and #ifdef.

Why Is Their UsageEssential? Different fuzzyTECH Editions need different fuzzyTECH C Runtime Libraries.

The building process for the different libraries is controlled by preprocessordefinitions. You have to set one or more preprocessor definitions to build alibrary that matches the C code generated by your fuzzyTECH Edition. SomeEditions may generate C code for different computation resolutions. Thecomputation resolution is determined by the base variable type selected in theProject Options dialog Global. These editions need two libraries, one for 8-bitresolution and one for 16-bit or ‘double’ resolution.

Where Can They Be Set? Preprocessor definitions on compile time can either be set in the command lineof your compiler or in a dialog of your integrated development environment.Please refer to the manual of your compiler.Note: Most C compilers support in the command line version the switch -D or/D to set a preprocessor definition.

Which Shall Be Set? Refer to the tables below to find out which preprocessor definition must be setfor which library and which edition.

Edition Library Name Preprocessor Definitions (optional)Professional FTC16.LIB

FTC8.LIBFTLIBC16 PRECOMPILERFTLIBC8 PRECOMPILER

FT_KRCFT_KRC

Online FTC16.LIBFTC8.LIB

FTLIBC16 ONLINEFTLIBC8 ONLINE

FT_KRCFT_KRC

MCU-C, MCU-MP FTC16.LIBFTC8.LIB

FTLIBC16FTLIBC8

MCU-166, MCU-320, MCU-96 FTC16.LIB FTLIBC16MCU-51, MCU-ST6, MCU-374,MCU-11/12

FTC8.LIB FTLIBC8

Page 281: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

281

Preprocessor Definition Description

FTLIBC16 Enables 16 bit computation resolution.Note: The double interface of the code generator uses 16 bit resolution too.

FTLIBC8 Enables 8 bit computation resolution.PRECOMPILER Enables additional data used by the non MCU fuzzy algorithms.FT_KRC Enables the support of Kernighan&Ritchie C compilers. The default is

ANSI-C.

Sample Assuming you use the fuzzyTECH Professional Edition and the Microsoft VisualC/C++ Compiler. In order to create a library with 16 bit computation resolutionyou may compile all C files in the directory RUNTIME/C/LIB/SRC with thefollowing command line call:

cl.exe -c -DFTLIBC16 -DPRECOMPILER *.C

where cl.exe is the call to the Microsoft compiler, -c is the compilercommand for generating object files only, -D is the command to set thepreprocessor definitions and *.C is the wildcard for all C source files in thecurrent directory.

6.1.4.2. Using the Generated Module

Generate the C Module This section shows how C code generated by fuzzyTECH can be integrated inyour own software modules. Select “Tools\Compile to...\C...” in the main menuof fuzzyTECH to generate the current fuzzy logic project as C code. The codegenerator creates two files with the same name as the fuzzy system, one with thefile extension *.C, the other one with the extension *.H. The *.C file containscode and data of the fuzzy logic system, the *.H file contains the exportinterface of this module. Note, that the name of each exported function orvariable in this *.H file ends with the name of the fuzzy logic system. Note thatthe generated modules use the project independent fuzzy logic algorithms of thefuzzy library. Assuming you want to integrate two different fuzzy logic systemsin your application. Furthermore the fuzzy logic systems have the namesMYPROJ1.FTL and MYPROJ2.FTL. Generating the C-Modules for bothsystems will create the files:

MYPROJ1.C, MYPROJ1.HMYPROJ2.C, MYPROJ2.H

Overview The following enumeration gives an overview about the steps necessary tointegrate a fuzzy system module into the source code of your softwaremodule(s):

Page 282: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

282

1. Include C header files• Include the export interface(s) of the fuzzy system module(s).• fuzzyTECH Online Edition only: Include the export interface of the fuzzy

online module.2. Initialization during startup of your application

• fuzzyTECH Online Edition only: Initialize the fuzzy online module.• Initialize the fuzzy system module(s).

3. Computation of each fuzzy system module:• Set the input variables.• Call the fuzzy computation.• Get the output variables.

4. fuzzyTECH Online Edition only: Call the fuzzy online communication.5. fuzzyTECH Online Edition only: Trace control allows you to start or stop the

trace process with your own logical expressions.

Include Header Files You have to include a *.H file for each fuzzy system module in your C sourcecode. Users of the fuzzyTECH Online Edition have additionally to include thefile ONLINE.H which is located at RUNTIME\C\INCLUDE. Add thefollowing lines to the include section of your source code.

/*all fuzzyTECH Editions *//*include the export interfaces of the fuzzy systems*/#include "myproj1.h" /*fuzzy system 1*/#include "myproj2.h" /*fuzzy system 2*/

/*fuzzyTECH Online Edition only *//*include the export interface of the online module */#ifdef FT_ONLINE#include "online.h" /*fuzzy online manager*/#endif

Initialization Each fuzzy system module must be initialized only once during the startup of theapplication. The initialization function has no parameters and no return value.Users of the fuzzyTECH Online Edition have to initialize the fuzzy onlinemodule additionally. It’s important to do this before initializing the fuzzy systemmodules. Add the following lines to the part of your source that contains thestartup sequence.

/*fuzzyTECH Online Edition only *//*initialize the fuzzy online manager */#ifdef FT_ONLINEinitonline(); /* must be done first */#endif

/*all fuzzyTECH Editions *//*initialize the fuzzy system modules */initmyproj1();initmyproj2();

Page 283: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

283

Fuzzy Computation:Parameter Passing The fuzzyTECH C code generator supports two different possibilities of passing

the input and output variable values between your source code and the fuzzysystem module. This option is controlled by the Public Input and Outputcheckbox in the dialog “Project Options/Code Generator”.Depending on your setting you get C code with a computation function using:1. Function Parameters2. Global Variables.

Note that global variables will probably be easier to handle, if you change thenumber of input or output variables of your fuzzy logic system. The resultingcode may also be a little bit faster.

Fuzzy Computation:Data Type and Rangeof the Variables The fuzzyTECH C code generator supports different data types for input and

output variables of the fuzzy system. The data type is defined by the radiobuttons Base Variable Data Type in the dialog “Project Options/Global”.Depending on the setting in this dialog you get C code using variables with1. Data type FUZZY, which is 8 bit unsigned integer.

Value range: The code values set in the Variables Properties: Base dialog.2. Data type FUZZY, which is 16 bit unsigned integer.

Value range: The code values set in the Variables Properties: Base dialog.3. Data type double, which is the C standard type.

Value range: The shell values set in the Variables Properties: Base dialog.Fuzzy Computation:Function Prototype The function name for the fuzzy computation is in any case the same as given for

the fuzzy logic system itself. Depending on the chosen parameter passing anddata type options the fuzzy computation function exported in the *.H file willhave different prototypes.

1. Global variables, all data types:FLAGS myproj1(void);

2. Function parameters, data type FUZZY:FLAGS myproj1(FUZZY in1, FUZZY in2, ..., FUZZY* out1, FUZZY* out2, ...);

3. Function parameters, data type double:FLAGS myproj1(double in1, double in2, ..., double* out1, double* out2, ...);

If you use global variables the *.H file exports all input and output variables ofthe fuzzy logic system with the correct data type automatically. The names ofthese variables are constant. They are based on the names you have used infuzzyTECH and follow this scheme:<Variable Name>_<Module Name><Term Name>_<Variable Name>_<Module Name>

Page 284: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

284

If you use the function parameter interface, you have to declare variables in yoursource code. One variable for each input and each output of the fuzzy logic isrecommended. You are free to use any names for these variables, but their datatype has to be either double or FUZZY. When calling the computationfunction, you have to place your variables at the correct position that matches thefuzzy logic system. In any case the function needs first the inputs. They are inalphanumeric order sorted by the variable names used in fuzzyTECH. Thefunction expects call-by-reference parameters after the inputs. This is one pointerfor each output variable in alphanumeric order.

Fuzzy Computation:Function Call Assuming that the code of MYPROJ1 uses function parameters, the code of

MYPROJ2 uses global variables, and both fuzzy systems use the data typeFUZZY, your source code may look like the following pseudo C code:

/*i/o-handling and computation *//*fuzzy system MYPROJ1 with function parameters */FLAGS flags;/*declare some variables of data type FUZZYFUZZY a, b, c, ...; /* your variables */FUZZY x, y, z, ...; /* your variables */.../*compute the fuzzy system */flags = myproj1(a, b, c, ...,&x, &y, &z, ...);........./*i/o-handling and computation *//*fuzzy system MYPROJ2 with global variables *//*set all input variables of the fuzzy system */in1_myproj2 = ...; /* variables exported by MYPROJ.H */in2_myproj2 = ...; /* variables exported by MYPROJ.H */in3_myproj2 = ...; /* variables exported by MYPROJ.H */.../*compute the fuzzy system */flags = myproj2();/*use the output variables of the fuzzy system */... = out1_myproj2; /* variables exported by MYPROJ.H */... = out2_myproj2; /* variables exported by MYPROJ.H */... = out3_myproj2; /* variables exported by MYPROJ.H */...

Fuzzy Computation:Return Value The fuzzy computation function returns a value of the type FLAGS with the

fuzzy logic inference control flags. Each bit in FLAGS represents one outputvariable, starting with the lowest order bit and assigned in sequence to the outputvariables in alphanumeric order. A zero bit for a variable indicates that for thisoutput variable at least one rule has fired. Hence, a return value of zero indicatesthat for every output variable at least one rule has fired. The number of bits ofthe data type FLAGS depends on the fuzzyTECH Edition:

Page 285: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

285

fuzzyTECH Edition FLAGSProfessional, Online 32 bit integerMCU-96, MCU-166, MCU-320 16 bit integerMCU-C, MCU-ST6, MCU-MP,MCU-51, MCU-11/12

8 bit integer

Consider a fuzzy logic system with four (4) output variables: A_Output,B_Output, C_Output and D_Output. For this system, the bits 3...0 of the returnvariable correspond to variable A_Output ... D_Output. All higher order bits arenot used. A return value of 5, evaluated in a specific control cycle, indicates thatno rule has fired for the second and the forth output variable.

32-bitvalue

FLAGSflags=5

Variables inOutput Interface

OutputValue

MSB: 31 0 not used -30 0 not used -29 0 not used -28 0 not used -27 0 not used -

... ... ...... 0 not used -

... ... ...4 0 not used -3 0 A_Output calculated2 1 B_Output default-value1 0 C_Output calculated

LSB: 0 1 D_Output default-value

Figure 164: Return Flags of a Return Value 5 for a System With Four OutputVariables (32-bit FLAGS type)

Online Communication The fuzzyTECH Online Edition has the option to enable an online connectionwith your fuzzy runtime system. Add a call to the fuzzy online module in yoursource code to support this communication mechanism.

/*fuzzyTECH Online Edition only */#ifdef FT_ONLINEonline(); /* call the online module */#endif

Note that you must call this function regularly and as often as possible.Otherwise the online communication will run into a time-out. For example, ifyour application has a kind of main control loop, this would be the best place toinsert the function call.

Page 286: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

286

Note that the function online() should not interrupt the computation of thefuzzy systems. This is important, in case you use a timer interrupt to call thisfunction.

Note that the function online() is programmed in such a way that it consumesas little time as possible. During an active online connection it copies themaximum number of 76 bytes and sends an answer to fuzzyTECH before itreturns. If no active online connection is running, the function returnsimmediately.

Trace Control The fuzzyTECH Online Edition offers the option to generate C code supporting atrace buffer that records the input and output values of the fuzzy system in real-time in your application. During an online connection the trace process iscontrolled by the Trace Control dialog. The dialog offers an option to start orstop the trace process by external trigger events. Therefore the generated C codeexports two additional functions that control the trace process. Call thesefunctions in your source code to start or stop the trace at arbitrary logicalconditions. Note that once the Trace process has been started, multiple calls ofthe following start and stopp function are ignored:

/*fuzzyTECH Online Edition only *//*evaluate your own logical conditions *//*to start or stop the trace process */#ifdef FT_ONLINEif((fCond1 && fCond2) || fCond3) /*this is a sample!*/ StartTracemyproj1();else StopTracemyproj1();#endif

Code Samples The following pseudo C code samples illustrates the user interface of the fuzzymodules for different settings of the code generator options, i.e. base variabledata type and parameter passing.

Page 287: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

287

/* Example 1: MYMAIN.C */

/* single fuzzy project, function parameters, integer data type */

#include "myproj.h" /* include fuzzy system */

... /* more includes */

... /* more declarations */

void main(void) { /* main program */

FUZZY myin1, myin2,..; /* declare local variables */

FUZZY myout1, myout2,..; /* declare local variables */

FLAGS rv; /* declare return value */

... /* more code */

initmyproj(); /* initialize fuzzy system */

... /* more code */

while(!stop) { /* control loop */

... /* more code */

myin1 = ... /* set the input variable */

myin2 = ... /* set the input variable */

... /* more code */

rv = myproj(myin1, myin2,.., /* call the fuzzy system */

&myout1, &myout2,..); /* */

... = myout1; /* use the output variables */

... = myout2; /* use the output variables */

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 288: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

288

/* Example 2: MYMAIN.C */

/* single fuzzy project, function parameters, double data type */

#include "myproj.h" /* include fuzzy system */

... /* more includes */

... /* more declarations */

void main(void) { /* main program */

double myin1, myin2,..; /* declare local variables */

double myout1, myout2,..; /* declare local variables */

FLAGS rv; /* declare return value */

... /* more code */

initmyproj(); /* initialize fuzzy system */

... /* more code */

while(!stop) { /* control loop */

... /* more code */

myin1 = ... /* set the input variable */

myin2 = ... /* set the input variable */

... /* more code */

rv = myproj(myin1, myin2,.., /* call the fuzzy system */

&myout1, &myout2,..); /* */

... = myout1; /* use the output variables */

... = myout2; /* use the output variables */

... /* more code */

} /* end of control loop */

... /* more code */

} /* end of main program */

Page 289: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

289

/* Example 3: MYMAIN.C */

/* multiple fuzzy systems, global variables, */

/* any data type, online support */

#include "myproj1.h" /* include fuzzy system 1 */

#include "myproj2.h" /* include fuzzy system 2 */

... /* more fuzzy systems */

#ifdef FT_ONLINE /* */

#include "online.h" /* include online module */

#endif /* */

... /* more includes etc. */

void main(void) { /* main program */

FLAGS rv; /* declare return value */

... /* more code */

#ifdef FT_ONLINE /* */

initonline(); /* initialize online module */

#endif /* */

initmyproj1(); /* initialize fuzzy system 1*/

initmyproj2(); /* initialize fuzzy system 2*/

... /* initialize other systems */

... /* more code */

while(TRUE) { /* control loop */

... /* more code */

myin1_myproj1 = ...; /* set input data ... */

myin2_myproj1 = ...; /*...for fuzzy system 1 */

... /*...more inputs */

rv=myproj1(); /* call fuzzy system 1 */

... = myout1_myproj1; /* transfer output data ... */

... = myout2_myproj1; /*...to process */

... /*...more outputs */

... /* more code */

myin1_myproj2 = ...; /* set input data ... */

myin2_myproj2 = ...; /*...for fuzzy system 2 */

... /*...more inputs */

rv=myproj2(); /* call fuzzy system 2 */

... = myout1_myproj2; /* transfer output data ... */

... = myout2_myproj2; /*...to process */

... /*...more outputs */

#ifdef FT_ONLINE /* */

online(); /* call online module */

#endif /* */

... /* more code */

} /* end of control loop */

} /* end of main program */

Page 290: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

290

6.1.4.3. Online Communication Module

Online CommunicationChannels The fuzzyTECH Online Edition offers the option to enable an online connection

with your fuzzy runtime system. The fuzzyTECH Shell is running on a MSWindows operation system while your fuzzy runtime system may run on adifferent hardware platform. If you want to connect both systems, you have todecide, which communication channel is the best for your purpose. In every caseboth applications must use the same communication channel with the samesettings.

Communication Channelsof fuzzyTECH fuzzyTECH supports different standard communication channels as the serial

interface, shared file systems and IPX/SPX. Note, that fuzzyTECH offers an openinterface. You may write your own DLL that uses other communicationchannels. Refer to Section 7.2 for details.

Communication Channelsof Fuzzy Runtime System The main modules of the fuzzy online manager are part of the fuzzy library. This

does not include the layer that accesses to the hardware of the communicationchannel. It is separated due to portability reasons. The module consists of twofiles named COMM.C and COMM.H and has a fix interface that is used by thefuzzy library. You will find source codes for some communication modules inthe sub-directories of …\RUNTIME\C\LIB\SRC\ONLINE\COMM . The fileREADME.TXT in this directory contains additional information. You will findready-to-go modules for:1. MS DOS: Serial Interface2. OS/2: Serial Interface3. All: Shared File System

If you have decided which channel is the best for your target system, it may benecessary to change the original source code to set your preferred parameters.For example you may change the settings for the serial interface or you maychange the communication directory for shared file systems.

User Defined Modules If you use an other platform for your fuzzy runtime system, you have toimplement your own communication module. A prototype can be found in…\RUNTIME\C\LIB\SRC\ONLINE\COMM\USER\COMM.C. It contains fourempty functions that1. initialize and open the communication channel,2. close the communication channel,3. transmit bytes to the communication channel,4. receive bytes from the communication channel.Please follow the instructions in the comments of the functions. Note, that youshould not change the function prototypes. If you need help or more information,do not hesitate to contact our technical support.

Page 291: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

291

6.1.4.4. Compiling and Linking

This chapter describes the compiling and linking process of all modules that arepart of the fuzzy runtime system. Due to the great number of different Ccompilers, this section is a rather general description and not a step-by-stepguidance. It may be necessary to browse your compiler manual to realize thebuilding steps.

If you implement a new application please follow the steps of the enumerationbelow. If you add a fuzzy runtime system into an existing application pleaseproceed analogously.

1. Check, whether your C compiler is installed correctly.2. Check, whether you have built the fuzzy library.3. Create a new project or makefile for your application.

• Add your software module(s) to the project.• Add the fuzzy module(s) to the project. If your edition supports different data types, please note that it’s not

possible to integrate 16 bit or double fuzzy modules together with 8 bitfuzzy modules in the same application.

• Add the correct fuzzy library to your project. FTC16.LIB for fuzzy modules with data type 16 bit or double. FTC8.LIB for fuzzy module with data type 8 bit.• Add the communication module to your project (Online Edition only).• Add the directory …\RUNTIME\C\INCLUDE to the include file search

path of your compiler.• Add the directory …\RUNTIME\C\LIB to the library search path of your

compiler.4. Build the application.

• Compile your own module(s).• Compile the fuzzy module(s).• Compile the communication module (Online Edition only).• Link all object files and libraries.

5. Execute the application.

Figure 165 illustrates the build process for the fuzzyTECH Online Edition. Notethat all other editions do not need the communication module.

Page 292: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

292

Figure 165: Building an Application with Fuzzy Runtime Systems and Online

6.1.4.5. Examples

All fuzzyTECH Editions generating C code (refer to Table 5 of Section ) comewith at least one sample that shows the integration of the generated code in usermodules. The samples are located in the sub-directories of…\RUNTIME\C\SAMPLES. More details about the samples can be found inREADME.TXT.

MYMAIN Sample This sample aims only to illustrate the user interface between your own code andthe generated fuzzy module. Note, that most parts of the source code aredummies. There is no kind of display or interaction if you run the sample.

Directory and Files This sample is located at …\RUNTIME\C\SAMPLES\MYPROJ.It consists of following files:MYPROJ.FTL fuzzy systemMYMAIN.C your application codeMYPROJ.C fuzzy moduleMYPROJ.H fuzzy module export interfaceFTC16.LIB your fuzzy library

Page 293: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

293

Build Procedure For compilers of Microsoft or Borland the batch file BUILD.BAT demonstratesall steps necessary to build an running application.

6.1.5. COBOL Code

Requirements The COBOL code generator is available only, if you own a license for thefuzzyTECH COBOL Add-on. Also fuzzyTECH generates COBOL code only forthose fuzzy systems that have set '16 Bit unsigned integer' in “Tools/ProjectProject Options/General” in the field “Base Variable Data Type”.

The COBOL programs correspond to COBOL ANSI ’85 High Level‘ X3.24-1985 standard. Any code generated by fuzzyTECH can be used royalty-free. Thisapplies also to the fuzzyTECH COBOL Runtime Library, as long as it has notbeen modified and is part of a fuzzy system that was generated by fuzzyTECH.

Overview Each implementation of a COBOL fuzzy runtime system consists of at leastthree modules:1. The fuzzyTECH COBOL Runtime Library contains all fundamental fuzzy

algorithms that are independent from any fuzzy system.2. One sub-program for each fuzzy system. Those sub-programs are generated

by the fuzzyTECH COBOL code generator. They contain code and datawhich are specific to the corresponding fuzzy system.

3. A main or sub-program that calls the fuzzy system(s).

Figure 166: Integrating modules for a COBOL runtime system.

Page 294: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

294

6.1.5.1. COBOL Runtime Library

The fuzzyTECH COBOL Runtime Library consists of the sub-programsHFUZTECH.COB and BWOB.COB. This source codes contain the fundamentalfuzzy logic algorithms, that are independent from any specific fuzzy system.

The files are located in the sub-directory ..\Runtime\Cobol\Src.

6.1.5.2. Using the Generated Sub-ProgramGenerating aCOBOL sub-program This section demonstrates how to integrate the COBOL Code generated by

fuzzyTECH into your own COBOL programs. Click in the main menu offuzzyTECH on "Tools/Compile To.../COBOL...". This translates the fuzzysystem into COBOL source code. The code generator creates two files that havethe same name as the fuzzy system. One of the files has as extension *C.CPYand contains the i/o variables of the fuzzy system as copy book. The second filehas the extension *.COB and contains code and data of the fuzzy system. ThisCOBOL sub-program can compute the corresponding fuzzy system by callingthe fuzzyTECH COBOL Runtime Library.

Overview The following enumeration gives a short overview how to integrate and use theCOBOL sub-program into your own source codes.1. Copy the i/o interface2. Compute the fuzzy system

• Set the input variables• Call the fuzzy computation• Get the output variables

If you integrate more than one fuzzy system, you have to repeat these steps foreach system. Now the steps are described more detailed. Let’s assume that thename of the fuzzy system is ’TEST’. Then the fuzzyTECH COBOL codegenerator writes the following files:

TEST.COBTESTC.CPY

Copy Book First of all import the i/o interface of the fuzzy system into your main or sub-program. For that purpose use the copy book TESTC.CPY generated byfuzzyTECH. Your source code should contain the following lines:

WORKING-STORAGE SECTION.COPY TESTC.

Parameter Passing andFuzzy Computation By using the copy book you get the i/o variable names of the fuzzy system. In

the following example this are the names In1, In2, Out1 and Out2. Use the

Page 295: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

295

variable names in the copy book to set values of your program to the inputvariables of the fuzzy system. Then you can compute the fuzzy system by callingthe sub-program. This re-calculates the output variables of the fuzzy system.Nextyou can read the values of the output variables in your program. For this yourCOBOL source code should look similar to this:

MOVE ... TO IN1MOVE ... TO IN2CALL ’TEST’ USING BY CONTENT TEST-IN BY REFERENCE TEST-OUTMOVE OUT1 TO ...MOVE OUT2 TO ...

Data Type andValue Range The fuzzyTECH COBOL code generator uses the data type PIC S9(05) BINARY

for the i/o variables of the fuzzy system. The value range of each variable isdefined by the corresponding 'Code Values' settings in fuzzyTECH.

6.1.5.3. Example

The following example demonstrates a minimum main program that calls theCOBOL code generated by fuzzyTECH.

IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. AUTHOR. INFORM. DATE-WRITTEN. APRIL 1999. *----------------------------------------------------------------- ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. *----------------------------------------------------------------- DATA DIVISION. *----------------------------------------------------------------- WORKING-STORAGE SECTION. COPY TESTC. *----------------------------------------------------------------- PROCEDURE DIVISION. *set input variables of fuzzy system ’TEST’ ---------------------- MOVE 12345 TO IN1 MOVE 54321 TO IN2 *compute fuzzy system TEST --------------------------------------- CALL ’TEST’ USING BY CONTENT TEST-IN BY REFERENCE TEST-OUT *get output variables of fuzzy system ’TEST’ --------------------- DISPLAY OUT1 DISPLAY OUT2 STOP RUN.

Page 296: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

296

6.1.6. M Code

All fuzzyTECH Editions support the generation of a fuzzy system as M-code.Generation of M-code is one way to integrate fuzzyTECH blocks intoMATLAB®/SIMULINK®. Another way is to use the FTRUN add-on module forintegration as described in Section 6.1.2. Note: M-code does not allow access tointernal or external interfaces. Thus, system visualization and on-the flyoptimization can not be supported. In order to create a fuzzy task in Mapplications:

1. Create your fuzzy system in fuzzyTECH:2. Save your project in FTL using names that have not previously been used as

applications or built-in M functions. Although FTL files use differentextensions, the fuzzyTECH M-code generator creates *.M files.

3. Use the “Compile to/ M...” option in the Tools main menu, do not overwritebuilt-in M functions.

4. Write an M user program (e.g., MYMAIN.M) that integrates the fuzzycontroller M code.

5. Ensure that your environment is configured in a way that the necessary M-code library files are available (see …\RUNTIME\MATLAB\SRC\… ). Thegenerated code will call M-code functions from this library.

Code Integration The integration of a fuzzy system in M is simple. In order to use the generated Mcode, the user program must:

1. Call CRANE.M to activate the generated knowledge base.2. Poke input values into the knowledge base memory by using a predefined

index. The index is assembled by the names of the variables and the projectname. The two names are connected by an underscore, e.g.:kbm(Variable1_myproj)= inputvalue;

3. Call the computation engine hfuztech to return with this function a flagindicating either a value computed by fuzzy rules or the default value.

4. Peek the output values from the knowledge base memory. Use the predefinedindex like in step 2: e.g.:outputvalue = kbm(Variable1_myproj);

M-Code Example%––---- M-Code-Example MYMAIN.M------------------crane; % activate controllerkbm(Angle_crane) = 26000;kbm(Distance_crane) = 0;flags = hfuztech;if( flags > 0 )s = sprintf(’ANGLE:%5d DISTANCE:%5d POWER:%5d -NO RULE FIRES-’, kbm(Angle_crane), kbm(Distance_crane), kbm(Power_crane) );

Page 297: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

297

else s = sprintf(’ANGLE:%5d DISTANCE:%5d POWER:%5d -RULES HAVE FIRED-’, kbm(Angle_crane), kbm(Distance_crane), kbm(Power_crane) );end

6.2. Using TECH as Server

This section provides a reference to the interface functionality of the fuzzyTECHintegrated computation kernel.

MS Excel, VisualBasic,or other MS WindowsApplications In order to find the appropriate implementation technique for your fuzzy

solution, this section explains how to interface the fuzzyTECH computationkernel to MS Excel, MS VisualBasic or other MS Windows applications byusing DDE, Serial Link and RCU.

Figure 167: fuzzyTECH Development Shell as server for fuzzy computations

Page 298: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

298

6.2.1. DDE

DDE is one of the ways to connect fuzzyTECH with other MS Windowsapplications.

What is DDE? DDE is the acronym for Dynamic Data Exchange. DDE is a communicationprotocol designed by Microsoft to allow applications in the Windowsenvironment to send/receive data and instructions to/from each other. Itimplements a client-server relationship between two concurrently runningprograms. The server application provides the data and accepts requests from anyother applications interested in its data. Requesting applications are calledclients. Some applications (e.g. Microsoft Excel) can simultaneously be both aclient and a server.

DDE Address DDE uses so-called DDE addresses to identify data items. A DDE addressconsists of three parts in the following notation: Server|Topic!Item.

fuzzyTECH can be used both as client or server. Also fuzzyTECH can be clientand server at the same time. In any case DDE is used to exchange the followingdata items between fuzzyTECH and other applications:1. The values of the fuzzy system’s input variables2. The values of the fuzzy system’s output variables (after re-computation of

the fuzzy system).

6.2.1.1. fuzzyTECH as DDE Server

MS Windows applications can use fuzzyTECH as DDE server. Refer to the clientdocumentation to see where and how to enter the fuzzyTECH DDE addresses inthe client application. The fuzzyTECH DDE addresses are built as usual by thethree parts Server|Topic!Item. fuzzyTECH accepts the topic ’System’ and a so-called Debug topic, that is addressed with name of the fuzzy system that is openin fuzzyTECH.

Debug Topic Client applications can use the debug topic only, if one of the debug modes isactivated in fuzzyTECH. Clients can link (hot, warm or cold) to all i/o variablesof the fuzzy system to read their current values. If the debug mode is ’Interactive’clients have write access (DDE Poke) to the input variables.

The fuzzyTECH DDE addresses consist of the application name FTWIN (server),the name of the fuzzy system (topic), and the name of the variable (item), suchas:

Page 299: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

299

Additionally, fuzzy variables contain the name of a variable's term in the itemelement, such as: FTWIN|CRANE!Angle.zero

Example Debug Topic The directory ..\DDE\Excel\Sample2 contains an example demonstrating, howMS Excel as DDE client can use fuzzyTECH as DDE Server. First, openSERVER.FTL into fuzzyTECH and activate a debug mode, then openCLIENT.XLS into MS Excel.

System Topic Clients can address the System topic when fuzzyTECH is running. The followingitems can be addressed with the topic FTWIN|System:

File The client gets name and path of the fuzzy system that isopen in fuzzyTECH (FTWIN|System!File).

Edition The client gets name and release number of the fuzzyTECHEdition (FTWIN|System!Edition).

Execute Commands DDE clients can send commands (DDE Execute) to the topic FTWIN|System.This way clients have some kind of remote access to fuzzyTECH. The clientmust send the command as string. Each command must be enclosed by squarebrackets.

Client applications can guarantee that the execution of several single commandscannot be interrupted by user actions. For that purpose concatenate all singlecommand to one string.

Commands Parameter DescriptionOpen "<File>" fuzzyTECH opens the file specified

by <File>.Debug 1 | 0 fuzzyTECH enables (1) or disables

(1) the debug mode "Interactive".Compile <Code Type>, "<Dest>" fuzzyTECH generates source code

specified by <CodeType> into thefolder specified by <Dest>.

Exit none fuzzyTECH will be terminated.

Refer to the fuzzyTECH Help system for a value list of the parameter<CodeType>.

Page 300: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

300

SamplesExecute Commands The following example strings demonstrate valid commands, that are accepted

and executed by the fuzzyTECH DDE server:

[Open("c:\temp\myfuzzy.ftl")][Compile(0, "c:\temp\")][Compile(22, "d:\code\")][Debug(1)][Debug(0)][Exit][Open("d:\fuzzy systems\my.ftl")][Debug(1)][Open("c:\temp\sample1.ftl")][Compile(28, "c:\temp")][Exit][Open("c:\sample1.ftl")][Compile(0, "c:\temp")][Open("c:\sample2.ftl")][Compile(0, "c:\temp")][Exit]

6.2.1.2. fuzzyTECH as DDE Client

fuzzyTECH can be configured a DDE client. For that purpose all (or some) i/ovariables of the fuzzy system open in fuzzyTECH can be linked with one (ormore) DDE clients. Nearly every MS Windows application can act as DDEserver. This way fuzzyTECH can use e.g. MS Access or MS Excel as DDEserver. The same applies to most software packages in process visualization antautomation.

If the debug mode ’Interactive’ is enabled in fuzzyTECH, each i/o variable with aDDE link connects itself with the corresponding DDE Server. The followingapplies to those variables.

Input Variables(Hot Link) fuzzyTECH sets up a so-called hot link to the corresponding DDE server. This

means: Each time the DDE server changes the value of the corresponding item,the input variable in fuzzyTECH is updated automatically and the fuzzy system isre-computed.

Output Variables(Poke) As soon as fuzzyTECH changes the value of an output variable, fuzzyTECH

writes (DDE Poke) the new value into the corresponding DDE server. Note thatsome DDE servers don’t allow poke operations. In doubt refer to documentationof the server.

Configuration Open the DDE Links dialog in fuzzyTECH (“Edit/DDE Links”) to map the i/ovariable to DDE server addresses. Figure 168 demonstrates the link to an MSExcel Workbook. The DDE addresses of MS Excel are built from the schemeServer|Topic!Item as follows: Server is fix 'Excel'. The Topic identifies a certainsheet in a certain workbook, here [Server.xls]Sheet1. The item identifies acertain cell in the sheet given by the topic. The items use the so-called R1C1reference style.

Page 301: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

301

Figure 168: Set the DDE Address in the DDE Links dialog

Example The directory ..\DDE\Excel\Sample1 contains an example demonstrating, howfuzzyTECH as DDE client can use MS Excel as DDE Server. Note that you haveto open a file into fuzzyTECH that matches the language of your MS Excel. OpenCLIENT_E.FTL for English Excel or open CLIENT_D.FTL for Germanlanguage Excel. Dependent on the language the items (cells) in MS Excel areaddressed with the R1C1 or Z1S1 notation.

6.2.2. fuzzyTECH Remote Control Unit (RCU)

Integration in VisualBasic applications, Access, Excel, VisSim and theDataAnalyzer are all based on the fuzzyTECH Remote Control Unit (RCU). Thefunction of the RCU interface is contained in the FTRCU.DLL. This DLL islocated in the FTHOME directory of your fuzzyTECH installation. You can findthe headers for this DLL in a separate directory called FTxxx\RCU\C.

The RCU headers support two types of interfaces:• the single call remote interface (SCI) for the most quick and easy integration• the standard call remote interface (STCI) supports a complete function set for

controlling fuzzy computations from your application.

Page 302: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

302

6.2.2.1. C Code

Single Call (SCI) The SCI is the easiest way to request a fuzzy computation from fuzzyTECH. Thesingle function call• verifies whether fuzzyTECH is started and starts fuzzyTECH if required,• verifies whether a determined project is loaded and loads the project if

required,• verifies whether RCU-debug mode is enabled and switches to this mode if

required,• sets the values of the input variables,• processes a computation of the fuzzy system,• returns a specified output variable’s defuzzified result of the fuzzy system.

Every time an SCI function is called, a complete check procedure is executed.Thus, the SCI does not provide the best performance for processing hugeamounts of data.

Standard Call Interface The STCI gives you remote control of the main operations in fuzzyTECHthrough separate function calls. The STCI includes functions to:• set the state of fuzzyTECH; start (optional: minimized) and terminate

fuzzyTECH, and enter or leave the RCU debug mode,• load a project in fuzzyTECH or execute the File New command,• check the current project, plus deliver project name and the number of input

and output variables,• get information about each variable of the fuzzy system. Such information

include, above all, the name of the variable, type of the variable(input(output), data type, and an index for quick access.

• set new values of input variables, referencing them either by variable name orby index,

• process a computation of the fuzzy system,• return a single or all defuzzified results of the output variables.

WIN.INI In order to initiate a RCU connection from an application to fuzzyTECH, RCUhas to know the location of the fuzzyTECH home directory. This information isstored in the file WIN.INI, in the section [FTWIN] by the variableFTWINPATH. This specification is obligatory for any kind of RCUcommunication. The variable FTWINPATH points to the directory wherefuzzyTECH is installed. If you have problems with your installation or if youchange the path of the home directory, please check the WIN.INI for thefollowing section:

[FTWIN]FTWINPATH=DRIVE:\PATH\FTxxx

Page 303: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

303

Function Call Reference All RCU functions are described in the header file RCUFUNC.H of the…\RCU\C directory. A summary of the header is printed in the followinglistings:

/* +---------------------fuzzyTECH Remote Control Unit----------------------+ *//* the single call remote interface *//* scaleable number of inputs and outputs: *//* Parameters: *//* Project : Name of the fuzzyTECH project file. (LPSTR) *//* NumIn : Number of input interfaces of the project file. *//* (unsigned short) *//* NumOut : Number of output interfaces of the project file. *//* (unsigned short) */

#ifdef _ftrptypes/* Return : 0 : Ok. *//* != 0 : an error occurred. */unsigned short FAR PASCAL FTWINRTE_SCINM(LPSTR Project, unsigned short NumIn, unsigned short NumOut, double FAR* lpIn, double FAR* lpOut);/* lpIn : Sequence of inputs values according to the alphabetical order of the*//* interface input variable names. (far pointer to an array of doubles)*//* lpOut: Sequence of outputs values according to the alphabetical order of the*//* interface output variable names. (values computed by fuzzyTECH). *//* (far pointer to an array of doubles) */

unsigned short FAR PASCAL FTWINRTE_SCINAM(LPSTR Project, unsigned short NumIn, unsigned short NumOut, LPSTR* lpInNames, LPSTR* lpOutNames);/* lpInNames : Far pointer to an array of string pointers. *//* Each string gives an input value for one input interfaces. *//* lpOutNames: Far pointer to an array of string pointers. *//* Each string gives an output interface name. */

unsigned short FAR PASCAL FTWINRTE_SCINAMVAL(LPSTR Project, unsigned short NumIn, unsigned short NumOut, LPSTR* lpInNames, double FAR* lpIn, LPSTR* lpOutNames, double FAR* lpOut);/* lpInNames : Far pointer to an array of string pointers. *//* Each string gives an intput interface name. *//* lpIn : Input values according to the sequence given by lpInNames. *//* lpOutNames: Far pointer to an array of string pointers. *//* Each string gives an output interface name. *//*lpOut: Outputs values expected according to the sequence given by lpOutNames.*/

/* Usage of the single call interface functions SCI04-SCI20: *//* The sequence of the input values must be set in the alphabetical order *//* of the input variable names. (Refer to the variable listbox in fuzzyTECH). *//* These simple functions do not support error handling. *//* Parameters: */

Page 304: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

304

/* Target : 1 <= index <= NumOut. Specifies the requested *//* output interface. (unsigned short)*//* I1,...: Sequence of input values (double) *//* Return: the result of requested output interface. */

double FAR PASCAL FTWINRTE_SCI04(LPSTR Project, unsigned short NumIn, unsigned short NumOut, unsigned short Target, double I1, double I2, double I3, double I4);

double FAR PASCAL FTWINRTE_SCI08(LPSTR Project, unsigned short NumIn, unsigned short NumOut, unsigned short Target, double I01, double I02, double I03, double I04, double I05, double I06, double I07, double I08);

double FAR PASCAL FTWINRTE_SCI12(LPSTR Project, unsigned short NumIn, unsigned short NumOut, unsigned short Target, double I01, double I02, double I03, double I04, double I05, double I06, double I07, double I08, double I09, double I10, double I11, double I12);

double FAR PASCAL FTWINRTE_SCI16(LPSTR Project, unsigned short NumIn, unsigned short NumOut, unsigned short Target, double I01, double I02, double I03, double I04, double I05, double I06, double I07, double I08, double I09, double I10, double I11, double I12, double I13, double I14, double I15, double I16);

double FAR PASCAL FTWINRTE_SCI20(LPSTR Project, unsigned short NumIn, unsigned short NumOut, unsigned short Target, double I01, double I02, double I03, double I04, double I05, double I06, double I07, double I08, double I09, double I10, double I11, double I12, double I13, double I14, double I15, double I16, double I17, double I18, double I19, double I20);

#endif

Note: For all function modes, appropriate constant expressions are defined. Please usethem instead of the numbers they represent. If you use a different programminglanguage, please use similar concepts to declare the function modes.

Page 305: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

305

/* +---------------------fuzzyTECH Remote Control Unit----------------------+ *//* =================== the standard call remote interface ====================*//* function declaration and description: */unsigned short FAR PASCAL FTWINRTE_State(unsigned short Mode);/* defines for FTWINRTE_State: */#define RTESTD_STE_CLOSE 0#define RTESTD_STE_STARTNORMAL 1#define RTESTD_STE_STARTICON 2#define RTESTD_STE_DEBUG 4#define RTESTD_STE_NODEBUG 8#define RTESTD_STE_STAYOPENFLAG 16#define RTESTD_STE_TERMINATEFLAG 32

Usage: Starting and terminating fuzzyTECH, and switching to the debug mode can bedone with the functions listed above. The parameters used are:

Parameters: Value DescriptionMode: 0 Terminate the fuzzyTECH application

1 Start fuzzyTECH as a window2 Start fuzzyTECH as an icon4 Enter debug mode (necessary for computing)8 Leave debug mode16 Normally fuzzyTECH is closed when the RCU

connection is destroyed. For this purpose,fuzzyTECH holds a StayOpen-Flag which is initiallyset to FALSE. A function call with the modeRTESTD_STE_STAYOPENFLAG sets that flag toTRUE.

32 Resets the StayOpen-Flag in fuzzyTECH to FALSE.Return: (Coded as a bitflag array)LO-bit (2^0): 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_LoadProject(LPSTR Name);/* defines for FTWINRTE_LoadProject: */#define RTESTD_FILE_NEW 0L

Usage: Loads a fuzzyTECH project file (*.FTL). The currently loaded file will bereplaced. The function can also initiate a "File New". The parameters used are:

Parameters: Value DescriptionName: OL If the parameter is long zero: "File New"

nonzero The value is interpreted as a pointer to string. IfName is an empty string: "File New"

Return: (Coded as a bitflag array)LO-bit (2^0) 0 No error

1 Error

Page 306: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

306

unsigned short FAR PASCAL FTWINRTE_GetProjectInfo(unsigned short Mode, long Data, long ExtData);\*defines forFTWINRTE_GetProjectInfo: */#define RTESTD_PRJ_SINGLEMODE 0#define RTESTD_PRJ_COMPACTMODE 1#define RTESTD_PRJ_NDCOMPACTMODE 2#define RTESTD_PRJ_PRJNAME 0#define RTESTD_PRJ_NUMINPUTS1#define RTESTD_PRJ_NUMOUTPUTS 2

Usage: Retrieves the number of input and output variables. The name of the loadedfuzzyTECH project is also returned. The parameters used are:

Parameters: Value DescriptionMode: 0 Single mode: With this mode it is possible to ask for

single units of information. No special data structureis needed.

1 Compact mode: Here, the given data structure isfilled with all information available for this function.

2 Compact mode (prerequisite: no debug mode): Thismode is comparable to mode 1, except that thecomputation indices of the input/output variables arenot transferred to the caller. For this reason, thismode ignores the debug state of fuzzyTECH. Forfurther details see the header.

Data: The parameter data depends on the mode chosen forthe variable Mode.

0 In single mode: get project name1 In single mode: get number of input variables2 In single mode: get number of output variables

In compact mode: the parameter Data represents apointer to a structure in which all projectinformation will be set by the function.

ExtData: If single mode is selected, ExtData represents apointer to an appropriate data structure. If thecompact mode is selected, the parameter ExtData isnot used.

Return: (Coded as a bitflag array)LO-bit (2^0) 0 No error

1 Error

Page 307: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

307

unsigned short FAR PASCAL FTWINRTE_GetInterfaceInfo(unsigned short Mode, long Data, long ExtData);/* defines for FTWINRTE_GetInterfaceInfo: */#define RTESTD_ITFC_COMPACT 0#define RTESTD_ITFC_LVNAME 1#define RTESTD_ITFC_FASTIDX 2#define RTESTD_ITFC_ITYP 3#define RTESTD_ITFC_INOUT 4#define RTESTD_ITFC_IDXACCESS 1#define RTESTD_ITFC_RESET 2#define RTESTD_ITFC_NEXT 4#define ERRINFO_LISTEND 0x0010

Usage: Retrieves information about all input/output variables defined in fuzzyTECH.

Parameters: Value DescriptionMode: 0 Compact Mode (all information is stored in one data

structure)1 Gets the name of linguistic variable.2 Gets the fast computation index.3 Retrieves the data type.4 Determines whether it is an input or output variable.

Data: The functionality of the parameter Data is definedby a HIWORD and a LOWORD. The HIWORD ofData determines the selection of a variable by settinga bitflag. If the flag “Access mode” is chosen,LOWORD contains an access index. LOWORDremains unused in any other cases. The flag “reset”lets you scroll back to the beginning of the variable´slist, “next” lets you skip to the following variable. Ifnon of both flags is set, the currently highlightedvariable is read. If the compact mode is selected, theLOWORD is ignored.

HIWORD: 1 Access mode2 Reset Flag4 Next Flag

8,16,32 Not UsedExtData: Contains a pointer to the appropriate data structure.Return: (Coded as a bitflag array)LO-bit (2^0) 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_GetInterfaceCompIdx(LPSTR LVName, long Data);

Page 308: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

308

Usage: Retrieves the fast computation index for a defined variable. This function can beuseful if the interface variable names remain fixed and only the fast computationindex is requested by the client.

unsigned short FAR PASCAL FTWINRTE_SetConversation(unsigned short Reference, unsigned short Datatype, unsigned short ParamMode, unsigned short FAR* CMode);/* defines for FTWINRTE_SetConversation */#define RTESTD_CONV_SINGLE 0#define RTESTD_CONV_ARRAY 1#define RTESTD_CONV_DOUBLE 0#define RTESTD_CONV_INDEX 0#define RTESTD_CONV_NAME 1

Usage: Sets the mode for passing values to and from the fuzzyTECH developmentsystem.

Parameters: Value DescriptionReference: 0 Single value data transfer

1 Array value data transferDatatype: 0 DoubleParamMode: 0 Referenced by index (or a set of them)

1 Referenced by name (or names)CMode (Return): This function leads to the setting of the variable

Cmode. Thus the set variable is used as an inputparameter by calling the functions:FTWINRTE_SetCrispInput(WORD CMode,...FTWINRTE_GetCrispOutput(WORD CMode,...and determines there the index mode.

Return: (Coded as a bitflag array)LO-bit (2^0) 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_SetCrispInput(unsigned short CMode, long Value, long Data);

Usage: Sets a crisp value for the input value of the fuzzy logic system.

Parameters: Value DescriptionCMode: ----- Generated by FTWINRTE_SetConversation.Value: pointer Depending on FTWINRTE_SetConversation.

ParamMode =0: pointer to WORD index(indices). Ifthis Reference is 1, Value expects all input values.Otherwise, only one input can bet set.

Page 309: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

309

ParamMode =1: pointer to string(s) pointer(s) of allinput variable names.

Data: pointer Data represents a pointer to double(s).Return: (Coded as a bitflag array)LO-bit (2^0): 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_Compute(void);

Usage: Initiates the computation of the fuzzy logic system.

Parameters: Value DescriptionReturn: (Coded as a bitflag array)LO-bit (2^0): 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_GetCrispOutput(unsigned short CMode, long Value, long Data);

Usage: Gets the result of an output variable as computed by fuzzyTECH for the fuzzylogic system.

Parameters: Value DescriptionCMode: ----- Generated by FTWINRTE_SetConversation.Value: pointer Depending on FTWINRTE_SetConversation.

ParamMode =0: pointer to double value(s). If thisreference is 1, Value refers to a set of output values.Otherwise, only one output is passed.ParamMode =1: pointer to string(s) pointer(s) ofoutput variable names.

Data: pointer Data represents a pointer to double(s).Return: (Coded as a bitflag array)LO-bit (2^0): 0 No error

1 Error

unsigned short FAR PASCAL FTWINRTE_GetFuzzyInterfaceInfo(unsigned short Mode, long Data, long ExtData);/* defines for FTWINRTE_GetFuzzyInterfaceInfo: */#define RTESTD_FUZLV_COMPACT 0#define RTESTD_FUZLV_NUMTERMS 1#define RTESTD_FUZLV_FASTIDX 2#define RTESTD_FUZLV_TERMNAME 3#define RTESTD_FUZLV_TERMVAL 4

Page 310: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

310

Usage: Retrieves information about all fuzzy input/output variables in fuzzyTECH.

Parameters: Value DescriptionMode: 0 Compact mode: The name of the data structure is

RCU_FUZZYLV and is defined in rcutypes.h. Thepointer is of the type LPRCUFUZZYLV.

1 Gets the number of terms of the linguistic variablestored in an interface.

2 Gets the fast computation index of a specific term.3 Gets the name of a specific term.4 Gets the term value of a specific term of a variable.

For further details see the header.Data: The function of Data is divided into HIWORD and

LOWORD.ExtData: Contains a pointer to the appropriate data structure.Return: (Coded as a bitflag array)LO-bit (2^0) 0/1 No error/ error

unsigned short FAR PASCAL FTWINRTE_SetFuzzyInterface(unsigned short Mode, long Data, long ExtData);/* defines for FTWINRTE_SetFuzzyInterface: */#define RTESTD_FUZLV_COMPACT 0#define RTESTD_FUZLV_SINGLE 1

Usage: Sets term value of fuzzy interface in fuzzyTECH.

Parameters: Value DescriptionMode: 0 Compact mode: Sets a single term value of a specific

term of a variable. For further details see the header.Data: The function of Data is divided into HIWORD and

LOWORD.ExtData: Contains a pointer to the appropriate data structure.Return: (Coded as a bitflag array)LO-bit (2^0) 0/1 No error/ an error is occurred

6.2.2.2. MS Excel

fuzzyTECH Editions cooperate with MS Excel by using the single call interfaceof the fuzzyTECH remote control unit. fuzzyTECH provides an Assistant in Excelto create Excel function calls.

Installation Install fuzzyTECH and MS Excel separately.

Page 311: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

311

Integrate FTWIN32.XLA In Excel, call “Tools/Add-Ins…” and integrate the file FTWIN32.XLA (forExcel 7.0) or FTWIN.XLA (for Excel 5.0 ) from the FTxxx\RCU\EXCELdirectory. fuzzyTECH is now automatically called when Excel is started. ThefuzzyTECH Assistant"fuzzyTECH:Excel Assistant" appears as a separate sectionamong the Excel toolbars. If Excel is not able to integrate the fuzzyTECHAssistant, check the installation of the fuzzyTECH remote control unit. If Excelasks you if you wish to copy your file into the Excel home directory it’s better toanswer “no”. This has a beneficial effect on upgrading your old fuzzyTECHEdition. A new fuzzyTECH edition provides a new Assistant in Excel which mayrequire the elimination of the old one. By saying “no” you will save time sincethe previous Assistant won’t have to be removed.

Fuzzy Function Call The assistant generates function calls in all cells assigned to the output interfacesof a fuzzy project. The functions use parameters to determine the fuzzy projectused, the number of input and output interfaces used, the cell references of inputcells, and the number of the outputs used to compute the cell values. In thefollowing, some examples of valid function calls are provided.

Examples The first example shows a call to a fuzzyTECH project CRANE.FTL with twoinputs, one output, using the first (and only) output, which references input 1from cell A1 and input 2 from cell B1 of Sheet1. The second example connectsthe project BENCH4.FTL using eight inputs and four outputs. The function callresults in a value from output number 3 and uses the cell references A3 to H3 toread input data from Sheet1.

=FTWIN32.XLA!FuzComp("DRIVE:\FTxxx\SAMPLES\CONTROL\CRANE\CRANE.FTL",2,1,1,Sheet1!$A$1,Sheet1!$B$1)

=FTWIN32.XLA!FuzComp("C:\FTONLINE\SAMPLES\BENCH\BENCH4.FTL",8,4,3,Sheet1!$A$3,Sheet1!$B$3,Sheet1!$C$3,Sheet1!$D$3,Sheet1!$E$3,Sheet1!$F$3,Sheet1!$G$3,Sheet1!$H$3)

Working on Fuzzy Calls The functions generated are implemented as macro function calls. The functioncalls can be edited, overwritten or deleted if the fuzzy system must bedisconnected from the spreadsheet. Also, a function call can be typed directlyinto a spreadsheet cell. The parameter syntax is nearly self explanatory withinthe given examples. The macro function FUZCOMP has a variable parameterlist and uses the following arguments:1. The complete path and name of the fuzzyTECH project file.2. The number of input variables.3. The number of output variables.4. The index of the output variable used to compute the cell result.5. The cell references to the input variables.

Page 312: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

312

The index for specifying an output variable is determined by assigning indexnumbers in alphanumeric order according to the output interface variable namescounting upward from 1. The cell references connecting the input interfaces aresequenced alphanumerically according to the input variable input interfacesvariable names.

Interface The fuzzy functions in the spreadsheet require that the fuzzyTECH Assistantinterface (FTWIN.XLA or FTWIN32.XLA) is loaded in Excel. The macrofunction FUZCOMP is enabled by this interface.

Worksheet Names inCell References The fuzzyTECH Assistant adds the current worksheet name to the cell reference.

Thus, fuzzy calls can use cells from different spreadsheets. Make certain that noblanks are used in the worksheet name. Although blanks can be used in Excel,macro function calls fail when the worksheet name contains blanks.

Absolute andRelative References The fuzzyTECH Assistant always uses absolute references as function

parameters. If you want to copy a fuzzy function by using relative cell referencesor fill a cell area with the fuzzy function call, delete the $-signs from thereference parameters.

How to deactivate thefuzzyTECH Assistant If you want to deactivate the fuzzyTECH Assistant, choose the “Add-Ins” option

in the Tools main menu and deselect the fuzzyTECH Assistant.

6.2.2.3. MS VisualBasic

fuzzyTECH integrates the RCU-interface into MS VisualBasic applications.Although not all features of the RCU-Interface are supported under Visual Basic,the interface completely enables the single call interface and the standardinterface as basic modules. This module can be added to your application byusing the [Add-File] item in the [File] menu of MS VisualBasic. The basicmodule RCUFCNS.BAS is in the FTxxx\RCU\VB directory of your fuzzyTECHinstallation. The module RCUXMPLE.BAS gives an example for the use ofinterface procedures. The procedure enables the single call interface and thestandard call interface of the fuzzyTECH remote control unit. LoginRCU has tobe called before using the RCU interface. Afterwards, the variable RCUHandleholds the access handle for the loaded RCU DLL. LogoutRCU has to be calledbefore the program is terminated.

Single Call Interface The SCI is used, for instance, with the following commands:

RCUHANDLE Reset the handle of the RCU-DLL.

LoginRCU Connect Visual Basic to the FTRCU.DLL. If this DLL isloaded appropriately, the global variable RCUHandle has avalue greater than 32.

Page 313: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

313

LogoutRCU Disconnects Visual Basic from FTRCU.DLL.

Single Call Functions The following single call functions are enabled:• FTWINRTE_SCI04() for projects with up to 4 input variables• FTWINRTE_SCI08() for projects with up to 8 input variables• FTWINRTE_SCI12() for projects with up to 12 input variables• FTWINRTE_SCI16() for projects with up to 16 input variables• FTWINRTE_SCI20() for projects with up to 20 input variables

All functions use a parameter list, where you determine the:• Filename, of the fuzzy project with complete path• NumInputs, number of input variables in the project• NumOutputs, number of output variables in the project• Output_i_Idx, index of the referenced output• InputValues,.. variables or values passed to the inputs

Note • Every call of a SCI function returns exactly the one output value of thereferenced output variables. If you need the result of other output variables,you have to call the SCI function with a different reference index again.

• Output variables are referenced by an index. The index number is determinedby assigning index numbers in alphanumeric order according to the outputvariable names counting upward from 1.

• The SCI function has no variable parameter list. Thus, you must enter inputvalues for the maximum number of inputs supported by the function. In theexample, although the crane controller only has two inputs, you must includetwo additional values in the parameter list of the SCI function, which are notused.

Standard CallRemote Interface The standard remote call interface allows a more efficient, but also more

sophisticated way to access information provided by fuzzyTECH. In addition tothe SCI functionality it allows you to get information about a specified project infuzzyTECH and to pass or retrieve arrays of data. The usage of the standardinterface can take place as follows:

Connect the FTRCU.DLL As already mentioned, first you have to initiate the connection to RCU by callingLoginRCU.

Start fuzzyTECH,Load a Project,Enable Debug Mode In order to use a fuzzy system in your VB application, start fuzzyTECH from

your application, load a project and switch fuzzyTECH into debug mode. Thus,RCU commands enable these tasks.

Page 314: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

314

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======Dim n As IntegerDim ret As Integerret = FTWINRTE_State(RTESTD_STE_STARTNORMAL)

’ start fuzzyTECHn = FTWINRTE_LoadProject("C:\FTWIN\TEST\CRANE.FTL")

’ load the projectn = FTWINRTE_State(RTESTD_STE_DEBUG)

’ enable debug mode

Retrieve Project Structure Before using a fuzzy system, you may check that the appropriate project isloaded (or still loaded) in fuzzyTECH. Also, determining the number of input andoutput interfaces is mandatory. This information about the project structure canbe requested via RCU functions.

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======Dim PData As FUZZYSTRUCT ’ structure defined in RCUFCNS.BASn = FTWINRTE_CMGetProjectInfo (RTESTD_PRJ_COMPACTMODE,PData,0)

’ get project information in PData, e.g.:’ PData.NumIn contains # input interfaces’ PData.NumOut contains # output interf.

PData.PrjName = NullString(PData.PrjName)’ PData.PrjName contains the project name’ to use it in VB convert the null terminated’ string into a Visual Basic string

Read Interface Items You can get information about the interface type, the variable used, and thecomputation methods used in the interface to specify the interfaces in your fuzzyproject.

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======Dim ITFCData As ITFCSTRUCT ’ structure defined in RCUFCNS.BASn = FTWINRTE_CMGetInterfaceInfo (RTESTD_ITFC_COMPACT, RTESTD_ITFC_RESET * 65536,ITFCData) ’ get information of the first interfaceITFCData.LVName = NullString(ITFCData.LVName)

’ ITFCData.LVName contains the LV name’ to use it in VB convert the null terminated’ string into a Visual Basic string

RTESTD_ITFC_NEXT ’ gets information of the following interf.’ If the return value is nonzero than:’ no more interf. are available or an error’ occurred, the data structure is not filled

Page 315: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

315

Transfer and ComputeValues Before you can use the functions for setting and retrieving fuzzyTECH input and

output values, it is necessary to define the type of data transfer for fuzzyTECH.RCU supports the transfer of single data as well as the transfer of data arrays.You can reference variables by index or by their variable names.

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======Dim CMode As Integern = FTWINRTE_SetConversation(RTESTD_CONV_SINGLE, RTESTD_CONV_DOUBLE, RTESTD_CONV_NAME, CMode)

’ sets single data transfer and text reference’ the function sets CMode, that is used in’ SetCrisp- and GetCrisp- functions.

Dim VData As DOUBLESTRUCTVData.LV1 = 4.09n = FTWINRTE_NAMSetCrispInput(CMode, "Distance", VData)

’ sets the input variable Distancen = FTWINRTE_Compute() ’ initiate a computing stepDim OData As DOUBLESTRUCTn = FTWINRTE_NAMSVGetCrispOutput(CMode, "Power", OData)

’ get output Power in OData.LV1

DOUBLESTRUCT allows to pass an array of output values to VisualBasic. Thestructure may be extended for the use of multiple parameters.

Disconnect FTRCU.DLL The connection to RCU has to be interrupted before the program is terminated.This can be realized by calling the following function:

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======LogoutRCU ’ disconnect VB from FTRCU.DLL

6.2.3. Serial Link

The Serial Link debug mode links any other hardware supporting a serialcommunication port to fuzzyTECH to let you use the development shell as afuzzy data server. In order to use the Serial Link:• Specify the transfer parameters (baud rate, port number,...) in the dialog

“Tools/fuzzyTECH Preferences/Serial Interface”.• Select “Debug/Serial Link” from the main menu.

fuzzyTECH is now ready to receive the values of the input variables from theserial port.

Page 316: ft531manual

Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

316

• Write the values of the input variables to the serial port of the PC by usingthe protocol format described in the next paragraph.

This will cause fuzzyTECH to compute the fuzzy system and to return the valuesof the output variable via the serial interface to the client software. fuzzyTECHstands by to receive the next set of input variable values. In order to end theserial debug mode, either select [Serial Link] from the [Debug] pull down menu,select a different debug mode, or close the Debug: Serial Link window thatalways appears when Serial Link mode is active.

Protocol Format The communication protocol used by the Serial Link debug mode uses float datatypes in ASCII format.• All input variables of the fuzzy system has to be set,• Their sequence is alphanumeric (the same as shown in the left list box of the

Watch Window.• Each input variable has to be set and delimited by null characters (ASCII(0)).• The maximum number of ASCII characters per value is 100.• After a null character was set behind the last input variable, an additional

“Ctrl-Z” character (ASCII(26)) has to be written to start the computationwithin fuzzyTECH.

Examples of accepted float values are:

123 123.5677433200 123-123 0.0123 .01231.98E5 +1.98E+5 -.012E-19

If all outputs are computed, fuzzyTECH sends back all output variable values inthe same format. fuzzyTECH uses standard C formatting functions to convert thefuzzy logic inference result into a float string. This conversion routine alwaystries to minimize the number of bytes used for transfer. The sequence of theoutput variables is alphanumeric, the same order as appears in the right list boxof the Debug: <mode> window. After all output variable values are written, a‘Ctrl-Z’ character (ASCII(26)) is sent.

Example In order to send the three input values 3882.3, 0.235 and 1.76E-1 via serial modeto fuzzyTECH: ( ‘þ‘ is noted as ASCII(0)):

3882.3þ.235þ1.76E-1þ^Z

If the computed output variable values are 0.34 and 90.322, the string receivedfrom fuzzyTECH would be:

Page 317: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

317

.34þ90.322þ^Z

Errors If fuzzyTECH finds an error in the protocol format (such as the wrong number ofinputs), an error box appears on the screen and the debug mode is terminated.

Integer Values If you are using the Serial Link mode to communicate with a microcontroller asthe target processor, you can also restrict the values sent and received to integers.This will avoid the computational effort to convert integers to float and viceversa. Simply make sure that the Shell values are set to the Code values for allinput and output variables (Variables Properties: Base dialog). Since fuzzyTECHuses the exact same algorithm in all debug modes that is implemented in thegenerated code, values of the output variables will always be integers.

Page 318: ft531manual

Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

318

The fuzzyTECH Shell supports open interfaces that allow users to implementnew components. These new components will be integrated as user definedextensions in fuzzyTECH. Both interfaces are based on MS Windows DLLs.A 32 bit compiler for MS Windows is necessary to create DLLs.

7.1. NeuroFuzzy: User Defined LearnMethods

fuzzyTECH provides an easy way to include a user defined learning method foruse with the NeuroFuzzy module. (Refer to Table 4 of Section 9.4 to find outwhich editions are provided with the NeuroFuzzy module or for which editions itcan be delivered as add-on.) All methods are constructed as dynamic linklibraries (DLL).

Example Source The following two examples, delivered as source code, show how to use thisfunction of the NeuroFuzzy module.

7.1.1. Compile and Register a DLL

If you are using Microsoft Visual C/C++ 4.x you can load the workspace fileNFLEARN\C\SAMPLES\SAMPLES.MDP to compile the example provided.

Page 319: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

319

Registration You may program as many learning methods in as many different DLLs as youlike. Note, each library (DLL) can contain multiple learning methods but onlyone specified selection mode. For the DLL with the name LEARN.DLLcontaining the methods MyNewMethod and MySecondMethod, add thefollowing statements to your registry data base:

[HKEY_LOCAL_MACHINE\SOFTWARE\INFORM\fuzzyTECH\5.3\NeuroFuzzy\Learn5\DllName] LEARN.DLL

[HKEY_LOCAL_MACHINE\SOFTWARE\INFORM\fuzzyTECH\5.3\NeuroFuzzy\Learn5\Method] MyNewMethod

Implement the LEARN.DLL MySecondMethod analogous to example of theLEARN.DLL MyNewMethod mentioned above.

Attention If you are not firm in handling the registry data base call your systemadministrator.

If fuzzyTECH is started, it only searches for the LEARN.DLL in the fuzzyTECHinstallation directory only. If the methods are found in the DLL, the specifiednames MyNewMethod and MySecondMethod are now available in the methodlist box of the Neuro Configuration dialog.

7.1.2. Code Example

Examples Two examples of user defined learning methods are included in the fuzzyTECHNeuroFuzzy module. The example (learn_b.c) shows a batch learn method and iscommented on in detail in the source code. If you would like to compile andinclude this method in fuzzyTECH, please refer to the source code comments,too. The other example, LEARN.C, is used to explain how to program userdefined learning methods. Before implementing a new Learn DLL you shouldread the header file NFLEARN\C\INCLUDE\NEUROLRN.H to get moreinformation about the functions and variables. A step-by-step guide for theimplementation can be found in the comments of the fileNFLEARN\C\SAMPLES\LEARN\LEARN.C.

Module LEARN.C This module demonstrates how to define new learning functions for thefuzzyTECH NeuroFuzzy module. The module is divided into sections. First,increment the value NUM_LEARN_FNCTNS (see Section 2 below). Thenspecify the function name (see also Section 2). Next, program your learningmethod (see Section 10). If you would like to program a special learningexample selection, program your SPECIFIED selection in Section 9.

Page 320: ft531manual

Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

320

Sections to Touch In this file, you don’t need to touch any sections other than Section 2, Section 9and Section 10. Add the function name of your learning function (as defined inSection 2) in the module definition file LEARN.DEF with a new number.

Example UserMethod @6

MyNewMethod @7 <--this line is new!

Create the DLL Build your new DLL. Add a new entry in the registry data base to use this newfunction in fuzzyTECH.

Header File After these steps, you can use your new learning function the same way as thestandard learning functions provided with the NeuroFuzzy module. If you haveany questions on parameters in user defined learning methods or parameterswhich can be defined by a user in the shell, please refer to the fileNEUROLRN.H.

Section 2: Definition of the module contents. Specify here how many learning functions areavailable in this learn module.

#define NUM_LEARN_FNCTNS 1 // increment NUM_LEARN_FNCTNS to implement a new // learning function

Specify here which Example-SelectionMode is valid:

#define SEQUENTIAL_MODE TRUE#define RANDOM_MODE TRUE#define USER_MODE FALSE

Next, declare the names of the learning functions.Warning: the names must be identical to the function names declared in<SECTION 10>.

char *MethodNames[] = {"UserMethod"}; // add your new learning function here // e.g. {"UserMethod","MyNewMethod"}

Section 9: Functions for sample data selection. The selection function is always calledbefore the learning function is started. That means, the learning process is a callsequence of function pairs (1 -> selection and 2 -> computation).

Page 321: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

321

WORD FAR PASCAL ExampleSelection(void){ WORD example; // possible SelectionMode options are : // SEQUENTIAL, RANDOM, RESET and SPECIFIED // if SEQUENTIAL, RANDOM or RESET is used the second parameter (examplenumber) // has no effects. // For further information and a detailed description of each SelectionMode // see the file neurolrn.h

if (SelectionMode == SPECIFIED) { // calculate your example number here return NeuroExampleSeek(SEQUENTIAL, example); } return NeuroExampleSeek(SelectionMode, example);

// enter the SelectionMode of your NewMyMethod here if you want // to disable the SelectionMode choice in fuzzyTECH and always use // the same SelectionMode. // If you don´t need a SelectionMode other then SEQUENTIAL, RANDOM // and RESET you don´t have to touch anything in this section}

Section 10:

int FAR PASCAL UserMethod(void) // use the same learning function name as // declared in section 2 of this file // f.i. int FAR PASCAL MyNewMethod (void)

7.2. Online: Implementing User DefinedCommunication Channels

The fuzzyTECH Online Edition and the fuzzyTECH MCU Editions including theRTRCD Module can use different communication channels to enable an onlineconnection to a fuzzy runtime system that was generated by one of thefuzzyTECH code generators. If the application using the fuzzy runtime systemruns on a hardware that is not supported by the standard communicationchannels, you may implement your own communication modules both for theruntime system and fuzzyTECH. This chapter describes the implementation of anonline communication channel DLL as extension for fuzzyTECH. Refer toSection 6.1 for more details on the communication channel for your fuzzyruntime system.

Page 322: ft531manual

Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

322

Functions Each fuzzyTECH online communication channel DLL (FTOCC) has toimplement and export the following functions:

LPSTR CALLBACK ftoccGetInfo (HWND hWndParent, BOOLfLongInfo);BOOL CALLBACK ftoccSetup (HWND hWndParent);BOOL CALLBACK ftoccOpen (HWND hWndParent, DWORDdwTimeout);BOOL CALLBACK ftoccClose (HWND hWndParent);BOOL CALLBACK ftoccTransmit(HWND hWndParent, LPBYTE lpCommBuffer, BYTEbNumToTransmit);BOOL CALLBACK ftoccReceive (HWND hWndParent, LPBYTE lpCommBuffer, BYTEbCommBufferSize);

Sample FTOCC\FTOCC.DLL is a prototype for a user defined online communicationchannel. The source code and a Microsoft Visual C make file of this DLL can befound in the directory FTOCC\SRC. Please use a copy of these files as base foryour own implementation. More details on implementing the functions can befound in the source code comments.

Registration You may implement as much communication channel DLLs as you want. Eachnew DLL must be registered in the registry data base of your computer.

If you are not firm in handling the registry data base please ask your systemadministrator for help.

You have to create an new subkey DllNameX, where X is the first unusednumber. The following sample adds the DLL MYFTOCC.DLL to fuzzyTECH 5.3.

[HKEY_LOCAL_MACHINE\SOFTWARE\INFORM\fuzzyTECH\5.3\Communication Channels\DllName4]C:\MYPATH\MYFTOCC.DLL

Page 323: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

323

ActiveX Windows ActiveX is a technology to embed one software system into another.This technology was formerly referred to as OLE/OLX, which stands for objectlinking and embedding.

DDE Dynamic Data Exchange, a technology that allows two software programs underMS Windows to exchange data. fuzzyTECH supports a DDE interface.

DLL Dynamic Link Library, a file containing functions that can be called by aprogram. fuzzyTECH uses DLLs internally to structure its code modules, but alsoprovides DLLs as interfaces to other software programs, e.g. the FTRUN.DLLand FTRCU.DLL.

DoS Degree of Support. Adding an individual weight to each rule extends the conceptof “on/off” rules to a representation where rules themselves are “fuzzy”. Thisallows for the rule base to be fine tuned during optimization. Since the mappingof the input of the rules to the output now itself is fuzzy, this concept is oftenreferred to as a “Fuzzy Associative Map” (FAM). The tuning parameter is called“Degree of Support” (or a fuzzy rule’s weight).

DSP Digital Signal Processors are micro processors with a special hardware architec-ture that enables them to compute digital signal processing algorithms very fast.

FAM See DoS.

FTL Fuzzy Technology Language, a file format for fuzzy logic systems supported bymost software and hardware vendors of fuzzy logic solutions. Developed by IntelCorp. and Inform Software Corp. in 1991, FTL allows for the exchange of fuzzylogic systems between different software and hardware tools and platforms. AllfuzzyTECH Editions store their projects as FTL files. FTL is an ASCIIdescription language and can thus be read and edited using any text editor.

FTR fuzzyTECH Runtime, a file format generated by fuzzyTECH or FTRUN. A FTRfile is a binary data representation of a fuzzy logic system. Depending on theoptions used, a FTR file can even contain all the necessary information forfuzzyTECH to reconstruct an entire FTL file from it.

Page 324: ft531manual

Inform Software Corporation Chapter 8: Glossary

324

FTRCU fuzzyTECH Remote Control Unit, an interface that allows you to tie in thecomplete fuzzyTECH development system in other software programs. In everyfuzzyTECH installation from release 5.0 on, this file is located in the installationdirectory of fuzzyTECH and can be used by any other program to "remotecontrol" fuzzyTECH. For example, all three simulations of the fuzzyTECH 5.0Demo use this interface to start fuzzyTECH remotely, open the appropriate fuzzylogic system, and let fuzzyTECH compute the output values of the fuzzy logicsystem under simulation.

FTRUN fuzzyTECH Runtime Module, an interface that only integrates the runtime kernelof fuzzyTECH with other software programs. FTRUN is available as 16-bit DLL(FTRUN.DLL) and 32-bit DLL (FTRUN32.DLL).

fuzzyTECH Viewer The fuzzyTECH Online Edition is delivered with the fuzzyTECH Viewer, aversion of fuzzyTECH that can visualize any fuzzy logic system that is computedby the Runtime Module. The fuzzyTECH Online Edition license comprises thedistribution license of the fuzzyTECH Viewer, thus you may include thefuzzyTECH Viewer with any of your generated fuzzy logic systems freely if youare a fuzzyTECH Online Edition user.

IPX/SPX Protocol The Internetwork Packet Exchange/Synchron Package Exchange protocol is anetware protocol that can be used for data exchange via a certain type of netware(e.g. Novell Netware/Intranetware).

OLE/OLX Object Linking and Embedding, a technology for embedding one softwaresystem into another, now called ActiveX.

PLC Programmable Logic Controllers are used in industrial automation. Thesecontrollers are programmable, they can be used in an harsh industrialenvironment and have integrated digital/ analog IO modules.

RTF Rich Text Format, a file format for documents supported by most wordprocessing software, such as MS Word, MS Wordpad (comes with Windows95),WordPerfect, WordPro, and StarWriter. The documentation generator offuzzyTECH uses RTF to output documents.

SFS A Shared File System (SFS) is a directory that can be accessed by both programs.This directory can be located on a PC (i.e. C:\TEMP) of both fuzzyTECH and theRuntime Module run on the same PC. If fuzzyTECH and the Runtime Module runon different PCs, this directory must either be located on a network server or onone of the PCs as a shared directory.

Page 325: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

325

This appendix contains various topics, such as installation guidance, requiredmemory size, essential files and directories, an overview of functions andtechnical restrictions for all fuzzyTECH Editions, support addresses, a keywordindex and the license agreement.

9.1. Software Installation

This section guides you through the installation of the software on your PC. Youmust have the following:• a PC with a 486 processor or better (a Pentium type PC is recommended for

fast simulation results)• minimum 16 MB main memory (RAM)• minimum 25 MB free space on your hard disk• VGA graphics (256 colors and 800 x 600 resolution recommended)• a mouse or an equivalent pointer device• MS Windows NT 4.0, MS Windows 95, or later.

Installation Follow the instructions given below in order to install fuzzyTECH successfully:• Insert the fuzzyTECH CD-ROM into the appropriate CD-ROM drive.• On your desktop, press the [Start] button on the taskbar. Choose the option

[Run…] in the pop-up menu. Specify your CD-ROM drive via the [Browse]button and select SETUP\DISK1\SETUP.EXE on the CD-ROM or enter thepath and name of the installation program in the edit field (e.g.D:\SETUP\DISK1\SETUP.EXE).

• Follow the instructions that appear on the screen.Note: You don’t need the copy protection (dongle) to install fuzzyTECH.

Network Installation: fuzzyTECH can be installed on a network drive to be used by different clientPCs. Because the setup procedure has to update the registry database of eachlocal PC, the setup routine must be started on each local PC overwriting previousnetwork drive installations. This overwriting procedure has no side effects onother clients.

Page 326: ft531manual

Inform Software Corporation Chapter 9: Appendix

326

Note: After installation, you may have to re-boot your PC before you can usefuzzyTECH. If such a re-boot is required, you will be informed by the setuproutine’s windows and dialogs. Pay attention to notes displayed on screen duringinstallation.

Start Menu The setup procedure generates a new item “fuzzyTECH 5.3” in the MS WindowsStart menu. The new item contains the fuzzyTECH Editions, softwaresimulations, and help files. Since fuzzyTECH may be updated faster than thismanual, you should refer to the README.TXT file for latest release informationnot contained in this manual.

Uninstalling To uninstall fuzzyTECH, proceed as follows: In the task bar, click the [Start] key,then Settings, and then Control Panel. There you choose the folder Add/RemovePrograms. A tabbed dialog Add/Remove Programs Properties opens. In the listedprograms of its Install/Uninstall page, choose fuzzyTECH 5.3 and click the[Add/Remove…] key to uninstall fuzzyTECH.

Copy Protection All fuzzyTECH Editions use a copy protection device. The copy protectiondevice is a small matchbox sized device with two 25-pin connectors on eachside. This device has to be plugged on a parallel port (printer port) of your PC.The red arrow on the device indicates the computer side. If you are using aprinter, you may connect the printer cable to the rear end of the protectiondevice. The copy protection device does not disturb printer operations. You mayalso use more than one protection device at the same time. The copy protectiondevice stores the licensing information of your software. fuzzyTECH will onlyrun on your PC if the protection device is plugged into the parallel port. Youmay install the software without the protection device. This allows you to installfuzzyTECH on more than one PC. However, you may only use fuzzyTECH onone PC at a time, since the copy protection device must remain plugged in duringoperation. Since fuzzyTECH needs the information stored in the protectiondevice at various design steps, it must be plugged in the entire time while usingfuzzyTECH.

Updates Because the protection device contains license information, you never need tochange the protection device when receiving an update. Always include yourlicense number in all update orders, so the new version will run with yourprotection device.

Compatibility The protection device used with fuzzyTECH is carefully designed not to interferewith any other software or hardware products using the parallel printer port. Ifyou are using copy protection devices from other vendors at the same time andyou are experiencing problems, try to change the sequence of the devices. If thisdoes not solve the problem, please contact Inform.

Page 327: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

327

9.2. Memory Size

Code generated by fuzzyTECH Editions always consist of three parts:• library function code,• rule and membership function data segments (knowledge base), and• the fuzzy system function.

These codes and data may be stored in ROM areas. In addition, the fuzzy systemneeds RAM space to store intermediate variables for the fuzzy logic algorithm.While the library function code size is constant, the size of the rule andmembership function data segments and the size of the fuzzy system functionvaries with the complexity of the system.

RAM Size Total RAM required by the fuzzy logic system generated may be computed as:

nI nOSV = N (∑ti + ∑to ) + C + N (nI + nO) (Public IO)

i=1 o=1 nI nO

SV = N ( ∑ti + ∑to ) + C (No Public IO)

i=1 o=1

SV : size of RAM required (in Byte)

nI : number of input variables

nO : number of output variables

ti : number of terms for the linguistic input variable i

to : number of terms for the linguistic output variable o

N : equals 1 for 8 bit code and 2 for 16 bit codeC : a constant for internal variables (public declarations)

C = 22 byte for MCU-96 Edition C = 26 byte for MCU-320 Edition C = 22 byte for MCU-MP Edition, 16Cxx/17Cxx devices 16-bit C = 12 byte for MCU-MP Edition, 16Cxx/17Cxx devices 8-bit C = 11 byte for MCU-MP Edition, 16C5x/16C57 devices C = 9 byte for MCU-ST6 Edition C = 7 byte for MCU-51 Edition C = 0 byte for MCU-166 Edition C = 11 byte for MCU-374 Edition C = 12 byte for MCU-HC11/12 Edition, HC12 family C = 17 byte for MCU-HC 11/12 Edition, HC11 family

Remark: Internal Registers used, if available.

Page 328: ft531manual

Inform Software Corporation Chapter 9: Appendix

328

ROM Size The exact size of the knowledge base is computed by the fuzzyTECH compilerand is printed as comments at the end of the generated code. In addition to thecalculated ROM sizes of the knowledge base, the size of the fuzzyTECH kernelroutines (refer to the .MAP file of your linker) selected from the library must beconsidered. The sum of knowledge base size and size of fuzzy functions is therequired ROM space for the complete fuzzy task. The upper bound for the size ofthe knowledge base (rule and membership segment) can be computed as:

nI nO nR

SF ≤ ∑4Nti + ∑Ntj + ∑( Ir+ 2ÂOr + 2 ) + nIi=1 j=1 r=1

SF : size of knowledge base (in Byte)

nI : number of input variables

nO : number of output variables

nR : number of rules

ti : number of terms for the linguistic input variable i

tj : number of terms for the linguistic output variable j

Ir : number of input conditions for the rule r

Or : number of output conditions for the rule r

N : equals 1 for 8 bit code and 2 for 16 bit code

9.3. Directories and Files

Directories During the installation of fuzzyTECH, it is possible to specify the position of thefuzzyTECH home directory. The location and the directory name suggested bythe installation procedure is “C:\Program Files\fuzzyTECH”. Depending on thefuzzyTECH Edition, some of the following subdirectories are created:

DDE Contains samples showing how to use fuzzyTECH as DDE server and/or client.DOCIT Contains files used for the documentation generatorfuzzyTECH The home directory contains all executable files.HELP Contains the files of the fuzzyTECH help system.LANGUAGE Contains subdirectories to separate files for the use of different languages.RCU Contains the dynamic link libraries FTRCU.DLL and FTRCU32.DLL, plus

source code samples demonstrating how to use the libraries. The libraries allowyou to connect and remotely control fuzzyTECH from other MS Windowsapplications.

Page 329: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

329

RCU\EXCEL Contains the files used by MS Excel to integrate the fuzzyTECH ExcelAssistant by using the MS Excel Add-In Manager.

RUNTIME\C Contains the files required to generate an application using fuzzyTECH C-codegeneration. Usage is explained by several source code samples.

RUNTIME\FTRUN Contains the fuzzyTECH runtime modules FTRUN.DLL and FTRUN32.DLL.RUNTIME\MATLAB Contains source code and samples to integrate M-code generated by

fuzzyTECH in MATLAB/SIMULINK.RUNTIME\XYZ For hardware dedicated fuzzyTECH Editions, this directory contains the source

code and samples for integrating fuzzy systems on the hardware device.SAMPLES\BENCHxx Contains the project files of several benchmark projects. Depending on the

edition, xx is either 8 or 16.SAMPLES\BUSINESS Contains project and application files of business applications.SAMPLES\CONTROL Contains project files and executable simulations of technical and control

applications.SAMPLES\NEUROFUZ Contains samples for the fuzzyTECH NeuroFuzzy-Module.SERLINK Contains source code samples showing how to use the serial link debug mode

of fuzzyTECH.USEREXT\FTOCC Contains a code sample for demonstrating the implementation of additional

communication channel.USEREXT\NFLEARN Contains the source code of a sample to generate a user defined DLL with

additional training methods for the NeuroFuzzy-Module.

Project Files Files using the fuzzyTECH 2.x format (*.FTP) can be opened by fuzzyTECHrelease 3.x and higher. However, fuzzyTECH release 3.x (and higher) alwaysuses the Fuzzy Technology Language format (*.FTL) to save projects.

Data Files In fuzzyTECH, several components use data files. The Fuzzy Design Wizard,Batch and File Recorder debug modes, and Data Clustering and NeuroFuzzyoptimization with the NeuroFuzzy module all require and support the use of thefuzzyTECH data formats.

File Names Generally, you are free to choose both input and output names. As defaults,fuzzyTECH uses the following conventions:• The file names are the same as the FTL file name of the actual project.• Input files containing real data are identified by the *.IN extension.• Input files containing data sets generated by fuzzyTECH's pattern generator

are identified by the *.PTN extension.• Input files containing trace records from the fuzzyTECH Online Edition are

identified by the *.TRC extension.• Sample Data Files used by the NeuroFuzzy Module are identified by the

*.EXP extension.• Output files from the batch mode are identified by the *.OUT extension.

Page 330: ft531manual

Inform Software Corporation Chapter 9: Appendix

330

Data Formats Data files can be either of two format types. The data type can be selected in theProject Options dialog. When fuzzyTECH writes data - in either the batch mode,data clustering, pattern generator or trace analyzer - the selected format is used.Both types of formats use:• All values and names in ASCII.• A header that contains a complete list of the variable names.• Lines of data.

The header consists either of• TYPE 1: One single line, which contains a # character followed by the

variable names that are separated by blanks or tabs.• TYPE 2: Three lines where the first and the third lines are ignored and can be

used for comments and descriptions. The second line lists the variable names.

In the data lines, every line in the file corresponds to a record and must beterminated by a line feed (ASCII 13). All values in a line must be separated byone or more spaces or tabs.• TYPE 1: contains just the values.• TYPE 2: contains a first value in every line from Line 4 on, which is always

treated as a record name. The record name may not be longer than 40characters. Also, a timestamp can be entered here. The record name may notcontain any spaces or tabs.

The values of the input (and output) variables must be cited after the record namein every line. The file may contain only input data, input and output data, orcomputed output data using an additional flag variable.

Example InputTYPE 1 An example of an input file or a pattern file in format TYPE 1 looks like this:

# Angle Distance -45 22 -40 22 -35 22

Example InputTYPE 2 An example of an input file or a pattern file in format TYPE 2 looks like this:

Input data for Fuzzy Crane Control Angle Distance---------------------------------------CRANE_#1 -45 22CRANE_#2 -40 22CRANE_#3 -35 22

Page 331: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

331

In batch mode, there is no limit to the number of records in a file. Activate thebatch mode by selecting “Debug/Batch”. A prompt for the input and output filenames appears.

Sample Data FileTYPE 1 The sample data file contains all input and output variables.

# Angle Distance Power -45 22 -9.2435 -40 22 -9.1976 -35 22 -8.9763

Sample Data FileTYPE 2

Input data for Fuzzy Crane ControlAngle Distance Power

-------------------------------------------CRANE_#1 -45 22 -9.2435CRANE_#2 -40 22 -9.1976CRANE_#3 -35 22 -8.9763

The output files or trace files contain all input and output variables and a "flags"column. This column indicates output variables for which no rule has fired.Flags is an integer and each bit in FLAGS represents one output variable, startingwith the lower order bit and assigned in sequence to the output variables inalphanumeric order. A zero bit for a variable indicates that for this outputvariable at least one rule fired. Hence, a return value of zero indicates that forevery output variable at least one rule fired. The data type for FLAGS dependson the fuzzyTECH Edition. An example file is shown below:

Example OutputTYPE 1

# Angle Distance Power flags -45 22 -9.2435 0 -40 22 -9.1976 0 -35 22 -8.9763 0

Example OutputTYPE 2

Input data for Fuzzy Crane ControlAngle Distance Power flags

---------------------------------------------------CRANE_#1 -45 22 -9.2435 0CRANE_#2 -40 22 -9.1976 0CRANE_#3 -35 22 -8.9763 0

Page 332: ft531manual

Inform Software Corporation Chapter 9: Appendix

332

9.4. Features Overview

Technical Restrictions fuzzyTECH is available in different editions to provide the most comprehensivesupport for your target platform and application area. Due to differences in thecapabilities of the supported hardware platforms, technical restrictions apply tothe size of the fuzzy systems. Table 1 shows an overview of the maximumnumber of interfaces, variables, terms, rule blocks and rules for the differentfuzzyTECH Editions. A "-" sign indicates that no practical limit exists. The totalnumber of Linguistic Variables (Total LV) represent the number of input, outputand intermediate variables of the entire fuzzy logic system. The columns Inputand Output show the maximum amount of input and output variables. Terms perLV relates to the total number of terms for each linguistic variable. The columnTotal Terms shows the maximum number of terms that may occur in one fuzzylogic project. The Rules sections shows the maximum total number of RuleBlocks and Rules that a fuzzy logic project may contain, as well as the maximumtotal number of input variables (Inputs per RB) and output variables (Outputs perRB) that can be assigned to a rule block.

Restrictions Linguistic Variables(LV)

Rules

Feature/ Edition

Total LV Input Output Termsper LV

TotalTerms

Rule Blocks(RB)

Inputs perRB

Outputsper RB

Total Rules

Business Prof. 255 255 32 32 255 32 8 4 -Business 255 255 32 32 255 32 8 4 -

Professional 255 255 32 32 255 32 8 4 -Online 255 255 32 32 255 32 8 4 -IA-S5 32 32 8 5 255 8 8 4 640

Simulation 255 255 32 32 255 32 8 4 -Student 8 4 1 8 255 1 4 1 50MCU-C 255 255 8 8 255 32 8 4 -MCU-96 127 127 16 8 127 32 8 4 -

MCU-166 127 127 16 8 127 32 8 4 -MCU-320 255 64 16 8 255 32 8 4 -MCU-51 255 255 8 8 255 32 8 4 -

MCU-374 255 255 8 8 255 32 8 4 -MCU-ST6 8 4 1 7 255 1 4 1 -MCU-MP 16 8 4 7 255 1 8 4 2048

MCU-HC11/12 127 127 8 8 253 32 8 4 -MCU-HC05/08 255 255 8 8 255 32 8 4 -

Table 1: Limitations of Different fuzzyTECH Editions

Membership Functions fuzzyTECH supports various fuzzy logic inference methods and algorithms.Table 2 lists methods of fuzzification and Types of membership functions (MBF)supported by each fuzzyTECH Edition. Standard MBFs are sometimes called "4-point definitions". Arbitrary MBFs can be defined with up to 16 points ofdefinition. Inverse MBFs (inverse terms) are useful for filling a rule part with thenegated form of an already existing term. The column MBF Shapes shows the

Page 333: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

333

available approximation functions for membership functions. The columnFuzzification Method lists the supported algorithms for the fuzzification step ofthe fuzzy logic inference. Fuzzy Input indicates that variables are inputted asfuzzy values (i.e. as vectors of membership degrees) instead of crisp values. ForLook-up-MBF fuzzification, MBFs are computed as look-up-tables by codegenerators. This speeds up the computation on some microcontrollers and fuzzyprocessors, but consumes considerable memory space. The standard fuzzificationmethod is computation at run time (Compute MBF). For most target hardwareimplementations, this is the most efficient approach. On some microcontrollerfamilies, the slope fuzzification method (Fast Computation of MBF) is faster.Slope fuzzification is a variant of Compute MBF.

MembershipFunctions

Type Shape Fuzzification Methods

Feature/ Edition

StandardMBF

ArbitraryMBF

InverseMBF

linear s-shape

FuzzyInput

Look up

MBF1)Compute

MBFFast MBF

Computation 2)

Business Prof. x x x x x x - x -Business x x x x x x - x -

Professional x x x x x x - x -Online x x x x x x - x -IA-S5 x - - x - - - x -

Simulation x x x x x x - x -Student x - - x - x - x -MCU-C x - - x - x - x xMCU-96 x - - x - x - x -

MCU-166 x - - x - x - x -MCU-320 x - - x - x - - xMCU-51 x - - x - x x x x

MCU-374 x - - x - x - - xMCU-ST6 x - - x - - - - xMCU-MP x - - x - - - - x

MCU-HC11/12 x - - x - x - x xMCU-HC05/08 x - x x - x - x x

Table 2: Membership Types and Fuzzification Methods of fuzzyTECH Editions( 1) MBFs stored as look up table , 2) Slope fuzzification)

Inference andDefuzzification Table 3 summarizes supported methods of fuzzy logic inference and

defuzzification. The fuzzy inference consists of three computational steps:Aggregation, Composition, and Result Aggregation. Different operators can bechosen for aggregation (Input aggregation) and result aggregation. Fuzzyoperators used for aggregation (Minimum or Maximum) combine thepreconditions of each fuzzy rule. Beside this standard operators, somefuzzyTECH Editions support compensatory operators (Gamma, Min-Avg, Min-Max), that help to compute relations between rules formulated with the logicstandard operators AND (Minimum) and NOR (Maximum). The second step ofthe fuzzy rule inference, the composition, works generally with the PROD-Operator as fixed operator. Standard Rules are rules with a fixed rule weight(Degree of Support = 1.0) that cannot be changed. FAM Rules stands for "Fuzzy

Page 334: ft531manual

Inform Software Corporation Chapter 9: Appendix

334

Associative Maps" and refers to individually weighted rules (Degree of Support= DoS). The last step of fuzzy inference is the so-called result aggregation. ItsMAX operator selects the maximum firing degree of all rules matching to theterm. The BSUM operator uses a bounded sum. Thus, all firing degrees aresummed by using a bound of one. Note that BSUM result aggregation isdifferent from BSUM MoM and BSUM CoA. The bounds are zero and one. Theresult of the fuzzy inference is a fuzzy value that has to be re-transformed into acrisp value. This transformation is called Defuzzification. Different computationmethods can be applied for defuzzification.The standard defuzzification is CoM(Center-of-Maximum), delivering the "best compromise" for the inference result.It is equivalent to most implementations of Center-of-Area (CoA) and Center-of-Gravity (CoG) methods. The MoM (Mean-of-Maximum) method delivers the"most plausible" result. Hence, it is mostly used in applications such as patternrecognition, data analysis, and decision support. The defuzzification methodHyperCoM (see last column) is only available as add-on module for a feweditions. HyperCoM is a defuzzification method that takes both positive andnegative experience into consideration (e.g. in the form of recommendations andwarnings). A hyperdefuzzification strategy weights these recommendations andwarnings against each other and computes a membership function, from whichHyperCoM then computes the optimum based output value.

Inference/Defuzzification

Aggregation OperatorsStandard / Compensatory

Composition ResultAgrregation

Defuzzification

Feature

Edition

Minimum/Maximum

Gamma(γ)

Min-Avg

Min-Max

Stan-dard

FAMRules

Max BSum CoM COA1)

MoM FuzzyOutput

HyperCoM

2)

Business Prof. x x x x x x x x x x x x xBusiness x x x x x x x x x x x x x

Professional x x x x x x x x x x x x xOnline x x x x x x x x x x x x xIA-S5 x - - - x x x - x - - - -

Simulation x x x x x x x x x x x x xStudent x - - - x x x - x - x x -MCU-C x - - - x x x - x - x x -MCU-96 x - - - x x x - x - x x -

MCU-166 x - - - x x x - x - x x -MCU-320 x - - - x x x - x - x x -MCU-51 x - - - x x x - x - x x -

MCU-374 x - - - x x x - x - x x -MCU-ST6 x - - - x - x - x - - - -MCU-MP x - - - x - x - x - x - -

MCU-HC11/12 x - - - x x x - x - x x -MCU-HC05/08 x - - - x x x - x - x x -

Table 3: Inference and Defuzzification Methods of Different fuzzyTECH Editions(1) Fast CoA, neglects overlaps, 2) Only available as add-on module)

System Optimizationand Analysis All fuzzyTECH Editions are fully equipped with graphical debuggers (Debug

Modes) and Analyzers that can be used for optimizing and debugging a fuzzysystem (Table 4). fuzzyTECH’s graphical analyzers are all internal and help you

Page 335: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

335

to verify and analyze the behavior of the fuzzy system. The Trace Analyzer haslimited function for IA-S5 Edition and is not available for MCU-HC05 Edition.However, remote debugging on external target platforms requires either Onlineor RTRCD debug modes. Contrary to the Online debug mode, the RTRCD mode(Real Time Remote Cross Debugging) runs only with basic cross debuggingfunctions, but more efficient in view of computation speed and code size. Thisonline development allows you to connect fuzzyTECH with a running fuzzy logicsystem in real-time and to monitor and modify it on your PC via CommunicationChannels.

Tools Debug Modes (internal) Communication Channels Add-Ons 1)

Feature

Edition

Inter-active

File/Batch

SerialLink

RCU/DDE

RTRCD On-line

TCP/IPIPX/SPX

DDE

SerialInter-face

(RS232)

SDI5)

SFS User-def.(FTOCC)

NeuroFuzzy

HyperCoM

Business Prof. x x x - x3) x3) x3) - x3) x x2) x

Business x x x x - - - - - - - x2) x

Professional x x x x - x3) x3) x3) - x3) x x x

Online x x x x - x x x - x x x2) x

IA-S5 x x x x x3) - - x - - x x -

Simulation x x x x - - - - - - - x xStudent x x x x - - - - - - - x -MCU-C x x x x - - - - - - - x -MCU-96 x x x x x - - x - x x -

MCU-166 x x x x x - - x - - x x -MCU-320 x x x x - - - - - - - x -MCU-51 x x x x x - - x - - x x -

MCU-374 x x x x - - - - - - - x -MCU-ST6 x x x x - - - - - - - - -MCU-MP x x x x - - - - - - - x -

MCU-HC11/12 x x x x x - - x x - x x -MCU-HC05/08 x x x x x4) - - x4) - - x x -

Table 4: Debugger, Communication Channels and Add-On Modules for Different fuzzyTECH Editions(1) Add-On Modules, not included in all Editions, 2) NeuroFuzzy Module included, 3) Only with the FTRUN.DLL or

fuzzyTECH Runtime Control, 4) Only for HC08, 5) Only for Motorola: Serial Debug Interface Background Debug Mode)

Add-on Modules Some fuzzyTECH Editions can be used with the add-on modules (Table 4) thathave extended features. The NeuroFuzzy Module integrates artificial neuralnetwork technology including its modified learning procedures into fuzzy logic.It contains the FuzzyCluster Module that is suited for preparing training datasand integrates data mining techniques into fuzzyTECH. HyperCoM is an add-onmodule, that offers with its Hyperinference defuzzification method a fundamen-tal expansion of fuzzy logic by allowing the definition of prohibitive rules.

Page 336: ft531manual

Inform Software Corporation Chapter 9: Appendix

336

Code Generation Table 5 lists supported code generator options. The File Code option generates acomplete C source code for an executable program which accepts file data asinput and writes outputs to a file as well. Since fuzzyTECH generates thecomplete fuzzy logic system as a single function, input and output values can betransferred as function parameters (Function Call) over the system stack or asglobal variables (Public I/O).

Some fuzzyTECH MCU Editions support only Public I/O, since passing variablesover the stack can be inefficient. All fuzzyTECH MCU Editions utilizing anassembly library as a kernel support calling fuzzy logic functions from Assemblycode and from C code (C interface). The C Code column lists which C compilerstandard is supported. The columns Internal Resolution and Code InterfaceResolution show the computational resolution within the inference engine.Besides, Code Interface Resolution indicates the data types of the interfaces, too.

CodeGeneration

Code-Options Hardwarespecific

Code

C-Code ActiveX/

FTRUN

COBOL InternalResolution

Code InterfaceResolution

Feature/ Edition

FileCode

Funct.

Call1)Public

I/OC ASM ANSI K & R FTR COBOL

2)8-bit 16-bit 8-bit 16-bit double

Business Prof. x x x - - x x x x x x x x xBusiness - - - - - - - - - - - - - -

Professional x x x - - x x x x x x x x xOnline x x x - - x x x x x x x x xIA-S5 - - - - - - - - - x - - x x

Simulation - - - - - - - - - - - - - -Student - - - - - - - - - - - - - -MCU-C x x x - - x - - - x x x x -MCU-96 x x x x - x - - - - x - x -

MCU-166 x x x - x x - - - - x - x -MCU-320 x x x x - x - - - - x - x -MCU-51 x - x - x x - - - x - x - -

MCU-374 x x x - x x - - - x - x - -MCU-ST6 x - x - x x - - - x - x - -MCU-MP x - x - x x - - - x x x x -

MCU-HC11/12 x x x - x x - - - x - x - -MCU-HC05/08 x x x - x x - - - x - x - -

Table 5: Code Generation Options of fuzzyTECH Editions( 1) I/O passing as function parameter, 2) Only available as add-on module)

Page 337: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

337

9.5. Support Contact

USA and Canada Inform Software Corporation2001 Midwest Bd.Oak Brook, IL 60523, U.S.A.Phone 1-630-268-7550Sales 1-800-929-2815Fax 1-630-268-7554E-mail [email protected]

Europe andElsewhere INFORM GmbH

Pascalstrasse 23D-52076 Aachen (GERMANY)Phone +49-2408-945680Fax +49-2408-945685E-mail [email protected]

Internet: http://www.fuzzytech.com

Page 338: ft531manual

Inform Software Corporation Chapter 9: Appendix

338

9.6. Index

*.DAT Extension 91*.EXP Extension 91*.IN Extension 91*.OUT Extension 91*.PTN Extension 91*.TRC Extension 91

3D Plot Analyzer 18, 96

ActiveX 201Add-on Modules 335Aggregation 161, 171Analyzer

Rule Analyzer 94, 100Analyzer Tools 93AND 161, 171Applications of Fuzzy Logic 146Approximate Logic 165Arbitrary MBF 170Average Error 182, 189Avg. Deviation 189

Base Variable 60, 68, 153, 166Batch Debug Mode 92Biomedical Fuzzy Systems Association 148BMFSA 148Boolean Logic 146, 148, 161, 176Break Criteria 182, 189Build Procedure 293

C Code 202Center-of-Area Method 58, 174Center-of-Gravity Method 59, 164, 174Center-of-Maximum Method 58, 164, 173Client 102Clustering 135CoA Defuzzification 58, 174COBOL Code 202COBOL Code Generator 293

COBOL Runtime Library 294Code Generation 336Code Range 60Code Values 59, 60CoG Defuzzification 59, 174CoM Defuzzification 58, 173Communication Channel 103Compensatory Operators 171Competitive Learning 182Composition 72, 161, 162

Operator 172Compute MBF 58Container Crane Control 156Continuous Logic 146, 147Copy Protection 326Cross Sections 95Customizing fuzzyTECH 43

Data Files 329Data Format 330DDE 103, 298Debug Modes 86, 334Decision Support Systems 147Default Value of Linguistic Variables 61Defuzzification 58, 163, 166Defuzzification Methods 333Degree of Membership 166Degree of Support 82, 172Design Mode 13, 14Don’t Care Rules 77Don't Care Rules 84Dynamic Stop Condition 130

Error Backpropagation 184, 188Excel Assistant 311Extension .EXP 329Extension .IN 329Extension .OUT 329Extension .PTN 329Extension .TRC 329

Page 339: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

339

FAM 172, 184, 187Inference 172Rules 77, 81

Fast Computation of MBF 167File Format 91File Names 91, 329File Recorder Mode 91FLSI 148FT38.LIB 230FTMP.LIB 214FTOCC.DLL 104FTRUN 203, 205, 207, 209FTRUN.DLL 201FTSDI.DLL 104FTWIN.XLA 311FTWIN32.XLA 311Fuzzification 158, 159, 165Fuzzification Methods 333Fuzzy Associative Map 172Fuzzy Associative Maps 82, 184, 187Fuzzy Control 165Fuzzy Design Wizard 48Fuzzy Input 58Fuzzy Logic 123

Comp. Fuzzy vs. Conventional Control 157Inference 158, 160Operators 161Patents on 148Rules 165

Fuzzy Logic Systems Institute Iizuka 148Fuzzy Operators 79Fuzzy Output 59Fuzzy Rule Inference 166, 171Fuzzy Runtime System 102Fuzzy Set Theory 153Fuzzy System 102FUZZYLIB.ST6 210fuzzyTECH

Data Formats 329fuzzyTECH

COBOL Runtime Library 293Preferences 43Runtime Control 202Runtime DLL 32Runtime Library 102

Shell 43Technical Restrictions 332

fuzzyTECH PreferencesGeneral 43Matrix Rule Editor 45Save 44Serial Interface 46Text Editors 44Watch Window 44

GAMMA Operator 72Grid 68

Hebbian Learning Rule 179Hyper CoM Defuzzification 59

IF Part 171Inference Methods 333Information About the Current Project 109Input Interfaces 58Input Variable 57Installation 325Interactive Debug Mode 48, 87, 89Intermediate Variable 57Inverse Term 69IPX/SPX 104

Japan Society for Fuzzy Theory and Systems 148

Keyboard Use 53Knowledge Base 327

Labels 62, 166Lambda-Type Membership Functions 167Learning Rate 182, 188, 192Library Function Code 327LIFE 148Linguistic Control Strategies 157, 158Linguistic Labels 159Linguistic Terms 155, 159Linguistic Variable 155, 159, 166Linguistic Variable Editor 62Look up MBF 21, 58Look-up Table 58Lotfi Zadeh 147L-Shaped MBF 66

Page 340: ft531manual

Inform Software Corporation Chapter 9: Appendix

340

M Code Generation 202Margins 90Matrix Rule Editor 24, 76, 80Max 72Max Dev. Stop Condition 130MAX Operators 171Maximum Error 182Maximum Operator 72, 161, 171MAX-Min Inference 172MAX-PROD Inference 172MBF 166, 332

Definition 66Type 66

MCU-HC05/08 258MCU-HC11/12 267Mean-of-Maximum Method 58, 174Membership

Degree of 154Function 66, 166

Membership Function 62, 154, 332Min 72Min Operator 171Min-Avg Operator 72Minimum Operator 72, 161, 171Min-Max Operator 72Model-based Control 157MoM Defuzzification 58, 174Monitor Debug Mode 87, 102Monitor&Modify 102Monitor&Modify Debug Mode 39, 87

Online 103RTRCD 102

Multi-Client 203Multiple Instances 203Multi-Systems 203, 204, 266Multivalued Logic 147

Neural net behaviour 180Neural Net Structure 177Neural Net Technology 176NeuroFuzzy 176

Configure Training of 129Defuzzification Methods 128Iterations 132Learning Methods 188

MBF-Conversion 131Open Components 129Record Sample Data 125Stop Conditions 130Training 131Training Control 132Training Method 188vs. Neural Nets 184

Neuron 176Bias of a 177Mathematical Model of a 177

NOT 161Number of Iterations 182, 189

Off-line Optimization 48Online Connection 32Online Optimization 48Online Timing 104Online Wizard 33OR 161, 171Output Interfaces 58, 59Output Variable 57

Pattern Generator 89Pavlov’s Dogs 179Performance Evaluation with Gen. Data 89PID Control 157Pi-Type Membership Functions 167Probability and Fuzzy Logic 151PROD 72Product Operator 72Project Editor 12Project Information 109, 110Prototyping 53Psycholinguistics 150Psycolinguistic Research 169

RAM Size 327RCU 108, 301Real-Time Optimization 48Remote Control Unit 108Reserved RAM 211Result Aggregation 171, 172ROM Size 328Rule

Complete and Incomplete 77

Page 341: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

341

Completeness 95Condition 171Consequence 171Don’t Care 77FAM 77

Rule Analyzer 100Rule Block 22, 53, 70

Properties 23, 75Utilities 78, 133Wizard 71

Rule-based Fuzzy Logic Systems 155

Sample Sequencing 183, 190Serial Interface 103Shared Filed System 103Shell Values 59Shell Values 60Singleton Membership Functions 174SOFT 148Spreadsheet Rule Editor 76S-shape functions 177S-Shaped MBF 169Standard MBF 167Statistics Analyzer 28, 100Statusbar 13, 47Steps[%] Field 95Structure of a Fuzzy Logic Controller 158S-Type Membership Functions 167Sucosoft S40 104Synapse 177System Analysis 334System Optimization 186, 334

TCP/IP 103Technical Restrictions 332Term 62, 166Text 53, 55THEN Part 171Time Plot 15, 97Toolbar 13, 47Trace Analyzer 29, 101, 335Transfer Plot Analyzer 94Treeview 12, 47

UncertaintyLexical 150

Mathematical Principles of 149Stochastic 149

Updates 326

Variable Type 57Variables 53Verification of a Fuzzy Logic System 48View Main Menu 46

Watch Window 88Winner Neurons 182, 189

Z-Type Membership Functions 167

Page 342: ft531manual

Inform Software Corporation Chapter 9: Appendix

342

9.7. License Agreement

Please read this agreement carefully prior to opening this package. By opening this sealedpackage, you will be bound by the following terms and conditions. In the event that youdo not agree with any of them, you should promptly return the package unopened. Yourmoney will be refunded.

1. Term:This Agreement is effective from the date on which you open the package containing theprogram. You may terminate it at any time by destroying the program together with allcopies, modifications, and merged portions in any form. It will also terminate uponconditions set forth elsewhere in this Agreement or if you fail to comply with any term orcondition of this Agreement. You agree upon such termination to destroy the programtogether with all copies, modifications, and merged portions in any form.

2. License:Pursuant to this Agreement, you may use the program on a single computer or anyreplacement for that computer. In support of your use of the program on the singlecomputer, you may copy the program into any computer readable or printed form forback-up or modification purposes. You may modify the program and/or merge it intoanother program for your use on the single computer. YOU MAY NOT USE, COPY ORMODIFY THE PROGRAM, IN WHOLE OR IN PART, EXCEPT AS EXPRESSLYPROVIDED IN THIS AGREEMENT.

Any portion of this program merged into another program will continue to be subject tothe terms and conditions of this Agreement. If you transfer the program, you must at thesame time either transfer all copies whether in printed or computer readable form to thesame party or destroy any copies not transferred, including all modifications and portionsof the program contained or merged into other programs. You must also reproduce andinclude the copyright notice on any copy, modification, or portion merged into anotherprogram. IF YOU TRANSFER POSSESSION OF ANY COPY, MODIFICATION, ORMERGED PORTION OF THE PROGRAM TO ANOTHER PARTY, YOUR LICENSEIS AUTOMATICALLY TERMINATED.

You may not sublicense, assign, or transfer the license or the program except as expresslyprovided in this Agreement. Any attempt to otherwise sublicense, assign, or transfer anyof the rights, duties, or obligations hereunder is null and void.

3. Ownership:This program is property of INFORM. You do not become owner of the program, but areentitled to use the program according to the terms of this agreement.

4. Limited Warranty and Limitation of Liability:Inform warrants that, for a period of ninety (90) days from the date of delivery to you asevidenced by a copy of your receipt, the diskette(s) on which the program is furnished,

Page 343: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

343

under normal use will be free from defects in material and workmanship. This warranty islimited to you and is not transferable.

During the 90-day warranty period, Inform’s sole liability and your exclusive remedyunder this warranty will be, at Inform’s option, to replace any diskette not meeting theforegoing warranty which is returned to Inform or an authorized Inform dealer with acopy of your receipt, or if Inform or the authorized dealer is unable to deliver areplacement diskette that is free of defects in material or workmanship, to refund thelicense fee and terminate this agreement.

The foregoing warranty does not extend to any diskette that has been damaged as a resultof accident, misuse, abuse, or as a result of service or modification by anyone other thanInform or an authorized dealer.

Inform does not warrant that the operation of the program will meet your requirements orthat the operation of the program will be uninterrupted or error-free. You assumeresponsibility for the selection of the program to achieve your intended results, and for theinstallation, use, and results obtained from the program.

Should you use this program to develop programs for the operation of machinery,automobiles or any other technical equipment which might cause any kind of bodilyinjuries or property damages if these programs do not work properly, it is your duty to useadequate safety devices, working separately and independently from the developedprograms and the controller-systems, in order to prevent such injuries or damages. It isyour duty to test the equipment under working conditions before using it.

EXCEPT FOR THE ABOVE EXPRESS LIMITED WARRANTIES, INFORM MAKESNO OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, WITH RESPECT TOTHIS PROGRAM, INCLUDING, BUT NOT LIMITED TO THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE. THE PROGRAM IS LICENSED AS IS. INFORM EXPRESSLYDISCLAIMS ALL WARRANTIES NOT STATED HEREIN. IN NO EVENT SHALLINFORM’S LIABILITY FOR ANY DAMAGES OR LOSS TO YOU OR ANY OTHERPERSON EXCEED THE LICENSE FEE PAID FOR THE PROGRAM. IN NO EVENTWILL INFORM BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANYDAMAGES, INCLUDING ANY LOSS OF DATA, INCIDENTAL ORCONSEQUENTIAL DAMAGES, EXPENSES, LOST PROFITS, LOST SAVINGS, OROTHER DAMAGES ARISING FROM THE USE OR INABILITY TO USE OURPROGRAM.

SOME STATES DO NOT ALLOW THE LIMITATION OR EXCLUSION OFINCIDENTAL OR CONSEQUENTIAL DAMAGES FOR CONSUMER PRODUCTS,SO THE ABOVE LIMITATIONS OR EXCLUSIONS MAY NOT APPLY TO YOU.THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS; AND YOU MAYALSO HAVE OTHER RIGHTS WHICH VARY FORM STATE TO STATE.

5. General:If you have any questions concerning this Agreement, including warranty service, youshould contact Inform.

Page 344: ft531manual

Inform Software Corporation Chapter 9: Appendix

344

If any provision or portion of a provision of this Agreement is determined to be invalidunder any applicable law, it shall be deemed omitted and the remaining provisions andpartial provisions of this Agreement shall continue in full force and effect.

This Agreement will be governed by the laws of the State of Illinois.

You agree to be bound by this Agreement’s terms and conditions; you further agree that itis the complete and exclusive statement of the Agreement between us which supersedesany proposal or prior agreement, oral or written, and any other communications betweenus relating to the subject matter of this Agreement.

Microsoft Windows, Microsoft C, and Microsoft DOS are registered trademarks ofMicrosoft Corporation, Inc. Turbo C and Borland C are registered trademarks of Borlandinternational, Inc. MCS-96 and MCS-51 are registered trademarks of Intel Corporation,Inc. fuzzyTECH is a registered trade mark of Inform Software Corporation.

Page 345: ft531manual

Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

345