Você está na página 1de 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.
© INFORM GmbH / Inform Software Corporation, 1986-1999

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

II
“It is the mark of an instructed mind to rest satisfied with that degree of precision which
the nature of the subject admits, and not to seek exactness where only an approximation of
the 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 they
are 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 is
faster 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 that
are 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

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

Chapter 1 provides an overview of the basic features of the fuzzyTECH


development system. Make yourself familiar with the fuzzyTECH development
strategy by using the animated simulation included in the purchased software.

Chapter 2 describes the setup procedure of an online connection between


fuzzyTECH and a runtime module as fuzzy system. The steam generator
simulation serves as example for a runtime module.

Chapter 3 explains individual design steps for the development of fuzzy-logic


based systems and describes the fuzzyTECH design and optimization tools.

Chapter 0 guides you through the development of NeuroFuzzy systems. In the


first part of this chapter a NeuroFuzzy system is developed using the Fuzzy
Design Assistant and trained with fuzzyTECH’s NeuroFuzzy module. The
second part explains individual design and optimization steps for NeuroFuzzy
systems and describes fuzzyTECH’s cluster modules.

Chapter 5 gives a brief introduction to the theory of Fuzzy Logic and


NeuroFuzzy and explains the basics of adaptive systems.

Chapter 6 introduces the fuzzyTECH code generation functions. Integration of


C-code, M-code and ASM libraries are explained. Moreover, it shows how fuzzy
logic systems are implemented and how the fuzzy computation kernel in
fuzzyTECH can be used for your application.

Chapter 7 explains the implementation of new components which are integrated


as user defined extensions into the open interfaces of fuzzyTECH.

Chapter 8 contains a glossary, in which essential and frequently used


terminology is explained.

Chapter 9 is regarded as an appendix that contains reference sections on various


topics, such as installation guidance, memory sizes, files and dictionaries, an
overview on the technical restrictions of all fuzzyTECH editions, contact
addresses for support, and a keyword index allowing quick access to certain
subjects and the license agreement.

IV
Figures Depending on the options enabled in fuzzyTECH, such window elements as
statusbars, toolbars, list boxes and others may be visible or invisible. Hence, the
windows depicted as screen shots on the following pages may look slightly
different 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 first
letter of a word is capitalized to emphasize that it is a name of a dialog or
field or another entry in one of the fuzzyTECH windows. Such words
referring 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 the
right 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 the
entry. This pull down menu lists the available functions for the entry. These
options 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 the
element. In fuzzyTECH, the right mouse button is only used for activating
“pop-up” menus in some windows. Click right in one of fuzzyTECH’s
windows and select the option with the left mouse button to activate a pop-up
menu. The pop-up menus contain functions and options that are available
only for the associated window. In most windows, these functions and
options are also accessible through toolbars. You can enable or disable
toolbars through the option Toolbars in the View menu. The way of using
mouse 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 key
words.

V
1. Getting Started with fuzzyTECH: The Crane Simulation.......................................................................9
2. Online Debugging the Steam Generator Drum Simulation ..................................................................30
3. Designing Fuzzy Logic Systems ...............................................................................................................42
3.1. First steps ...........................................................................................................................................47
3.1.1. Rapid Application Development with the Fuzzy Design Wizard ...........................................48
3.1.2. System Definition....................................................................................................................53
3.1.2.1. Structure of a Fuzzy Logic System ..............................................................................53
3.1.2.2. Editing Objects.............................................................................................................53
3.1.2.3. Definition of Text Objects ...........................................................................................55
3.1.2.4. Defining Linguistic Variables ......................................................................................56
3.1.2.5. Defining Membership Functions..................................................................................64
3.1.2.6. Defining Rule Blocks...................................................................................................70
3.1.2.7. Formulation of Fuzzy Rules.........................................................................................75
3.1.3. Optimization and Debugging ..................................................................................................85
3.1.3.1. Off-line Debug Modes .................................................................................................87
3.1.3.2. Online Debug Modes ...................................................................................................87
3.1.3.3. Switching into Debug Mode ........................................................................................88
3.1.3.4. Test System Performance Using Data..........................................................................89
3.1.3.5. fuzzyTECH Analyzers ..................................................................................................93
3.1.3.6. Online Optimization...................................................................................................101
3.1.3.7. Connecting fuzzyTECH to other Applications ...........................................................107
3.1.4. fuzzyTECH Documentation and Revision Control System ...................................................108
3.1.4.1. Project Information ....................................................................................................109
3.1.4.2. Documentation Generator ..........................................................................................110
3.1.4.3. Revision Control System ...........................................................................................110
4. NeuroFuzzy Design .................................................................................................................................114
4.1. First steps .........................................................................................................................................114
4.1.1. Generating a Fuzzy XOR System by the Fuzzy Design Wizard ...........................................114
4.1.2. NeuroFuzzy Training of Fuzzy Systems: The XOR Example ..............................................116
4.2. NeuroFuzzy System Design.............................................................................................................123
4.2.1. Clustering with fuzzyTECH...................................................................................................135
5. Fuzzy Primer ...........................................................................................................................................146
5.1. Fuzzy Logic......................................................................................................................................147
5.1.1. History...................................................................................................................................147
5.1.2. Types of Uncertainty .............................................................................................................149
5.1.3. Fuzzy Logic Technologies ....................................................................................................155
5.2. Computing Fuzzy Systems...............................................................................................................165
5.2.1. Fuzzification..........................................................................................................................166
5.2.2. Fuzzy Rule Inference.............................................................................................................171

VI
5.2.3. Defuzzification ......................................................................................................................173
5.3. NeuroFuzzy Technologies ...............................................................................................................176
5.3.1. Basics of Adaptive Systems ..................................................................................................176
5.3.2. Combining Neural and Fuzzy................................................................................................183
5.4. Computing NeuroFuzzy Training ....................................................................................................185
5.4.1. Learning Fuzzy Rules............................................................................................................187
5.4.2. Learning Fuzzification and Defuzzification..........................................................................190
5.5. Data Clustering ................................................................................................................................192
6. Implementing Fuzzy Runtime Systems .................................................................................................200
6.1. Using fuzzyTECH Code Generators................................................................................................200
6.1.1. fuzzyTECH Runtime Control (ActiveX) ...............................................................................202
6.1.2. fuzzyTECH Runtime DLL (FTRUN.DLL)............................................................................203
6.1.2.1. FTRUN API ...............................................................................................................205
6.1.2.2. FTRUN Integration Using Software Development Tools..........................................207
6.1.2.3. FTRUN Integration in Standard Software .................................................................209
6.1.2.4. FTRUN Configuration ...............................................................................................209
6.1.3. Hardware Specific Code........................................................................................................210
6.1.3.1. MCU-ST6 Edition......................................................................................................210
6.1.3.2. MCU-MP Edition.......................................................................................................213
6.1.3.3. MCU-51 Edition ........................................................................................................222
6.1.3.3.1. Fuzzy Library............................................................................................222
6.1.3.3.2. RTRCD Communication Module .............................................................223
6.1.3.3.3. Generating and Using the Assembler Module ..........................................223
6.1.3.3.4. Building an Executable File ......................................................................228
6.1.3.4. MCU-374 Edition ......................................................................................................230
6.1.3.5. MCU-96 Edition ........................................................................................................236
6.1.3.5.1. Fuzzy Library............................................................................................237
6.1.3.5.2. RTRCD Communication Module .............................................................237
6.1.3.5.3. Using the Generated C Module.................................................................238
6.1.3.5.4. Building an Executable File ......................................................................244
6.1.3.6. MCU-166 Edition ......................................................................................................245
6.1.3.6.1. Fuzzy Library............................................................................................246
6.1.3.6.2. RTRCD Communication Module .............................................................246
6.1.3.6.3. Using the Generated Assembler Module ..................................................246
6.1.3.6.4. Building an Executable File ......................................................................251
6.1.3.7. MCU-320 Edition ......................................................................................................252
6.1.3.8. MCU-HC05/08 Edition..............................................................................................258
6.1.3.8.1. Fuzzy Library............................................................................................258
6.1.3.8.2. RTRCD Communication Module (only for M68HC08)...........................259
6.1.3.8.3. Using the Generated Assembler Module ..................................................259
6.1.3.8.4. Building an Executable File ......................................................................264
6.1.3.9. MCU-HC11/12 Edition..............................................................................................267
6.1.3.9.1. Fuzzy Library............................................................................................267
6.1.3.9.2. RTRCD Communication Module .............................................................268
6.1.3.9.3. Using the Generated Assembler Module ..................................................269
6.1.3.9.4. Building an Executable File ......................................................................274

VII
6.1.3.10.IA-S5 Edition .............................................................................................................275
6.1.4. Portable C Code ....................................................................................................................278
6.1.4.1. Building the fuzzyTECH C Runtime Library .............................................................279
6.1.4.1.1. Preprocessor Definitions ...........................................................................280
6.1.4.2. Using the Generated Module .....................................................................................281
6.1.4.3. Online Communication Module.................................................................................290
6.1.4.4. Compiling and Linking ..............................................................................................291
6.1.4.5. Examples....................................................................................................................292
6.1.5. COBOL Code........................................................................................................................293
6.1.5.1. COBOL Runtime Library ..........................................................................................294
6.1.5.2. Using the Generated Sub-Program.............................................................................294
6.1.5.3. Example .....................................................................................................................295
6.1.6. M Code..................................................................................................................................296
6.2. Using fuzzyTECH as Server .............................................................................................................297
6.2.1. DDE.......................................................................................................................................298
6.2.1.1. fuzzyTECH as DDE Server ........................................................................................298
6.2.1.2. fuzzyTECH as DDE Client.........................................................................................300
6.2.2. fuzzyTECH Remote Control Unit (RCU) ..............................................................................301
6.2.2.1. C Code .......................................................................................................................302
6.2.2.2. MS Excel....................................................................................................................310
6.2.2.3. MS VisualBasic..........................................................................................................312
6.2.3. Serial Link .............................................................................................................................315
7. User Extensions of the fuzzyTECH Shell ..............................................................................................318
7.1. NeuroFuzzy: User Defined Learn Methods ..................................................................................... 318
7.1.1. Compile and Register a DLL.................................................................................................318
7.1.2. Code Example .......................................................................................................................319
7.2. Online: Implementing User Defined Communication Channels .....................................................321
8. Glossary....................................................................................................................................................323
9. Appendix ..................................................................................................................................................325
9.1. Software Installation ........................................................................................................................325
9.2. Memory Size ....................................................................................................................................327
9.3. Directories and Files ........................................................................................................................328
9.4. Features Overview ...........................................................................................................................332
9.5. Support Contact................................................................................................................................337
9.6. Index ................................................................................................................................................338
9.7. License Agreement ..........................................................................................................................342

VIII
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 and
covers only the most important features pertinent to the crane simulations. Refer
to 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 basics
of fuzzy logic theory are explained in Chapter 5. If you are not familiar with the
concepts of fuzzy logic, please read this section before proceeding. The
following description has been structured so that you can follow it in parallel on
your PC.

Disabled Features Depending on your fuzzyTECH Edition, you may find options disabled or menu
entries depicted in the screen shots that are missing in your fuzzyTECH Edition.
Section 9.4 gives a complete function overview of all fuzzyTECH Editions.
fuzzyTECH
Program 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 the
fuzzyTECH Shell. The other options start the process simulations and open the
help files. Click on “READ ME FIRST” to view the most up-to-date information
about the software.

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

Figure 1: The Setup Routine Automatically Creates the fuzzyTECH


Program Group in the Program Menu.

Start the Container First, start the container crane simulation by clicking the crane
Crane Simulation symbol in the fuzzyTECH program group.

Figure 2 shows the crane simulation window. The container (yellow) is already
picked 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 Angle
and Distance are computed by the process simulation, while Power is the control
variable either set manually or by the fuzzy logic controller. Enable the manual
control mode by clicking the [Manual] button. The Distance is more than 20
yards, while Angle and Power are zero.

Manual Control Use the [-], [0] and [+] buttons to control the Power. First, click once or twice on
the [+] button. This sets the motor power either to 0.75 or 1.5 kilowatts. The jerk
caused by this makes the Angle oscillate lightly, but is not sufficient to put the
crane in motion due to the friction in the mechanical system. At least 3 kilowatts
motor power is required to set the crane head in motion. Now, further increase
the motor power by clicking on the [+] button again. The [0] button resets the
motor power setting to zero and the [-] button lets you apply negative motor
power for braking. You can also use the [-], [0] and [+] buttons on your
keyboard. 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 the
large weight of the container, the “container drives the crane” rather than vice
versa. This strong feedback of the load to the drive is typical for container
cranes, and it causes one of the major difficulties for the control of such
processes.

10
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 2: Watch and/or Control the Container Crane in Operation in the Crane
Simulation 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 the
container can be released. The container must not sway as releasing a swaying
container could damage its contents. There exist two simple strategies to position
the container without swaying over the truck. One is to move the crane head
slow enough to prevent any sway of the container. Since you are safe from wind
gusts with the software simulation of the crane, this certainly works. However, it
may take a long time to reach the target. The other simple strategy is to start with
full power, position the crane head over the target position and wait until the
container stops swaying. This works since the sway is of no harm during
transportation and there are no wind gusts. However, it also takes far too much
time. Both of these simple strategies are not practical for container cranes. The
opportunity costs of a container ship tied up in a harbor go into thousands of
dollars each hour. Hence, loading and unloading must be completed within a
minimum amount of time. Only an anti-sway control strategy of the container
crane operator can achieve this. Try this yourself: start with medium power. If
you apply full power right from the start, the container starts to sway very
strongly and takes a long time to stabilize later. If the container sways a little
behind the crane, you can further increase the power because this situation is
stable. The increased power gets the container to the target faster. Watch the
container 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 also
moves 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.

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

Start fuzzyTECH Start your fuzzyTECH Edition first in order to use the pre-defined fuzzy logic
controller 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 in
fuzzyTECH nor can a second set of these windows be opened. However, use the
system icon to minimize the Project Editor and the symbol to hide or show
the 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 Project
Editor shows more the relations between all objects of the project, the Treeview
displays the hierachic structure of the fuzzy logic system. Similar to the MS
Windows Explorer, the Treeview lists all objects as well as the current debug
mode or the analyzers used, allowing thus quick access for editing them or the
whole project (see Section 3.1.2.2). Clicking one of the object groups shows
further 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 contains
various pull down menus with numerous options, some of which contain further
menus 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 generated
by add-on modules that might not be included in the standard installation of your
fuzzyTECH edition. Those options are indicated by gray font color. If some
menu items, e.g. the Debug or Analyzer menu, appear in such a gray color - then
they are deactivated. They need certain prerequisites for being accessible. Refer
to the fuzzyTECH Help in such cases (“Help/fuzzyTECH Help”). All menu
entries are accessible by shortcuts, press the [Alt] key together with the
underlined letter of the respective function. This mechanism is based on
Windows conventions. Hardware dedicated packages may generate additional
menu items that are explained later in this manual (e.g. the FUZZY-166
package). For each menu entry, the edition required and other preconditions for
use of this entry are listed. If these paragraphs are missing, either there are no
preconditions or the item is available in all editions.

12
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Statusbar At the lower border of the main fuzzyTECH window, a gray bar displays
information about current settings, selected commands, modes or about an
operation in progress. The statusbar consists of three fields. The left field
indicates basic operations of fuzzyTECH, such as loading, saving, or code
generation. When fuzzyTECH is idle, this field displays “Ready”. The left field
has a second function: when the mouse pointer moves over a button of the
toolbar, the left field displays a short description of button’s function. The right
field of the statusbar always displays the current debug mode. Upon start of
fuzzyTECH, no debug mode is active and thus the right field displays “Design
Mode”. The middle field displays the progress of complex fuzzyTECH
operations, such as loading, saving or the current state of a data transmission.
Load the Container
Crane 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 and
saving files, as well as related functions. Select the option “File/Open” and open
the file “CRANE.FTL” located in the subdirectory
“...\SAMPLES\CONTROL\CRANE\”. You may also click on the file name in
the lower part of the File menu, if it is displayed there. Here, the most recently
saved files are automatically listed for quick reload. The installation routine pre-
sets this list. This option can be deactivated in “Tools/fuzzyTECH
Preferences/General” by clicking the checkbox of “Recently Used File List”.

While fuzzyTECH opens a project, the middle field of the statusbar displays
which component of the fuzzy logic controller is currently loaded. Depending on
the speed of your PC, this may be too fast to follow. At the end of the loading
procedure, fuzzyTECH’s Project Editor and Treeview window display the
structure 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 Intermediate
Variables to see all of the project’s variables. “Angle” and “Distance” are the
output variables (measured variables) of the crane simulation and, hence, the
input variables of the fuzzy logic controller. Power is the input variable
(command variable) of the crane simulation and, hence, the output variable of the
fuzzy logic controller. There are no intermediate variables in this project.
Linking the respective inputs and outputs of the crane simulation and the fuzzy
logic controller yields a closed control loop.

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

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

Use fuzzyTECH as server


for 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 can
be remote-controlled by an external simulation program. Link the controller to
the simulation by selecting the [Fuzzy] button in the crane simulation. For a
short time, the left field of the statusbar displays “Loading Knowledge Base...”.
During this period, fuzzyTECH builds an internal representation of the current
fuzzy 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: RCU
Debug Mode”. In addition, a new window titled “Watch: RCU” (Figure 5)
opens. This window always shows the current values of all input and output
variables of the fuzzy logic controller.

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

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

14
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 used
by 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 currently
loaded in fuzzyTECH is checked. If the current project matches or a matching
project can be loaded, then fuzzyTECH switches into “RCU Debug Mode”. If
one of the checks fails, an error message appears.

Debug Mode When linking to a simulation, fuzzyTECH always checks that the simulation and
the fuzzy logic controller match. The check verifies that all variable names used
are the same in the controller and the simulation. You may program simulations
in any program language under MS Windows or you may use a professional
simulation software package.
Start the Fuzzy Logic
Control 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 Angle
and Distance and sends them to fuzzyTECH where they are the inputs of the
fuzzy logic controller. fuzzyTECH then computes the value of the output variable
Power and sends it back to the crane simulation. The crane simulation uses the
value of Power to compute the reaction of the crane a time unit later and displays
the new situation in its window. This sequence repeats itself until either the
[Stop] or [Reset] button of the simulation is pressed. Depending on the
computation and video performance of your PC, you see this loop as a smooth
movement of the container crane.

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

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

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

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

The right list box Plot Items displays all variables displayed in the Time Plot and
can be hidden by clicking the [List Box] symbol. All input and output
variables can be inserted into the Time Plot by clicking the toolbar buttons [Add
Input Variables] or [Add Output Variables] . You can also choose variables
for display by clicking the button [Configuration ] in the toolbar of the Time
Plot 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 tabbed
dialogs Variables, Terms, and Rules (Figure 7).

Figure 7: The Time Plot Configuration Dialog Lets You Specify


Linguistic Variables, Terms, and Rules for Display in the Time Plot.

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

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

16
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

click all three of these variables to move them into the list box “Variables in
Time 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 Time
Plots in each fuzzyTECH session. Each Time Plot is uniquely identified by a
number in its title bar. On the right side of the Time Plot window, a list box
shows now all selected Plot Items. The left part of the window displays the plot
area. 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 all
three control variables over time (Figure 8).

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

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

Customizing Time Plots You may set the resolution of the time axis in the toolbar’s drop list to customize
a 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 screen
space. The [Reset] button clears the plot area. Click the button
[Configuration] to add or delete elements from the Time Plot. Move the mouse
pointer over the buttons without pressing a mouse button to see a quick
description in the left field of the statusbar. You can also access the toolbar
functions through the pop-up menu activated by clicking right somewhere in the
Time Plot window. You can turn the Time Plot toolbars on and off in the main
menu 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

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

Configuration” in the fuzzyTECH Preferences dialog Save, all Time Plots still
opened while leaving the debug mode are reopened automatically when calling
the debug mode again.
Time Plot of Rule
Firing 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” entry
in the “Rule Block:” list box. 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 number after the point identifies the number of the rule in
the respective rule block; the second 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 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 “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 the Time Plot, the respective rule is
shown abbreviated under the plot area. You may mix any combination of
linguistic variables, terms and rules in a Time Plot.

The Spreadsheet Rule Editor represents a second and much easier possibility to
add rules to the Time Plot. Invoke the Spreadsheet Rule Editor by clicking on the
rule block in the window of the project editor. Click then into the DoS column to
open a pop-up menu at the end of which is a Time Plot menu. This menu lists all
open Time Plots. Choose the one to which you want to add the rule by clicking
it. The added rule is then displayed in the respective Time Plot in the list Plot
Items.
Analyzing
Control 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 and
computing resources if you have a low-performance PC. Select the option
“Analyzer/New 3D Plot...” from the main menu. The 3D Plot, as shown in
Figure 9 displays the control surface of the crane controller. The 3D Plot always
shows two input variables on the horizontal axis and one output variable in the
vertical 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 button
beside the right drop-down list to change the resolution of the 3D Plot. This
displays a list of possible plot resolutions. A high resolution can result in slow
response and redraw times of the time plot, depending on the video and
computing performance of your PC. You can select the output variable using the
second rightmost field and the two input variables using the two fields on the
left. The four arrow buttons on the left side of the toolbar rotate the plot in all
directions. A double click on an arrow button starts a (continuous) rotation; the
hand button stops this rotation. The [Vertical] button flips the 3D Plot for
better visibility.

18
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

If the output variable selected for the 3D Plot depends on more than the two
inputs displayed, the control surface exhibits dynamic dependence on these
variables. If the [Repaint] button is pressed, the 3D Plot is repainted every time
one of these other input variables changes to reflect the change in the control
surface shape. Note that this only results in a smooth display if you have a PC
with 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 automatically
closed. If you have enabled “Save Window Configuration” in the dialog
“fuzzyTECH Preferences/Save”, all 3D Plots still opened upon leaving the debug
mode are automatically reopened when you reenter debug mode.
Display of
Operation 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 the
operating point over time (green trace). Enable [Trace], then reset and start the
crane 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 and
Distance=0. The height of the control surface and its color indicate the reaction
of the fuzzy logic controller to the combination of the input variables.

With the Time Plot and 3D Plot, you analyze the “outside” performance of the
fuzzy logic controller by using input and output variables. In the next steps, you
analyze the internal structure. The RCU debug mode is closed remotely by
closing the crane simulation.
Linguistic Variable
Editors 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 the
respective 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 variable
editor by choosing the option “New Variable” or “Figure 10 shows the editor
window for the linguistic variable “Angle”. Click the [Variable] button in the
main toolbar or use the shortcut [Ctrl] + [V] create a new linguistic variable.

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

Figure 10: Variable Editor Window for “Angle”.

Customizing the
Variable 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 a
list box showing the terms for the linguistic variable. A term can be selected by
clicking the term name either above the plot area or in the list box. You can also
hide the list box Term using the [Listbox] button of the toolbar. This is useful
to 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 the
menu “View/Toolbars”. All toolbar functions are accessible by the pop-up menu
of the Variable Editor. Click right somewhere in the Variable Editor window to
activate this pop-up menu. Click the system icon of the Variable Editor
window to close a Variable Editor.

Editing Linguistic Terms Double-click on the term name in the list box “Term” of the Variable Editor to
change 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 you
change the colors that fuzzyTECH automatically associates to terms. Refer to
Section 3.1.2.5 for detailed information about this dialog, creating terms, as well
as defining and editing their membership functions.
Editing System Structure
in 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, Rule
Blocks and Text. Text objects have no impact on the actual information being
processed. Variable interfaces can also contain fuzzification and defuzzification.
Rule Blocks contain the fuzzy logic rules of a system design. These elements
suffice 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 mouse
movement is then limited to the horizontal or vertical direction, depending on in
which direction the move started. If you do not want to use the mouse, you can
highlight any object using the [Tab] key, moving it with the cursor keys, and
placing it with the [Return] key.

20
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Properties dialogs The properties of an object can be edited by so-called Properties. There are
different ways to open a Properties dialog: click right an object in the Project
Editor or the object’s name in the Treeview and choose the option Properties
from 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 right
either Angle or Distance in the Treeview and choosing the option Properties. In
the Project Editor window, you can differentiate input and output variable
interfaces by the location of the method icon. With input interfaces, the icon is
on 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 Linguistic
Variables Wizard or change it in the Properties dialog. fuzzyTECH support three
types of variables: input variables, intermediate variables and output variables.
Input and output variables are assigned to a rule block via an interface that is
displayed in fuzzyTECH’s Project Editor as box containing the name of the
variable and the chosen method for fuzzification or defuzzification. Intermediate
variables have no interfaces.

Input Variables For input variables, three different fuzzification methods are supported. In the
Project Editor window, each method is represented by a different icon. “Fuzzy
Input” 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 primarily
used in decision support applications where the input stems from a linguistic
source rather than a technical sensor. The fuzzification method, “Compute
MBF”, is the standard fuzzification method used in almost all applications. This
method only stores the definition points of the membership functions in the
generated code and computes the fuzzification at runtime. Some fuzzyTECH
MCU Editions (dedicated assembler code generation for microcontrollers) also
support the “Look up MBF” method. This method computes the membership
functions completely at compile time and stores all values in a table in the
generated code. This method results in extensive code sizes and is only provided
where it delivers expedited computation.

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

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

The Hyper CoM method is used for fuzzy applications, which require not only
positive experience in the form of recommendations, but also negative
experience in the form of warnings and prohibitions.
Definition of
Fuzzy 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. Each
row corresponds to a single fuzzy logic rule or more, depending on the fact, how
many outputs the Rule Block has. The leftmost column assigns a number to each
row (gray fields). Clicking on this field highlights the rule; clicking again de-
selects it. The next two columns contain the variables Angle and Distance and
are titled with IF. The IF field comprises the “if-part” of the rule, i.e. each cell in
a variable column represents the terms of the variables that is used as rule
condition. The two columns under the THEN field describe the THEN part of the
rules, i.e. the rule consequences. The column titled with Power contains its
output terms used as rule output. The DoS column contains individual rule
weights. The rule weight ranges from zero to one, indicating the degree, to which
a 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 all
possible 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 column
has been clicked on, the pop-up menu lists decimal DoS values from 1.0 to 0.0
and the option 0..1. This opens a window containing a slider and a input field
that 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 new
rule, another empty row appears at the end of the table. An empty row can also
be inserted within the Spreadsheet Rule Editor. You can either click right on the

22
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

left, gray field displaying the row number. Choose the “Insert Row” option in the
pop-up menu. An empty row will be inserted before the row that was selected.
Incomplete rules are automatically deleted when the Spreadsheet Rule Editor is
closed. 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 one
rule input, e.g. Angle and Distance), a cell can be empty. Empty “if-parts” of a
rule are considered as “don’t care” conditions. A rule that contains an empty
field 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 the
Delete Row option. If you want to deactivate a rule temporarily, set its DoS
value to 0.0. Thus this rule has no influence on the fuzzy system, is complete and
will not be deleted when closing a Spreadsheet Rule.

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

Figure 12: The Rule Block Properties: Operators Dialog

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

Result Aggregation Choose an fuzzy operator for result aggregation in the field Result Aggregation
of the Rule Block Properties/Operators dialog (Figure 12). fuzzyTECH supports
two methods for result aggregation, the maximum method (MAX) and the
bounded sum method (BSUM). If more than one rule have the same result, the
MAX method takes the maximum of their DoS values as final result. The BSUM
method takes the bounded sum. Thus, all firing degrees are summed by using a
bound of one. Note that BSUM result aggregation is different from BSUM MoM
and BSUM CoA. The bounds are zero and one. For more details on computation
of aggregation and result aggregation methods, refer to Chapter 5. The usage of
the 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 the
Sort Rules dialog. Choose in this dialog a criterion, according to which the rules
of this rule block are to be sorted. The sequence of rules as shown in Figure 11 is
the result of sorting Distance according to its terms or, more precisely, the
maxima of its membership functions (open the Variable Editor of Distance to
compare this). Sort the rules as shown in Figure 11, since the rules are later
referenced by their row number.

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

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

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


Matrix.

24
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

In contrast to the Spreadsheet Rule Editor, the Matrix Rule editor presents the
rules in form of matrices. It is possible to switch between the rule editors, but
only one can be open for a rule block at the same time. If the fuzzy system
contains 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 rule
block in its title bar . Many experienced fuzzy logic designers prefer the Matrix
Rule Editor to the Spreadsheet Rule Editor when designing complex systems. It
comprises more functions that help to detect rule inconsistencies or rule gaps and
allows 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 on
the number of output variable per rule block, one matrix or more matrices. All
inputs 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 selected
for display in the matrix. A term list box of an input variable appears disabled in
gray color, if this is chosen for display in the matrix.

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

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

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

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

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

Due to the complexity of the Matrix Rule Editor, its further functions shall not be
described 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 the
toolbar symbol to return to the Spreadsheet Rule Editor.
Test and Verification
Using 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. fuzzyTECH
offers numerous debug modes to support this development step. The different
debug modes are descriped more detailed in Section 3.1.3. All debug modes
cooperate with the editors and analyzers you have learned to use to expedite
system verification. When you switch from Design Mode to any of the debug
modes, the entire fuzzy logic system developed is simulated by fuzzyTECH. All
editors become dynamic, i.e. they graphically display information flow,
fuzzification, defuzzification, and rule inference. In addition, most system
components may still be edited during debugging. First, a quick introduction into
handling the Interactive debug mode.

System Test Using


Interactive 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 the
crane controller. Open the Spreadsheet Rule Editor window for the rule block by
double-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 functions
in the Variable Editors for “Angle” and “Distance”, a thin vertical line shows the
fuzzification. The firing degree of each rule is shown by small black bars on both
sides of the DoS values in the Spreadsheet Rule Editor. Click on the bar to see
the 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 eighth
rule in Figure 14 fires. This rule states that in the starting position, the crane
should start with medium power. The defuzzification shown in the Variable
Editor for “Power” is unequivocal, and a crane connected to this controller

26
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

would now start with 10 kilowatts power. The situation changes after a short
time. As the crane starts to move, the load of the crane sways behind and the
distance 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 the
crane motor should be powered up. This situation is represented by the ninth rule
that now fires completely (Figure 15). In a similar fashion, you can now test the
fuzzy logic system performance for arbitrary situations. Change the “then-part”
of the ninth rule from “pos_high” to “neg_high”, and you instantly see the
effects of this in the Variable Editor for “Power”. Similarly, any change of a
membership function or a rule weight is instantly reflected in all editors.
Using Analyzers in
Interactive 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 select
any controller operating point. All Editors are updated to show fuzzification, rule
inference, and defuzzification for exactly this operating point. Likewise, any
change of input variable values in the Variable Editors for “Angle” and
“Distance” is reflected instantly in the 3D Plot. By enabling the Trace option in
the 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

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

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

Figure 15: Modifications in the System Become Instantly Visible in All Editors
and 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 the


Crane Controller Start the container crane simulation again (…\SIMCRANE.EXE). Start the crane
by clicking the [Fuzzy] button. All editors and analyzers of fuzzyTECH show
fuzzification, rule inference, and defuzzification while the crane is running. Does
your 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 crane
operates.

Statistics Analyzer Activate the Statistics Analyzer by selecting “Analyzer\Statistics” from the main
menu bar, or by clicking the main toolbar button [Statistics] . In contrast to
Time Plot, Transfer Plot, and 3D Plot, the Statistics Analyzer is not displayed
with a own window. Rather, it adds a new column [min-#-max] to each
Spreadsheet Editor open. Open a Spreadsheet Rule Editor to see the Statistics
column [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 DoS
value greater than zero. The frequency a rule fires can either be displayed as

28
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 or
relative values. Pressing the button [Reset Statistics Counter] resets the counting.

Trace Analyzer The Trace function provides a real-time trace on the target hardware. Because
the trace buffer is kept on the target hardware, the trace is not limited by the
bandwidth of the serial communication. Also, by tracing slow processes, the
Trace 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 target
hardware and is configured at compilation time. The trace frequency may be
changed any time from the PC. You may upload the contents of the trace buffer
to the PC for further analysis at any time. fuzzyTECH automatically converts the
trace buffer into ASCII format readable by the File Recorder. The Trace function
is 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 Technology
Language) to store fuzzy logic systems. If you manually edit an FTL file that
was 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 multiple
purposes. 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. These
simulations may be started directly by double-clicking their respective icons.
Some of the simulations also allow a manual control of the process. To control a
process 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 one
process simulation may be started at the same time to avoid conflicts. Note: The
installation procedure has created a separate subdirectory for each process
simulation in the …\SAMPLES\ subdirectory. Each of these subdirectories
contains the SIMULATE.EXE file with the process simulation and the *.FTL
file with the description of the fuzzy logic controller to be loaded by fuzzyTECH.

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

The animated Steam Generator Drum simulation demonstrates fuzzy


logic control using the fuzzyTECH software package and the
fuzzyTECH Runtime DLL. Open this simulation from the Start menu
(“Start/Programs/fuzzyTECH/Examples/Simulations/..”). The steam
generator simulation is indicated by the right icon:
Steam Generator Drum
Simulation 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 is
executed manually by operators. Manual start-up is used because of the large
number of process variables involved, their interdependencies, and their non-
linear relationships that render the use of conventional automation techniques
impossible. As in many similar applications, fuzzy logic makes an automated
solution possible because human operator experience can be put directly into a
solution.

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

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

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

30
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Steam Generator
Operation 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 also
connected to a throttle valve, which delivers steam to the turbines that drive the
electric generators. Because the water capacity of the heat exchanger pipes much
exceeds the water capacity of the drum, starting the pump and the heat-up
procedure itself changes the water level in the drum strongly. The drum shall
never be empty because this would yield air into the heat exchanger pipes and if
the drum runs full, the water must be drained. Because the water used has been
purified, draining water is expensive.

Figure 16: Steam Generator Drum Simulation Window

Fuzzy Logic Start-up


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

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

The next step gives you a brief overview on the fuzzyTECH Runtime DLL.
The fuzzyTECH
Runtime 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 of
modifying or monitoring a running fuzzy logic system; it only computes the
output variables of the fuzzy logic system based on its inputs. The fuzzyTECH
Runtime DLL is available in different executable formats, such as Windows 16-
bit and 32-bit DLL component. For some software packages and process control
systems such as InTouch, FactoryLink, or SIMULINK, specialized "ready-to-
use" Runtime Module are available, too. All fuzzyTECH Runtime DLLs can
open any fuzzy logic system that follows the *.FTR file format.

While you may use the FTRCU interface to let fuzzyTECH itself compute the
outputs of a fuzzy logic system, in some cases, the Runtime Module is the better
choice:
• The fuzzyTECH Runtime DLL is much smaller than the complete
fuzzyTECH development system. For example, FTRUN32.DLL is less than
100KB of size.
• The Runtime DLL is much faster than the complete fuzzyTECH development
system. For example, on an i486 PC, a large fuzzy logic system computes in
about 1/10th of a millisecond.
• The Runtime DLL is free. If you are a licensed user of the fuzzyTECH
Professional or Online Edition, you can distribute the Runtime DLL with
your fuzzy logic system.
• One Runtime DLL can be called as a server by multiple client software
programs. Each client program can use multiple instances of different fuzzy
logic systems at the same time.

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

The next step shows you how to configure the online connection link between
fuzzyTECH and its Runtime DLL on the same PC.
Configuring an
Online Connection The following instructions give you a step-by-step guidance at configuring an
online connection between fuzzyTECH and a fuzzy runtime system. This
example uses as fuzzy runtime system the Steam Generator Drum Simulation,
the fuzzyTECH Runtime DLL (FTRUN32.DLL), and the two files START.FTR
and PRESS.FTR, both generated by fuzzyTECH.

32
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Start a fuzzyTECH edition that supports online debugging. Please note that
online modifications are impossible with a fuzzyTECH Demo edition or the
fuzzyTECH Viewer. No fuzzy system should be loaded in the fuzzyTECH Project
Editor. Open the Online Wizard by clicking the Treeview entry Online
Connections by the right mouse key and choosing the option Online Wizard in
the 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 the
online connection. As for the Steam Generator Drum Simulation, the results of
this 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” window
that opens together with the simulation’s window at starting the Steam
Generator Drum simulation. If DDE is not chosen as online communication
channel, change this setting of the fuzzyTECH Runtime DLL in its
configuration file FTRUN32.INI. This file is stored in the Windows
directory, e.g. C:\WINDOWS. In the paragraph [FTRUN], go to the
command COMMCHANNEL and set it to COMMCHANNEL=DDE. After
the communication channel was changed, restart the Steam Generator Drum
Simulation.
3. The files (or fuzzy systems) START.FTR and PRESS.FTR were generated
by a fuzzyTECH code generator with the option Online Code enabled. This
requirement is fulfilled, provided that you haven’t changed the files after
fuzzyTECH was installed.

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

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


fuzzyTECH

For fuzzyTECH, DDE has to be chosen as communication channel as well. This


can be done by choosing FTDDE.DLL in the list of Current Settings in the
Online Wizard. After DDE was set as communication channel both for
fuzzyTECH and the fuzzyTECH Runtime DLL, click the [Next>] button in the
Online 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. The
fuzzy systems START and PRESS are listed with their so-calles time stamps
below the entry "Online Connections" in fuzzyTECH’s Treeview window.
Additionally, the system loaded in the fuzzyTECH’s Project Editor has been

34
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

entered in the Treeview, too. If, for many reasons, the online connection could
not be set up, the Online Wizard appears with a negative report page. The Online
Wizard 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 runtime
system is to debug online, it has to be loaded into fuzzyTECH’s Project Editor
first. In the Online Wizard, choose the option "Open System". The option
"Download" is not available as long as no fuzzy system is loaded into
fuzzyTECH’s Project Editor.

Figure 21: Online Wizard: Open a fuzzy system

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

There are two possibilities to open a fuzzy system that corresponds with one of
the systems on the fuzzy runtime system: either the right FTL file is stored on a
data medium or the system is opened from the fuzzy runtime system. The Online
Wizard lists all systems that can be opened on the fuzzy runtime system. In the
case of the Steam Generator Drum Simulation, the both fuzzy systems START
and PRESS are listed. Choose the one of the systems in the list of the Online
Wizard 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 system
selected before is loaded into fuzzyTECH’s Project Editor. It corresponds
completely with one of the fuzzy systems on the fuzzy runtime system, which is
proven by the identical time stamps displayed in the Treeview. The entry
"untitled" below the Treeview entry Online Connections, fuzzyTECH’s Project
Editor has been replaced by the time stamp. Simultaneously, the fuzzy system’s
name is displayed in the title line of the Treeview. The correspondence of the
systems is indicated by the bitmap . This page of the Online Wizard offers the
two online debug modes Monitor and Monitor&Modify. Choose the Monitor
debug 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 debug
mode is active, fuzzyTECH calls cyclically (asynchronously) the runtime system
for the latest values of input and output variables and displays these in all open
fuzzyTECH editors.

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


initiated by fuzzyTECH. Thus, if no link is enabled, the controller is able to
operate without the development system. For security purpose, all telegrams are
transferred via handshake. If no message appears or a telegram is only partly
received at the target, the development system and the online debugger will sleep

36
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

but let the controller work. Every message completely received at the target is
acknowledged by the online debugger. This acknowledgment must reach the
development hardware in a time period shorter than the time out interval
determined in the Timeout field in the dialog Online Timing (Figure 73) in
Tools/Project Options. Otherwise, a message appears and the Online Connection
is terminated.
The Fuzzy Logic
Control Strategy Click [Start] button (or the [Stop], the [Reset], and the [Start] button if the
simulation is already running) in the Steam Generator Drum Visualization
window to run the start-up procedure again from the beginning. You can follow
the actions of the fuzzy logic controllers in the Steam Generator Simulation
window:
• 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 that
visualize each component of the process. However, the internal particulars of the
fuzzy logic systems are not shown here. You need to start fuzzyTECH to
remotely access the running system as set forth in Configuring an Online
Connection. This remote access is described in the step Online Development with
fuzzyTECH”.

Operating the power plant at a stable operating point does not provide any
special difficulty for conventional control engineering. To keep the operating
point constant, individual PID type controllers are used to keep each process
variable constant. However, automatic control of the start-up procedure is not
that straight forward since the inter-dependencies between the process variables
becomes a very important factor that cannot be modeled using single loop PID
controllers. Thus, human operators control the start-up procedure manually by
following 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 in
the drum and thus imposes a severe disturbance to the process.
• When the circulation and the drum water level are stable, the fire can be
started in the furnace. Because this disturbance can cause the water level to
abruptly raise to a potentially dangerous point, the water level is temporarily
lowered prior to starting the fire.

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

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

StartPump, BoilerFill, StartFire, BuildPressure, and Operating. Notice that this is


an intermediate linguistic variable that does not have membership functions
associated with its terms. The variable Status is only used within the fuzzy logic
system as an input to the other two fuzzy rule blocks.

Based on the system state estimation of the first fuzzy rule block, the second
fuzzy rule block controls the two discrete output signals of the fuzzy logic
system, 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 the
measured water level and its time derivative, the third fuzzy rule block
determines the set values of both the feed and drain water valve. The total
number of rules in the third fuzzy rule block is 34.
Continuous Operation
of 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 in
the steam generator drum and pressure steadily increases. During this stable
operation after the pressure has been built up in the drum, the second fuzzy logic
controller PRESS.FTL implements a fuzzy-PI type control strategy to control
steam flow. The structure of a fuzzy-PI control element is commonly used in
industrial applications. It consists of a fuzzy logic system using the error
(delta_press) and its time derivative (dt_Pressure) as inputs and outputs an
increment/decrement command for the valve position. Notice that the actual
fuzzy logic control strategy implements a PD-type controller. The overall
behavior is PI-type however, because the output is used to increment or
decrement the command variable.

The structure of the fuzzy logic controller PRESS.FTL shows three more
interfaces in fuzzyTECH that are not connected to any other objects in
fuzzyTECH. Two of these interfaces (SteamFlow and Pressure) are only
visualized in fuzzyTECH, the third (SetPressure) allows the user/developer to
modify/force the set point of the steam pressure controller remotely from
fuzzyTECH. Display and Force type interfaces/variables in fuzzyTECH are useful
when developing a fuzzy logic system because these variables can be used in all
editors, analyzers and the trace functions of fuzzyTECH just like any other
linguistic variable.

After you have evaluated the two fuzzy logic controllers, you can start the Online
Development with fuzzyTECH to analyze and modify the fuzzy logic systems on
different platforms "on the fly".
Online Development
with fuzzyTECH An online development with fuzzyTECH requires the complete correspondence
of the fuzzy system loaded in fuzzyTECH’s Project Editor with the fuzzy system
running on the fuzzy runtime system. The Online Wizard has helped you to open
such a fuzzy system on the fuzzy runtime system (as described in the step
Configure the Online Connection) and to switch into Monitor debug mode.

38
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

To demonstrate the effect of modifications on the Steam Generator Drum


Simulation, try the following operations in Monitor&Modify debug mode (not
available 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 an
online connection between both applications, open the fuzzy controller
START, and activate the Monitor&Modify online debug mode.
• In fuzzyTECH, open the Spreadsheet Rule Editor of the Process Control rule
block. 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 while
for the water circulation to stop due to the inertia of the circulation pump).
• When the circulation pump stops, the water circulation is interrupted. This
leads to an overheating of the steam generator and a reduced fire supply. A
fire-shut down occurs immediately (alarm message), and the system slows
down 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-establish
operation.
• This restart of the circulation pump causes a complete emptying of the drum,
because the previous overheat condition almost completely drove the water
out of the heat exchanger’s tubes.
• After this has been done, the fuzzy logic controller re-establishes stable
operation.

Switching off the Monitor&Modify debug mode now calls automatically the
Online Wizard (Figure 23), since the fuzzy system was modified in the course of
online 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 system
that it had before it was subject to online debugging). Another possibility is, that
you synchronize manually your fuzzy system yourself. Since you haven’t change
the 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 this
option was chosen, the Online Wizard informs you on its next page about the
steps fuzzyTECH performs to follow this command.

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

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 with
the "original" system. This original system is stored as FTL file, its location is
displayed in the Online Wizard. At last, fuzzyTECH overwrites the fuzzy system
on the fuzzy runtime system with the original file. Click the [Next>] button to
see how fuzzyTECH executes all steps. Close the Online Wizard and open the
other controller PRESS.FTL by clicking the entry PRESS - xx:xx:xx/xx/xxxx
below Online Connections in the Treeview with the right mouse key and
choosing the option Open in the pop-up menu. Now you can analyze the the
PRESS controller in the same way as the START controller.

40
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 continous
repainting of the 3D plot and the arrows pointing to the variable values. Click
multifoldly the symbol to rotate the 3D plot till it appears similar to
picture below. Click the toolbar symbol to start tracing and restart the
Steam Generator Drum Simulation. After the START controller has finished
the start-up procedure of the steam generator, the PRESS controller takes
over the control of the steam flow. As soon as the controller is active, the
values for delta_Press and dt_Pressure are traced cyclically in the 3D Plot as
green transfer curve.
• The Watch:Monitor&Modify debug mode window in fuzzyTECH lists the
SetPressure variable (type: Force) and its current value. Select the Force
variable SetPressure and set its value to "50" in the "Value:" field of the
watch window’s toolbar. As you can see in the window of the Steam
Generator Drum Simulation, this modification has a great effect on the
pressure.

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

41
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

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

The second section deepens your already gained knowledge of fuzzy logic and
fuzzyTECH to a degree that enables you to create fuzzy systems by yourself. The
system 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 to


improve 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 for
documentation and revision control. The Project Information Dialog lets you
enter project information, such as the author of the project, date of last project
change, comments, etc. A documentation of the project loaded in fuzzyTECH is
generated automatically as RTF file within a few minutes by using fuzzyTECH’s
Documentation Generator. fuzzyTECH’s Revision Control System allows you to
load, save and delete project files related to its revision state. The revision
control saves all important development steps as a complete revision history to
rewind to earlier development stages. Using fuzzyTECH’s Revision Control
System for system design documentation is thus a prerequisite for ISO-9000
compliant system development.

42
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Customizing the
fuzzyTECH Shell The fuzzyTECH shell can be customized in many ways. Open the fuzzyTECH
Preferences dialog (Figure 26) from the main menu “Tools/fuzzyTECH
Preferences”. This dialog consists of the tabbed dialogs General, Save, Text
Editors, Watch Window, Matrix Rule Editor and Serial Interface. The settings
made in these dialogs are valid for all fuzzy systems you create or load in
fuzzyTECH, i.e. they are not system-specific.

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

fuzzyTECH
Preferences: General
General Settings
Recent Used File List:
By activating this option, the number entered here is the number of the most
recently used files that are shown at the end of the “Files” entry of the main
menu.

Quick Help Window Active:


By activating this option, the Quick Help Window will be displayed after
fuzzyTECH has been started.

Enable Confirm Dialogs:


When enabled, this option ensures that a confirmation dialog is shown for any
action that changes a fuzzy logic system. Experienced designers should disable
this option to accelerate the design process.

43
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Open Matrix Rule Editor by Double-clicking Rule Block


Double-clicking a rule block opens the Matrix Rule Editor instead of the
Spreadsheet Rule Editor (default setting).
File Format
Commented File Format:
fuzzyTECH supports two different file formats. Here you can choose between a
file format with or without comments.
fuzzyTECH
Preferences: Save
Save Options
Automatic Project Backup:
fuzzyTECH saves the current system in a separate ...\BACKUP directory at
regular intervals as specified by the time period. Back-up files of fuzzy systems
are 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 Preferences
dialog 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 you
save the *.FTL file. The functions “Open...” and “Save As...” in the main menu
File also let you save and open *.CFG files under a different project name. This
allows you to have multiple configurations for the same project.

Prompt for Project Information:


The dialog Project Information is automatically displayed to enter general
information about the current project after the instruction had been given to save
it.
fuzzyTECH
Preferences: 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.
fuzzyTECH
Preferences: Watch Window
Watch Window
Open Iconized:
The Watch: Debug <Mode> Window is active in any debug mode. It always
displays the crisp values of all input and output variables of the system. Enabling
this option always minimizes the Watch Window any time you start the debug
mode. If you have low video resolution, you can use this option to save screen
space and computing time.

44
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Use Colors
Enable or disable this option to show input, output and intermediate variables in
the Watch Window colored or uncolored.

Show Intermediate Variables


All intermediate variables are listed in the Watch Window.

Edit DDE Input Variables


Choosing this option, a DDE linked input variable can be edited additionally in
the Watch Window.

Digits No. of Digits after Decimal:


For some values, such as in the Watch Window or in the display of definition
points in the Variable Editor, the number of decimal places can be determined in
the edit field of this option.
fuzzyTECH
Preferences: Matrix Rule Editor
Matrix RuleEditor
Advanced Display in Matrix Items
Additional information can be displayed in the matrix items. If this check box is
enabled, 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 Items


The size of the matrix items corresponds to the window size of the Matrix Rule
Editor. However, the size of the items cannot be smaller then the mimimum size
of matrix items (in pixel ) entered in this edit field.

Maximum Size of Matrix Items


The size of the matrix items corresponds to the window size of the Matrix Rule
Editor. However, the matrix items can be streched only up to the maximum size
of 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 Matrix
Rule Editor shows its matrix items at opening according to the preferred display
option. Once the Matrix Editor is open, it can be switched between different
display options using the symbols of its toolbar. The following display options
are available:

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

45
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

(DoS=0). Brighter gray tones indicate a DoS value within the interval [0,1]. If no
rule at all is defined for a matrix item, it appears with a black background. In
debug mode, the toolbar symbols [Input Aggregation] or [Composition with
Degree 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 the
rule.

Term Colors
The output term of the strongest rule is displayed for each matrix item. The
color of a matrix item corresponds to the color assigned to the output term in the
Variable Editor.

False Colors
The output term of the strongest rule is displayed for each matrix item in false
colors. The false colors scale goes from bright green to dark green for positive
terms and from bright red to dark red for negative terms. The color tone relates to
the position of the term in the term list of the Variable Editor. The first
positive/negative term of this list is bright green/red, the last term is dark
green/red.
fuzzyTECH
Preferences: Serial Interface
The serial interface of the Online/RTRCD or Serial Link connection is
configured in this dialog. Click the [Help] button in this dialog to open the
fuzzyTECH Help to read a description of the dialog’s options.
Customization of the
Viewing 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 to
view 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 to
Configure 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 to


provide quick access. Toolbars can be defined for the fuzzyTECH windows listed
in the pop-up menu that opens if you choose the option Toolbars in the View
main menu. Here you can decide whether you want to see or hide the toolbar.

46
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Statusbar: Enabling or disabling this option lets you see (or hide) the statusbar. A check
mark beside the command indicates that the statusbar is visible. The Statusbar is
the gray area at the bottom of the main window of fuzzyTECH that displays
information about the currently selected command, the current system state or
about an operation in progress.
Zoom Project
Editor 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 switched
on and off. The resolution of the gridlines is determined automatically.
Term List
Box: Term List Boxes in the Variable Editor can be made visible or invisible by
choosing the Show All or the Show None option.
Plot
Background: 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 thickness
in the windows of the Variable Editor and the Time Plot.
Object
Comments: 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 overview
of the following contents:

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

47
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

System Definition Section 3.1.2 presents the basic steps involved in the definition of an initial fuzzy
logic system prototype using fuzzyTECH: set up of the system’s structure,
definition of the linguistic variables, membership functions, rule blocks, text, and
the formulation of the fuzzy logic rule base.
Off-line
Optimization 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 used
to verify system behavior in abnormal situations. Depending on the type of
application, either pre-recorded process data or pattern-generator created data
sets may be used for optimization. Within off-line optimization, fuzzyTECH
offers a number of analyzers for system verification. Also, a mathematical
simulation of the process or window’s application software can be linked to
fuzzyTECH.
Online
Optimization 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) is
connected to the development PC via a link (e.g., a serial cable). This allows the
visualization of the entire inference flow, like in the Interactive mode, except that
it 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. In
most closed-loop applications, online optimization features speed up the
development cycle by magnitudes.

fuzzyTECH analyzers are described in Section 3.1.3.5. Refer to Section 3.1.3.6


for more details on online optimization. After the system has been optimized and
verified, it can be implemented on various hardware platforms. An overview of
fuzzyTECH-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 the


Fuzzy Design Wizard

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

48
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 default
parameters for many design decisions from the data. With these features, the
FDW is well suited to create the “empty” fuzzy logic system that NeuroFuzzy
training requires.(refer to Section 4.1.1).

Dialog Sequence The FDW activates a sequence of dialogs that guide you through the creation of
a complete fuzzy logic prototype. The FDW can also be used to create a new
component for an existing fuzzy project. Each window contains a few of the
several required design steps. For each step, reasonable defaults are displayed
when entering the dialog. The defaults can be accepted or changed. Note that you
can overwrite later all of the default parameters if desired. The sequence of
dialogs 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 by
clicking the respective button in the main toolbar. Follow the instructions given on the
following pages.

Control Buttons The [Help], [Cancel], [Previous], [Next] and [End] buttons are located at the
bottom of each FDW window. The [Next] button always takes you to the next
window. The [Previous] button always brings you back to the previous window.
By stepping back and forth in the FDW windows, you can reverse any design
decision you make. The [End] button forces the FDW to generate the fuzzy logic
system with the current specifications. Since the FDW proposes default values
for 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 is
generated.

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 interval
and the distribution of the values, to propose default variables in later FDW
windows.

49
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 of
them. The number of terms can be changed for each variable in the following
FDW dialogs.

50
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

➔ Accept the suggested default settings and click the [Next>] button to open the next FDW
dialog (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 is
default setting) of the system. Define the first input variable: give it a name or
leave 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 for
defining the next variable opens. This is continued as long as there are input, intermediate and
output variables of the system to be defined. After all variable have been defined, the next
FDW dialog Define Defuzzification opens. This dialog helps to define 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 (Figure 31). To keep the system
structure as simple as possible, just define only one rule block. Enabling the
check box, “Create Rule Base”, lets the FDW generate a complete rule set for
each 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 true rules, this is equivalent to a set of completely
false rules. Hence, the generated rule set contains no information. The reason for
creating a complete, but totally false rule set is that the NeuroFuzzy training can
only start with an existing rule set.

51
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Figure 31: The Last FDW Window Specifies Whether and


How 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, This
Confirmation 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 the
following sections.

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

52
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

3.1.2. System Definition

System definition is a fundamental step for setting up a fuzzy logic system with
fuzzyTECH. After a system prototype has been generated using the Fuzzy Design
Wizard, it is edited and adopted to the system. This section describes the objects
of 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 includes
the input and output variables with their linguistic terms. In addition to the
linguistic variables, a preliminary rule set must also be created for a first system
prototype. For complex systems, a structure of rule blocks, linguistic variables,
and text blocks (as optional objects) can be designed. System structure is
displayed graphically in the Treeview and Project Editor window. In the Project
Editor, information flow between rule blocks and linguistic variables is indicated
by 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 the
window:
• Text: Text is an (optional) object used to make a fuzzy logic system structure
more transparent and describe the system structure. Text objects have no
computational influence and can be inserted at any place in the worksheet in
different colors and font sizes.
• Variables: Each input or output variable of the system is linked with an
interface. Interfaces are displayed as small boxes showing the variable’s
name and an icon representing the chosen computation method. Input
interfaces 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 Variables
are not linked with an interface and occur thus only in the rule block they
belong to.
• Rule Blocks: In fuzzyTECH, individual rules are confined into rule blocks to
build the system structure: Each rule block contains the rules for a set of
variables. 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 the
fuzzyTECH 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 you
switch 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

53
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

group and the [Return] / [Enter] key to activate an object. An object can also be
activated with the [Space] bar. Switch from any window to the Treeview by the
shortcut [Alt] + [0] (zero). Select an object in the Treeview and press the
function key [F2] to rename it. Some objects, such as definition points in the
Linguistic Variable Editor or the objects in the Project Editor, may be moved
within the window. In order to arrange these objects with the keyboard, first
select or activate the object to be moved using the [Tab] key, and move it with
the 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 using
the left mouse button. Holding the [Shift] key before dragging the object
provides positioning assistance: the direction in which the object was first
dragged is fixed. Different cursor shapes indicate the movement mode. Clicking
on any object with the left mouse button highlights the respective object.
Double-clicking an object opens the editor for this object. Double-clicking left a
rule block activates the Spreadsheet Rule Editor for this rule block
Pop-up Menu of the
Project 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 fuzzyTECH
windows 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 the
properties of the highlighted object or create new objects. Note that in the Project
Editor or Treeview, different pop-up menus open according to the highlighted
object. The following shortcuts (see Figure 34) call fuzzyTECH’s different
wizards 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 by
using Wizards, you can edit or change the properties of the generated objects by
so-called “Properties” dialogs. Open such a Properties dialog by highlighting the
respective object in the Project Editor or Treeview, clicking right to choose the
option “Properties” in the pop-up menu.

54
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Editors Besides Properties dialogs that function as editors, there are some fuzzyTECH
windows that function as editor, too. Use the Matrix Rule Editor or Spreadsheet
Rule Editor to edit rule blocks or the Variable Editor for linguistic variables. All
are 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 Spreadsheet
Rule 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 it
right and choosing the option Delete. Then a dialog appears, asking you to
confirm your intention in order to avoid objects to be deleted unintentionally.

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

3.1.2.3. Definition of Text Objects

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

Figure 35: Text Properties Dialog

55
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 window
with 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 by
clicking the [Font] button in the Text Properties dialog. Confirm the settings and leave this
dialog by clicking the [OK] button. Create then other text as comment for each object in your
system.

After closing this dialog by clicking the [OK] button, the new text has to be
positioned in the Project Editor Window by clicking there on the appropriated
place. Text objects can be copied into the Project Editor and Treeview by
selecting it in one of both windows, opening its pop-up menu and choosing the
option 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 a
patient’s temperature. You assign his temperature to such categories like: “very
high temperature ” (fever), “high temperature”, normal temperature”, or “low
temperature”. 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.

56
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

➔ 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 with
the right mouse key and choose the option New Variable.
Linguistic Variables
Wizard This function opens the first dialog of the Linguistic Variables Wizard
(Figure 37), which can also be opened by clicking the [Variables] symbol in
fuzzyTECH’s main toolbar. Define name, type, and computational method for the
variable in this first dialog “Define Linguistic Variable”. fuzzyTECH uses a pre-
defined variable definition to prototype the variable. At this place it may be
mentioned 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 this
field. Depending on the chosen variable type, different computation methods are
listed in the field Method. Each input and output variable is automatically
generated with an input or output interface (indicated as small frame or box).
Each interface can only contain one linguistic variable. For details on fuzzy input
variables and fuzzy output variables, refer to Chapter 5.

An intermediate variable passes information from one rule block to another in


fuzzified form (e.g. as vector of the firing degrees of an intermediate variable's
single terms). Therefore, intermediate variables can only be linked with a rule
block, but not with an interface. Intermediate variables are never subject to
fuzzification or defuzzification. That's why the intermediate variable's values are
"only" linguistic (fuzzy) values and membership functions of variable terms do
not play any role for it.

57
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

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

Figure 38: Different Fuzzification Methods

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

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

Figure 39: Different Defuzzification Methods

58
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

The Center-of-Area method is sometimes called Center-of-Gravity (CoG). The


last interface box shows the hyperdefuzzification method Hyper CoM.
Defuzzification can also be omitted to allow a “fuzzy” output or to use
customized defuzzification methods.

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

An interface type similar to the input interfaces is


selected by the “Display” radio button. Like input
interfaces, the Display interface reads and displays the
assigned process variable value.

The Force interface is handled similar to output


interfaces. Instead of values calculated by the fuzzy
computation, the values to be forced can be entered in
the 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 specify
range, default value, and name of the base variable. The fields “Minimum” and
“Maximum” let you specify the universe of the base variable. Two
representations exist in fuzzyTECH: Shell Values and Code Values. The base
variable’s unit, entered in the field Unit, serves only the purposes of displaying
the unit of the base variable in the variable editor.

Figure 40: Linguistic Variables Wizard: Base Variable Range

59
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 Shell
representation and the Code representation. The Shell representation is used for
all editors and debugging tools during development, while the Code
representation is used in the generated code (assembler, C, ...). In all fuzzyTECH
Editions that support floating point resolution for fuzzy logic inference, the Shell
representation 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, in
hardware implementation, the angle of the load is measured by an incremental
sensor with an output in the interval from 240 to 1400. The necessary conversion
can be automatically made through fuzzyTECH by entering the range [-90°,
+90°] for Shell values and the range [240, 1400] for Code values. The Shell
values are used for all editors and analyzers within fuzzyTECH, as well as for the
debug modes File Recorder and Batch. The Code values are only used to
generate the C or assembler code. If you want the Shell and the Code
representation to be equal, just enter the same range. Use the respective buttons
to 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 type
selected in “Tools/Project Options/Global Options”:

Data Type Minimum Maximum


8 Bit Integer 0 255
16 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 Project
Options/Global dialog to activate this dialog, the same values are used in the
generated code. However, the use of double resolution float variables is of
prohibitive computational effort for most microcontrollers and other real-time
process controllers. Also, many compilers used with these target hardware
platforms cannot provide libraries for this computation. Hence, the column
“Code Values” lets you specify integer values for the minimum and the
maximum of the variable in the generated code. The possible range for these
integer values depends on the base variable data type. Assuming you want to
implement the crane controller on a 16-bit microcontroller. Your distance sensor
delivers 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 converts
these 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 of
fuzzyTECH can tie in the range conversion with the fuzzification code. This
saves both on conversion code, as well as computing steps, and makes the code
produced more efficient. If you do not need this automatic range conversion,

60
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

click the [Minimum] and [Maximum] buttons to achieve maximum integer


resolution. 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 the
fuzzy logic system. The field “Base Variable Unit” lets you specify a unit string
for 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, the
default 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 “MBF
Definition” of the Linguistic Variables Wizard (Figure 41).

MBF Definition The degree, to which a crisp value belongs to a fuzzy set, is determined by a
function, the so-called membership function (MBF). Membership functions are
explained 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 visually
define the membership functions of the linguistic variable from a holistic view,
and choose term names from several default name sets. According to the selected
number of terms, different name sets are provided in the drop-down list. Use the
high shoulder option to generate standard variables that are used in input
interfaces, and use the low shoulder option for variables used in output
interfaces. A symmetrical or non-symmetrical approach can be appropriately
selected according to the respective application.

61
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

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

Figure 42: Comment the New Linguistic Variable

➔ Enter a comment for this variable. Click then [End] or [Next>] and in the following
confirmation 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 the
Variable Editor, click right to open its pop-up menu.

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

62
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

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

Sort Terms Terms are listed in the Variable Editor window’s list box according to their
position. They can be sorted by clicking the toolbar button [Sort Terms] . First
of all, positive terms are listed, then negative terms. Within the list of the
positive and negative terms of a variable, terms are sorted according to the
maximum of their membership function. In order to help you visually
differentiate 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: Base
Variable 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 is
the 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 Wizard
dialog “Base Variable Range”.(see page 60), except the lower part Grid
Resolution. That’s why the same dialog is opened if the Variable Editor’s toolbar
symbol [Grid] is clicked. The function of the Grid symbol and all the other
symbols of the Variable Editor’s toolbar is explained in Section 3.1.2.5.

63
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 linguistic
values (terms), ranges of value, and membership functions. The degree of
membership, 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. A
membership degree of 0.0 means no membership at all, a degree of 1.0 - absolute
membership.

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

64
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

In some applications, the value that characterizes a term best is not a specific
number, but an interval. For example, any distance within ±2 yards from the
target 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. To
create a new term, choose the option New Term from the Variable Editor’s pop-up menu or
click its [New Term] toolbar button .

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

65
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

Figure 47: The Term Properties Dialog Lets You Specify a


Characteristic Features of a Term.

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

MCU Editions support only L-Shaped (Linear Shape) membership functions of


Standard MBF type. For standard MBFs, straight lines are used to connect the
definition points of a term (i.e. its maximum and minimum). See Figure 45 for
the definition of the term zero.

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

Point Definition of
Membership 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 can
have a degree of membership of either 0 or 1 (refer to Section 5.1 for details on
Standard MBF’s). A term’s definition points are drawn as small rectangles: a
highlighted rectangle ( ) indicates a selected point, and an empty rectangle
( ) shows a deselected point. A highlighted point’s coordinates are shown in
the lower left part of the Variable Editor. Point coordinates can also be directly

66
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

entered by entering the value followed by pressing the [↵] key. For a variable
with multiple terms, the membership functions of all terms are displayed. In
order to select a term in the Variable Editor, click on the term name in the listbox
or above the plot area.

The definition points of membership functions can be freely positioned and


dragged. The definition points of the membership function of the selected term
appear as small squares in the plot area. You may highlight individual definition
points with mouse click and then drag them. A highlighted definition point is
indicated 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 point
for the selected term. In order to delete a definition point, select it by
highlighting the point with a mouse click and then press the [Del] key. The
confirmation dialogs that pops up any time you clear a system component can be
avoided by disabling the “Enable Confirm Dialogs” option in Tools/fuzzyTECH
Preferences/General.
Operate on
Multiple 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 the
most left point and depress the [Ctrl] key. While pressing the key, fuzzyTECH
lets you select additional points. As long as you hold the key, you can move the
complete set of selected points. Using the [Shift] key selects a complete range of
points. With this feature, sections of the MBF defined by multiple definition
points can be dragged. Note that the left and right most points can only be moved
vertically. If the most left or right point is contained in a highlighted set of
points, the whole set can only be moved only vertically. This ensures the
definition 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 Term
Properties 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 choosing
the 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_fever
to 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 a
membership degree of 1 in the fuzzy set describing the term.
2.) Once the values having a membership degree of 1 have been defined, the
corresponding 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.

67
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

The grid resolutions for the base variable (horizontal axis variable) and
membership degree (vertical axis) can be chosen independently. Enter the value
“0.1” for “Membership”. This allows the membership degree of definition points
to be set at values of 0, 0.1, 0.2, etc.. Enable the check box “Snap to Grid” and
close the dialog box by clicking [OK]. If you now drag definition points, only
grid positions are considered. The fields “x” and “y” show the coordinates of the
nearest grid position to the current mouse cursor position while no definition
point is highlighted. If one definition point is highlighted, the “x” and “y” fields
show its position. You can now also enter new coordinates for this point in the
fields. If more than one definition point is highlighted, the fields show the
coordinates 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 point
and the [Return] key to place it.

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

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

Converting to
Standard 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, if
the vertikal grid is set to 1 (for the membership) and the option “Snap to Grid” is
aktivated. For Standard MBFs, two membership functions are converted into one
with a fixed overlap (for every given value of the base variable, exactly two
membership 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

68
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

The toolbar button [Convert to Standard MBFs] in the Variable Editor


converts the term definitions to Standard MBFs, i.e. all other points are set
automatically. You may use the converter function at any time during system
design.

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 of


the 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 define
rules with negated linguistic statements (like IF “Distance” = not far). See also
Section 3.1.2.7.

Inverse terms are created by clicking the Variable Editor’s toolbar symbol [New
Inverse Term...] or this option from the Variable Editor’s pop-up menu. This
generates a new term (µ') with the inverse properties of the original term’s
membership function (µ), i.e. the term that was selected in the Variable Editor’s
term 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 is
not computed during runtime to allow a higher degree of flexibility during
optimization. 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.

69
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

• They are virtual, i.e. their membership functions are not displayed
graphically.
• Due to their virtuality, they cannot be edited directly. If the term, from which
an inverse term was generated is edited, then all changes made with this
‘original’ term are transferred synchronously to its inverse term. Inverse
terms can, however, be deleted separately.

➔ Create an inverse term. Choose a term in the Variable Editor’s term list, from which you want
to generate an inverse term. Then click the toolbar symbol [New Inverse Term] . Inverse
terms are always listed at the end of the term list, after the “non-inverted” terms. The properties
of an inverse term can only be changed by changing the properties of the term, from which it
was generated (original term). Open the dialog Term Properties by double-clicking its original
term 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 the
inverse 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 and
pressing the [Del] key. In the Treeview, you wont be successful as long as the Variable Editor
of this variable is open.

3.1.2.6. Defining Rule Blocks

In fuzzyTECH individual rules are confined into rule blocks to build the system
structure. A rule block holds the inference with the production rules and connects
system outputs to system inputs. The number of rule blocks that can be defined
in 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 two
variable columns and two operator boxes. The left column shows the variables
used in the precondition of fuzzy rules. The right column shows the variables
used for the conclusion of fuzzy rules. The upper box displays the Condition
Aggregation 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 Rule
Block...] in the Project Editor's pop-up menu.

70
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Rule Block Wizard This invokes the Rule Block Wizard (Figure 50) which gives comprehensive
help at designing a new rule block. The Rule Block Wizard can also be called by
clicking 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, variables
can be assigned to the rule block as inputs or outputs and a name can be entered
for 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 or
Output list using the [>Input>] or [>Output>] key. After input and output variables have been
selected, 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 are
used for the fuzzy inference of this rule block which involves three
computational steps: aggregation (or input aggregation), composition, and result
aggregation. As for input and result aggregation, different fuzzy operators can be
chosen. The default operator is Min for aggregation, and Max for result
aggregation. The default operator for composition, the second step of the fuzzy
inference, is the PROD operator.

Aggregation The aggregation operator is used to combine the different preconditions of a


condition (figure 12). Some fuzzyTECH Editions (refer to Section 9.4) support
three operator families, all of which have been successfully applied in fuzzy
logic applications:

71
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Min-Max
Min-Avg
GAMMA

The mathematical properties of these operator families are explained in Section


5.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 or
the 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 entire
precondition (left hand side) of a rule is fulfilled with the Degree of Support. The
fuzzy operator for composition is the PROD operator. You cannot choose
another operator for composition; fuzzyTECH uses the PROD operator as a
default and does not support other operators for the composition.

72
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Result Aggregation The result aggregation operator combines the results of rules, i.e. their
conclusions (THEN-parts), to show the degree to which identical terms of a
linguistic variable are valid. fuzzyTECH supports two methods for result
aggregation: the Max (Maximum) and BSUM (Bounded Sum) method. The Max
method selects the rule with the maximum firing degree of all rules matching to
the term. The Bsum uses a bounded sum. Thus, all firing degrees are summed by
using a bound of one. Note that BSUM result aggregation is different from
BSUM MoM and BSUM CoA. The bounds are zero and one. The result
aggregation 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’s
next 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 this


dialog. Deactivate the check box “<INPUTVARIABLE> has an influence on
<OUTPUTVARIABLE>” in the middle of this dialog, if an input variable shall
not influence the output variable. This input variable is then contained in the rule
block. It has, however, no influence on the inference. This dialog opens for each
variable assigned to the rule block.

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

73
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

A comment for the rule block can be entered into the Rule Block Wizard’s
comment dialog. This comment is shown as tool tip comment, as well as at the
generation 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 block
that 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

74
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Rule Block Properties Once a rule block has been generated, its properties can be changed using the
Rule Block Properties dialog (Figure 54). To open it, select a rule block either in
the Treeview or in the Project Editor and choose [Properties...] in the pop-up
menu 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 of
only 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 inference
process, all system output variables are associated with a fuzzy value. In the
following, the Crane Simulation sample of Chapter 1 is used to demonstrate the
following degrees of support (DoS) assigned to the linguistic variable Power:

Example
The linguistic result for “Power”:
neg_high degree of support = 0.00
neg_medium degree of support = 0.00
zero degree of support = 0.00
pos_medium degree of support = 1.00
pos_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 represent
unambiguous controller strategies at specific operating points. From there,
construct your rule set by working backwards step-by-step until the most detailed
rule is defined.

Example
The operation point:
“If the crane has reached the target point and the load is not oscillating, no
power 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 crane
behavior can easily be defined. For example, if the load is oscillating slightly at
the target point, the following rule could be defined:

75
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

Rule Editors fuzzyTECH supports different rule editors: the Spreadsheet Rule Editor and the
Matrix Rule Editor, as well as textual input in FTL syntax from any ASCII editor
such 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 rule
block 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 in
the Project Editor or Treeview, clicking right to activate its pop-up menu, and
choosing the option Spreadsheet Rule Editor.
Spreadsheet Rule
Editor 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 in
the 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 is
assigned to each input variable, showing its terms. A DoS column is assigned to
each output variable, containing the degree, to which a rule is supported (Degree
of 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 in
the Spreadsheet Editor represents one (or more) fuzzy logic rule(s), with its
inputs (conditions) on the left side and its outputs (consequences) on the right

76
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

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

Each cell of the DoS column (Degree of Support) indicates an individual rule
weight. The cells of variable columns contain only the terms used for the rule. If
a term of an output variable is negative (Hyper CoM defuzzification method), its
name appears in red letters. In the spreadsheet, negative terms are listed after
positive terms.
Complete and
Incomplete 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 as
incomplete (invalid), if either the IF, DoS, or THEN part is lacking. Incomplete
rules are deleted automatically when closing the rule editores. In fuzzyTECH, a
fuzzy 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 one
condition of them has no influence on the consequence (= output variable of the
THEN part), then it is possible to ignore this condition (input variable) for the
respective rule. This is then a so-called “don’t care rule” and means that the
result of the THEN part does not depend from all its conditions in its IF part. A
sensible usage of don’t care rules can help to reduce the amount of rules to a
considerable 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 to
a non-existent rule. For some design steps, the definition of a rule with a DoS of
0 can be useful. For example, an advantage of rules with a DoS of 0 is, that they
are already part of the total amount of rules, but have no influence on the fuzzy
system. They are regarded as complete and will not be cleared when closing the
rule editor. Thus an active rule can temporarily be deactivated by setting its DoS
value to zero and may later be re-used. FAM rules are explained in detail later
for 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 be
changed. This activates pop up menus listing the possible values (term names)
for the current variable.

77
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Create and
Delete 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 to
Table 1 of Section 9.4), a new empty row will automatically be created for each
new entered rule. To insert a new empty row between the other rows, click right
a row number (first gray column) to select a row, and choose Insert Row from
the pop-up to insert the new row above the selected row. Another possibility to
create rules is to use the Rule Block Wizard (Section 3.1.2.6).

Delete rules by making them incomplete: either delete their inputs or their
outputs 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 of
0.0 are regarded as non-active, complete rules and are not automatically erased
when the rule editor is closed. Another, easier way for deleting is to highlight a
rule by clicking its row number, and pressing the [Del] key. Or click right the
row 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 the
Spreadsheet 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 Block
Wizard generates then all rules automatically with a DoS of 1.0. Now change some rules and
their degrees of support.

Sort Rules The Spreadsheet Rule Editor features various sort options to organize large rule
bases. 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 the
variable Distance according to the maximum of its MBFs (terms). Open the
Variable Editor of Distance to compare the sequence of terms.
Rule Block
Utilities 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 mouse
key a gray field below the toolbar to open the Spreadsheet Rule Editor’s pop-up
menu. Choose the Rule Block Utilities option to open a dialog with the following
functions:
• “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 rule
block 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”.

78
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

• “Create Partial Rule Block” only creates a rule for each combination of input
variable terms. You have to specify the output variable terms for each rule
manually. The rules for which you do not specify an output term are
incomplete and are erased when you close the Spreadsheet Rule Editor. The
weights 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, and
result aggregation. For input aggregation and result aggregation, different fuzzy
operators can be chosen. For composition, the fuzzy operator is the PROD
operator. It is fixed and cannot be changed. Fuzzy operators can be chosen and
parameterized 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 trace
rules. The degree to which any of the rules fire is displayed graphically to allow
visualization of the information flow in the system. In any debug mode, the
Spreadsheet Rule Editor displays two small boxes for every rule and output
variable located left and right of the Degree of Support value. The height of the
black bar in the boxes indicates the aggregation (left bar) and composition (right
bar) results.

79
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

➔ After you have changed its rules and generated new ones, delete the duplicated rule block to
obtain the previous (original) structure of the Container Crane project (CRANE.FTL). Switch
to the Matrix Rule Editor by clicking the Spreadsheet Rule Editor’s toolbar symbol [Matrix
Editor]. This editor can also be called by selecting a rule block in the Project Editor, opening
its pop-up menu, and choosing the Matrix Rule Editor option. Or simply by double-clicking a
rule 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 extended
functions. When designing complex rule bases, the Matrix Rule Editor allows a
better survey of the rule block and helps to find rule inconsistency and rule gaps
due to its graphical display of matrix items. The Matrix Rule Editor window
consists of a toolbar, an IF field and a THEN field, and one or more rule
matrices. The number of rule matrices depends from the number of the rule
block’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 at
the 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 list
box of an input variable is of grayish color, it indicates that the term of this
variable is displayed in the rule matrix. The empty entry in input variables’term
list boxes is used to define “don't care” rules.

80
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 this
term.

Rule Matrix Two input variables or an input variable and an output variable can be displayed
in the rule matrix. In both cases, the Matrix Rule Editor is displayed in a
different way. The buttons appear in a gray color, if variables are already
displayed in the rule matrix or if the selected combination is not allowed. Next to
the variable's name are two buttons for selecting variables for display in the rule
matrix. The left button assigns the terms of the selected variable to the rows of
the rule matrix. The right button assigns the terms of the selected variable to the
rule matrix columns. The axes of a matrix can be swapped by clicking the
toolbar symbol [Swap Row and Columns]. One or more rule matrixes are
displayed at the editor's right side. Each rule matrix contains a matrix item (cell
or field) for all combinations of the selected variable's terms. Each matrix item
maps one or more fuzzy rule. Black items indicate non-defined rules, all other
items - defined rules. Each item comprises rules with the same IF part. This
means, that each matrix item displays the output term of the strongest rule. If
more than one rule were defined for a matrix item, the matrix item displays the
strongest rule as well. Additionally, in the viewing option [Display Degree of
Support] (default setting), one or more *** signs indicate that this items
contains more than one rule. If a matrix cell contains a defined rule, it is
displayed 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 for
this cell the names of terms, standing on the horizontal and vertical axis of the matrix. Compare
them with the names of terms in the IF and THEN field. Then click further matrix cells, read
the terms’ names for each highlighted cell and watch the changing display in the term lists of
the IF and THEN field. You see that the term lists of the IF and THEN field display always the
rule selected in the matrix (red-bordered matrix cell). Now hold the [Ctrl] key down while
selecting more matrix cells. ). Now hold the [Shift] key down, while clicking the upper left
matrix cell and then the lowest right matrix cell. All matrix cell lying between the cells that
were clicked on are selected. These two kinds of multiple selection can be useful for rule
editing.

FAM Rules If a unique consequence for a given combination of input variables cannot be
found, 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” = zero
THEN “Power” = mostly zero but somewhat pos_medium

81
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

One approach is to define a new term as “mostly zero but somewhat


pos_medium.” This approach, however, would result in an excessive amount of
terms and membership functions. Moreover, system structure would become
unnecessarily complex and difficult to survey. Using FAM, this ambiguity can
be expressed in rules. Figure 58 displays a possible representation of the rule of
the Example above. Within the matrix, a white field represents a completely
plausible rule (100% true) and a black field represents a totally implausible rule
(100% false). Gray shades indicate partial plausibility. The degree to which a
rule 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 each
rule extends the concept of “on/off” rules to a representation in which rules
themselves are “fuzzy.” This allows for the rule base to be fine-tuned during
optimization. Since the mapping of the input of the rules to the output is now
itself fuzzy, this concept is often referred to as a “Fuzzy Associative Map“
(FAM).

Figure 58: Taking ambiguities into consideration by using FAMs: One rule is
fully 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 fuzzy
rule and its weight (DoS).

Create Rules Double-clicking a black matrix cell (i.e. a cell that contains no fuzzy rule) creates
a new rule with a DoS of 1.0. The term displayed in the term list box of the
corresponding output variable is chosen to be the output term (and thus rule
consequence). Alternatively to this method, a new rule can also be generated by
right-clicking its corresponding matrix cell to open a pop-up menu. Choosing a
term from it inserts a new rule with a DoS value of 1.0. To add further rules to a
matrix 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, the
THEN part of an existing rule shall be changed, choosing a new output term
generates automatically a new rule in addition to the previous one. To change the

82
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 which
a 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 matrix
cell contains more than one rule, this deletes only the strongest rule (i.e. the rule
with the highest DoS). Then again the rule with highest degree of support is
displays 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 a
rule with the right mouse key and choose the option Delete All from the pop-up
menu to clear all rules. Or choose the output term of a rule and click Delete in
the next side pop-up menu, if only one rule (i.e. the rule with the specified output
term) 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, the
matrix 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 three
rules, 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 viewing
mode [Display Term Colors] , open the Variable Editor for “Power”, and compare the term
colors. In the Matrix Rule Editor, click the (down) arrow of the term list box in the THEN
field, and select each output term. Rules containing the selected output term appear in the
matrix as highlighted, red-bordered matrix cells. The rule containing the output term neg_high
cannot be displayed in the respective matrix cell due to stronger rules, but can be found this
way.

Viewing Modes and


Display 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 the
abbreviated name of its output term in a matrix cell. Rules can also be displayed
with the term colors of their output terms and false colors. Refer to the
fuzzyTECH Online Help for an explanation of the Matrix Rule Editor’s toolbar
buttons.
If fuzzyTECH runs in a debug mode, different display options can be chosen for
the Gray Scale Mode in the Matrix Rule Editor. They refer to the computation of
fuzzy rules (fuzzy inference). The inference process of each rule consists of two
phases: aggregation and composition. Aggregation refers to evaluating the
conditons of each rule (its inputs), while composition refers to the evaluation of
the rule consequences (its outputs). The following options can be displayed in
the matrix cells:

83
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

• Input Aggregation, i.e. the degree to which a rule’s (input) conditions are
fulfilled, 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 fires
is fulfilled.

If the option Advanced Display of Matrix Items is enabled in


Tools/Preferences/Matrix Rule Editor, additional information are displayed in
the matrix items, e.g. a small number in the upper left corner of a matrix item
indicating the total number of rules defined for this item, including don’t care
rules, too.

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

Don’t Care Rules in the


Matrix 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, edited
and deleted in a rule matrix as well. The influence of don’t care rules interferes
with rules that are nearly identically formulated. They differ from each other in
so 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 completely
defined rules.

In the Matrix Rule Editor, those rules interfered by a “don’t care rule” are
indicated by a bar that stretches over the affected matrix items. If “gray scale” is
chosen as viewing option (default setting), then the name of the chosen term of
the output variable is displayed within the bar. The entire matrix is marked, if
both 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.9
IF “Angle” = zero THEN “Power” = pos_medium WITH 0.5
For the first rule, the input variable Angle has no influence on the output variable Power. For
the second rule, the input variable Distance has no influence on Power. Don’t care rules can
overlap FAM rules. Overlapped rules are indicated by the Advanced Display of Matrix Items
as well as bars, overlying the respective matrix rows or columns (Figure 59).

84
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

The Matrix Rule Editor allows to define swap definitions or overlapping


definitions, having both don’t care rules and completely defined rules for the
same range. Don’t care rules are then displayed in the background, but appear in
the foreground as soon as the matrix item assigned to the don’t care rule is
selected. However, it is recommended to avoid swap definitions, since they the
make 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 is
only valid, if it has at least one condition in its IF part. Since the currently loaded fuzzy system
Container Crane (CRANE.FTL) contains only two input, you have to generate a further input
variable. Assign the new variable as input to the rule block using the Rule Block Properties
dialog. 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 step
only serves the restoration of the initial situation. Choose a term in the new variable’s term list
box to remove the output variable Power from Angle and Distance’s sphere of influence. Now
define the input variables Angle and Distance as “don’t care” by clicking the right lower matrix
cell. This highlights all matrix cells, and the term list boxes of Angle and Distance display no
name.

3.1.3. Optimization and Debugging

System optimization is usually required to achieve the desired system


performance. Now, after you have learnt to set up a fuzzy system, the next
development step is to optimize and test this system. Because the optimization
strategy varies with each type of application, fuzzyTECH offers different debug
modes. When switching from design mode in debug mode, fuzzyTECH simulates

85
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

the developed fuzzy system. All editors display the entire inference process
graphically. The effects of modifications made in debug mode are immediately
displayed.

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 and
you cannot create new variable or terms. However, you may modify any existing
membership functions and create new definition points. Also, rules within an
existing Rule Block can be added, modified or deleted.

All debug modes are mutually exclusive. The Debug menu (Figure 60) is only
active, if a project has been defined or loaded. Within the Debug menu, the
active debug mode is indicated by a check mark (b). You may switch from any
debug 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 whether
they are to be used on a running process in real-time on target hardware (online
development), or whether they run on the development workstation/PC (off-line
development). The online optimization technique is a unique fuzzyTECH feature
in which development, debugging, and visualization features are available while
the process is under the control of the fuzzy system.

Off-line debug modes use the internal computation kernel in fuzzyTECH to


compute the results of a fuzzy project. Online debugging is based on generated
code compiled for the target system. Both enable an interactive system
development. Online modifications require access to system parameters in the
implemented 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 features
and editors. This allows you to review all fuzzy design steps, but modifying the
basic structure of the fuzzy project is impossible.

86
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

3.1.3.1. Off-line Debug Modes

Interactive Lets you check systems response to manually entered input data. The Interactive
Debug 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 effect
of the changes instantly. This allows quick “if-then” analysis.

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

After activation of Serial Debug Mode, fuzzyTECH waits for the process or
simulation to write all input values of the fuzzy logic system to the serial
interface. When all input values are received, fuzzyTECH computes the output
values and writes them back to the serial interface. Then, fuzzyTECH waits for
the next input. The communication format is ASCII: ASC(31) is used as
delimiter 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 files
as input to the fuzzy logic system. These input data files may stem from process
monitoring, the fuzzyTECH Pattern Generator, or real-time traces.

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

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

3.1.3.2. Online Debug Modes


Monitor
and 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 the
generation of C code that can be modified remotely from the development PC

87
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

while running on the target hardware. The development PC is connected to the


target hardware (process controller, PLC, micro-controller board) by a serial
cable, a field bus, a common file system or a similar communication medium.
“Monitor” establishes communication with the target hardware and lets you
visualize the entire information flow of the fuzzy logic system in real time.
“Monitor&Modify” lets you modify the running system in addition to allowing
visualization of information flow.

For microcontroller implementations, RTRCD delivers a reduced functionality


version of the fuzzyTECH Editions with Online mode. An unlicensed fuzzyTECH
Edition 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 Watch
Window (Figure 61) that is displayed as long as a debug mode is active. The
only exeption is the Batch debug mode that runs without displaying the Watch
Window. If a debug mode is chosen in the main Debug menu, the chosen mode
is displayed in the title bar of the Watch Window, in the Status bar and in the
Treeview. Leave a debug mode by either closing the Watch Window or clicking
this debug mode in the Debug menu again.

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

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

88
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

No Rule Firing If in any debug mode, no rule for the current combination of input values fires an
output variable, then the value of this linguistic output variable is set to its
default 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 which
no rule has fired.

➔ Switch into Interactive debug mode by selecting “Debug/Interactive” or click the symbol
[Interactive] in fuzzyTECH’s main toolbar.
Start Interactive
Debugging 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 Watch
Window appears only if no errors could be detected.

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

In debug mode, all design editors such as the Variable Editor and the
Spreadsheet Rule Editor graphically display the entire inference process. A
system can also be designed in this debug mode. This accelerates development
time because the effects of design changes are now visualized immediately. The
effects of membership function or rule modifications made in this mode are
immediately displayed. Though most of the system can be designed in
Interactive debug mode, some restrictions do apply. Structural changes to the
system – such as adding or deleting new linguistic variables or rule blocks – are
impossible.

3.1.3.4. Test System Performance Using Data

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

Performance Evaluation
with 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 input
data 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 Project
CRANE.FTL in fuzzyTECH (“File/Open/…/Samples/Control/Crane”). fuzzyTECH features a
Pattern Generator to create sample patterns that cover the control space. Select “File/Pattern
Generator” to activate the Pattern Generator, as shown in Figure 62.

89
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Figure 62: The Pattern Generator Creates Test Input Data Sets for the Current
Fuzzy 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 upper
and 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 the
minimum and maximum values are part of the pattern in all instances.
fuzzyTECH computes and displays the resulting number of patterns as “Number
of Records” and the disk space required to save these patterns as “Disk Space”.
Click on the [Generate..] button to create the pattern. fuzzyTECH proposes that
you accept the file name. The file extension *.PTN is appended to indicate a
pattern 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, the
upper 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 the
Pattern Generator window (Figure 62). If, for example, you specified “From: 0”,
“To: 10”, and “Step: 3” for a variable, then the pattern would comprise the
values 0, 3, 6, and 9, if the margin option is set to off or the values 0, 3, 6, 9, and
10 if the margin option is set to on.

Disk Space Generating complex patterns may result in large data files. The field “Number of
Records:” shows the computed number of records which would be generated
with the current settings. On this basis, the field “Disk Space (KB):” indicates an
estimation 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 consists
of more than 10000 records, a warning box lets you confirm the action.

90
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

File Format The file format in which the pattern data is generated is equivalent to the
fuzzyTECH file format (Section 9.3). fuzzyTECH supports two formats: a file
format 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 suggested
name 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 the
generation of the pattern, a dialog shows the progress and lets you interrupt the
process by clicking on the stop button.

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

91
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Batch mode, but instead of creating an output file, the entire processing of the
sample 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 as
fuzzyTECH is in File Recorder debug mode, the File Recorder dialog is always at
the top of all open windows to allow constant access to its controls. Information
about the sample data file and the current record can be read below the VCR-like
buttons. The File Recorder window is always at the top of any other fuzzyTECH
window. The File Control group contains a scroll bar and “VCR-like” buttons for
browsing 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, a
vertical red line is plotted in the Time Plot. If you change anything in the fuzzy
logic system, such as membership functions or rules, a vertical yellow line
indicates 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 a
timestamp as the record name. By moving the scroll bar, you may directly access
any record. In order to change the file, click on the [Read File...] button (Figure
63) and specify a new file name for the sample data. Other sample data that have
not been generated by fuzzyTECH’s Pattern Generator have to be converted into
a fuzzyTECH data format to make them readable. Refer to the fuzzyTECH Help
system 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 debug
mode (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 by
clicking [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 may
use the Batch Mode. The Batch Mode does not display the fuzzy logic inference
in all editors, but generates an output file that contains the computed output
values in addition to the input values. The output file contains all input variables,

92
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

➔ Activate the Batch Mode by “Debug/Batch”. A prompt for the input and output file names
appears., 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 can
view the result file “CRANE.OUT” by “File/View File...”.

During processing, the inference flow is not displayed. You may interrupt the
Batch mode by pressing [Stop] on the Batch Mode Message box that is displayed
while computing great amounts of sample data.
File Recorder versus
Batch 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, but
displays them graphically. The File Recorder mode enables you to connect your
system to pre-recorded sample data files for analysis. Batch mode processes files
with input data and generates a result file for further processing with other
software. In File Recorder mode, the number of records in a file is limited; in
Batch mode this number is unlimited.

If your fuzzy system is already installed within your process or a simulation, the
fuzzyTECH Trace Analyzer allows you to trace the process at the interfaces of
the fuzzy controller (see Section 3.1.3.5). If the preprocessing is not yet
determined, the fuzzyTECH DIAdem Module lets you apply signal conditioning
and 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 Debug
mode does not support system visualization and analyzers. Open as many
analyzers as you like. If no debug mode is activated, the [Analyzer] menu in
fuzzyTECH’s main menu is disabled. Leaving a debug mode closes all active
analyzers. fuzzyTECH offers the following analyzer tools to verify a fuzzy
system’s behavior:

Transfer Plot Lets you analyze the static input/output characteristic of a fuzzy logic system as
a 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 as
a scaleable, rotational 3D Plot.

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

93
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

Statistics Lets you control the use of fuzzy rules by a statistics column in the Spreadsheet
Rule 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 to
replay, 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 the
option Save Window Configuration is enabled (Tools/fuzzyTECH Preferences/
Save). fuzzyTECH uses a .CFG project file to save the project configuration even
when you exit fuzzyTECH.

➔ Activate a debug mode and open the Transfer Plot Analyzer either by clicking its symbol in
fuzzyTECH’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 input
variables and one output variable are always shown in this graph. In a fuzzy
system with more than two input variables, the non-selected variables possess a
given value, which is either defined (in Interactive debug mode) or determined
by the linked process or data file (in other debug modes). The two input variables

94
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

are shown on the horizontal and vertical axis, and the value of the output variable
is displayed as the color of the area spanned by the input variables. The color bar
on the lower part of the window shows the color-value relation. The resolution of
the 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 – of
the transfer characteristic are also displayed above and to the right side of the
Transfer Plot. In the upper left part of Figure 65, the output value “Power” is
displayed over the variation of the input variable “Angle”. All other input
variables remain the same.
Control Areas not
Covered 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 for
computation and the plot shows a black colored area. The completeness of a
fuzzy system’s rule base is sometimes difficult to verify. A rule base can be
complete in two ways: within the entire control space or within the control space
actually used by the system. While the entire control space can be studied using
the Transfer Plot or 3D Plot analyzer, the control space actually used depends
upon the process itself. By using the File Recorder Mode, combined with the
Transfer Plot Analyzer in the Trace mode, control space operating points are
displayed within the Transfer and the 3D Plot. This helps to pinpoint the process
states for which no rules were defined and to distinguish superfluous rules.

If a fuzzy system contains rule blocks structured similar to Figure 66 (upper


part), it is recommended to transform intermediate variables into output variables
to visualize all rules of each rule block. Open the pop-up menu of the
intermediate variable in the Treeview and choose the Properties option to
transform it into an output variable. Thus an interface is assigned to the
intermediate variables acting as output for one rule block. Now it can be selected
for display in a Transfer Plot.

Figure 66: Transforming an intermediate variable into an output variable to


visualize a rule base

95
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

➔ 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 tracing
will 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 Transfer
Plot and back. Rather than just the actual operating point, the Trace function in
Transfer Plot draws a history of all operational states since Trace was started. In
order to reset the trace, select the [Reset] button from the toolbar. Note that
the 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 main
toolbar or its entry in the Analyzer main menu. Cross-check the fuzzy rule base of the crane
controller by displaying the transfer characteristic of all rule blocks with the option [Hide
Plot 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 its
own toolbar. Use the rightmost drop down list box (the arrow-down button
displays the list of the possible resolutions) to change the resolution of the 3D
Plot. A high resolution can result in slow response times of the plot, depending
on the video and computing performance of your PC. Use the 3D Plot’s toolbar
to change the plot’s viewing options, to choose the variables to be plotted and to
call the Trace function. You can select variables for display in the plot by using
the drop down list boxes (below the 3D Plot’s toolbar) displaying variable
names.

Rotate the Plot The four arrow buttons on the left side of the toolbar rotate the plot
in 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.

96
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 68: 3D Plot

Repaint and Background


Paint 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. If
the [Repaint] button is pressed, the 3D Plot is repainted every time one of
these other input variables changes to reflect the change in the control surface
shape. Note that this only results in a smooth display if you have a PC with very
high video and computing performance. You can enhance this effect by enabling
the background paint mode [Hide Plot Drawing]. This creates the picture in
the background and dumps it to the screen.
Trace in
Trace 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 may
switch 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 define
up to 10 Time Plots in each fuzzyTECH session. Each Time Plot is uniquely
identified by a number in its title bar. Refer also to the paragraph Analyzing Time
Response (Chapter 1, page 15), in which detailed instructions are given for
handling this analyzer.

➔ In order to open a new Time Plot, select Analyzer/New Time Plot... in fuzzyTECH’s main
menu. 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 customize
the 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.

97
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Use the [List Box] symbol from the toolbar to hide the Plot Items to save
screen 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 Plot
Config…” in the pop-up menu of the Time Plot.

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

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

The two left list boxes of the “Variables” dialog display elements that you can
select for display. The right list box titled “Variables in Time Plot” shows the
elements 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 Time
Plot”. Just double-click on the highlighted variable or use the [Add] button to move variables
from the left list box to the right one. You can delete inserted variables by selecting them via
mouse click and pressing the [Remove] button. After you have selected the three linguistic
variables 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 Plot
Items. The left part of the window displays the plot area. A scale for the element
highlighted in the Plot Item list box is displayed on the left border of the plot

98
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

➔ 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 all three control variables over time
(Figure 70).

The blue line (Power) starts with medium positive Power. After the container
sways slightly back (red line declines), the fuzzy logic controller increases the
motor power (blue line increases). When the sway becomes too large (red line
deep down), the fuzzy logic controller reduces motor power (blue line declines).
After reducing the sway (red line comes back up), the fuzzy logic controller
increases 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 Output
Variables, As Well As Rule Firing Degrees Over Time.

Time Plot of Rule


Firing 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 the
instructions 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 number
after the point identifies the number of the rule in the respective rule block; the
second 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 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 “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 the
Time Plot, the respective rule is shown abbreviated under the plot area. You may
mix any combination of linguistic variables, terms and rules in a Time Plot.

99
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

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

Rule Analyzer Use the Rule Analyzer to point out for the last computation step, which rules had
influence on the value of the selected variable (Power). The Rule Analyzer can
be configured by its toolbar. By selecting the symbol the rules are sorted by
the aggregation values. By selecting the symbol the rules are sorted by the
result aggregation values. For each term those rules are listed that meet the
following 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. The
Rule Analyzer lists the following rules:

Figure71: Rule Analyzer for Output Variable “Power”

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

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

100
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

maximum firing degrees. The number between the bars counts how often a rule
fires with a DoS greater than zero. The frequency a rule fires can either be
displayed 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 absolute
or relative values. Reset the statistics counter to zero by clicking the toolbar
button [Reset statistics counter].

You can turn the Statistics analyzer off by deselecting Analyzer/Statistics in


fuzzyTECH’s main menu or by clicking the [Statistics] toolbar button in
fuzzyTECH’s main toolbar.

Trace Analyzer The trace function lets you trace the dynamic behavior of a fuzzy system during
runtime. While computing a fuzzy system, the input and output values of each
computation cycle are written into a special data buffer. The contents of this data
buffer can be written into a file using one of the fuzzyTECH data formats. The
advantage of such a trace lies in the possibility to analyze the dynamic behavior
of the fuzzy system at any time later. The debug mode File Recorder is
especially 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 Rule
Editor and 3D Plot can be opened additionally.

The Trace option lets you configure a trace buffer on the target hardware or in
the internal computation kernel of fuzzyTECH. A trace buffer must be assigned
to your fuzzy controller to enable the Trace Analyzer. Select “Tools/Project
Options/Code Generator”. The Code Generator dialog can not be accessed when
a debug mode is open. In the Settings field, choose the option Online Code, then
the 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 leave
the 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 the
simulation, the performance of the fuzzy controller on the real system varies in
most control applications. This is due to various reasons. When real process data
has been used, feed-back of the control actions is not taken into consideration.
When using a simulation, model-based simulations are almost always
approximations 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 a
look” at the inputs and outputs of a fuzzy system on a fuzzy runtime system and
to modify the fuzzy system during runtime.

101
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 client
provides the input values for the fuzzy system, initiates computation, and
calls for the output values for further processing.
2. fuzzyTECH Runtime Library: fuzzyTECH provides different runtime libraries
containing fuzzy algorithms, e.g. fuzzyTECH Runtime DLL, fuzzyTECH
Runtime Control, fuzzyTECH C Runtime Library, fuzzyTECH Assembler
Runtime Library, fuzzyTECH COBOL Runtime Library, ...etc.
3. Fuzzy System: A fuzzy system can be at least one file generated by one of
fuzzyTECH’s code generators, containing specific data of the fuzzy system
(rules, membership functions, etc.).

During Online/RTRCD optimization a communication channel connects the


fuzzyTECH development system on the PC with the target hardware. Depending
on your fuzzyTECH edition this communication channel can be e.g. a serial cable
or a PC network (see below for details).

Figure 72: Online Development, using a communication channel to connect the


Development System and the Target System.

The Online Edition enables you to do online optimization with all target
platforms. The Professional Editions enable you to carry out online optimization
only 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 fuzzy
system on the target without modifying it. In this mode, the fuzzification, rule
evaluation and defuzzification are visualized. The communication can also be
used for Tracing. All trace data are recorded as real time data on the fuzzy
runtime 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.

102
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

• 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 debug


mode 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 link
between fuzzyTECH and a fuzzy application on a target system. The
MCU/RTRCD-Editions only allow a serial interface as communication channel.
The serial interface allows communications with the target hardware. The dialog
for the Serial Interface Configuration is opened via “Tools/fuzzyTECH
Preferences/Serial Interface”. The IA-S5 Edition uses a serial cable with PG
interface.

In addition to the serial link, the following communication channels are available
for 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 the
configuration of the Serial Interface is opened. This communication channel
is available in Online/RTRCD Editions.
• Shared File System: If this channel is chosen fuzzyTECH uses a set of files
for online communication. The files are passed via a directory on a file
system that may be shared by fuzzyTECH and the target system application.
Note: The shared file system directory must be an exclusive resource that can
only be used by one instance of fuzzyTECH and one target system application
at the same time. Therefore, fuzzyTECH protects the directory against access
from other instances of fuzzyTECH by creating an empty file named
FTOMLOCK. The target system application protects the directory against
access from any other target system application with an empty file named
FTOSLOCK. This communication channel is only available in the Online
Edition.
• ...\FTDDE.DLL: If this channel is chosen fuzzyTECH uses MS Windows
DDE for online communication. This is the best communication channel for a
FTRUN based fuzzy runtime system running on the same PC as fuzzyTECH.
The [Setup] button is deselected and appears therefore in a grayish color
because there is nothing to setup for DDE.
• ...\FTTCPIP.DLL: If this channel is chosen fuzzyTECH uses a network
supporting the TCP/IP protocol for online communication. This channel

103
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

should be chosen, if two PCs are connected to such a network and PC1 is
running fuzzyTECH and PC2 is running a FTRUN based fuzzy runtime
system. 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 for
online communication. The network, e.g. Novell Netware/Intranetware, must
support the IPX/SPX protocol. This channel should be chosen, if two PCs are
connected to such a network and PC1 is running fuzzyTECH and PC2 is
running a FTRUN based fuzzy runtime system. The [Setup] button lets you
specify the network address of PC2. It consists of the three values Network,
Node and Socket. The appropriate values for PC2 are shown in the FTRUN
information window as a string with the following scheme: Online: IPX/SPX
on <Network>.<Node>.<Socket>.
• ..\FTSDI.DLL: This communication channel is only available for the
fuzzyTECH MCU-HC11/12 Edition. It should be used for RTRCD
communication, if your M68HC12 target system has a Background Debug
Mode (BDM) connector for a Serial Debug Interface (SDI). If this channel is
chosen fuzzyTECH uses the MMDS1632 protocol on the serial interface. The
[Setup] button lets you specify serial port number, baud rate and the address
of 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-implemented
fuzzyTECH Online Communication Channel DLLs. If this channel is chosen
fuzzyTECH uses an empty prototype of such a DLL. The source code of this
sample is located at ..\USEREXT\FTOCC\SRC and can be used as basis for
implementing new communication channels.

Online Timing The period of time, in which online information are requested, is defined in the
Settings field of the Online Timing dialog (see Figure 73) in Tools/Project
Options. As the calculations from the target hardware are visualized in the
fuzzyTECH editors, a time period for the update of the editors has to be defined.
The Refresh Time determines the time interval after which the current
operational 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 no
response from the target is stated after the determined timeout value ([Time Out]
field). The Time Out parameter determines the time interval in which a response
has to be obtained from the target system. A message box appears, if this time
interval is exceeded, and the online connection is terminated.

104
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Necessary Steps Follow these steps to optimize a fuzzy system with the Online/RTRCD debug
mode 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 Online
Wizard in the pop-up menu. Follow the instructions of the Online Wizard.
Refer to the paragraph Configuring an Online Connection of Chapter 2 to
read 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 the
Online Code option enabled (see step 1 above), and integrate it within the final
system. This compacts the code, since all code optimization features are disabled
when generating online code.

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

105
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

Terminating
Online 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 offers
the user to save his system, to restore the original system, or to let him
synchronize the system himself manually. Synchronizing the system is necessary
in order to allow a later re-connection to the runtime system.
Interrupts while
Online Debugging If the Online/RTRCD debug mode is interrupted due to communication errors
(e.g. interrupting the power supply for your PC or unplugging the
communication cable), the fuzzy system loaded in fuzzyTECH and the system on
the runtime system may not be synchronous any more. If an interrupt occurs,
follow the instructions of the Online Wizard.
Co-ordinationg Online
Communication The online communication uses master-slave operations. All requests are
initiated by fuzzyTECH. Thus, if no link is enabled, the controller is able to
operate without the development system. For security purpose, all telegrams are
transferred via handshake. If no message appears or a telegram is only partly
received at the target, the development system and the online debugger will sleep
but let the controller work. Every message completely received at the target is
acknowledged by the online debugger. This acknowledgment must reach the
development hardware in a time period shorter than the time out interval
determined in the Timeout field in the dialog Online Timing (Figure 73) in
Tools/Project Options. Otherwise, a message appears and the Online Connection
is terminated.

Password Protection To allow only qualified personal to modify the fuzzy system on the target
through Online /RTRCD mode you can protect the access to the Online /RTRCD
mode with a password. Choose the option Password Protection from Tools/
Project Options/Code Generator and generate the code. You will have to define
the password when you generate code. The password has always to be entered
when Online/RTRCD debug mode is started. The password must consist of five
characters at least. To change the password, click the respective system’s name
in the Treeview with the right mouse key and choose the Change Password
option from the pop-up menu.
Open Fuzzy System on
Runtime 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 a
compressed copy of the current fuzzy system (FTL file). Later this system can be
re-loaded with the help of the Online Wizard, provided that fuzzyTECH and the
runtime system are connected via a communication channel. Upload may be
specially useful, if the matching FTL file does not exist any more.

106
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Overwrite Fuzzy System


on 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 that
the fuzzy system loaded in fuzzyTECH’s Project Editor and the fuzzy system on
the runtime system match in significant parameters (number of inputs/outputs,
data type, storage space...). Downloading can be carried out with the help of the
Online Wizard, if fuzzyTECH and the runtime system are connected to each
other via a communication channel. The download option is especially useful for
modifications of the system’s structure (additional intermediate variables,
additional terms, and additional rule blocks), since such modifications cannot be
carried out in the debug mode Monitor&Modify.

Fast Processes Some processes are too fast to be optimized on-the-fly. In such cases, the Trace
Analyzer 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 real
time for a defined time interval. Via a communication channel, this data can later
be 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 other


applications, e.g. process simulations. All interfaces described in this section use
the internal computation kernel in fuzzyTECH to compute the results of a fuzzy
project. This allows a complete system visualization in all editors and analyzers
of fuzzyTECH as well as an interactive system development. fuzzyTECH
supports 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 fuzzy
computations. fuzzyTECH is completely controlled by this application.
fuzzyTECH activates a special debug mode, that cannot be influenced by the
user. 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.

107
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

DDE DDE is another way to connect fuzzyTECH with MS Windows applications. For
data exchange with other applications via DDE, fuzzyTECH can function both as
server and client. We recommend to use this interface together with the
Interactive 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 interface
and the Serial Link Protocol. Serial Links are explained in detail in Section 6.2.3.

3.1.4. fuzzyTECH Documentation and Revision


Control System

fuzzyTECH provides different tools that let you document and commented on
your entire project. The Project Information tabbed dialog displays the latest
state of your project. fuzzyTECH’s Revision Control System lets you save each
development step for revision and project control. fuzzyTECH’s Documentation
Generator creates automatically a documentation of your entire project.

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

108
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

3.1.4.1. Project Information

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

This activates the tabbed dialog Project Information (Figure 76). Its General
page 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, further
information on the current project are displayed, such as the total number of
input/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 be
different to the file name. A project name can be up to 16 characters long and
may not contain any spaces. The default project name is the same as the FTL
file.

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

Enter project-related comments on the Comment page of this dialogs. These


comments are added automatically to a documentation generated by
fuzzyTECH’s Documentation Generator.

109
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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 the
currently loaded fuzzyTECH project will be configured. This documentation is
maintained in form of a report and saved in RTF format. Thus it can be
processed further with another text processor. Clicking the [Generate…] key
starts the automatic project documentation according to your settings. Refer to
the 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 under
development in a file. In the case of fuzzyTECH this is an ASCII format file in
FTL syntax with the suffix *.FTL. Optionally, fuzzyTECH stores the information
on editor and analyzer configurations in a *.CFG file that is an ASCII format file
following the same syntax rules as most MS Windows *.INI files. While this is
the standard way to handle project files in software development, the
modifications to a system under design must often be documented. This is a must
for developers who are obliged to document system modifications in an ISO9000

110
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

compliant fashion. In software engineering, such documentation is handled by a


Revision 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 any
commercial Revision Control System. However, Revision Control Systems are
powerful and complicated tools, and if you do not already use one that has been
set up, you can use the integrated Revision Control System of fuzzyTECH.
Because of its tight integration with fuzzyTECH, revision control becomes an
easy task, plus the overhead cost required to work with a revision control system
is easily recovered the first time you decide to revert to an earlier stage of
development.
fuzzyTECH’s
Revision Control System fuzzyTECH’s Revision Control System (RCS) uses *.REV files to store multiple
*.FTL files, plus additional information describing the modifications from
previous development stages. Each development stage is represented by its
*.FTL file. In brief, a *.REV file contains the sequence of *.FTL files of a
development project. You can store each *.FTL file that represents a specific
stage 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, even
a 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 persons
can modify revisions of the fuzzy logic system.
Work with Existing
REV Files Open the existing file CREDIT.REV contained in the subdirectory
…\SAMPLES\BUSINESS\CREDIT\..., to become familiar with the RCS. You
can either select File/Open from the main menu bar and set Filetype to Revision
File (*.REV), or select File/Revision Control… from the main menu bar and
click 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 from
unauthorized 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 in
the *.REV file. In CREDIT.REV, five stages of CREDITx.FTL, are stored. The
first column of the list box shows the project name, which is the original name of
the *.FTL file. The sequence of the listed projects is the chronological sequence
in which revisions have been stored in the RCS. It cannot be changed. The
Date/Time column shows when the *.FTL file was added to the *.REV file. The
Author and Comments columns show who developed the revision and what was

111
Inform Software Corporation Chapter 3: Designing Fuzzy Logic Systems

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

Figure 78: The Revision Control Dialog Lists All Stages of


a Fuzzy System Development.

Retrieving FTL Files


from 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 mouse
key and select the option [Check Out] in the pop-up menu. Because an *.FTL
file 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 the
file during development as any other *.FTL file.
Storing FTL Files
in 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 with
fuzzyTECH. Then, open the Revision Control dialog again by selecting
File/Revision Control from the main menu bar. If you have restarted fuzzyTECH
since the last time you opened the *.REV file, you have to open it again by
clicking on the [Open REV...] button. Click on the button [Check In] to store the
current *.FTL file as new revision. This opens a dialog (Figure 79) that lets you
specify the author’s name and describe the modifications made.

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

112
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Printing a Complete
Development History Click on the [History...] button to print a complete development history that
covers all revisions. This delivers all the revision information plus all comments
into a single text file that can be edited, printed, or integrated into other
documents.

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 KB
of disk space, the CREDIT.REV file that contains all of them in condensed
format uses less than 10 KB of disk space. You can also use the *.REV file
format, which stores only one *.FTL file, if you either need a more compact
representation than *.FTL or if you want to protect the *.FTL file from being
read by unauthorized persons.

113
Inform Software Corporation Chapter 4: NeuroFuzzy Design

The composition of this chapter is analogous to Chapter 1. First, familiarize


yourself with NeuroFuzzy design by using samples and development tools.
Second, design your own NeuroFuzzy system with the aid of the NeuroFuzzy
Glass Sensor Simulation.

4.1. First steps

Make your first steps with NeuroFuzzy design by following the instructions
given in the next two sections. The first section walks you through the generation
of a fuzzy XOR system from a sample data file. In the section which follows, the
generated system (the XOR example) is then trained with the NeuroFuzzy
Module.

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

4.1.1. Generating a Fuzzy XOR System by the


Fuzzy Design Wizard

The Fuzzy Design Wizard (FDW) supports quick generation of a system


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

114
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

➔ 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 the
main 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 dialog
Read Project Information From…. Select the “XOR.EXP” file from the
subdirectory “...\SAMPLES\NEUROFUZ\XOR”. After you have done that, the
next 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 the
number of terms for individual linguistic variables later. By analyzing the file
“XOR.EXP”, the FDW discovered that the system to be created requires two
input and one output variables. Due to the simple structure of the training data,
the FDW does not propose intermediate variables. Move to the next FDW
window by clicking the [Next] button or pressing the [Return] key.

The following three FDW windows specify the three linguistic variables of the
system. The first of these FDW windows defines the first input variable, “Input
A”. By analyzing the sample data set, the FDW has set the range for the variable
from 0 to 1. The FDW has also determined that only 0 and 1 values are specified
for all variables and proposes the term names “false” and “true”. You may
choose 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 next
FDW window.

The next FDW window defines the next input variable, “Input_B”. Accept the
proposed defaults and step to the next FDW window that defines the output
variable. For the output variable, the FDW proposes the range -1 to 2. This
results from considering the possibility that a later shift of the membership
functions out of the range 0 to 1 could be necessary. Accept the default values
proposed 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 the
simplicity of the training data, the FDW proposes just one rule block. Enabling
the check box, “Create Rule Base”, lets the FDW generate a complete rule set for
each 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 true
rules, this is equivalent to a set of completely false rules. Hence, the generated

115
Inform Software Corporation Chapter 4: NeuroFuzzy Design

rule set contains no information. The reason for creating a complete, but totally
false rule set is that the NeuroFuzzy training can only start with an existing rule
set. 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], a Confirmation
dialog appears. Confirming the dialog or pressing [End] generates the system as
shown 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 train
the exclusive or (XOR) example.
Development Steps
with NeuroFuzzy The development of a solution using the fuzzyTECH NeuroFuzzy Module
consists of the following steps:
1. Obtain training data, cluster if necessary
2. Create an “empty” fuzzy logic system
3. Enter all existing knowledge in the solution
4. Open the components of the fuzzy logic system to be trained
5. Configure the NeuroFuzzy Module
6. Train with the sample data
7. Evaluate system performance
8. Manual optimization
9. Implementation as “pure” fuzzy logic system

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

116
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

➔ 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 located
in the subdirectory “...\SAMPLES \NEUROFUZ\XOR…”.

Training Data The editor window shows the contents of the file (Figure 81). The first and third
row of the file contain comments, while the second row specifies the names of
the linguistic variables “Input_A”, “Input_B” and “Output”. The actual data
records 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 start
with the record names “sample1” … “sample4”, plus the values of the two input
variables and one output variable follow. The values must follow the IEEE
format for float values. You may use any ASCII editor to generate a training data
file. Also, most spreadsheet, data base, or data acquisition software systems can
generate 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 already
completed this step in the previous section.
Open Components
for 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 open
all rules and the output variable for training.

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

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

117
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Figure 82: Open the Membership Functions for Learning.

➔ Next, open the Spreadsheet Rule Editor for the Rule Block. The Fuzzy Design Wizard has
already 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 enter
the interval in which the NeuroFuzzy Module may alter the DoS of the rules. Click on the DoS
value 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 adjust
any further settings here. Now open the NeuroFuzzy Configuration dialog either by clicking
the respective button in the main toolbar or by selecting “Tools/Neuro/Configuration...” in the
main menu.
Configuring the
NeuroFuzzy 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 (Figure
83) shows all available training algorithms. The NeuroFuzzy Module of a
fuzzyTECH Edition in Demo mode only supports one basic algorithm: the
“Random Method”. You may also code your own training algorithm by using the
elements provided by the NeuroFuzzy Module and listing them in the “Learn
Methods:” list box.

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

118
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

The group “Learn Parameters:” lets you set parameters for the algorithm. Leave
these parameters at the proposed default values for the training of the XOR
example. The group “Stop Conditions:” lets you specify when the training
should automatically terminate. The three conditions are alternately used. For
instance, if you enable “Max. Steps:” with a value of 100 and “Max. Dev.:” with
a value of 0.1, the training stops after 100 training cycles or when the maximum
error is lower than 10%, whichever occurs first. If you do not select any stop
condition, you must stop training manually. The group, “Selection Mode:”, lets
you 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 in
some way, you should select “Random”.

➔ Since the XOR contains sorted samples, select Random as Selection Mode, make sure all other
options 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 the
opened fuzzyTECH editors and analyzers. Therefore you should configure and
arrange all fuzzyTECH editors and analyzers before you start training. Figure 84
shows a window configuration that works well when training the XOR example.

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

Figure 84: Possible Window Configuration for Learning.

119
Inform Software Corporation Chapter 4: NeuroFuzzy Design

The 3D Plot initially does not show any transfer surface since plotting is
suppressed for areas where no rule fires. You can enforce plotting the transfer
surface 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 Block
Utilities from it. Select “Set all DoS” and “User Defined” and enter a value of 0.01 in the value
field. When you click [OK], all rules fire to a very small degree and the 3D Plot draws a
transfer surface.

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

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

Learn Control Dialog The learn control dialog is controlled via its toolbar where you find buttons to
start and stop training, and to process single training steps. Two
buttons control the Plot area: an error plot and an error statistic are
available. A list of samples that continue to produce a significant error is
generated by the button and is displayed in the bottom section of the dialog.
In order to verify the training results during interrupted training, determines
the current system’s state. enables the update of all windows shown in
fuzzyTECH. 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 error
statistic or both. The error plot shows the training history of the maximum
deviation (Max. deviation) and the average deviation (Avg. deviation). The
statistic plot classifies the deviations of all samples. The number of samples
fitting into each deviation class is displayed.

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

120
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

current sample, number of training cycles, and the iteration timer value. The
iteration timer value shows the computing time the last training cycle required to
train 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 of
all opened editors and analyzers in fuzzyTECH for each training example. Enable
this option to interactively watch the training progress. Note that enabling this
option 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 [NeuroFuzzy
Training] button in the main toolbar. The last configuration of the NeuroFuzzy
Module is stored until you close fuzzyTECH.

Output and Target Values The list box “Output - Target - Computed:” displays a row for each output
variable under training. The left item in each row is the name of the output
variable, 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 under
training. This list box is only updated in single-step mode. This function, for
example, allows you to determine which samples are causing any significant
remaining error. Next, initiate Training by pressing the [Start] button. Because
the NeuroFuzzy Module only generates fuzzy logic systems that are easy to
comprehend, it only operates with Standard MBFs. Therefore, all membership
functions are converted to Standard MBFs at each initiation of the training. If
you have followed all of these steps, you should now be able to monitor the
training in the windows of fuzzyTECH. The NeuroFuzzy Module modifies the
DoS 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 the
trained fuzzy logic system. Between these points, the resulting fuzzy logic
system performs a continuous approximation.

121
Inform Software Corporation Chapter 4: NeuroFuzzy Design

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. One
interesting 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 data
is in complete conflict with sample4. If you restart the training with this
modified example file, you see that the error remains high. This is due to the fact
that 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 you
want to eliminate rules that only have a small influence on the system after
training, you can use the “alpha cut” function from the Rule Block Utilities
dialog.

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

122
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 using
both intuition and engineering heuristics. As a result, elements of everyday
language are used to represent desired system behavior, thus circumventing the
need for rigorous mathematical modeling. This provides an efficient way of
designing, optimizing, and maintaining highly complex systems and results in
robust and fault-tolerant systems.

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

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

123
Inform Software Corporation Chapter 4: NeuroFuzzy Design

successfully design a system by utilizing NeuroFuzzy technology, you require


both a brief introduction to the basics of adaptive systems, and knowledge of
how to use the NeuroFuzzy Module. If you are not familiar with NeuroFuzzy
technology, please first read the Fuzzy Primer in Chapter 5 of this manual. This
section is intended to show the NeuroFuzzy development using the fuzzyTECH
NeuroFuzzy Module for deriving a classification system. Typical applications
for such a classification system are the recognition of objects that are separated
by color (e.g. recycling glass, containers, or paper) or the quality control of paint
jobs (e.g. car painting).
Recycling Glass
Classification Collecting and recycling glass is one of the leading processes guiding us towards
ecological waste management. Although glass itself is collected separately, glass
of different colors and items made of different materials must be sorted and
separated to gain a sufficient quality of recyclable raw material. In glass
recycling plants, the bottles are sorted into containers that later are melted
together and processed in a batch process to new glass. In this process, it is
essential that the bottles be sorted into the containers in a mix that yields the
desired glass color when melted and processed. Because different customers of
the produced glass require different colors and the mix of incoming bottles
changes, no clear definitions can be set with reasonable effort for the sorting of
the bottles. Rather human operators sort the bottles manually, using the
experience in which mix of bottles will result in the desired color of the
produced glass.

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

Classifier Simulation The Glass Sensor simulation is a simplified version of a real world application in
a glass recycling plant. This animated simulation demonstrates the use of
NeuroFuzzy technologies to generate an entire fuzzy logic system solely from
sample data. The simulation was reduced to just four containers for didactic
purposes.

The classifier hardware was implemented as a simulation under MS


Windows. The simulation can be opened by clicking the right icon in
the fuzzyTECH program group.

124
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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

Applying NeuroFuzzy The classification problem requires an adaptive approach. First, the solution
must include the ability to learn additional color classes. Second, describing the
classification criteria within fuzzy rules is not very efficient. However, recording
sample data assigned with the desired classification is simple. The simulation
includes the option to record data to a file. Within the simulation, the correct
glass type is always determined. Thus, the correct glass type is always assigned
to 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 calculated
by using the defuzzification procedure: 1 represents a red bottle, 2 a green, 3 a
white, 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 data
be recorded?

Quality of Sample Data When you use training data recorded from a real process, chances are that many
data sets are redundant. Use of training data sets with redundant records
lengthens training significantly. Even more critical, if most of the data records
describe 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% of
your recorded training data may describe the steady state and only 5% of the data
describes other conditions. Using this data results in a controller that excels in
the steady state but performs poorly in the other conditions. Training data that
stems from a real process should be clustered before it is used in NeuroFuzzy
training to avoid this situation.

The NeuroFuzzy Module provides a clustering function that features standard


clustering methods as well as fuzzy clustering methods. For the examples used
with the attached software, no clustering is required. Hence, clustering will not
be treated any further here.

125
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Figure 87: Glass Classification Simulation

➔ Start the simulation by clicking on the NeuroFuzzy sensor simulation icon in the
fuzzyTECH program group. In the simulation window (see Figure 87), start the record mode by
clicking the [Record] button. Every [Step] records a sample. Generate a sample file with 12
samples. Click the [Stop] button to terminate the record mode. The data is saved in the file
NFSENSOR.EXP in the …\SAMPLES\NEUROFUZ\NFSENSOR directory (Figure 88). Use
the 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. A
system can be no better than the quality of the data presented. Within the
following development, we work with only the 12 samples. The simulation can
of course be used later to record files containing up to 50 samples. In order to
investigate the influence of the number of sample data, these data can be used in
later 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 training
can start. This structure consists of linguistic variables, terms, membership
functions, rule blocks, rules, and interfaces. fuzzyTECH supports development of
an “empty” structure with the Fuzzy Design Wizard (FDW). The FDW allows
the setup of a fuzzy prototype in minutes. Also, the FDW can extract information
from sample data files. The use of the FDW was already explained in detail in
Section 4.1.1.

126
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 88: Sample Data Recorded With the Simulation

➔ Start the FDW by using the [Design Wizard] button in the main window toolbar or use the
option “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 file
NFSENSOR.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 the
output variable. Because of the fact that the classifier uses four color types, an
output 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 are
input and output variables to be defined. Change the number of terms for the output variable
from 5 to 4. Press the [Next>] button to step through the following FDW design steps, define
defuzzification method and rule blocks, and generate the system by confirming the last FDW
dialog.

127
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Base Variable Range of


Output 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, this
definition seems to be inappropriate when compared to “Type” data using values
between 1 and 4. The FDW uses equidistant terms in all Lambda style.
Defuzzified values always result in-between or on the maxima of the Lambda
terms. Thus, all existing output values must be larger than or equal to the
smallest term maximum and less than or equal to the largest. This means larger
than or equal to 1 and smaller than or equal to 4 in the given example.
Defuzzification Methods
and 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 of
optimization. The system response to small parameter changes is evaluated to
determine the gradients. Non compromising defuzzification methods do not react
to small changes. Thus, only compromising methods can be used for training.
Using a Generated
Rule 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 fuzzy
system, but they can be used for NeuroFuzzy training. This approach lets the
NeuroFuzzy training affect only the set of rules that influence system behavior
within the given sample data. All other rules are not changed and can be deleted
later. In addition, rules generated by the FDW are automatically open for
training.

Step 3: Enter Knowledge In this step you enter all existing knowledge on the solution into the fuzzy logic
system. The NeuroFuzzy Module uses this so-called “a-priori” knowledge as a
starting point for the training. The access to the “empty” system allows you to
find a system configuration where training results can be explained. Select
variable and term names in such a way that resulting fuzzy rules represent
control, 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 a
big advantage of the NeuroFuzzy approach over a neural net solution. If no
knowledge of the solution exists, skip Step 3. The NeuroFuzzy Module extracts
the necessary information solely from the sample data in this case. Note: even if
all information required to build the solution is already contained in the training
data, entering existing knowledge expedites the training. If the training data is of
poor quality, using existing knowledge to help the NeuroFuzzy Module may be
the only way to come up with a solution at all.

128
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Step 4: Open Components The NeuroFuzzy Module training paradigm is highly structured. You can define
exactly which components of the system shall be modified by the NeuroFuzzy
Module. For linguistic variables, you can open specific terms for training, and
for 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. If
you manually created a rule block in the Project Editor, activate the spreadsheet editor and use
the [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 complex
applications, often the main part of the NeuroFuzzy system is implemented in the
conventional fuzzy logic approach derived from human expertise. NeuroFuzzy
training can be used to complete this knowledge for areas where not enough
expertise 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 clicking


the [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 prototype
approach for most applications. If the training does not converge, the
configuration can be changed within the training procedure.

129
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Hints to Select
Learn Parameter Learning parameters allow for a better control of learning methods. Details
concerning the learning methods are explained in the NeuroFuzzy section of the
primer chapter of this manual. The learning parameter, Step Width (DoS),
determines the maximum amount that a fuzzy rule is changed within a single
training iteration. Due to the normalized notation of the DoS, the Step Width
(DoS) can use values between 0 and 1. Step Width (Term) determines the
changes implemented in the positions of terms. Terms are shifted along their
base variable axes. Because base variable ranges are not normalized, the Step
Width (Terms) is noted as a percentage of the complete base variable range.
Normally, one starts a training procedure using large training steps; later
optimizations are better performed with smaller step widths.

Winner Neurons Winner neurons determine the basic training strategy: Winner Neurons: 1 means
that in every training iteration only one rule - the winner in competition to all
other rules - is changed. Thus, using this configuration lets the NeuroFuzzy
training work in a fashion similar to approaches known as “Competitive
Learning." Within most NeuroFuzzy training ventures, this approach was found
to 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 the
derived solution fulfills the error criteria. The average or the error of the worst
sample can be used as the determining criteria. Note: the first criterion to be met
always terminates training. For classification applications, the error of single
sample is more of interest than the average error. Even when all samples except
one are perfectly trained, the failed sample may cause a malfunction that can not
be 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 increase
the learning performance of the training. An error threshold is defined for which
training computation is skipped for all samples that produce errors under the
defined limit. Thus, only the samples still “bad enough” are used for further
training of the system. The more samples found which produce errors below the
threshold, 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 achieve
this situation during all training iterations. Hence, when system error is large
during the first iterations, use a very high threshold entered in the [From] field. If
the system reaches this threshold, we can lower it step by step until we reach the
final objective entered in the [To] field.

130
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

How to use the


Dynamic 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 the
current threshold; thus, the factor chosen must be between 0 and 1. A factor of 1
fixes the threshold to the [From] value; a factor of 0 completes the training in
two steps: one using the [From] and the second using the [To] threshold. Values
between 0 and 1 control the dynamic threshold steps. Values close to 1 result in
training only the worst samples.
A lower factor determines larger threshold steps and thus results in more samples
affected within the iterations. A factor close to one results in shorter computation
times per iteration but probably more iterations.

➔ Confirm the training configuration by pressing [OK] and save the project (the Neuro
Configuration 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 lets
you control the training via a dialog and allows the full visualization of the fuzzy
computation during the training. In order to view fuzzyTECH editors and
analyzers during training, you must open and position them on the screen before
the Learn Control window is opened.

➔ Open the “Type” Variable Editor and the Spreadsheet Rule Editor. Locate the windows on the
screen. 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 system
behavior. During training, computing sequences are completely determined by
the sample sequence.

Sample Data NeuroFuzzy training optimizes a fuzzy system by comparing sample data with
the computed output of the fuzzy system. Thus, the training is based on sample
data. For each training session, a sample data file must be selected. Multiple
sample data files can only be used sequentially.

➔ Activate the Learn Control window by selecting “Tools/Neuro/Learning” in the main menu or
select the [Neuro Learning] button in the main window toolbar. In the file selector box
which 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 variables
are automatically converted to standard variables. If you do not confirm the
conversion, MBF training is disabled.

131
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Training Control The toolbar contains buttons to start and stop training, or process single
training steps . The following two buttons control the plot area: [Error Plot]
and [Error Statistic] . The [Show Error List] button computes a list of the
current 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 the
maximum and average errors. The [Update] button updates all windows open
in 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 the
toolbar) is disabled, enable the link to the fuzzyTECH Watch window by selecting this button
and 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 several
times in an iterative procedure. One training iteration is defined as a computing
step using one complete pass through the sample data. At the end of each
iteration:
• 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.

132
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Step 7: Evaluate
System 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 not
satisfactory, 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 samples
presented (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 the
system depends greatly on the application. In closed-loop control applications,
often online optimization using a real process or a simulation is very efficient. In
data analysis applications, a prototypical implementation of the training result
and further tests show whether and in what respect the solution needs further
optimization.

Figure 90: NeuroFuzzy Training of the Sensor

Reduce the Rule Set Usually, a rule set subjected to NeuroFuzzy training includes more rules than
required in the final system. Often the objective of the training is to find
functionally redundant rules or unnecessary rules. The superfluous rules can be
deleted using the Rule Block utility (Figure 56).

133
Inform Software Corporation Chapter 4: NeuroFuzzy Design

➔ Choose the Rule Block Utility option from the pop-up menu of the Spreadsheet Rule Editor. In
the dialog, select the alpha cut utility, and enter a small value or zero in the user defined value
field. 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’s
objective. More specific training runs allow for an interactive approach using
manual optimizations, as well as the ability to train partial systems. Also, the
positions of membership functions can be included in the training procedure. For
the sensor application, the system setup takes into account that the output terms
perfectly match the given color classes.

Using these MBFs for training results in a system where color classes can only
be represented by combinations of rules. Thus, for the sensor, training only input
MBFs may enhance the system.
Open single
Rules 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 results
from previous training can be modified in later training sessions. The
spreadsheet 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 be
implemented on microcontrollers, PC, workstations, PLC or industrial
controllers.

➔ Start the NeuroFuzzy Glass Sensor Simulation. The [Record] button lets your system run and
sample data. The [Fuzzy] button in the simulation’s window connects your developed
NeuroFuzzy glass sensor simulation with fuzzyTECH. The sensor should work properly for
most of the bottles. In order to enhance the performance of the sensor system, record a sample
file with more samples and repeat the development steps 6 to 9.

134
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

4.2.1. Clustering with fuzzyTECH

This section guides you through a simple clustering example with the
FuzzyCluster Module of fuzzyTECH. The example covers the basic steps it takes
to use clustering techniques as a means of data reduction.
An example of a simple mathematical function with one input and one output is
used to illustrate the use of the clustering module:
2
Output = 
Input 

 10 

For input values ranging from 0 to 100 with a step width of 10, the input and
output values are given in the file CLUSTER1.EXP located in the subdirectory
…\SAMPLES\NEUROFUZ\CLUSTER\. The following figure shows the
contents of this file.

Figure 92: The File CLUSTER1.EXP Contains 11 Data Samples Describing a


Simple Mathematical Function.

Training the
CLUSTER1.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 specify
the 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) terms
per output variable. Overwrite both values with “7” to create seven (7) terms
each for input and output variables. Overwrite the input variable range from the
proposed [0;100] to [-15;115] and accept all other proposed values to generate
the project.

135
Inform Software Corporation Chapter 4: NeuroFuzzy Design

Enable the Interactive debug mode and open a 3D Plot. Double-click on the
button 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”. Open
the Neuro Configuration dialog, select “Learn Methods:” to “RandomMethod”
and “Selection Mode:” to “Random”. In the group “Stop Conditions”, set the
value 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 with
an 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 in
CLUSTER1.EXP can be converted into fuzzy logic rules rather quickly by the
NeuroFuzzy module. Now, what would happen if many more data points were
available? The file CLUSTER2.DAT for example contains 100 data points
following the same mathematical function as the data points contained in
CLUSTER1.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 and
output. Hence, a significantly better representation of the mathematical function
as with the training data contained in CLUSTER1.EXP would almost be
impossible because of the granularity of the linguistic variables involved. Thus,
using file CLUSTER2.DAT instead of CLUSTER1.EXP would only slow down

136
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

the training process, but most likely does not deliver a better result. Note, with a
small problem such as used here for illustration, the NeuroFuzzy module still
delivers reasonable results, but if problems get more complex, using large data
files can result in prohibitive computational effort.

Figure 94: The File CLUSTER2.DAT Contains 100 Data Samples Describing
the Mathematical Function.

Clustering Data For these reasons, the data contained in CLUSTER2.DAT should be clustered to
typicals before used for NeuroFuzzy training. Start fuzzyTECH’s clustering
function by selecting “Tools/Cluster/IsodataCluster...” from the main menu of
fuzzyTECH. Specify the file CLUSTER2.DAT in the “Cluster Data from…”
dialog (…\SAMPLES\NEUROFUZ\CLUSTER). This opens the IsodataCluster
Configuration dialog.

Figure 95: The Isodata Cluster Configuration Dialog Lets You Specify Range,
Accuracy, and Usage of Each Variable.

137
Inform Software Corporation Chapter 4: NeuroFuzzy Design

The Isodata Cluster Configuration dialog contains a large list box that lists each
variable 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. In
order to change these values, select the variable in the list box and enter the new
values in the edit fields above the list box. Modify the accuracy of both variables
to 11.75%. Press the [Start] button to start clustering.

At the same time clustering is starting a Cluster Progress dialog (Figure 96) is
opened, 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 pressing
the [Esc] key on the keyboard. This opens another control dialog that lets you
continue, end, or reset clustering. While this dialog is open, you can work with
other programs.

100
80
60
40
20
0
0 20 40 60 80 100

Figure 97: The Output File of the Clustering Step, CLUSTER2.EXP


Contains Only the Typical Points of File CLUSTER2.DAT.

138
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

After clustering is completed, the “Write Typicals to…” dialog opens. Store the
typicals under the name CLUSTER2.EXP in the subdirectory
…\SAMPLES\NEUROFUZ\CLUSTER\ and confirm the following dialog, if
you wish to view the file. The previous figure shows the 16 data points that
IsodataCluster computed as typicals from the CLUSTER2.DAT file. The 16
typicals can now be used for NeuroFuzzy training to be converted into fuzzy
logic rules.
Removing
Redundant 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 the
data point (50, 25). All these data points can be replaced by a single typical using
a clustering method, because a single data point is sufficient for the NeuroFuzzy
training.

100
80
60
40
20
0
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 accuracy
of 3% was not large enough to remove all redundancy. If you cluster the file
CLUSTER3.DAT with an accuracy of 7% for all variables, IsodataCluster
removes all redundant data points. Determining the best accuracy setting for
IsodataCluster may require a few test cycles.

139
Inform Software Corporation Chapter 4: NeuroFuzzy Design

100
80
60
40
20
0
0 20 40 60 80 100

Figure 99: IsodataCluster Has Removed Most of the Redundant Data Points.

100
80
60
40
20
0
0 20 40 60 80 100

Figure 100: With an Accuracy Setting of 7%, IsodataCluster Removes All


Redundant Data Points.

Resolving Conflicts The FuzzyCluster Module can resolve conflicts during clustering if the “Check
Data Consistency” option is enabled in the IsodataCluster Configuration dialog.
Use the file CLUSTER6.DAT that contains the same samples as file
CLUSTER2.DAT plus two conflicting data points. The following figure
illustrates the contents of file CLUSTER6.DAT.

140
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

100
80
60
40
20
0
0 20 40 60 80 100

Figure 101: The File CLUSTER6.DAT Contains the Same Samples as


CLUSTER2.DAT, Plus Two Conflicting Data Points.

Activate “Tools/Cluster/IsodataCluster...” from the main menu, select the file


CLUSTER6.DAT, enable at first the “Check Data Consistency” option in the
IsodataCluster Configuration dialog, and set then the Accuracy of the input
variable to 2% and Accuracy of the output variable to 7%. When you start
clustering, the Resolve Data Discrepancy dialog opens (Figure 102).

Figure 102: The Resolve Data Discrepancy Dialog Opens


for Every Detected Pair of Conflicting Data Points.

The Resolve Data Discrepancy dialog opens for every conflicting pair of data
points. 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 same
typical, the outputs differ greatly from each other.

The buttons of the right side of the dialog show the options for resolving the
conflict. The upper two buttons let you select just one of the data points, causing
the clustering function to remove the other one from the data point set. If you
select one of these options, the other data point is automatically written to a Skip
file. The button [Use Both] leaves the conflicting pair of data points in the set,

141
Inform Software Corporation Chapter 4: NeuroFuzzy Design

whereas the button [Use Neither] removes both data points. The button [Skip
All] removes all conflicting data points that will be found while clustering,
which results in suppressing the automatic call for the Resolve Data Discrepancy
dialog. The button [Cancel] causes the clustering function to the further use of all
conflicting data points. [Cancel] is similar to having not enabled the “Check Data
Consistency” option in the IsodataCluster Configuration dialog at all.

Now select [Use #24] because data point #103 is wrong. The FuzzyCluster
module now prompts you for a file and location to which to write the data points
removed from the data sample while solving conflicts. Accept the proposed
filename and location. The Resolve Data Discrepancy dialog opens again and
displays the discrepancy between data points #85 and #102. Select [Use #85]
because data point #102 is wrong. Then, clustering proceeds as in the examples
from before.
Displaying Sample File
Contents 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 the
3D Plot analyzer. Just open the file DUMMY.FTL contained in the subdirectory
…\SAMPLES\NEUROFUZ\CLUSTER\ that contains two input variables named
Input and Output and the output variable DummyOut.

Figure 103: The 3D Plot Analyzer of fuzzyTECH Can Be Used to Plot


the 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 3D
Plot. 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 start
browsing the file CLUSTER6.DAT by clicking the button in the File Control
field of the File Recorder Window.

142
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 the
columns Input and Output, select “Insert/Chart” and select a scatter type of the
diagram). All graphs shown in this section about IsodataClustering have been
made this way.

FuzzyClustering In the previous section with the square function, an academic example of
clustering & training was used to show the usage of IsodataCluster computation.
The following example shows the fuzzy clustering approach by using real, raw
data for the design of a fuzzy logic system. Such raw data first needs to be
clustered to create a training data set of typicals. This data set is then used for
NeuroFuzzy training to create a fuzzy logic system. The raw data sample file is
contained 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 large
number of data points, they can hardly be plotted in a transparent fashion.

Configuration Because the variables Continuity, Inc_Exp, and Liquidity have different
interpretations, since as to how similar data points differ, select
“Tools/Cluster/FuzzyCluster…” from the main menu bar. The “Fuzzy Cluster
Configuration” dialog looks similar to the “Isodata Cluster Configuration”
dialog. However, the distance measure between two data points is defined by
fuzzy logic membership functions rather than by an accuracy measure.

Figure 104: The Fuzzy Cluster Configuration Dialog Lets You Define
Membership 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 are
considered to be completely similar and Delta describes the distance above
which two values for the variable are considered to be completely dissimilar. For

143
Inform Software Corporation Chapter 4: NeuroFuzzy Design

the variable Inc_Exp, enter a Delta of 5 and an Epsilon of 3. The resulting


membership function is shown in the Membership Function Fuzzy Clustering
group of the Configuration dialog. For the variable Continuity, enter a Delta of
10 and an Epsilon of 5. The resulting membership function is:

For the variable Liquidity, enter both a Delta and an Epsilon of 3. The resulting
membership function is:

This type of membership function does not allow any “fuzziness”: the interval in
which two values of Liquidity are considered similar is as crisp as with
IsodataCluster. 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 “FuzzyCluster
Configuration” dialog. On a Pentium™100 class PC running Windows95™,
FuzzyCluster reduces the 500 sample data file to 72 typicals. Store the typicals
as CREDIT4.EXP, open the file CREDIT1.FTL in fuzzyTECH, and train the
fuzzy logic system using the RandomMethod with Selection Mode: Random. If
you have the 3D Plot open with Background Paint and Trace enabled, you can
follow the NeuroFuzzy Module approximating the typicals by modifying the
rules. Note, the NeuroFuzzy Module only reaches an average error in the order
of 10%. This is due to the fact that real world data was used; it still contains
inconsistencies or typicals that cannot be represented by just three (3) terms per
input variable. You can repeat FuzzyCluster with the following settings for Delta
and Epsilon to use an even smaller set of typicals:

Variable Delta Epsilon


Inc_Exp 10 5
Continuity 20 10
Liquidity 5 5

This setting assumes that the variable Continuity stems from a calculation of the
balance fluctuation of the applicant. Thus, the information this variable delivers
to the assessment is rather “fuzzy,” and the membership function has been
widened. Also, the membership functions for Inc_Exp and Liquidity are defined
wider. When you use FuzzyCluster with these settings, the generated set of
typicals contains 26 data points.

144
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Clustering of Large
Data 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 in
the directory in which you installed fuzzyTECH. Simply call CLUSTER.EXE
from the file manager or install it in a program group. When installed in a
program group, FuzzyCluster shows its icon:

Because FuzzyCluster is a separate program, multi-tasking operating systems


can run it in the background. When called directly, FuzzyCluster starts with its
own main window. This window, however, does not contain new functions; it
primarily lets you select the clustering method and activate the online help
system for FuzzyCluster.

145
Inform Software Corporation Chapter 5: Fuzzy Primer

Fuzzy logic is an innovative technology that allows a description of the desired


system behavior by using everyday spoken language. Applications range from
consumer electronic goods and household appliances to auto electronics, process
engineering, and industrial automation solutions. Many successful applications
are achieved not by conventional mathematical modeling, but with fuzzy logic
and its everyday language. Fuzzy logic “fills” ambiguous descriptors such as
permanent, light, or above average with crisp mathematical models so they can
be 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 of
modern computers – is based upon its principles of precision. Despite the
advantages of its accuracy, classical Boolean Logic has a major drawback: it
cannot reproduce human thought patterns.

A Natural Logic Fuzzy logic is a continuous logic patterned after the approximate reasoning of
human beings. As a theoretical mathematical discipline, fuzzy logic is designed
to react to continuously changing variables and challenge traditional logic by not
being restricted to the conventional binary computer values of 0 and 1. Instead, it
allows for partial and multi-valued truths. This discipline is especially
advantageous for problems that cannot be easily represented by mathematical
modeling because data is either unavailable, incomplete, or the process is too
complex.

The real-world language used in fuzzy control allows programmers to


incorporate the ambiguous, approximate nature of human logic into computers.
The use of linguistic modeling – instead of mathematical modeling – greatly
enhances system transparency and modification potential. It leads to quick
development cycles, easy programming and accurate control.

146
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

5.1. Fuzzy Logic

The first section of this chapter gives a short history of fuzzy logic. If you are not
interested in the history of fuzzy logic, skip this section and go on to Section
5.1.2 and its introduction to the basic concepts of fuzzy logic or Section 5.1.3
about 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 to
1965. It was written in the U.S. by Lotfi Zadeh, Professor of Systems Theory at
the University of California, Berkeley. From there, the history of fuzzy logic
follows 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 in
Europe. At Queen Mary College in London, England, Ebrahim Mamdani used
fuzzy logic to control a steam generator that he could not get under control with
conventional techniques. At the RWTH University of Aachen, Germany, Hans-
Jürgen Zimmermann used fuzzy logic for decision support systems. Other
industrial applications, such as the control of a cement kiln, followed as a result
of 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 fuzzy
logic with terms such as “multi-valued logic“ or “continuous logic.”

Starting around 1980, fuzzy logic gained more momentum in decision support
and data analysis applications in Europe. Many of the more advanced fuzzy logic
technologies were developed in application and research projects. Most
developments were triggered by empirical research regarding how well fuzzy
logic models the human decision and evaluation processes.

Fuzzy Logic in Japan Inspired by the initial European fuzzy logic applications, the first Japanese
companies started to use fuzzy logic in control engineering after 1980. Due to
the poor computational performance of the first fuzzy logic algorithms on
standard hardware, most applications looked into dedicated fuzzy logic
hardware. Some of the first fuzzy logic applications were a water treatment plant
by Fuji Electric in 1983 and a subway system by Hitachi which was opened
in 1987. The initial applications raised much interest in Japan, and there were a
number 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 most
out of this system. Fuzzy logic supports the generation of a fast prototype and

147
Inform Software Corporation Chapter 5: Fuzzy Primer

incremental optimization. Second, a fuzzy logic system always remains plain and
simple to understand. The “intelligence” of a system is not buried in differential
equations or source code. Since Japanese engineers generally develop systems in
a team where everybody desires to understand the underlying behavior of the
system, fuzzy logic delivered a more transparent means of system design. Also,
due to the nature of their culture, Japanese Engineers are not preoccupied with
Boolean logic. Nor does their language portray a negative connotation of the
word “fuzzy.”

Technological factors were only part of the reason why fuzzy logic came to be
used so broadly in such a short time. Another reason is that the Japanese
government joined forces with their large corporations to set up technology
transfer programs. After the IFSA’s (International Fuzzy Systems Association’s)
Japanese chapter was founded in 1985 to support fuzzy research, several new
industry 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 for
intelligent control or data processing. Photo and video cameras use fuzzy logic to
put the expertise of photographers in their control. Mitsubishi announced the
world’s first car in which every control system is based on fuzzy logic while
most other Japanese car manufacturers use fuzzy logic in at least some of their
components. In factory automation, Omron Corporation claims more than 350
patents. Fuzzy logic control also optimizes many chemical and biological
processes.

Fuzzy Logic in Europe In the late 80’s, major European corporations realized that they had almost lost
another key technology to the Japanese. They started a major effort in promoting
fuzzy logic in their applications. Since then, more than 200 successful fuzzy
logic mass market products have been launched in Europe. Additionally, an
uncounted number of industrial automation and process control applications have
successfully used fuzzy logic. The fuzzy logic enhanced products include home
appliances that realize major savings in energy and water consumption with no
added production costs, as well as many automotive applications. The industrial
automation 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 now
considered a “standard” design technique and has gained broad acceptance in the
engineering community. One of the supporting factors was the advent of
advanced fuzzy logic software design tools that support all development stages
of a fuzzy logic design. Some of the fuzzy logic design tool software houses

148
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

teamed up with major semiconductor and industrial automation equipment


manufacturers to provide a seamless development environment for most target
hardware platforms.

Fuzzy Logic in the U.S. Now that fuzzy logic has made the trip from the U.S. to Japan via Europe, it’s
coming back to the U.S. the same way. Recently, fuzzy logic has attracted a lot
of attention in the U.S., especially among companies who are in heavy
competition with both Asia and Europe. However, many argue whether this
uphill battle can be won. Some would argue yes, as there are many factors in
favor of the U.S. First, many applications completed in Japan involve products in
industries which U.S. manufacturers do not compete with the Japanese. Since
basically no major U.S. entertainment electronics manufacturer is left on the
world market, the use of fuzzy logic in camcorders, cameras, and hi-fi equipment
is a competitive factor mainly between Japanese corporations. In Europe, most
applications are in industrial automation, mostly due to their very high cost of
labor. In other application areas, such as automotive engineering, the U.S. faces
tough 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 support
systems, memory cache, and hard disk controllers as well as compression
algorithms for speech and video. Also, telecommunications applications such as
echo cancellation, network routing, and speech recognition benefit from fuzzy
logic. Combine this with the U.S. manufacturers’ muscle in communication
equipment, office automation, and computer software, and you can see a fair
chance that the U.S. can benefit from fuzzy logic technologies. Another factor is
the strong research background in neural net technologies in the U.S. All fuzzy
logic experts agree that the clever combination of neural network technologies
and 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 is
essential to understanding how fuzzy logic systems work. Advanced fuzzy logic
technologies are treated in Section 5.1.3.
Mathematical Principles
of Uncertainty Many mathematical disciplines deal with the description of uncertainties, such as
probability theory, information theory, and fuzzy set theory. It is most
convenient 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 a
certain event. Consider Statement 1:

149
Inform Software Corporation Chapter 5: Fuzzy Primer

Statement 1:
The probability of hitting the target is 0.8

The event itself – hitting the target – is well defined. Close shave, no cigar. The
uncertainty in this statement is whether the target is hit or not. This uncertainty is
quantified by a degree of probability. In the case of Statement 1, the probability
is 0.8. Statements like this can be processed and combined with other statements
using stochastic methods, such as the Bayesian calculus of conditional
probability.

Lexical Uncertainty A different type of uncertainty lies in human languages, the so-called lexical
uncertainty. This type of uncertainty deals with the imprecision that is inherent in
most words humans use to evaluate concepts and derive conclusions. Consider
words such as “tall men”, “hot days”, or “stable currencies”, for which there are
no 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 context
and the background of a person making an evaluation plays a role. Even for one
single person, an exact definition on whether a man is considered “tall” does not
exist. No law in existence determines the threshold above which a man is
conceived as “tall.” This would not make sense anyhow, because a law that
defines all men taller than 6’ 4” to be “tall” would imply that a man of 6’ 3” is
not tall at all. The science that deals with the way humans evaluate concepts and
derive decisions is psycholinguistics. It has been proven that humans use words
as “subjective categories” to classify qualities such as “height” or “temperature.”
Using these subjective categories, elements of the real world are evaluated by the
degree to which they satisfy the criteria. Even though most concepts used are not
precisely defined, humans can use them for quite complex evaluations and
decisions that are based on many different factors. By using abstraction and by
thinking in analogies, a few sentences can describe complex contexts that would
be 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 are


significant differences. First, the event itself is not clearly defined. For some
companies, a successful financial year means that they deferred bankruptcy, for
others it means to have surpassed last years profit. For one company, there may
be no fixed threshold that exists to define whether a fiscal year is considered to
be successful or not. Hence, the concept of a “successful fiscal year” is a
subjective category.

150
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Another difference lies in the definition of expressing probability. While in


Statement 1, the probability is expressed in a mathematical sense, Statement 2
does not quantify a probability. If someone expresses that a certain type of
airplane probably has problems, the actual probability can well be lower than
10%, still justifying this judgment. If someone expresses that the food in a
certain expensive restaurant is probably good, the actual probability can well be
higher than 90%. Hence, the expression of probability in Statement 2 is a
perceived probability rather than a mathematically defined probability as in
Statement 1. In Statement 2, the expression of probability is also a subjective
category much like “tall men.”
Modeling
Linguistic 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 not
have quantitative contents, humans can use them successfully for complex
evaluations. In many cases, the uncertainty that lies in the definition of the words
we use adds a certain flexibility. Consider for illustration the annual wage
increase negotiations between unions and industry. Both want to achieve the
same goal: an appropriate wage increase. The problem starts when they have to
express in percentage, what they mean by “appropriate.”

The flexibility that lies in the words and statements we employ is used widely in
our society. In most western societies, the legal system consists of a certain
number of laws that each describe a different situation. For example, one law
could express that theft of a car should be punished with 2 years of prison.
Another law could define diminished responsibility. For instance, the judge has
to decide in a court case the exact number of days in prison for a thief. The thief
stole a car while under the influence of a 0.1% blood alcohol level, plus he had a
bad childhood and his wife left him the day before. Since for each “real” case a
specific law does not exist, the judge must combine all applying laws to derive a
fair decision. This is only possible due to the flexibility in the definition of the
words and statements used in each law.
Fuzzy Logic as
Human 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 a
few distinct cases. These rules are discrete points in the continuum of possible
cases and humans approximate between them. Hence, for a given situation,
humans combine rules that describe similar situations. This approximation is
possible due to the flexibility in the definition of the words that constitute the
rules. Likewise, abstraction and thinking in analogies are only rendered possible
by the flexibility of “human logic.”

A mathematical model is required to implement this human logic in engineering


solutions. Fuzzy logic has been developed as such a mathematical model. It
allows representation of human decision and evaluation processes in algorithmic
form. There are limits to what fuzzy logic can do. The full scope of human
thinking, fantasy, and creativity can not be mimicked with fuzzy logic. However,

151
Inform Software Corporation Chapter 5: Fuzzy Primer

fuzzy logic can derive a solution for a given case out of rules that have been
defined for similar cases. So, if you can describe the desired performance of a
technical system for certain distinctive cases by rules, fuzzy logic can effectively
put 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 of
uncertainty can be expressed with probability theory. Rather than embarking on
a discussion of whether this is true, consider Example 1. If you find such a
statement in a medical textbook and want to implement it in a system, it looks
very easy at first glance. Suppose you have a patient that suffers from strong
fever, has no yellowish colored skin, but suffers from nausea. You can compute
the probability for a hepatitis infection using Bayesian calculus.

Example 1:
“Patients suffering from hepatitis show in 60% of all cases strong fever, in
45% 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 an
undisputed, single answer. Even if most doctors agree that if the threshold is at
about 102°F (39°C), this does not mean that a patient with temperature of
101.9°F does not have a strong fever at all while another patient with a
temperature of 102°F has a strong fever.

If a threshold for “strong fever” does exist, the reverse must also exist. This
implies that a very precisely measured body temperature results in a very precise
diagnosis. If this was true, you could measure your body temperature up to the
fifth significant figure and expect a doctor to tell you, based on this very precise
information, the disease from which you suffer. In reality, a doctor does not get a
competent diagnosis from the precision of a single parameter, but rather from the
evaluation many symptom parameters. Here, the precision of each parameter
does not, for the most part, infer the quality of the result. If the doctor asks you
whether you sweat at night, he is not interested in the precise amount but rather a
tendency.

As Example 1 illustrates, stochastic uncertainty and linguistic uncertainty are of


a different nature. Stochastic uncertainty deals with the uncertainty of whether a
certain event will take place and probability theory lets you model this. In
contrast, lexical uncertainty deals with the uncertainty of the definition of the
event itself. Probability theory cannot be used to model this since the
combination of subjective categories in human decision making processes does
not follow its axioms.

152
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

A “fuzzy” Set How can you model linguistic uncertainty adequately? If a doctor does not have
a precise threshold in mind when evaluating whether a patient suffers from
“strong fever,” how does it work? Psycholinguistic research has shown that a
doctor would compare the patient with two “prototypes.” On one side exists the
“perfect” strong fever patient: pale, sweating, and with chills. On the other side
exists the “perfect” patient without a fever, who does not show any signs of fever
at all. Comparing with these two extremes, a doctor evaluates where in-between
the two his patient ranks.

How can this be modeled mathematically? Consider set theory, where you would
first define the set of all patients with strong fever. Then you define a
mathematical function that indicates for each patient whether he is a member of
this set or not. In conventional math, this indicator function has to uniquely
identify each patient as member or non-member of the set. Figure 105 gives an
example of the set of “patients with strong fever” (black area), where the
indicator 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 patient
matches the prototype of a strong fever patient. Figure 106 gives an example of a
set where certain elements can also be “more-or-less” members. The “shade of
gray” indicates the degree to which the body temperature belongs to the set of
strong fever. This “shade of gray” that makes the black area in Figure 105 looks
as 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 to


which 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.

153
Inform Software Corporation Chapter 5: Fuzzy Primer

The range of µ is from 0 to 1, representing absolutely no membership to the set


and complete membership respectively.

Figure 106: The “fuzzy” Set of “patient with strong fever” Also
Allows Elements That Are “more-or-less” Members of the Set.

As a temperature of 94°F would have no membership at all, a temperature of


110°F would have complete membership. Temperatures between are members of
the 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 and
a temperature of 101.9°F are evaluated differently, but just slightly and not
relative to a crisp threshold. How to define membership functions for a certain
application is handled in Section 3.1.2.1.

Note: Fuzzy sets are a true generalization of conventional sets. The cases µ=0 and µ=1
of 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 is
called “fuzzy logic.” Here, the degree of membership in a set becomes the degree
of truth of a statement. For example, the expression, “the patient has a strong
fever,” would be true to the degree of 0.65 for a temperature of 104°F.

154
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 107: The Degree µ SF(x) to Which a Temperature x Is


Considered to Belong to the Set of Patients With “Strong Fever” Can
Be 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, normal
temperature, and low temperature exist. These are called “linguistic terms” and
represent the possible values of a linguistic variable. Figure 108 plots the
membership functions of all terms of the linguistic variable “fever” into the same
graph.

Figure 108: A Linguistic Variable Translates Real Values Into Linguistic Values.

This linguistic variable now allows the translation of a measured body


temperature, given in Fahrenheit, into its linguistic description. For example, a
body temperature of 100°F would be evaluated as “pretty much raised
temperature, and just slightly high fever.” How to use this technology in
engineering 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 been
developed. This book is restricted to the so-called “rule based” fuzzy logic
technologies. Nearly all recent fuzzy logic applications are based on this
methodology. This section gives a brief introduction to the basic technology of
rule based fuzzy logic systems using a case study in container crane control. A
detailed description of the fuzzy logic design methodology is given in
Chapter 3.

155
Inform Software Corporation Chapter 5: Fuzzy Primer

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 are
mounted to the crane head. The crane head moves on a horizontal track. When a
container is picked up and the crane head starts to move, the container begins to
sway (Figure 109). While sway is no problem during transportation, a swaying
container cannot be released.

Two trivial ways to solve this problem exist. One is to position the crane head
exactly over the target position, then wait until the sway dampens to an
acceptable level. On a calm day, this will eventually happen, but it takes far too
much time. A container ship needs to be loaded and unloaded in a minimum
amount of time for cost reasons. The other trivial option is to pick up the
container and move it so slow that no sway ever occurs. Again, this may work on
a calm day, but it takes far too much time. An alternative is to build container
cranes 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 the
solution.

Figure 109: Since the Container Is Linked to the Crane Head With a Flexible
Cable, the Container Starts to Sway When the Crane Moves. The Fuzzy Logic
Controller Compensates For This Sway Using the Human Operator’s
Experience (Screen Shot Of the Software Simulation).

For these reasons, most container cranes use a continuous speed control for the
crane motor under the direction of a human operator. The operator has to
simultaneously compensate for the sway while ensuring the target position is
reached in a minimum amount of time. This task is not easy, but a skilled
operator is capable of achieving acceptable results.

156
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Control Model
Alternatives 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 successful


because the control task is non-linear. Sway minimization is important only
when the container is close to the target. Other engineers have tried to derive a
mathematical model of the crane to use in a model-based controller. This results
in 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 Control
Strategy 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 that
any 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 container
sways. Depending on the reaction, he adjusts motor power to get the container a
little behind the crane head. In this position, maximum speed can be reached
with minimum sway.

Getting closer to the target position, the operator reduces motor power or even
applies negative power to brake. As the crane gets very close and power is
further reduced or reversed, the container gets a little ahead of the crane head
until the container has almost reached target position. Finally, the motor power is
increased so that the crane head is over the target position and sway is zero. No
differential equations are required for this operation, and disturbances and non-
linearities are compensated by the operator’s observance of the container’s
position.

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.

157
Inform Software Corporation Chapter 5: Fuzzy Primer

Implementing a Linguistic
Control 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 these
inputs to describe the current condition of the crane, the five rules of thumb can
be translated to an “if-then” format. Note that rule 3 has been translated into two
rules to fit the if-then format.

1. IF Distance = far AND Angle = zero THEN Power = pos_medium


2. IF Distance = far AND Angle = neg_small THEN Power = pos_high
3. IF Distance = close AND Angle = neg_small THEN Power =pos_medium
IF Distance = medium AND Angle = neg_big THEN Power = pos_medium
4. IF Distance = zero AND Angle = zero THEN Power = zero
If-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 of
Angle. The conditions are combined by AND, representing the fact that both
conditions 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 using
a programming language to code the “if-then” rules. The problem with this
method 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 with
the definition of “strong fever” discussed in the previous section. This is the
reason you can use fuzzy logic to implement a linguistic control strategy. The
following shows you step by step, how to design a controller using fuzzy logic
techniques.
Structure of a Fuzzy Logic
Crane Controller Figure 110 shows the complete structure of a fuzzy logic controller. First, all
sensor signals must be translated into linguistic variables. For example, a
measured distance of 12 yards may be translated into the linguistic value “still
medium, just slightly far.” This step is called “fuzzification,” as it uses fuzzy sets
for translating real variable values into linguistic variable values.

Once all input variable values are translated into the respective linguistic variable
values, the so-called “fuzzy inference“ step evaluates the set of if-then rules that
define system behavior. The result of this is again a linguistic value for the
output linguistic variable. For example, the linguistic result for Power could be
“a little less than medium.” The so-called “defuzzification” step translates this
linguistic result into a real value that represents the power setting of the motor in
kilowatts.

158
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 110: Structure of a Fuzzy Logic Controller For the Container Crane. The
Fuzzy Logic System Consists of Three Steps: Fuzzification, Fuzzy Inference, and
Defuzzification.

Fuzzification using
Linguistic 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 called
terms 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 Target
Position

159
Inform Software Corporation Chapter 5: Fuzzy Primer

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 head
to the target position is 12 yards and the Angle of the container is -30°. Example
4 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.00
zero to the degree of 0.00
close to the degree of 0.00
medium to the degree of 0.83
far 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.4
neg_small to the degree of 0.6
zero to the degree of 0.0
pos_small to the degree of 0.0
pos_big to the degree of 0.0

Fuzzy-Inference
using 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 and
compute the value of the output linguistic variable. Example 5 shows a subset of
three rules for illustration:

160
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Example 5:
Rule 1: IF Distance = medium AND Angle = neg_small
THEN Power = pos_high
Rule 2: IF Distance = medium AND Angle = neg_big
THEN Power = pos_medium
Rule 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 current
situation or not. In conventional logic, the combination of the two conditions can
be computed by the Boolean AND as shown in the following table:

A B A∧B
0 0 0
0 1 0
1 0 0
1 1 1

In the case of fuzzy logic, the Boolean AND cannot be used as it cannot cope
with conditions that are more-or-less true. Hence, new operators had to be
defined for fuzzy logic to represent logical connectives such as AND, OR, and
NOT. 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 logic
applications.

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 rules
of Example 5 using values from Example 4 can be computed as shown in
Example 7. The results are the degrees of truth of the IF parts and thus indicate
how adequate each rule is for the current situation.

161
Inform Software Corporation Chapter 5: Fuzzy Primer

Example 7:
Rule 1: min{ 0,83; 0.6} = 0.6
Rule 2: min{ 0.83; 0.4 } = 0.4
Rule 3: min{ 0.17; 0.6} = 0.17

Each rule defines an action to be taken in the THEN part. The degree to which
the 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 IF
part. Therefore, Rule 1 results dictate the action “Power = pos_high” to the
degree 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 truth
of the rule, however, in some cases it is advantageous to let the rules themselves
be fuzzy. In the composition step, the degree of truth of the IF part of the rule is
multiplied by a weighting factor. This factor represents the weight of the rule in
relation 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 Fuzzy
Associative Memories or the Compositional Rule of Inference. In this example
fuzzy logic inference, a weight of 1.0 is multiplied with the aggregation result in
the composition step. In fuzzyTECH this weight factor is referred to as the DoS
of 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 of
truth, these results must be combined before the defuzzification step. In a fuzzy
logic rule base, rules are defined alternatively: either Rule 1 is true, OR Rule 2 is
true, OR Rule 3 is true, OR ... Using the fuzzy logic operators as listed in the
example, the OR can be represented mathematically by the max operator. The
final result of the fuzzy logic inference for the linguistic variable Power is shown
in Example 8.

Example 8:
For the linguistic variable Power, the fuzzy inference result is:
neg_high to the degree of 0.0
neg_medium to the degree of 0.0
zero to the degree of 0.0
pos_medium to the degree of 0.4
pos_high to the degree of 0.6 ( = max {0.6; 0.17} )

This fuzzy inference method (Example 8) is sometimes called Max/Min or


Max/PROD inference. Advanced inference methods and fuzzy logic operators
are discussed in the following section. Experience with the optimization of fuzzy
logic systems has shown that it can be necessary to associate weights to each

162
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

rule. In Section 3.1.2.7 you find how if-then rules and weights can be defined for
a given application.
Defuzzification Using
Linguistic 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 translated
into a real value. This step is called defuzzification. The relation between
linguistic values and corresponding real values is always given by the
membership function definitions. Figure 113 plots the membership functions for
the linguistic variable “Power”.

Figure 113: Linguistic Variable “Power”.

The result of the fuzzy inference given in Example 8 is both fuzzy and
ambiguous since two different actions have non-zero truth degrees. How can two
conflicting actions that are defined in fuzzy sets be combined to a “crisp” real-
valued output for motor power? Consider how humans solve the problem of
combining two fuzzy and conflicting actions in Example 9.

Example 9:
Consider yourself in an apartment house at 11 p.m. You would like to listen
to some music such as Wagner or Nirvana, music that requires some volume
to be fun. On the other hand, your neighbors have already suffered quite a bit
from 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 order
to find a volume that compromises the two goals, you could turn on the
music and tune the volume until you balanced out the two goals.

163
Inform Software Corporation Chapter 5: Fuzzy Primer

As fuzzy logic mimics the human decision and evaluation process, a good
defuzzification method should also approximate this approach. Most
defuzzification 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 find
the maximum of the respective membership function. If the membership function
has a maximizing interval, the median of the maximizing set is chosen. For the
linguistic variable Power as shown in Figure 113, the computation of the typical
values is illustrated in Figure 114. Here, the gray arrows point to the horizontal
position of the typical values.

Figure 114: In the First Step of Defuzzification, the Typical Value For Each
Term 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 is
computed. Figure 115 illustrates this step. A “weight” proportional to the degree
to which the action is true is placed at the horizontal position of the typical
values. The weights are shown as the heights of the black arrows over the gray
arrows. The compromise crisp value is then determined by balancing the weights
“on a pen tip.” In the example, the position that balances the fuzzy inference
result is at the position of 10 kilowatts. This value is considered the best
compromise and is outputted to the motor.

This method of defuzzification is called “Center-of-Maximum“ and is identical


to the “Center-of-Gravity“ method using singleton membership functions. These
defuzzification methods are used in most fuzzy logic implementations. Other
defuzzification methods are introduced and compared in Section 0.

164
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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-world


situations, 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 superfluous
and time-consuming. Fuzzy logic expands the strict true/false classifications of
traditional logic and incorporates values such as mostly true and totally wrong. It
accommodates the anomalies of human thought patterns by allowing a situation
to 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 to
represent the linguistic elements of the rules. Technical quantities, represented by
linguistic variables, allow expressions to be more or less true in one or even
multiple sets. Linguistic rules are formed using operators that represent a
linguistic AND and OR. Finally, a computation of the applicability of the rules
themselves – represented by a linguistic IF...THEN expression – is performed.
This step is called fuzzy inference. In control applications, specialized
fuzzification and defuzzification methods link the entire system to the process.

Fuzzy Control In control applications, fuzzy logic is used to devise a control strategy using
every day spoken language. The goal of any control strategy is to obtain a
desired output, like crane motor power, from given inputs such as crane position
or load angle. Because cranes cannot interpret linguistic concepts, two-way
translations between crisp values and linguistic concepts are necessary. Thus, a
fuzzy logic process controller is created in three steps:

Fuzzification Crisp input values are translated into linguistic concepts, which are represented
by fuzzy sets. These concepts are called linguistic variables. Degrees of
membership for all input values are assigned.

165
Inform Software Corporation Chapter 5: Fuzzy Primer

Example: To what extent is 60 Yards considered far?

Fuzzy Rule Inference IF...THEN rules that define the relationship between the linguistic variables are
defined. 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 a
crisp 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 following
sections of this chapter.

5.2.1. Fuzzification

Linguistic Variable In fuzzy logic, the different values for a given linguistic variable represent
concepts, not numbers. Linguistic values (also called terms or labels) associated
with 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 value
between 0 and 1. This value is called the degree of membership. Degree of
membership 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. Degree
of membership values between 0 and 1 represent partial membership, thus
allowing for computations that are partly true and nearly false – a task which is
impossible using conventional logic. In fuzzy logic, a degree of membership is
usually 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 a
function known as a membership function (MBF). Typically, technical quantities
are represented on the horizontal axis of the function and membership degrees on
the vertical. The technical quantity is called the base variable and represents the
universe of discourse.

166
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 116: Membership Functions for “Distance”.

Standard MBFs Although scientific publications have suggested many different types of
membership functions for fuzzy logic, standard membership functions are used
in 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. The


membership degree of a base variable value as given by its piecewise linear
membership 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 Computation
of MBFs For microcontrollers without fast multiplication and division capabilities, some
fuzzyTECH Editions (see Table 2 of Section 9.4) offer an approximation of this
method called Fast Computation of MBF, which can be selected in the dialog
Project Options: Global.

167
Inform Software Corporation Chapter 5: Fuzzy Primer

Figure 118: Standard Membership Function Definition


With Two Points and Two Slope Values.

The method uses only two definition points and two fixed integer slope values to
reduce code size and computing effort (Figure 118). The method computes a
membership 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: µ =0
case 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 in


fuzzyTECH automatically modifies the MBF to a feasible definition by moving
any defined membership function point to the closest appropriate value.
Definition points 1 and 3 can be positioned as desired – restricted only by the
resolution of the base variable. However, definition points 2 and 4 can only be
positioned so that the resulting slope can be represented by integer numbers.
Look up MBF on
Standard 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-bit
microcontrollers. On the other hand, due to the large ROM requirement for look
up tables, only microcontrollers which can address external ROM would benefit

168
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

from this option. Hence, using look up tables for fuzzification is only supported
by the MCU-51Edition. The MCU-51 allows Look up MBF, Compute MBF, and
Fast Fuzzification with Standard MBF Types.

S-Shaped MBFs S-shaped MBFs are not available for all fuzzyTECH editions (refer to Table 2 of
Section 9.4). Scientific studies based on psycholinguistic research about the
human classification of continuous variables propose an alternative to these four
standard MBFs. From these studies, four axioms relating to membership
functions were derived:

1. µ(x) is continuous over X:


No infinitesimally small change of the base variable can result in a step
in the membership degree.
2. d(µ(x)) / dx is continuous over X:
No infinitesimally small change of the base variable can result in a step
in 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 step
in 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 base
variable has to be minimal for the definition of µ(x).

µ is the degree of membership; µ(x) the membership function; X the universe of


the 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 the
intervals 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 the
interpolation is S-shaped, rather than linear. In fuzzyTECH, S-shape membership
functions 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 in


fuzzyTECH. Note, S-shape membership functions require more run-time code
and computation time when they are not stored as look-up tables. S-shape
membership functions are not supported by all fuzzyTECH Editions.

169
Inform Software Corporation Chapter 5: Fuzzy Primer

Figure 119: S-shaped Membership Functions (Symmetrical).

Arbitrary MBFs While the majority of applications use standard MBFs (not S-shaped), some
membership function derivation methods and adaptation techniques do require
more general functions. For the most simple design methodology of these MBF
types and for the most efficient run-time code representation, arbitrary
membership 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 four
point definitions for all types of Standard MBFs to optimize code size and speed.
The fuzzyTECH Professional and Online Editions also allow MBF definitions
using linear shapes with more than four definition points rather than using
different interpolation procedures. In these Editions, the optimizing code
generator always picks the most effective algorithm. For example, if you are
only using Standard MBFs, the Professional and Online Editions use the same
algorithm as the MCU Editions.

Note: the Linguistic Variable editor in fuzzyTECH enforces the use of feasible
shape definitions. Once the membership degrees of all terms have been
evaluated, the controller strategy can be computed within the fuzzy logic
inference.

170
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

5.2.2. Fuzzy Rule Inference

Most fuzzy logic based systems use production rules to represent the
relationships among the linguistic variables and to derive actions from sensor
inputs. Production rules consist of a precondition (IF-part) and a consequence
(THEN-part). The IF-part can consist of more than one precondition linked
together by linguistic conjunctions like AND and OR.

Fuzzy Rule Inference The computation of fuzzy rules is called fuzzy rule inference. The inference is a
calculus consisting of the steps: aggregation, composition and, if necessary,
result aggregation. The first step of the fuzzy inference, aggregation, determines
the degree to which the complete IF part of the rule is fulfilled. Special fuzzy
operators are used to aggregate the degrees of support of the various
preconditions.

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 often
appropriate in small control applications. Sometimes other kinds of operators are
needed to signify the relationship of the different parts of the conditions. While
all fuzzyTECH Editions support Min and MAX operators, some editions also
support 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)
n
Min-Avg: µ IF = λ * mini (µ i ) + (1-λ) * Σ (µ i) / i
i=0
n 1-γ n γ
GAMMA: µ IF = ( ∏ (µ i )) * (1- ∏ (1-µ i))
i=0 i=0

171
Inform Software Corporation Chapter 5: Fuzzy Primer

MAX-MIN Inference The second calculation step of each production rule (composition) uses the
support of the precondition to calculate the support of the consequence. In
standard MAX-Min or MAX-PROD (sometimes called MAX-DOT) inference
methods, 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 often
consists of arbitrary rule addition and deletion. This method can result in a
clumsy trial-and-error approach, since the individual importance of a rule can be
expressed only as a 0 or 1. For this reason, most fuzzyTECH Editions support an
advanced inference method, the Fuzzy Associative Map inference, or FAM.
With FAM, each rule is assigned a Degree of Support representing the individual
importance of the rule. Rules themselves can be “fuzzy” – meaning, with a
support between 0 and 1.

The support of a consequence is calculated by linking the support of the entire


condition with the Degree of Support by a composition operator. Usually, the
product operator is used as the composition operator because then the Degree of
Support 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 must
aggregate the results of these rules. A result aggregation step determines the
maximum degree of support for each consequences which is used for all further
processing.

BSUM vs. MAX For the Result Aggregation, you may either select the MAX operator or the
BSUM (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 ))

172
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

5.2.3. Defuzzification

The result produced from the evaluation of fuzzy rules is, of course, fuzzy. In the
previous example, the result could be linguistically expressed as “mostly
pos_small but also “slightly zero.” Naturally, a crane motor cannot interpret
such a linguistic command. Membership functions are used to retranslate the
fuzzy output into a crisp value. This translation is known as defuzzification and
can be performed using several methods.

CoM Defuzzification Because more than one output term can be evaluated as valid, the defuzzification
method must compromise between the different results. The Center-of-
Maximum Method (CoM) does this by computing a crisp output as a weighted
average 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 the
gray arrows and the inference result is shown by the height of the black bar in
the 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 * YJ)
Y= = 18.1 KW.
ΣJ µ RESULT,TERM , J

173
Inform Software Corporation Chapter 5: Fuzzy Primer

MoM Defuzzification Some fuzzyTECH Editions support other defuzzification methods as well (refer
to 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 of
support. If the maximum is not unique (like in a Pi-shaped MBF), the mean of
the maximizing interval is computed. Figure 122 illustrates the MoM
defuzzification 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 the
most frequently used defuzzification method in fuzzy systems. This computation
method is not available for all fuzzyTECH Editions (refer to Table 3 of Section
9.4). With singleton membership functions, CoA and CoM defuzzification are
identical. Most CoA implementations are only approximations since they neglect
overlapping and can be represented with the CoM defuzzification method.

The CoA defuzzification supported by fuzzyTECH is not an approximation as it


uses numerical integration for the computation of the areas. Although
specification of the number of iterations used for numerical integration is
possible, the real CoA defuzzification is much slower than an approximated CoA
defuzzification, i.e., CoM, because it is computed during runtime. Figure 123
illustrates the CoA defuzzification process.

174
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 123: Defuzzification With Center-of-Area

Comparisons While the CoM and CoA defuzzification methods result in the “best compromise
solution,” MoM results in the “most plausible solution.” In control applications,
CoM is most commonly used because the output value represents the best
compromise of all inferred results. MoM is often used in pattern recognition and
classification applications as a plausible solution is most appropriate. Scientific
literature has suggested many other defuzzification strategies that have rarely
been used in industrial applications.
Hyper CoM
Defuzzification 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 many
applications, not only positive experience in the form of recommendations is of
importance, but also negative experience in the form of warnings and
prohibitions. In order to avoid undesirable operating situations (especially in the
interest of safety) or unacceptable product qualities, for protecting facilities and
cutting costs it is essential to adhere strictly to certain prohibitions or to give
appropriate heed to certain warnings. Using conventional type fuzzy controllers,
it is - in principle – possible to reproduce previously known transfer
characteristics at will. However, these cannot be used to observe warnings or
prohibitions in a systematic or transparent manner as a means of generating
favorable transfer characteristics.

Figure 124: The Hyper CoM defuzzification method

175
Inform Software Corporation Chapter 5: Fuzzy Primer

The Kiendl two-way fuzzy controller structure permits the exploitation of both
positive and negative fuzzy rules. These two separate rule sets produce two
membership functions µ +(u) and µ -(u), which – in respect of each possible
output value – indicate to what degree the value is recommended or not,
expressing the latter as warning. A hyperdefuzzification strategy weighs these
recommendations and warnings against each other and computes a membership
functions µ (u). The hyperdefuzzification method Hyper CoM then computes the
optimum based output value from this function.

5.3. NeuroFuzzy Technologies

If you wish to enhance fuzzy logic systems with learning capabilities, you can
integrate neural net technologies. The combination of fuzzy logic and neural net
technology is called “NeuroFuzzy” and combines the advantages of the two
technologies. Section 5.3.1 introduces the basic principles of neural nets, and
Section 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 of
imitating the human mind with computer systems. About 50 years ago,
researchers created the first electronic hardware models of nerve cells. Since
these first ventures, a large scientific community has grown dedicated to new
mathematical models and training algorithms.

Connectionism Today, this branch of computer science – connectionism – has gained


considerable popularity. The research area focuses on the behavior of highly
parallel computer architectures, namely, artificial neural nets. These nets use a
number of simple computational units, called “neurons,” which each try to
imitate the behavior of a single human brain cell.
How to Mimic Human
Nerve 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 a
human neuron. The cell itself contains a kernel surrounded by an electrical
membrane. Each neuron has an activation level that ranges between a maximum
and a minimum. Thus, in contrast to Boolean logic, there are not just two
possible values or states which may exist .

176
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Activation of Neurons Synapses exist to increase or decrease the activation of this neuron as a result of
inputs from other neurons. These synapses carry an activation level from a
sending neuron to a receiving neuron. If the synapse is an excitatory one, the
activation level from the sending neuron increases the activation of the receiving
neuron. If the synapse is an inhibitor, the activation from the sending neuron
decreases the activation of the receiving neuron. Synapses not only differ by
whether they excite or inhibit the receiving neuron, but also by the weight of
effect (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 be
seen as a simple processor aggregating information coming in from a number of
other units. Following the aggregation, the unit computes the output which is
passed via connections to another unit. Some units are connected to the outer
world on either the input or output side. Information is first given to the system
via the input units. It is then processed through the net and read from the output
units.
Simple Mathematical
Model 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 is
determined 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 the
weight, wi, represents the synaptic strength. Excitor synapses have positive
weights; inhibitor synapses have negative weights. An offset (bias) Θ is added to
the 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 of
the neuron with the so-called activation function. Different types of functions are
used for this – sigmoid functions are the most common.

177
Inform Software Corporation Chapter 5: Fuzzy Primer

Figure 126: Basic Structure of an Artificial Neuron

Output Function Sometimes, the calculated result generated by the activation function is then
further processed by another output function. This allows an additional filtering
of the output information of every unit.
Can Neural Nets
Copy 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 the
current ability of humans to model. Hence, any application based on this simple
neuron model is unable to exactly copy the human brain. This model is rather an
“inspiration” by nature than a “copy” of it. However, many successful
applications using this technique prove the benefit of neural nets based on the
simple neuron model.

Feedforward Nets For many applications, a determined net computation is as important as a


determined time behavior. Net architectures that allow for cyclic structures in-
between units compute output values depending on the inner activation of the
neurons. Even if the input does not change, the outputs may vary until the
computation inside the net reaches a stable state. Nets in which units are only
unidirectionally connected do not show this behavior. They are called
Feedforward Nets. Nets other than the feedforward type are of less practical
importance.

Neural Net Objectives The objective of a neural net is to process information in a manner that has been
previously trained into the net. Training uses either sample data sets of inputs
and corresponding outputs, or a teacher who rates the performance of the neural

178
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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. The
learning algorithm then modifies the individual neurons of the net and the weight
of their connections in such a way that the behavior of the net reflects the desired
one. The “knowledge” learned by the net is usually represented by the strength
of the connections linking the units and sometimes also by the configuration of
the units themselves.

Pavlov’s Dogs So, how do you teach a neural net? Basically, the method is similar to that used
with Pavlov’s dogs. More than hundred years ago, the researcher Pavlov
experimented with dogs. When he showed the dogs food, the dogs salivated. He
then installed a bell in the dogs’ cages. When he rang the bell, the dogs did not
salivate, as they saw no link between the bell and the food. He then trained the
dogs to associate food with the sound of a bell by always letting the bell ring
when he presented the dogs their food. After a while, the dogs also salivated
when just the bell rang and he presented no food.

Figure 127: Principle of Pavlov’s Dog Experiment. Before Learning, the Dogs
Salivated Only When Pavlov Showed Them Food, Ignoring the Bell. After, They
Learnt 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 and
the other one the fact that the bell rings. Both input neurons have links to the
output neuron, called the synapses. The thickness of the line represents the
synapse 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 the
line from the right input neuron to the output neuron is very thin.
The Hebbian
Learning 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 – the
synapse weight increases. From these experiments, a researcher by the name of
Hebb deducted the following learning rule:

179
Inform Software Corporation Chapter 5: Fuzzy Primer

Increase weight to an active input neuron if the output of this neuron should
be active.
Decrease weight to an active input neuron, if the output of this neuron
should be inactive.

This rule, called the Hebbian Rule, is the father of all learning algorithms. We
must focus a little more on the learning concepts to explain how this rule is
applied in today’s learning methods.

Supervised Learning If a given input pattern (e.g., a recognizable character) must be associated with a
specified output pattern (e.g., the set of all valid characters), we can supervise
each training step by comparing the computed and the desired results.

Unsupervised Learning If the task of our training procedure is to discover regularities within the
environment – like categorizing properties of given input patterns – there are
usually no specified output patterns or structures to supervise the training
success. This learning process is called unsupervised learning.
Training Phase and
Working Phase Neural net behavior is configured by altering the strength of the connections
linking the units. Supervised learning can be accomplished only by using sample
data completely separated from the process. Thus, a learning and working phase
can be distinguished.

Training Phase Developing a neural net solution means teaching the net a desired behavior. This
is called the learning phase. Either sample data sets or a “teacher” can be used in
this step. A teacher is either a mathematical function or a person that rates the
quality of the neural net performance. Since neural nets are mostly used for
complex applications where no adequate mathematical models exist and rating
the performance of a neural net is difficult in most applications, most are trained
with sample data.

Figure 128: Training and Working Phase for Supervised Learning

180
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Working Phase After the completion of learning, the neural net is ready to enter the working
phase. As a result of the training, when the input values match one of the training
samples, the neural net outputs values nearly equal to those of the sample data
sets. For input values in-between sample data input values, it approximates
output values. In the working phase, the behavior of the neural net is
deterministic. Thus, each possible combination of input values always produces
the 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 never
drifts towards hazardous behavior.

Learn Methods Today, the most often used neural net learning algorithms are applied in
feedforward nets using supervised training procedures. A well-known method,
the idea of which is essential to NeuroFuzzy systems, is the delta rule. More
sophisticated approaches, e.g., the error backpropagation method, were derived
because the delta rule can only be applied to nets with a single neuron layer.
Delta Rule and
Error 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 occurs
in the following steps:

Select Sample A sample must be selected from a sample data base. For the
training to succeed, a well-defined data base must be constructed,
as well as a specific policy to determine the sequence of samples
applied to the training algorithm.

Compute Network The network is fed with input data (forward propagation), and the
result 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 the
computed error. Various methods can be used for this task. The
delta rule uses Hebb’s learning rule to derive a simple
mathematical formula. The formula computes new values for the
weights of the trainable layer by expressing Hebb´s rule using a
product of the current weight’s activation and current error. This
product is partially added to each weight.

Back Propagation If a net consists of more than one layer, the error can not directly be assigned to
the weights. Thus, net weights are changed by starting from the output neurons,
stepping backwards through the net up to the input units.

181
Inform Software Corporation Chapter 5: Fuzzy Primer

Iteration The algorithm repeats these steps with every data set until the average error is
reduced to less than a pre-defined threshold. Note: this iterative approach can
never reduce the error for all data sets to zero because in most applications, the
data sets are somewhat ambiguous. Error Backpropagation is only used for
supervised learning.

Various Methods Based on this idea, several learning mechanisms are developed according to the
diverse application fields, net structures, and neuron models. All training
methods must be properly configured to succeed. Focusing on the supervised
learning procedures, only a few parameters are common:

Learning Rate The output deviation produced by each sample input must be minimized by the
neural training method. Thus, the objective of the problem is multi-dimensional.
A training step decreasing the output deviation of one sample may increase the
output deviation for the other sample cases. In order to converge on a solution
for all sample cases, the training steps are repeated, and for each computation a
small descent step is performed. This step length can be adjusted with the
Learning Rate as a global training parameter.

Updating Policy Standard or universal learning rates are not adequate for all net structures and
training situations. If nets use different types of neuron models, individual
adjustment of the learning rates is required. A random learning rate can find the
way out of a local minimum if a given training method does not converge to an
acceptable solution.

Winner Neurons Usually a distributed memory is used to train an Error Backpropagation


Network. In this case, all activated neurons producing a deviation from the
sample target value are updated. This of course can increase the error of other
samples, and a small learning rate must be chosen to protect former training
results. If local concepts are used, updating only the “best neurons” is a better
protection for former training results. If only one neuron wins the competition,
the method is called Competitive Learning. Nevertheless, both strategies cannot
avoid increasing errors.

Termination Criteria Each iteration process needs termination criteria. The simplest criterion is to stop
after a fixed number of iteration steps. Most often, the remaining net error is
considered when evaluating the termination condition. Here, the average of
errors due to the diverse sample data, as well as the maximum error of the worst
sample, may be considered. In both cases, different strategies can be employed
which drop samples for training if they produce results under the given
threshold. However, training one sample and decreasing its error can increase the
error of other samples. Even though a sample generates an output result under
the error threshold, it must be still tested in following training steps. It is
probable that the sample error will increase with further iterations of the learning
process and the sample must be trained again.

182
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Sample Sequencing Any given training step may have an effect on the results of any or all other
training steps. Therefore, the choice and sequence of samples influences the
training success. It is possible that the result of one training step, or a series of
training 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 behavior
with simple “if-then” relations. In many applications, this gets you a simpler
solution with less design time. In addition, you can use all available engineering
knowledge to optimize the system performance directly. While this is certainly
the beauty of fuzzy logic, it is at the same time its major limitation. In many
applications, knowledge that describes a desired system behavior is contained in
data sets. Here, the designer must derive the “if-then” rules from the data sets
manually – a major effort for large data sets. When knowledge about the system
to be designed is contained in data sets, a neural net presents a solution since it
can train itself from the data. However, few commercial applications of neural
nets exist. This is in contrast to fuzzy logic solutions, which are very common in
Asia and Europe.

The sparse use of neural nets in applications can be attributed to a number of


reasons. First, neural net solutions stand as a “black box.” You can neither
interpret what drives a certain behavior, nor can you modify a neural net
manually to influence a certain behavior. Second, neural nets require prohibitive
computational effort for most mass-market products. Third, selection of the
appropriate net model and setting the parameters of the learning algorithm is still
a “black art” which requires extensive experience. Of the aforementioned
reasons, the lack of an easy way to verify and optimize a neural net solution is
probably the major limitation.

Neural Nets Fuzzy Logic


Knowledge Implicit, the system Explicit, verification and
Representation cannot be easily inter- optimization are easy and
preted or modified (-) efficient (+++)
Trainability Trains itself by learning None, you have to define
from data sets (+++) everything explicitly (-)
Figure 129: Both Neural Nets and Fuzzy Logic Have Their Strengths and
Weaknesses.

183
Inform Software Corporation Chapter 5: Fuzzy Primer

In simple words, both neural nets and fuzzy logic provide powerful design
techniques that have individual strengths and weaknesses. Neural nets can learn
from data sets, while fuzzy logic solutions are easy to verify and optimize. If you
look at these properties side by side (Figure 129), it becomes obvious that a
clever combination of the two technologies delivers the best of both worlds.
Combine the explicit knowledge representation of fuzzy logic with the learning
power of neural nets and you get NeuroFuzzy.
Training Fuzzy Logic
Systems with NeuroFuzzy Many alternative ways of integrating neural nets and fuzzy logic have been
proposed in the scientific literature. However, very few have already been
successfully applied in industrial applications. Delta rule and error back
propagation algorithms have become the standard for most neural net
implementations. If the error back propagation algorithm is so powerful, why not
use it to train fuzzy logic systems, too? Alas, this is not straight forward. First of
all, 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 can
be used as “weights” in a neural training procedure. Second, the error back
propagation algorithm differentiates the transfer functions of the neurons to
determine the influence of each neuron. Here, the standard fuzzy logic inference
cannot be differentiated.
The Weights in a
Fuzzy System NeuroFuzzy development tools use expanded fuzzy logic inference methods to
solve the first problem. The most common approach is to use so-called Fuzzy
Associative Maps (FAMs). A FAM is a fuzzy logic rule with an associated
weight. The second problem can be circumvented by implementing a modified
error back propagation algorithm with fuzzy logic. For details, refer to the
computation section of this chapter. As a user of NeuroFuzzy tools, you do not
need to worry about the details of the algorithm. Today’s NeuroFuzzy tools work
as an “intelligent” assistant to help you with your design. They help you generate
and optimize membership functions and rule bases from sample data. You can
find further remarks pertaining to design steps you may use with NeuroFuzzy in
Section 4.2.
NeuroFuzzy vs. other
Adaptive 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, the
representation of the input and output variables by membership functions and
the structure of the information flow in the system already contain much of
the information that an unstructured neural net must derive from the sample
data sets.

184
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

• You can use any knowledge you already have of the system right from the
start. In most applications, a few things are perfectly clear. By using
NeuroFuzzy, you can implement all this knowledge in the initial fuzzy logic
system.
• You can exclude parts of the system from training. For example, this is
necessary in applications where some rules contain knowledge that is
essential to the safe operation of a plant.
• You can always interpret the result or current stage of the system as it
contains 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 compared
to 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 learning
algorithm when compared to a neural net.

In engineering, this is an advantage rather than a drawback. However, in


applications where no knowledge of the system’s structure exists, but massive
amounts of data are available, NeuroFuzzy may not deliver a solution at all.

5.4. Computing NeuroFuzzy Training

Neural Nets
without 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. The
following concepts must be realized to apply neural training strategies to
elements 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 into
layers. System inputs are members of the input layer and system outputs are
members of the output layer.
• The elements inside a layer are independent. Thus, all members of a layer can
be processed by parallel processors.

185
Inform Software Corporation Chapter 5: Fuzzy Primer

Fuzzy Logic as Neurons Fuzzy logic systems can be used for knowledge representation in neural systems
because:
• 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 Net
Knowledge Representation Thus structurally, fuzzy systems can easily be understood and calculated much
like a parallel structure. Storing knowledge in a fuzzy system, however, uses a
different 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 explained
and, 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 by
observing specific neurons.

Although fuzzy systems provide the advantages previously mentioned, an


automated training procedure applied to a NeuroFuzzy system does not always
implement the knowledge in the most plausible way. Within fuzzy systems,
desired responses can be expressed by using either one specific rule matched to a
required strategy, or by a combination of rules using perhaps a compromise
defuzzification method to obtain the same result. A training algorithm usually
supervises only the deviation between computed and desired output values, not
the number of rules used to represent a given sample.
Determined
Training Results Thus, the advantages of representing knowledge in fuzzy systems can only be
maintained if the NeuroFuzzy training can be directed to dedicated training
parameters and the modification of parameters does not disturb the transparency
of the elements used. The following chapters show how adaptive methods can be
integrated into fuzzy elements like linguistic variables and fuzzy rules.

186
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

5.4.1. Learning Fuzzy Rules

The basic idea of all early NeuroFuzzy approaches is to set up a complete fuzzy
rule base, not by entering the rules, but by presenting a set of training samples
and selecting the set of rules that represent the samples. For small systems, the
approach works adequately. When applied to the training of larger systems, the
approach 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. If
variable definitions do not provide a good match to the given sample
distribution, the training may not converge.
• If rules can only be switched on or off, neural training procedures cannot be
applied. Neural training methods usually use error gradients to heuristically
find the best search direction. A gradient can not be calculated when discrete
rules are used.

FAM Rules In neural nets, the parameters affected by the training procedure are the
connection weights between the neurons. Looking at a fuzzy system using
arbitrary sets of fuzzy rules, the firing strength of each rule output connects this
rule with the precondition of the following rule block. Using the technology of
Fuzzy Associative Maps (FAM), this connection can be weighted. This rule
plausibility can be used as the parameter to be calibrated in the neural training. A
neural training algorithm can calculate an error gradient by slightly changing rule
weights.

Restricted Training The result of using this approach in large systems can of course be a huge rule
base where most of the rules are assigned a local weight. The rules only
represent sample patterns in combination with several other rules in order to
restrict the number of rules used and to save a-priori knowledge that was entered
into 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 a
system that fulfills the requirements of the given samples.

187
Inform Software Corporation Chapter 5: Fuzzy Primer

How NeuroFuzzy Training


is Accomplished The NeuroFuzzy module provides methods for supervised learning. The heuristic
methods employed combine the two learning steps of error backpropagation with
the idea of competitive learning. After a system output is computed by forward
propagation, an output error is identified by comparing the system output with
the given sample output data.

Error Backpropagation This error is then used to determine the fuzzy rule most suited for influencing
system behavior. Using the selected learning rule, the plausibility of the fuzzy
rule is modified before the subsequent sample data set is read.

Learning Method The learning method is the computing heuristic that evaluates the winner neurons
for the next update. In addition, a strategy can be implemented to apply a
specified step width to the updated parameter.

Training Iterations Updating a system parameter decreases the error for one sample, but may
increase the error for all others. Thus, NeuroFuzzy uses an iterative computation
to find the fuzzy system which best matches all given samples. In most cases, the
samples must be trained multiple times to reach a sufficient result. An iteration is
completed 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 all
samples, the perform computation command is executed after each complete
iteration. The perform run may also be executed manually when the training is
stepped one sample at a time or stopped during an iteration. The perform run also
checks the break criteria of the training procedure. If the system fulfills all valid
criteria, the training is terminated. The result is a pure fuzzy system to be used in
the working phase.

Configuration Parameter For NeuroFuzzy training, the learning methods must be configured similar to
neural net training. The fuzzyTECH NeuroFuzzy Module allows the adjustment
of the following parameters:

Learning Rate The Learning Rate is a global training parameter which determines the step
width of each training step. The learning rate for DoS values is normalized as the
values themselves in the interval [0...1]. In other words, the DoS learning rate
determines the value that is added or subtracted to a winner DoS.
Learning Methods
in fuzzyTECH The NeuroFuzzy module allows standard methods (REAL_METHOD and
RANDOM_METHOD) and batch training procedures (BATCH_LEARN and
BATCH_RANDOM). The first of each group uses the learning rate entered as
constant training steps, while the second uses randomly defined steps from the
equally partitioned interval [0... learning. rate] for the update. If the training does
not converge, the random learning rate can help to avoid local minimums.

188
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Standard/Batch Learning The standard methods perform an optimization step per sample. Batch methods
calculate errors and gradients for all samples and update the systems parameters
after each complete iteration. Standard methods provide a better computation
performance and batch methods a better convergence behavior. fuzzyTECH also
allows you to include user defined methods by writing your own training
methods as a dynamic link library.

Winner Neurons Fuzzy Systems use local elements to represent knowledge. Only the winner
neurons are updated in order to keep a rule base transparent. The number of
winners determines how many neurons are updated within each iteration step.
Note that the more winner neurons are used, the less is the protection of training
results 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 pass
through the sample data. If the sample sequence is random, the iteration is
defined as complete after N sample data sets are trained, where N is the number
of samples in the sample file. Note: for random sequencing, samples can be
double trained in one iteration while other samples are skipped.

Avg. Deviation The Avg. Deviation (Average Deviation) criterion is fulfilled if the average of
the errors occurring during a complete iteration is less than a defined error
threshold. The average error is computed by adding the errors for each sample
divided by the number of samples. Note: the last computed error is taken into
account for each sample. For efficiency purposes, the error is only computed if
the sample is trained.

Max. Deviation The Max. Deviation criterion compares the error of the worst sample with an
error threshold. Samples under the threshold are skipped within the training
procedure. Training one sample can increase the error of other samples;
therefore, the training results are automatically evaluated after every complete
iteration. In order to evaluate the max deviation when the training is stopped,
before an iteration is completed, or when you step through the training
procedure, a perform command is mandatory. Max deviation can also be used as
a dynamic criterion.

Dynamic Break Condition The Max. Deviation criteria can be implicitly used to improve the training
performance of the NeuroFuzzy optimization. When using max deviation as the
stop criterion, only the samples that continue to produce an error larger than the
defined threshold are trained. The max deviation threshold can be dynamically
used to always evaluate only the samples producing the larger errors. The
threshold starts at the [From] value and is reduced by the [Factor] value each
time the threshold parameter is fulfilled. The training is stopped when the
threshold has reached the entered [To] value and all samples meet the designated
criteria. Note: the [From] value must be larger than the [To] value and the
[Factor] value must be less than 1.

189
Inform Software Corporation Chapter 5: Fuzzy Primer

Sample Sequencing The sample data may be provided in sequential or random order. Random
sequencing takes the next sample from the equally partitioned set of all samples.
User specified methods can be integrated through user defined dynamic link
libraries.
Interaction between
Fuzzy 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 or
not– are modified during the learning process via their degrees of support. These
modifications are processed using sample data accessed from external files. After
the learning process is complete, the trained rule base can be displayed and
edited in the fuzzyTECH Rule Editor. With a repeated call-up of the NeuroFuzzy
Module, the optimization of the fuzzy system can be enhanced by switching
between interactive editing and sample learning processes.

5.4.2. Learning Fuzzification and Defuzzification

Fuzzy rules determine the central component of the information processing of


the fuzzy system. Input and the output interfaces of the network that are
represented by fuzzification and defuzzification routines must mimic the neurons
of input and output layer of the desired network. In neural nets, the weights
between the input and the first hidden layer, as well as the last hidden layer and
the output layer, determine the input/output behavior. In a fuzzy system these
parameters are found in the fuzzification and defuzzification routines and can
thus be trained.
Training of the
Membership 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 standard
variables to be opened for training.

Figure 130: Standard Membership Functions Used for Input Interfaces:


Z, Lambda, and S Form.

190
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Standard Variables Before training is started, the membership functions of all open terms are
converted to these standard types. Different types are chosen based on their use
as input or output variables. Inputs are converted to Z-Lambda-...Lambda-S
types (Figure 130). For output variables, all terms are converted to lambda type
membership functions (Figure 131). In addition, the standard variables are
restricted to shapes which allow an overlap of no more than two terms. This
leads to a variable definition in which each term is determined by exactly one
parameter, the base value of the term’s maximum. As a result, each term must
intersect 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 Standard
Variables The fuzzyTECH NeuroFuzzy module uses the single characteristic parameter of
the term of a variable for the term’s adaptation. A change of this parameter
represents a horizontal shift of the term maximum. The base points of its
neighbor terms must also be changed to keep the membership function as a
standard type during this shift. Figure 132 shows how terms of a variable are
shifted 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 or
both. The manner in which the fuzzyTECH NeuroFuzzy Module treats the
parameters of the terms is similar to the modification of fuzzy rules. Therefore,
the learning mechanism depicted in the previous section can also be applied to
term learning.

191
Inform Software Corporation Chapter 5: Fuzzy Primer

Learning Rate Although fuzzy rules and membership functions are treated similarly by the
learning method, you can define differing learning rates for the two sets of open
parameters. Both learning rates can be adjusted independently. DoS values are
normalized in the interval [0...1], while Base Values are represented as Shell
values and can be changed according to a user defined interval inside the base
variable range. The learning rate for terms is entered as a percentage of the range
interval.

Restrictions Learning is not restricted to the output values of one output variable. Structures
with numerous variables, rule structures, and rule blocks are allowed. Often
fuzzy systems do not have a one-to-one correspondence – meaning that the same
results may be produced by different fuzzy systems. The convergence of the
learning procedure towards one specified solution can therefore not be
guaranteed.

5.5. Data Clustering

NeuroFuzzy techniques, which you experimented with in the previous section,


provide a powerful method for converting information contained in sample data
into fuzzy logic rules. The benefit of this is significant. In contrast to sample data
files, fuzzy logic rules can be interpreted and optimized in a straightforward
manner. However, in many cases the training data for the NeuroFuzzy learning
must 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 granting
policy from past data. In this past data, typically 98% of the cases cover standard
cases, while only 2% of the cases cover more unusual cases. Since any training
algorithm treats each case with the same importance, it spends most of its
attention on the standard cases and very little on the unusual cases. If you use
such sample data directly for training, it takes a long time for convergence and
the performance on the more unusual cases is likely to be low. Hence, removal
of redundant data greatly improves the training result in this case. Also, you may
have a certain degree of inconsistency in the cases because multiple credit
experts have processed the cases. These inconsistencies may be very hard to spot
as credit experts may well agree in certain situations but may strongly disagree in
others. If you use inconsistent training data, the NeuroFuzzy module averages
between the inconsistencies to minimize total training error. For small
inconsistencies, this may be the right way to proceed, but if you have a few
strong inconsistencies in the training data set, the training result may be poor. It
follows the rule, “garbage in, garbage out,” and you should remove these strong
inconsistencies before training.

192
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

fuzzyTECH integrates the FuzzyCluster Module to help you with preprocessing


of sample data. The functions contained in this module help you both in
removing redundant data and resolving strong inconsistencies in the data. The
FuzzyCluster Module contains two different clustering techniques: the industry-
standard IsodataCluster and the FuzzyCluster approach. The following section
introduces the specifics of the FuzzyCluster approach.

FuzzyCluster In order to illustrate the function of a clustering algorithm, consider a data set
using 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 clouds
are called “clusters.” A single data point can replace each of the members of
such a cluster to reduce the number of data points. Such data points are referred
to as “typicals.”

Output Variable

Input 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:

IF Input IS low THEN Output = low


IF Input IS medium THEN Output = low
IF Input IS high THEN Output = high

With only three (3) typicals for training, the training time for the NeuroFuzzy
Module would be much smaller than with the original sample data. Note, the
leftmost cluster contains far fewer data points than the middle cluster. If this
sample data had been used without preprocessing, this area would have gained
more attention from the NeuroFuzzy algorithm, because the NeuroFuzzy training
algorithm treats each data sample with the same importance.

193
Inform Software Corporation Chapter 5: Fuzzy Primer

Output Variable

Input Variable

Figure 134: The Data Points of the Example Can Be Grouped Into Three
Clusters. Each Cluster Is Represented By a “Typical” Data Point (Cross).

Resolving Conflicts The second objective of the data preprocessing step is to identify and solve
conflicts between data points. In the example, a single data point cannot be
grouped in a cluster. This data point is indicated by an arrow. It does not belong
to the leftmost cluster, because the distance to the other data points of this cluster
is too large. Thus, this data point conflicts with the other points, and the conflict
should be removed. Otherwise, the NeuroFuzzy training cannot later deduce a
clear rule from the sample data.

Output Variable

Input Variable

Figure 135: If a Data Point is Too Far Away From the Cluster, It Is Considered
a Conflict.

194
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Clustering Algorithm fuzzyTECH integrates both the standard IsodataCluster method, as well as the
innovative FuzzyCluster clustering method. Both methods are similar, except
that they use different distance measures for the determination of the distances
between data points. Also, fuzzyTECH’s integrates a data consistency check
within the clustering procedure.

Cluster Configuration Clustering means to combine “similar” data points into a single cluster. The
result of the clustering is the set of typicals, where each typical denotes one
cluster. Now, the question becomes: what is “similar”? The similarity of data
points 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 points
that are confined within the same accuracy measure are considered to belong to
the same cluster.
Computing Distances and
Data 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 than
the geometric length of the accuracy vector are marked and sorted. Starting with
the closest pair of data points, all “similar” pairs are combined. This results in a
new data point and the two original data points are erased from the data set. Each
time a new data point is inserted, the distances from this new data point to all the
other ones must be re-computed.

Output Variable

A B
D

Input Variable

Figure 136: Example of a Set of Six (6) Data Points


With Points Depicted In a 2-Dimensional Diagram.

Figure 136 shows an example of a set of six (6) data points. After all distances
are 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 are
removed.

195
Inform Software Corporation Chapter 5: Fuzzy Primer

Output Variable

A B
X
D

Input Variable

Figure 137: Example of a Set of Six (6) Data Points; Points


A 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.

Output Variable

A B
X
D
Y
E

Input Variable

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 are
X and C. X and C are combined into the new point Z. Since point X stemmed
from a combination of two points and point C is only one point, the new point Z
is 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 by
the number of original data points.

196
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Output Variable

Z
A B
X
D
Y
E

Input Variable

Figure 139: Example of a Set of Six (6) Data Points: A, B


Clustered to X; D, E Clustered to Y; and X, C Clustered to Z.

Now, no further combination of points can be made because the distances


between 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 not
similar to the output variable values, are marked and presented to the user for
resolution of the conflict.

Output Variable

E
C

Input Variable

Figure 140: Example of a Set Containing Conflicting Data Points: B


and C Use the Same Input Value Mapping on a Different Output.

197
Inform Software Corporation Chapter 5: Fuzzy Primer

Data points D and E are considered to have similar input variable values.
However, the corresponding output variable value is not similar. This puts these
two points in conflict with each other. Data points B and C are not considered
conflicting, because the respective output variable values are close enough to be
considered similar. Data points A and B are not considered conflicting since the
input variable values are not close enough to be considered similar. fuzzyTECH’s
clustering function brings these conflicts to the user’s attention. The user must
decide if only one data point shall be used, or if both or neither point shall be
used.

Fuzzy Clustering The clustering method, as discussed before, has proven to be useful in many
application areas. However, for many other applications, the fuzzy logic
extension, dubbed “FuzzyCluster” showed to be a useful extension. FuzzyCluster
uses a more sophisticated computation of the “similarity” of data points. First, it
does not use a “threshold”-like definition for the IsodataCluster method
presented. Second, it considers different similarity definitions for each variable.

FuzzyCluster associates each variable with a membership function that assesses


how similar two data points are, depending on the difference in value for the
given variable. In contrast to IsodataCluster, first the similarity of two data
points 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 considered
closest.

Difference

0 Epsilon Delta

Figure 141: FuzzyCluster Expresses the Similarity of Two Data Points


Using 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.

198
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Advantages of Clustering
and 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.

Real-World Data

Raw Data
1 2 3 4 1

#
2 3

I n p u
1 2 0 3 4

t
8 1 ß 2 3

Typical Data
Clustering

Typicals
Human Expert

NeuroFuzzy

Rules, Linguistic Variables

Fuzzy Logic

Figure 142: The Combination of Fuzzy Logic, NeuroFuzzy, and Clustering


Techniques 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 intelligent
systems. The previous figure shows the various types of system design that
combinations of the different techniques allow you. Explicit knowledge of
desired system behavior, such as decision policies, are inputted directly by
human experts as fuzzy logic rules and linguistic variables. If typical data is
available, the NeuroFuzzy module automatically converts it into rules and
linguistic variables of a fuzzy logic system. If only raw real-world data is
available, fuzzyTECH’s clustering function resolves conflicts in the data and
remove redundancies to generate the typicals.

199
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

fuzzyTECH provides two different approaches how other applications can


compute fuzzy runtime systems.

Standalone Systems If you want to use your fuzzy logic project in a standalone fuzzy runtime system
you should use the fuzzyTECH code generators. As result you will get source
codes that you may include in the software development project of your own
application. Your fuzzy runtime system will be very compact and fast. There is
no 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 systems
for your application, you should use one of fuzzyTECH’s standard interfaces for
interprocess communication with other applications. MS Windows standard
interfaces are supported as well as interfaces independent from the operating
system. This approach allows a complete fuzzy logic system visualization and
on-the-fly changes. Section 6.2 explains the details.

6.1. Using fuzzyTECH Code Generators

Overview fuzzyTECH provides different code generators specialized for different target
platforms. The generated code is royalty free. The computed results in the fuzzy
runtime systems are the equivalent, they do not depend on the code generator.
This overview should help you to find the optimal and most convenient solution
for your problem.

200
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 143: fuzzyTECH stand-alone Runtime Module as server for fuzzy


computations

ActiveX You can use the fuzzyTECH Runtime Control to integrate a fuzzy runtime
system 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 that
allows to load and compute any fuzzy systems. The fuzzyTECH Runtime Control
is 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 a
MS Windows operating system you should use the fuzzyTECH runtime module
FTRUN.DLL. It is easy to integrate into any software or programming language
that supports the integration of DLLs and you do not need any compiler tools to
compile the fuzzy runtime system. Section 6.1.2 explains the details.

201
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

MCUs DSPs PLCs fuzzyTECH provides optimized support for a wide range of target hardware
platforms. For common microcontroller, DSP and PLC architectures, fuzzyTECH
supports the generation of hardware specific code, i.e., code that has been
carefully optimized to perform at its best on the chosen target hardware. For
most of the supported architectures, Inform has teamed up with manufacturers of
the respective devices to ensure the most efficient implementation. Section 6.1.3
explains the details.

C Code Other hardware platforms are supported by the generation of C source code that
can be implemented on any existing target hardware platform supported by a C
compiler. Various options allow the customization of fuzzyTECH’s C code
generator 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 code
generator generates from a fuzzy system a *.COB file that contains COBOL
source code. COBOL-based user applications can use the fuzzyTECH COBOL
Runtime 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 mathematical


software packages that use M-Code for system representation. Section 6.1.6
explains the details.

Online/RTRCD Some code generators allow an online connection between the fuzzyTECH Shell
and the fuzzy runtime system. The online connection lets the fuzzyTECH Shell
visualize the fuzzy runtime system. Even changes of the running system are
possible; the runtime system can be optimized during runtime without any time
consuming re-compilations. Read the subsection that corresponds with your
edition for more details.

6.1.1. fuzzyTECH Runtime Control (ActiveX)

Definition The fuzzyTECH Runtime Control is a so-called in-process ActiveX server that
can load and compute any fuzzy systems. The fuzzyTECH Runtime Control is
integrated 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 to
generate FTR files (refer to Table 5 of Section 9.4).

202
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

FTR Files The fuzzyTECH Runtime Control is independent from any fuzzy logic system.
The code generator of fuzzyTECH stores the specific information of each fuzzy
logic system in *.FTR files. This files contain binary data only in a compact
format that is optimized for the Control.

Online Module The fuzzyTECH Runtime Control includes the Online module. This supports
online development with fuzzyTECH Editions that include the Online debug
mode (refer to Table 4 of Section 9.4). The following communication channels
are 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 of
different fuzzy systems at the same time, too. The fuzzyTECH Runtime Control
is 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 including
software 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 you
can 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 arbitrary
fuzzy logic systems. It is a MS Windows DLL and can be integrated into every
MS Windows application with a DLL interface. This may be standard software
as well as user written software.

203
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Availability FTRUN is available only for editions that are able to generate FTR files (refer to
Table 5 of Section 9.4).

FTR Files FTRUN is independent from any fuzzy logic system. The ‘code’ generator of
fuzzyTECH stores the specific information of each fuzzy logic system in *.FTR
files. This files contain binary data only in a compact format that is optimized for
FTRUN.

Online Module FTRUN includes the Online module. This supports online development with
fuzzyTECH Editions that include the Online debug mode (refer to Table 4 of
Section 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 enable
the Online Module.

Directory FTRUN is delivered in two versions. Both DLLs and a help system are located in
the directory …\RUNTIME\FTRUN:
FTRUN.HLP MS Windows Help System
FTRUN.DLL supports 16-bit applications for MS Windows
FTRUN32.DLL supports 32-bit applications for MS Windows.
Note that the Online module of this DLL does not run under the Win32s
Extension for MS Windows 3.1x.

Interface The interface between FTRUN and the client applications is the FTRUN
application programmer’s interface (API). It consists of functions that
1. open fuzzy logic systems (*.FTR files)
2. close fuzzy logic systems
3. set values to the fuzzy logic system
4. 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 different
fuzzy logic systems at the same time. FTRUN is also multi-client capable, that
is, 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 logic
system in a compact binary format.

204
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

2. The FTRUN DLL as fuzzy computation server that contains the FTRUN
API, the Online module and basic fuzzy algorithms which are independent
from any fuzzy system
3. One or more of your applications as clients that call the FTRUN API to use
the fuzzy logic system(s).

Figure 144 illustrates the hierarchy of these modules.

MS Windows

A.EXE B.EXE ... Z.EXE

FTRUNxx.DLL
FTRUN API + Fuzzy Algorithms + Online Module
A1.FTR B1.FTR ... Z1.FTR
A2.FTR B2.FTR ... .
A3.FTR . ... .
. . ... .
. . ... .
. . ... .

Figure 144: Fuzzy Runtime Systems with FTRUN

License You may add FTRUN to any other software including software 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 for FTRUN.

Performance FTRUN uses the same efficient techniques for the fuzzy logic computation as the
runtime systems implemented with the fuzzyTECH source code generators. Thus,
the performance of FTRUN is comparable to that of the fuzzyTECH C code
solutions. Refer to the benchmarks published at www.fuzzytech.com. The DLL’s
file sizes are about 100 KB for the 32-Bit DLL and about 50 KB for the 16-Bit
DLL.

6.1.2.1. FTRUN API

FTRUN consists of a very small function interface that can be used by every
software with an interface to DLLs. The functions can be subdivided into three
groups:
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.

205
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

2. The integer functions must be used if the FTR module was generated with the
base variable data type 16 bit Unsigned Integer. In this case no floating point
arithmetic is used.
3. The advanced users functions can be used to integrate the i/o-mapping of the
fuzzy systems dynamically at runtime. This allows the integration of any new
fuzzy logic system without recompiling your application.

Here the functions are listed in C language syntax. For more details about the
functions and their parameters please refer to the help system in the Windows
start 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 of
Standard 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 handle
and 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, when
you terminate your application.

Example The following ANSI C example opens a FTRUN project that supports the data
type double and performs fuzzy computations in a loop. The FTRUN project is
closed after the computation loop has been terminated.

206
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

#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 software
tools with a DLL interface. If you have built a client application, you have to
make sure that the application has access to the FTRUN DLLs. The fuzzyTECH
Setup 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 is
started or into the current working directory.

Borland Delphi The directory …\RUNTIME\FTRUN\DELPHI contains the FTRUN interface


and a integration sample for Borland Delphi. Please add the unit FTRUN32.PAS
to your project. This unit contains the function interface of FTRUN32.DLL in
Pascal syntax.

Microsoft Visual Basic


and VBA The directory …\RUNTIME\FTRUN\VB contains the FTRUN interface and a
integration sample for Visual Basic. Please add the module FTRUN32.BAS to
your project. This module contains the function interface of FTRUN32.DLL in

207
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Visual Basic syntax. Use the same approach for VBA (Visual Basic for
Applications), e.g. in MS Access or MS Excel.

Microsoft Visual C 32 Bit The directory …\RUNTIME\FTRUN\C contains the FTRUN interfaces for the
32 bit C compiler of Microsoft. The header file …\INCLUDE\FTRUN.H exports
the 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 a
integration sample for the 16 bit C compiler of Microsoft (Vs. 1.52). The header
file 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 or
VBA. The programming interface of the wrapper class are methods and
properties matching the very special fuzzy system the class was generated for.
The class “hides” the more general FTRUN-API. Developers preferring object
oriented programming may prefer this approach. The class module does not
contain any data but only some calling interfaces to the FTRUN-API, i.e.: If you
modify the fuzzy system, you must exchange the class module and re-compile
your application in those cases only, when the number or data type of the i/o
variables has changed. If you change rules our membership functions only, it is
sufficient to generate a new *.FTR file and to restart the application afterwards.
Wrapper Classes for
Visual 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 Visual
Basic or VBA project. Take care about the difference between a class module
and a standard module! The class module exports a special data type for the
fuzzy system starting with the prefix Ftr and ending with the name of the fuzzy
system, e.g. FtrTraffic or FtrCrane. You may declare variables of this data
type. Use the properties and methods of those variables to access the i/o
variables of the fuzzy system.
Wrapper Classes for
Visual 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 class
exports a special data type for the fuzzy system starting with the Prefix CFtr and
ending 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 of
those variables to access the i/o variables of the fuzzy system.

208
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

6.1.2.3. FTRUN Integration in Standard Software

FTRUN can directly be tied into popular standard software products, such as
simulation 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 are
available 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.INI
or 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 initialization
file does not exist or contains incorrect settings. The following features of
FTRUN can be configured:

1. The appearance of the FTRUN information window: It can be opened either


in standard size or as icon.
2. Error Messages: FTRUN displays error messages if incorrect function
parameters are detected. This may be useful during the debugging phase of
your 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 for


more details about the sections, entries and values in the initialization file.

Example
[FTRUN]
INFOWINDOW=1
COMMCHANNEL=DDE
ONLINETICK=55
QUIET=0

209
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

[SERIAL]
COM=1
BAUD=19200

[SHAREDFILESYSTEM]
SFSDIR=C:\TEMP\

[IPX]
SOCKETADDRESS=2FFF

6.1.3. Hardware Specific Code

Hardware specific code generators are only supported by the fuzzyTECH MCU
Editions and the fuzzyTECH IA Editions. Please refer to the subsection that
corresponds to your edition.

6.1.3.1. MCU-ST6 Edition

The fuzzyTECH MCU-ST6 Edition uses a specialized library, the fuzzyTECH


kernel FUZZYLIB.ST6. Since this kernel contains highly optimized assembler
functions, the generated code is efficient and compact enough to be implemented
on an ST6 device.

Compatibility The fuzzyTECH MCU-ST6 Edition supports all ST62xx and ST63xx devices of
the ST6 family.

Integration You need an ST6 assembler to integrate the fuzzy system. Inform recommends
using the SGS-Thomson AST6.EXE assembler. You may also use an In-Circuit
Emulator (ICE) for testing.

fuzzyTECH Kernel The fuzzyTECH MCU-ST6 Edition’s assembler code generator uses a
fuzzyTECH kernel that contains all fuzzy logic engine modules. The kernel is a
highly optimized assembler library.

Figure 145 illustrates the integration structure of the fuzzy logic system. The
user’s system code with all periphery code, plus pre- and post processing of
input and output data are all contained in the USER.ST6 source code file. This
code calls the fuzzy logic system as an assembler function contained in
MYPROJ.ST6. MYPROJ.ST6 is generated by the fuzzyTECH MCU-ST6 Edition
from MYPROJ.FTL. The source code in MYPROJ.ST6 uses the fuzzy inference
engine modules contained in the kernel FUZZYLIB.ST6.

210
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 145: Integration of the Fuzzy Logic System

Files The following files are necessary to integrate the fuzzy logic system with your
code:

FUZZYLIB.ST6 The fuzzyTECH kernel for the ST6 Microcontroller family.


This kernel contains modules for fuzzification,
defuzzification and rule inference. The FUZZYLIB.ST6
library file comes with the fuzzyTECH MCU-ST6 Edition
and is located in the …\RUNTIME\ST6\LIB\SRC
subdirectory. If you are encountering any compatibility
problems linking the kernel using linkers other than SGS
Thomson LST6 Version 3.0, please contact SGS-Thomson.

MYPROJ.ST6 The output file of the MCU-ST6 Edition. You have to


compile this file using a ST6 assembler, such as
AST6.EXE. For example, type:
AST6 -l -o MYPROJ.ST6
to generate the file MYPROJ.OBJ.

MYPROJ.INC A file also generated by the MCU-ST6 Edition.


MYPROJ.INC contains public variable definitions for
fuzzy logic system functions. You have to include this file
in USER.ST6.

USER.ST6 Your main program that contains all code of the pre- and
post processing of input and output data. Compile this file
using an ST6 assembler, such as the AST6. For example,
type: AST6 -l -o USER.ST6
to generate the file USER.OBJ.

Build Procedure An example of the required building procedure is contained in the file
BUILD.BAT, contained in the …\RUNTIME\ST6\SAMPLES\MYPROJ
subdirectory.

RAM Allocation The RAM segment for the fuzzy engine is automatically located for the label
ftstart. The RAM segments can be moved in the entire, available address
range by assigning a higher value to ftstart. Verify that the used RAM segment
does not exceed the address range.

211
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Calling the Fuzzy System Before the fuzzy system can be called-up from your main program, the
initialization routine must be called once:
call initmyproj

Example First, the input variables of the fuzzy system have to be assigned within the
control loop. For example, the values of the two input variables "Angle" and
"Distance" would be assigned in the following way:
ldi lv0_Angle, 020h
ldi 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: the
result 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 1
output 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 the
current combination of input variables. The name for this state variable is fix. If
invalidflags is 0, the output value is the result of at least one of the defined
fuzzy rules; if invalidflags is 1, the default value specified in the Variables
Properties: Base dialog is used as the output value.

Example The following shows an example of how to call the code generated by the
fuzzyTECH MCU-ST6 Edition from within your program. If you design your
own project, you have to replace the string ’myproj’ with your project name, both
in 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

212
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 fuzzyTECH


kernel. These routines are delivered as source code. Since the kernel contains
assembler functions highly optimized with regard to speed and size, the
generated code is efficient and compact. In order to achieve maximum
performance on different processors, the MCU-MP Edition supports the 16C5x,
16Cxx, and 17Cxx families with an 8-bit assembler library. In addition, a 16-bit
library is available for the 16Cxx and 17Cxx families. Banking is supported for
all families. Due to the diverse capabilities of the devices, different functions are
enabled by the MCU-MP Edition:

Device Resolutions Flag: Banking Flag: Family


16C5x 8 bit 0 0
16C5x 8 bit 1 0
16Cxx 8 bit / 16 bit 0 1
16Cxx 8 bit / 16 bit 1 1
17Cxx 8 bit / 16 bit 0 2
17Cxx 8 bit / 16 bit 1 2

The flags „Banking“ and „Family“ are used by the fuzzy kernel routines
internally, to optimize code and speed for the dedicated processor. They are
generated 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 assembler
to integrate the fuzzy system with the code of the entire system. You may also
use an in-circuit emulator (ICE) for testing (optional).

fuzzyTECH Kernel The MCU-MP assembler code generator uses an optimized fuzzyTECH kernel
that contains the fuzzy inference engine modules.

Figure 146 shows the integration of the fuzzy logic system: all periphery
interfaces and pre- and post processing of input and output data is contained in
the MYMAIN.ASM source code. This source code uses the fuzzy logic system
function as an assembler function contained in MYPROJ.ASM.

213
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Figure 146: Integration of the Fuzzy Logic System

Generated Code MYPROJ.ASM is generated by the fuzzyTECH MCU-MP Edition from your
project 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 as
the input variables and Output as the output variable. An additional example
showing 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 complete
fuzzyTECH kernel for each microcontroller family is
located 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 the


configuration of the current fuzzy system. This file must be
called, included and assembled with the main program.

MYPROJ.VAR A file generated by the MCU-MP Edition, containing the


declarations of all required variables. The file must be
included in the user’s main program.

FTPUBDEC.VAR contains public variable definitions for the fuzzy logic


kernel.

FTPUBDEC.MAC contains public macros for the fuzzy logic kernel.

214
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

FTMPxxxx.INC contains restrictions due to the selected controller family. A


file matching to the selected controller family (xxxx = 165x
or 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 assembled
by using the MPASM assembler.

Build Procedure Follow these steps in order to generate a fuzzy logic system and to integrate it
with 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 the
fuzzy logic function and includes the generated project like shown in the
sample.
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 the
subdirectories :
...\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 the
Fuzzy System The code in the file MYPROJ.ASM, generated by fuzzyTECH, provides two
assembler functions. One contains the entire fuzzy logic computation and the
other an initialization routine:

myproj
initmyproj

The initmyproj function initializes the internal variables of the kernel and
has to be executed once before the fuzzy logic system function can be used.
Temporarily
Used 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.

215
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

The variables are named VAR1, VAR2, ... The number of internal variables is
depicted 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 by
kernel routines. The usage of the kernel is identical to unbanked devices. If the
fuzzy system fits completely on one RAM page, banking is not required and the
kernel 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 page
because of table access via "RETLW".

RAM Allocation User defined variables can be appended to the RAM allocation of the fuzzy
system. For this purpose, the CBLOCK directive can be located directly after
the RAM allocation for the fuzzy system, as shown in the given examples. This
allows for dynamic RAM allocation by the user.

Limitations Due to the given capabilities of the supported devices, size limitations of the
fuzzy systems to be created exist.

RAM: A RAM check for the RAM required by the fuzzy system is
implemented in the generated code. If the designed system requires
more RAM than available in the device, the assembler will result in an
error. The required RAM can be reduced by using fewer terms or fewer
variables.

ROM: The knowledge base of the fuzzy system is located in the ROM area; for
the device family 16C5x it starts from address 000. These devices use
an RETLW instruction for table access. Thus, the system will use the
first page. Note, the generated tables, the inference routine and the
defuzzification routine must fit on this first page. Therefore, the
fuzzyTECH MP Edition uses only minimum aggregation, CoM
defuzzification and does not support FAM rules for the processors of
the 5x family. If the system exceeds the first page, an error occurs at
assembler time. In this case, fewer rules, fewer terms or variables must
be implemented. Note that rules require the most ROM space.

Return Value The fuzzy logic system returns a value in INVALIDFLAGS. Each bit in
INVALIDFLAGS represents one output variable, starting with the lowest order
bit and assigned in sequence to the output variables in alphanumeric order. A
zero 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 one rule fired. INVALIDFLAGS represents an 8-bit integer for the
fuzzyTECH MCU-MP Edition.

216
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 variable
A_Out and B_Out. All higher bits are not used. Evaluated in a specific control
cycle, a return value of 2 now indicates that no rule for variable A-out fired and
that B_Out was evaluated by at least one of the defined fuzzy rules. A return
value of 0 would indicate that at least one rule for every output variable did fire.

8-bit INVALIDFLAGS Variables in Output


value rv=2 Output Interface Value

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 Output
Interfaces

Example The following is an example of how to use the BUILD.BAT procedure for an
assembler code main program. If you design your own project, you have to
replace 'myproj' with your project name, both in file names and in function calls.
In this example, MYPROJ.FTL has two inputs and one output.

217
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Example MYMAIN.ASM for 16C5x (8-bit):


;–----------------------------------------
; USER MAIN FILE
;------------------------------------------
...
INCLUDE "MYPROJ.VAR"
...
ORG CODE_START
MYMAIN
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 LOOP
NO_FIRE
;CALL DEFAULTHANDLING
GOTO LOOP
;------------------------------------------
; RESET VECTOR
;------------------------------------------
ORG RESET_VECTOR
GOTO MYMAIN

END

218
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Example MYMAIN.ASM for 16Cxx (8-bit):


;------------------------------------------
; USER MAIN FILE
;------------------------------------------
...
INCLUDE "MYPROJ.VAR"
...
ORG CODE_START
MYMAIN
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 LOOP
NO_FIRE
;CALL DEFAULTHANDLING
GOTO LOOP

INCLUDE "MYPROJ.ASM"
;------------------------------------------
; RESET VECTOR
;------------------------------------------
ORG RESET_VECTOR
GOTO MYMAIN

END

219
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Example MYMAIN.ASM for 17Cxx (8-bit):


;------------------------------------------
; USER MAIN FILE
;------------------------------------------
...
INCLUDE "MYPROJ.VAR"
...
ORG CODE_START
MYMAIN
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 LOOP
NO_FIRE
;CALL DEFAULTHANDLING
GOTO LOOP
INCLUDE "MYPROJ.ASM"

;------------------------------------------
; RESET VECTOR
;------------------------------------------
ORG RESET_VECTOR
GOTO MYMAIN

END

220
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Example MYMAIN.ASM for 17Cxx (16-bit):


;------------------------------------------
; USER MAIN FILE
;------------------------------------------
...
INCLUDE "MYPROJ16.VAR"
ORDER EQU MSB_LSB ;compatibility
...
ORG CODE_START
MYMAIN
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 LOOP
NO_FIRE
;CALL DEFAULTHANDLING
GOTO LOOP
INCLUDE "MYPROJ16.ASM"
;------------------------------------------
; RESET VECTOR
;------------------------------------------
ORG RESET_VECTOR
GOTO MYMAIN
END

221
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.3. MCU-51 Edition

The fuzzyTECH MCU-51 Edition includes the RTRCD module and generates
assembler source code for the entire 8051 family. You need the
compiler/assembler tool kit from BSO/TASKING, IAR, INTEL,
KEIL/FRANKLIN or PLC to build an application for this family. 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 up to four


modules:
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 specific
fuzzy logic system.
3. One or more of your own software modules either in C or assembler
language for implementing the application that uses the fuzzy logic system.
4. A communication module that supports the serial interface of the 8051. Note
that this applies only, if you use the RTRCD option.

Figure 148 illustrates the hierarchy of these modules:

User Modules (*.C or *.A51)

Fuzzy Fuzzy ... Fuzzy Fuzzy Library


Module 1 Module 2 Module N FTxyz.LIB:
*.A51 *.A51 *.A51
Fuzzy Library FTxyz.LIB: RTRCD Module

Fuzzy Algorithms Communication


Module:
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 highly
optimized for both speed and size. The location for the libraries is
RUNTIME/51/LIB. Please refer to 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.

222
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Library Name CPU Memory Tool Kit Tool Kit


Mode Manufacturer Release
Number
FT51I.LIB 8051 Intel 2.3
FT51K.LIB 8051 Keil/Franklin 3.2 up to 4
FT51K5.LIB 8051 Keil/Franklin 5.0 or more
FT517K.LIB 80517 Keil/Franklin 3.2 up to 4
FT517K5.LIB 80517 Keil/Franklin 5.0 or more
FT251KS.LIB 80251 source Keil/Franklin 1.02 or more
FT251KB.LIB 80251 binary Keil/Franklin 1.02 or more
FT51TK.LIB 8051 BSO/Tasking 3.0 or more
FT517.LIB 80517 BSO/Tasking 3.0 or more
FT251TKS.LIB 80251 source BSO/Tasking 1.0 or more
FT251TKB.LIB 80251 binary BSO/Tasking 1.0 or more
FT51IAR.LIB 8051 IAR 5.12 or more
FT517IAR.LIB 80517 IAR 5.12 or more
FT251PS.LIB 80251 source PLC 2.01 or more
FT251PB.LIB 80251 binary PLC 2.01 or more

Note that fuzzyTECH does not support the RTRCD functionality for the tool kit
of Intel.

6.1.3.3.2. RTRCD Communication Module


Most code of the RTRCD module is part of the fuzzy library. This does not
include the communication module that access the serial interface. It is delivered
in 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 a
separate module COMM.C.

Note that COMM.C uses interrupts both for transmitting and receiving data. You
may have to change the interrupt priority, if you use more interrupts. Note that
the declarations of the functions and variables defined in COMM.C are fixed
interfaces of the fuzzy library. Do not change these definitions.

6.1.3.3.3. Generating and Using the Assembler Module


Generate the
Assembler Module This section shows how the assembler modules generated by fuzzyTECH can be
integrated into your own software modules. First select your tool kit
Manufacturer (BSO/TASKING, IAR, Intel, KEIL/Franklin or PLC) from the
menu “Tools/MCU-Tool Kit” in the fuzzyTECH Shell. Select “8051...” or
“80251...” from the “Tools/Compile to...” menu in the fuzzyTECH Shell to

223
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

generate the current fuzzy logic project as assembler code. The code generator
creates two files with the same name as the fuzzy system, one with the file
extension *.A51, the other one with the extension *.H. The *.A51 file
contains 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 of
the fuzzy logic system. The generated modules 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 to
integrate 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 from
Assembler 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 the
directory RUNTIME\51\SAMPLES\MYPROJ51.

MYMAINS.I CPU: 51 and 517; tool kit manufacturer: Intel


MYMAIN.IAR CPU: 51 and 517; tool kit manufacturer: IAR
MYMAIN.K CPU: 51, 517, 251; tool kit manufacturer: KEIL/FRANKLIN
MYMAINS.P2 CPU: 251; tool kit manufacturer: PLC
MYMAIN.TK CPU: 51 and 517; tool kit manufacturer: BSO/TASKING
MYMAIN.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 source
code. Users of RTRCD module have additionally to include the file RTRCD.H,
which is located at RUNTIME\51\INCLUDE. It is recommended to include the
fuzzy systems before the RTRCD.H file.

224
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Initialization Some initialization functions must be called only once during the startup of the
application. Users of the RTRCD module have first to initialize the RTRCD
module with the function initrtrcd() for C source code. It is important to
do this before initializing any fuzzy system modules. Afterwards each fuzzy
system module must 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 8 bit unsigned char. Their value range is defined
by 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 the
correct data type automatically. The *.H file contains the export interface to all
input and output variables of the fuzzy logic system for ANSI C language.
Additionally the value ranges are printed as comments in the file with the
extension *.H. The names of the exported variables are constant. They are
derived from the names you have used in fuzzyTECH and follow this scheme for
C 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 order
bit and assigned in sequence to the output variables in alphanumeric order. A
zero 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 one
rule fired. INVALIDFLAGS represents an 8-bit integer for the fuzzyTECH
MCU-51 Edition.

Example
Return 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 and
B_Out. All higher order bits are not used. A return value of 2 evaluated in a
specific control cycle now indicates that no rule for variable A_Out fired, and
that B_Out was evaluated by at least one of the defined fuzzy rules. A return
value of 0 would indicate that at least one rule for every output variable did fire.

225
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

8-bit INVALIDFLAGS Output Variables Output


value rv=2 Value

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 Output
Interfaces.

RTRCD Communication Add the following call to the RTRCD module in your C source code to support
the communication mechanism.

#ifdef FT_RTRCD
rtrcd(); /* 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, if
your application has a kind of main control loop, this would be the best place to
insert the function call.

Note that the function rtrcd()should not interrupt the computation of the
fuzzy systems. This is important, in case you use a timer interrupt to call this
function.

Note that the function rtrcd()is programmed in such a way that it consumes
as little time as possible. During an active online connection it copies the
maximum number of 76 bytes and sends an answer to fuzzyTECH before it
returns. If no active online connection is running, the function returns
immediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate code
supporting a trace 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 is controlled by the Trace Control dialog. The dialog offers an option to
start or stop the trace process by external trigger events. Therefore the generated
code exports two additional functions that control the trace process. Call these
functions in your source code to start or stop the trace at arbitrary logical
conditions.

226
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Note that once the Trace process has been started, multiple calls of the following
start 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 generated
assembler module. It uses two fuzzy systems with the names MYPROJ1.FTL
and 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 */

227
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

... = 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 all
modules that are part of the fuzzy runtime system. This section is a rather general
description and not a step-by-step guidance. It may be necessary to browse your
tool kit manual to realize the building steps. Please follow the enumerated steps
below if you implement a new application. If you add a fuzzy runtime system to
an existing application please proceed analogously.

1. Verify, whether your compiler/assembler tool kit for the 8051 or 80251
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 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.

228
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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, and
BUILDASM.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 the
sample can not give appropriate settings for your locator call. You have to adapt
it due to your hardware. Please refer to the manual of your tool kit for more
details about section locating.
Temporary
Used 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 the
variables 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 (for
example, for var1):
extern BYTE data var1;

The number of internal variables available for sharing in the MCU-51 Edition is
depicted in Section 9.4.

229
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.4. MCU-374 Edition

The fuzzyTECH MCU-374 Edition uses a specialized library, the fuzzyTECH


kernel. Since this kernel contains highly optimized assembler functions, the
generated code is much more efficient and compact compared to the C code
library described in Section 4.2. To achieve maximum performance with
different devices and compiler tool kits, the following kernels are delivered with
the MCU-374 Edition:

FT38.LIB Supports members of the 374 family with internal MUL / DIV
instructions for Mitsubishi tool kit.

FT38IAR.LIB Supports members of the 374 family with internal MUL / DIV
instructions for IAR tool kit.

Compatibility The fuzzyTECH MCU-374 Edition supports the entire Mitsubishi 374
microcontroller family with internal MUL / DIV instructions.

Integration To integrate the fuzzy system with the code of the entire system, you need an
Assembler. You may also use an in-circuit emulator (ICE) for test and
integration (optional). The assembler libraries FT38.LIB and FT38IAR.LIB are
ready compiled and archived. You do not need to create these libraries.

fuzzyTECH Kernel The MCU-374 code generator uses a fuzzyTECH kernel, containing the fuzzy
logic engine modules. The kernel is a highly optimized assembler library. Figure
150 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.A74
or MYMAIN.A31 source code. This source code calls the fuzzy logic system
function as an assembler function in MYPROJ.A74 for Mitsubishi or
MYPROJ.A31 for IAR.

Figure 150: Integration of the Fuzzy Logic System

Generated Code MYPROJ.Axx is generated by the fuzzyTECH MCU-374 Edition from your
project stored as MYPROJ.FTL. MYPROJ.Axx uses the fuzzy logic modules
contained in the kernel FT374.LIB. The file BUILD.BAT is located in the

230
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

subdirectory ..\RUNTIME\374\SAMPLES\MYPROJ74\ contains a full example


with the project name CRANE using Angle and Distance as input variables and
Power as output. To support the appropriate tool kit optimal, you have to choose
the tool kit in the menu “Tools/MCU Toolkit” and generate the controller in the
menu “Tools/Compile to/374...” for your tool kit. The code generator generates
an file with the extension *.A74 for the Mitsubishi tool kit and *.A31 for the
IAR 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. This
kernel contains configurable modules for fuzzification,
defuzzification and rule inference. The FT38x.LIB files are
located in the ..\RUNTIME\374\LIB\ subdirectory.

MYPROJ.Axx The file generated by the fuzzyTECH MCU-374 Edition. You


have to assemble this file using an assembler for the 374
microcontrollers 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 logic
functions and the inputs and outputs. If your main program is in
C, you can include this file in your source file.

MYMAIN.Axx This file contains an sample main program in assembler code.


This code calls the fuzzy logic system as an assembler code
function (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 in
C, you have to declare the fuzzy functions and interfaces. This can be done
by including the generated file MYPROJ.H in your main program.
2. Generate the file MYPROJ.A74 for Mitsubishi or MYPROJ.A31 for IAR
tool 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 or
C740 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=????

231
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

BUILD.BAT All these build steps are prepared in the batch file BUILD.BAT located in the
subdirectory ..\RUNTIME\374\SAMPLES\MYPROJ74\ for your appropriate
tool kit.
Debugging with
Serial 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 located
in the subdirectory ..\SERLINK\374\SAMPLES\. The example batch file
BUILD.BAT is prepared for using the Mitsubishi or the IAR tool kit. For details
concerning 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 by
the linker. RAM and ROM segments can be moved in the whole available
address range by linker commands. 6 bytes scratch RAM at the zero page are
used internally by the fuzzy kernel routines. All other RAM, used for the kernel
and fuzzy controller, can be freely located.
Calling the
Fuzzy System The code in the file MYPROJ.Axx, generated by fuzzyTECH, provides two
assembler code functions. One contains the entire fuzzy logic computation, the
other an initialization routine:

myproj:
initmyproj:

The initmyproj function initializes the internal variables of the kernel and
has 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. The
fuzzy function starts computing the input vector of the public global variables
and 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 are
generated for functions and variables are unique and cannot be mixed with other
projects. The library will only be linked once.
Temporary
Used 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 variables
must 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 in


Section 9.4.

232
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Return Value The fuzzy logic function returns a value in variable INVALIDFLAGS. Each bit
in INVALIDFLAGS represents one output variable, using the lower significant
bits in alphabetic sequence. A zero 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 one rule fired. INVALIDFLAGS represents a 8-bit
integer for the fuzzyTECH MCU-374 Edition.

8-bit FLAGS Variables in Output


value rv = 5 Output Interface Value

MSB:7 0 not used -


... ... ... ...
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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_Out
and D_Out. For this system, the bits 3...0 of the return variable correspond to
variable A_Out .. D_Out. All higher bits are not used. A return value of 5
evaluated in a specific control cycle now indicates, that no rule for both the
second 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 for
an assembler and an C code main program. If you design your own project, you
have to make sure, that the label myproj corresponds to the name of your
generated project, both in file names and in function calls. MYPROJ.FTL in this
example has two inputs and two outputs.

233
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Example MYMAIN.A74: (Mitsubishi tool kit)

.EXT _crane
.EXT _initcrane
.EXT _lv0_Angle
.EXT _lv1_Distance
.EXT _lv2_Power

.EXT _invalidflags
...
.SECTION CODE
main:
JSR _initcrane ;One time initialisation
...
LOOP:
...
LDA #$78
STA _lv0_Angle ;Setting first input
LDA #$87
STA _lv1_Distance ;Setting second input
JSR _crane ;call fuzzy function

LDA _invalidflags
BEQ 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

234
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Example MYMAIN.A31: (IAR tool kit)

.EXT _crane
.EXT _initcrane
.EXT _lv0_Angle
.EXT _lv1_Distance
.EXT _lv2_Power
.EXT _invalidflags
...
.SECTION CODE
main:
JSR _initcrane ;One time initialisation
...
LOOP:
...
LDA #$78
STA NP:_lv0_Angle ;Setting first input
LDA #$87
STA NP:_lv1_Distance ;Setting second input
JSR _crane ;call fuzzy function
LDA NP:_invalidflags
BEQ 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

235
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 the
compiler tool kit from BSO/TASKING or INTEL to build an application for this
family. 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 specific
fuzzy logic system.

236
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

3. One or more of your own software modules either in C or assembler


language 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)

Fuzzy Fuzzy ... Fuzzy Fuzzy Library


Module 1 Module 2 Module N FT96x.LIB:
*.C *.C *.C
Fuzzy Library FT96x.LIB: RTRCD Module

Fuzzy Algorithms Communication


Module:
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 highly
optimized for both speed and size. The location for the libraries is
RUNTIME/96/LIB. Please refer to the table below to find the library that
matches with your environment.

Library Name CPU Tool Kit Tool Kit Release


Manufacturer Number
FT96.LIB 80x96 INTEL 1.3
FT96TK.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 not
include the communication module that accesses the RS-232 serial interface. It is
delivered in assembler source code to allow changes of the settings. The file
name of the communication module is COMM.C for the serial interface, please
refer to the following directory:
RUNTIME\96\LIB\SRC

Note that the functions and variables defined in COMM.C are fixed interfaces of
the fuzzy library. Do not change these definitions.

237
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.5.3. Using the Generated C Module


Generate the
C 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 logic
project as C code. The code generator creates two files with the same name as
the fuzzy system, one with the file extension *.C, the other one with the
extension *.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 of
the fuzzy logic system. The generated modules use the project independent fuzzy
logic algorithms of the fuzzy library.

Integration The following enumeration gives an overview about the steps necessary to
integrate 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 source
code. Users of RTRCD module have additionally to include the file RTRCD.H
which is located at RUNTIME\96\INCLUDE. It’s recommended to include the
fuzzy systems before the RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of the
application. Users of the RTRCD module have first to initialize the RTRCD
module with the function initrtrcd(). It’s important to do this before
initializing any fuzzy system modules. Afterwards each fuzzy system module
must 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 is
defined by the code values in the Variables Properties: Base dialog. If the [Public
238
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Input and Output] option in Tools/Project Options/Code Generator is enabled,


the generated fuzzy logic system accepts its input and output variables as global
variables. They are exported in the *.H file with the correct data type
automatically. Additionally the value ranges are printed as comments. The
names of the exported variables are constant. They are derived from 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 in any case the same as given for
the fuzzy logic system itself. Depending on the chosen parameter passing and
data type options the fuzzy computation function exported in the *.H file will
have 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 of
the fuzzy logic system with the correct data type automatically. The names of
these variables are constant. They are based on the names you have used in
fuzzyTECH 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 your
source code. One variable for each input and each output of the fuzzy logic is
recommended. You are free to use any names for these variables, but their data
type has to be FUZZY. When calling the computation function, you have to place
your variables at the correct position that matches the fuzzy logic system. In any
case the function needs first the inputs. They are in alphanumeric order sorted by
the variable names used in fuzzyTECH. The function expects call-by-reference
parameters after the inputs. This is one pointer for each output variable in
alphanumeric 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 variables
in alphanumeric order. A zero bit for a variable indicates that for this output
variable at least one rule has fired. Hence, a return value of zero indicates that
for every output variable at least one rule has fired. The data type for FLAGS
represents a 16-bit integer for the fuzzyTECH Edition.

239
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 variable
correspond to variable A_Out .. D_Out. All higher order bits are not used. A
return value of 5 evaluated in a specific control cycle now indicates that no rule
has fired for the second and the forth output variable.

16-bit FLAGS Variables in Output


value rv=5 Output Interface Value

MSB:15 0 not used -


14 0 not used -
... ... ...
... 0 not used -
... ... ...
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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 Output
Interfaces (16-bit FLAGS type)

RTRCD Communication Add the following call to the RTRCD module in your source code to support the
communication mechanism.
#ifdef FT_RTRCD
rtrcd(); /* 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, if
your application has a kind of main control loop, this would be the best place to
insert the function call.

Note that the function rtrcd() should not interrupt the computation of the
fuzzy systems. This is important, in case you use a timer interrupt to call this
function.

Note that the function rtrcd() is programmed in such a way that it consumes
as little time as possible. During an active online connection it copies the
maximum number of 76 bytes and sends an answer to fuzzyTECH before it
returns. If no active online connection is running, the function returns
immediately.

240
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Temporary
Used 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 used
for other code. Therefore, the variables must be declared as external. The
variable names are var1, var2,..., and the declaration syntax is (for the example
var1):
extern FUZZY var1;

The number of internal variables available for sharing with the MCU-96 Edition
is depicted in Section 9.4.

Code Sample The following listing of pseudo C code illustrates the usage of the generated
assembler module. It uses two fuzzy systems with the names MYPROJ1.FTL
and MYPROJ2.FTL and supports the RTRCD module.

241
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

/* 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 */

242
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

/* 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 */

243
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.5.4. Building an Executable File


Build Steps This section describes the compiling, assembling and linking process of all
modules that are part of the fuzzy runtime system. Assuming you are firm in
using your tool kit and in adapting the locator instructions, that match with your
hardware, this section is a rather general description and not a step-by-step
guidance. It may be necessary to browse your tool kit manual to realize the
building steps.

Please follow the enumerated steps below if you implement a new application. If
you add a fuzzy runtime system to an existing application please proceed
analogously.
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 the
sample can not give appropriate settings for your locator call. You have to adapt
it due to your hardware. Please refer to the manual of your tool kit for more
details about section locating.

244
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 range
with linker commands. If a fixed memory allocation is necessary, a linker
command 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 generates
assembler source code for the entire 80C166/167/ST10 family. You need either
the compiler/assembler tool kit from BSO/Tasking or Keil/Franklin to build an
application for this family. 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 FT16xyz.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 specific
fuzzy logic system.
3. One or more of your own software modules either in C or assembler
language for implementing the application, that uses the fuzzy logic system.
4. A communication module that supports the serial interface of the
80C166/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)

Fuzzy Fuzzy ... Fuzzy Fuzzy Library


Module 1 Module 2 Module N FT16xyz.LIB:
*.A66 *.A66 *.A66
Fuzzy Library FT16xyz.LIB: RTRCD Module

Fuzzy Algorithms Communication


Module:
SERIALx.A66
Figure 154: Fuzzy Runtime Systems and RTRCD for 80C166 Family

245
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.6.1. Fuzzy Library


The fuzzy library is delivered in binary form for different tool kits. It is highly
optimized for both speed and size. The location for the libraries is
RUNTIME/166/LIB. Please refer to the table below to find the library that
matches with your environment.

Library Name CPU Memory Tool Kit Tool Kit Release


Model Manufacturer Number
FT166TB.LIB 80C166 Tiny BSO/Tasking 4.0 or more
FT166TB3.LIB 80C166 Tiny BSO/Tasking 3.0
FT166TK.LIB 80C166 Tiny Keil/Franklin 2.05 or more
FT167TB.LIB 80C167 Tiny BSO/Tasking 4.0 or more
FT167TK.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 not
include the communication module that accesses the serial interface. It is
delivered in assembler source code to allow changes of the settings. Note that the
80C166 is equipped with two serial interfaces (S0 and S1). You have to decide
which of both you want to use. The file name of the communication module is
either SERIAL0.A66 or SERIAL1.A66 for the serial interface S0 or S1. To
find the module that matches to your environment, please refer to one of the
following 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 receiving
data. You may have to change the interrupt priority, if you use more interrupts.
Note that the functions and variables defined in SERIALx.A66 are fixed
interfaces of the fuzzy library. Do not change these definitions.

6.1.3.6.3. Using the Generated Assembler Module


Generate the
Assembler 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 the
current fuzzy logic project as assembler code. The code generator creates two
files 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

246
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 of the fuzzy logic system. The generated
assembler modules use the project independent fuzzy logic algorithms of the
fuzzy library.

CPU Registers The generated assembler module dynamically allocates a local register bank on
the system stack (32 byte). Note, register R0 is never used by MCU-166
generated code and R0 must hold the user stack pointer. The generated code does
not use any special function registers (SFRs).

Integration You may either call the fuzzy logic module from C code or assembler code. The
following enumeration gives an overview about the steps necessary to integrate 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.
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 source
code. Users of RTRCD module have additionally to include the file RTRCD.H
which is located at …\RUNTIME\166\INCLUDE. It’s recommended to include
the fuzzy systems before the RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of the
application. Users of the RTRCD module have first to initialize the RTRCD
module with the function initrtrcd(). It’s important to do this before
initializing any fuzzy system modules. Afterwards each fuzzy system module
must 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 is
defined by the code values in the Variables Properties: Base dialog. The *.H file

247
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

contains the interface to all input and output variables of the fuzzy logic system
with the correct data type. Additionally the value ranges are printed as
comments. The names of the exported variables are constant. They are derived
from 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 variables
in alphanumeric order. A zero bit for a variable indicates that for this output
variable at least one rule has fired. Hence, a return value of zero indicates that for
every output variable at least one rule has fired. The data type for FLAGS
represents a 16-bit integer for the fuzzyTECH Edition.
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 variable
correspond to variable A_Out .. D_Out. All higher order bits are not used. A
return value of 5 evaluated in a specific control cycle now indicates that no rule
has fired for the second and the forth output variable.

16-bit FLAGS Variables in Output


value rv=5 Output Interface Value

MSB:15 0 not used -


14 0 not used -
... ... ...
... 0 not used -
... ... ...
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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 Output
Interfaces (16-bit FLAGS type)

248
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

RTRCD Communication Add the following call to the RTRCD module in your source code to support the
communication mechanism.

#ifdef FT_RTRCD
rtrcd(); /* 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, if
your application has a kind of main control loop, this would be the best place to
insert the function call.

Note that the function rtrcd() should not interrupt the computation of the
fuzzy systems. This is important, in case you use a timer interrupt to call this
function.

Note that the function rtrcd() is programmed in such a way that it consumes
as little time as possible. During an active online connection it copies the
maximum number of 76 bytes and sends an answer to fuzzyTECH before it
returns. If no active online connection is running, the function returns
immediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate code
supporting a trace 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 is controlled by the Trace Control dialog. The dialog offers an option to
start or stop the trace process by external trigger events. Therefore the generated
assembler code exports two additional functions that control the trace process.
Call these functions in your source code to start or stop the trace at arbitrary
logical conditions. Note that once the Trace process has been started, multiple
calls 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 generated
assembler module. It uses two fuzzy systems with the names MYPROJ1.FTL
and 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 */

249
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime 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
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 */

250
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

6.1.3.6.4. Building an Executable File


Build Steps This section describes the compiling, assembling and linking process of all
modules that are part of the fuzzy runtime system. Assuming you are firm in
using your tool kit and in adapting the locator instructions, that match with your
hardware, this section is a rather general description and not a step-by-step
guidance. It may be necessary to browse your tool kit manual to realize the
building steps.

Please follow the enumerated steps below if you implement a new application. If
you add a fuzzy runtime system to an existing application please proceed
analogously.

1. Verify, whether your compiler/assembler tool kit for the 80C166 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 FT16xyz.LIB with
x is the derivative of the 80C166 family: 6 or 7
y is the memory model: t
z is the tool kit manufacturer: b or k
• Add the communication module SERIALx.A66 (RTRCD only) with
x is the number of the serial interface: 0 or 1.
• Add the directory …\RUNTIME\166\INCLUDE to the include file
search path of your compiler.
• Add the directory …\RUNTIME\166\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).
• 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 and
MAKEKEIL.BAT for Keil/Franklin.

251
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Please use a copy of these files as basis for your own application. Note that the
sample can not give appropriate settings for your locator call. You have to adapt
it due to your hardware. Please refer to the manual of your tool kit for more
details about section locating.

6.1.3.7. MCU-320 Edition

The fuzzyTECH MCU-320 Edition uses a specialized library, the fuzzyTECH


kernel. For the C2X and C5X families, this kernel contains highly optimized
assembler functions. For the C3X and C4X families, this kernel is provided as
C source code. This is due to the fact that for the C2X and C5X families, the
assembler kernel is far more efficient compared to the C code solution, while the
C3X and C4X families are capable of processing even the C kernel very
efficiently. For implementations on the C3X and C4X family, refer to
Section 6.1. For the C2X and C5X families, the following assembler language
kernels 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 entire
system. Inform recommends using TI’s development tools. You may also use an
In-Circuit Emulator (ICE) for testing and integration (optional). The assembler
kernel FT320_XX.LIB is already compiled and archived. You do not need to
create this library.

fuzzyTECH Kernel As a C code generator, the MCU-320 code generator uses a fuzzyTECH kernel
that contains the fuzzy inference engine modules. Thus, the files generated are in
C, 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, plus
the pre- and post processing of input and output data are contained in the
MYMAIN.C source code. This source code calls the fuzzy logic system function
as a C function. This function is contained in MYPROJ.C.

252
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Generated Code MYPROJ.C is generated by the fuzzyTECH MCU-320 Edition from your project
and stored as MYPROJ.FTL. MYPROJ.C uses the fuzzy logic modules
contained in the kernel FT320_XX.LIB. The file BUILD.BAT in the
subdirectory …\RUNTIME\320\SAMPLES\MYPROJ contains a complete
example 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 signal
processor family. This kernel contains configurable modules
for fuzzification, rule inference and defuzzification. The
FT320_XX.LIB file comes with the fuzzyTECH MCU-320
Edition in the ...\RUNTIME\320\LIB subdirectory.

FTLIBC.H This file contains the function prototypes of the


FT320_XX.LIB. It is always included in MYPROJ.C. This file
also contains declarations of the configuration variables of the
FT320_XX.LIB. The FTLIBC.H file comes with the
fuzzyTECH MCU-320 Edition in the subdirectory
...\RUNTIME\320\INCLUDE.

MYMAIN.C Your main program, containing all interfaces, plus pre- and
post processing of input and output data.

MYPROJ.C The output file of the MCU-320 Edition. You have to compile
this file using a TMS 320 compiler, such as the DSPCL. For
example, type:
DSPCL -v50 -ma -mx MYPROJ.C MYMAIN.C or
DSPCL -v25 MYPROJ.C MYMAIN.C
to generate the file MYPROJ.OUT.

MYPROJ.H Also generated by the MCU-320 Edition. MYPROJ.H contains


a function prototype for the fuzzy logic system function. You
have 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 or
DSPCL -v25 MYPROJ.C MYMAIN.C -z LINK.CMD
to generate the file CRANE.OUT.

253
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

BUILD.BAT All these building steps are summarized in the file BUILD.BAT, which is found
in the subdirectory ...\RUNTIME\320\SAMPLES\MYPROJ for the CRANE
project. 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 once
before 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 all
output variables are listed as parameters. The sequence of variables is
alphanumeric. The return value identifies output variables for which no rule has
fired.

Public IO If the [Public Input and Output] option in the dialog “Project Options/Code
Generator” is enabled, the fuzzy logic system generated accepts its input and
output variables as global variables. For the variable names, the name of the
fuzzy logic project (same as *.FTL file name) is appended with an underscore
after each variable name (low caps). For example, in MYPROJ.FTL with the
variables 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 the
inputs 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 entire
fuzzy logic computation. In order to initialize this function, the file MYPROJ.C
contains the same initialization function whether the [Public IO] option is
enabled or disabled. The initialization function must be called once before
calling the fuzzy logic system function. After this initialization, the fuzzy system
function does not need any further initialization.

Return Value The fuzzy logic system 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 variables
in alphanumeric order. A zero 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 one rule fired. The data type for FLAGS represents
a 16-bit integer for the fuzzyTECH MCU-320 Edition.

254
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 variable
correspond to variable A_Out .. D_Out. All higher bits are not used. A return
value of 5 evaluated in a specific control cycle indicates that no rule for both the
second and the forth output variable fired. A return value of 0 would indicate
that at least one rule for every output variable did fire (see Figure 157).

16-bit FLAGS Variables in Output


value rv=5 Output Interface Value

MSB:15 0 not used -


14 0 not used -
... ... ...
... 0 not used -
... ... ...
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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 Output
Interfaces (16-bit FLAGS type)

Example Integration The following examples show how to call the code generated by the fuzzyTECH
MCU-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 to
replace 'myproj' with your project name both in the file names and in the
function calls.

255
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 */;
}
}

256
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 */;
}

257
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.8. MCU-HC05/08 Edition

The fuzzyTECH MCU-HC05/08 Edition includes the RTRCD module for the
HC08 and generates assembler source code for the entire M68HC05 and
M68HC08 families. You need the compiler/assembler tool kit from COSMIC or
HIWARE to build an application for this families. 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 up to four


modules:
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 specific
fuzzy logic system.
3. One or more of your own software modules either in C or assembler
language 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)


Fuzzy Fuzzy ... Fuzzy Module Fuzzy Library
Module 1 Module 2 N FTxyz.LIB:
*.S *.S *.S
Fuzzy Library FTxyz.LIB: RTRCD Module
Fuzzy Algorithms Communication
Module:
COMM.S or
COMM_BDM.S
Figure 158: Hierarchy of the Fuzzy Runtime Systems and RTRCD (only for
M68HC08) 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 highly
optimized for both speed and size. The location for the libraries is
…\RUNTIME\MCUHC05\LIB or …\RUNTIME\MCUHC08\LIB. Please refer
to 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.

258
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Library Name CPU Tool Kit Tool Kit Release Number


Manufacturer
FT05COS.LIB M68HC05 COSMIC 4.0 or more
FT05HIW.LIB M68HC05 HIWARE 5.0 or more
FT08COS.LIB M68HC08 COSMIC 4.0 or more
FT08HIW.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 not
include the communication modules that access the serial interface. They are
delivered in assembler source code to allow changes of the settings. Usually this
is necessary, since different types of microcontrollers store code, data, or the
interrupt 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 also
Tools/fuzzyTECH Preferences/Serial Interface). 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. Note that the functions and
variables defined in COMM.S are fixed interfaces of the fuzzy library. Do not
change these definitions.

6.1.3.8.3. Using the Generated Assembler Module


Generate the
Assembler Module This section shows how the assembler modules generated by fuzzyTECH can be
integrated into your own software modules. First select your tool kit
Manufacturer (COSMIC or HIWARE) from the menu “Tools/MCU-Tool Kit” in
the fuzzyTECH Shell. Select “HC05...” or “HC08...” from the menu
“Tools/Compile to...” in the fuzzyTECH Shell to generate the current fuzzy logic
project as assembler code. The code generator creates two files 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 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 of the fuzzy logic system. The generated
modules 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 to
integrate a fuzzy system module into the source code of your software module(s)
in C language.

259
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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.C
or 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 software
module(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 source
code. 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 before
the RTRCD.H file.

Initialization Some initialization functions must be called only once during the startup of the
application. Users of the RTRCD module have first to initialize the RTRCD
module with the function initrtrcd() for C source code or JSR
_initrtrcd for assembler source code. It is important to do this before
initializing any fuzzy system modules. Afterwards each fuzzy system module
must be initialized. The initialization function follows the scheme:
void init<Module Name>(void); /* for ANSI C */
XREF _init<Module Name> ;for assembler
JSR _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 defined
by the code values in the Base Variable dialog. The *.S or the *.C file exports
all input and output variables of the fuzzy logic system with the correct data type

260
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

automatically. The *.H file contains the export interface to all input and output
variables of the fuzzy logic system for ANSI C language. Additionally the value
ranges are printed as comments in the files with the extension *.H and *.S. The
names of the exported variables are constant. They are derived from the names
you 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 control
flags. Each bit in FLAGS or of ACCUMULATOR A represents one output
variable, starting with the lowest order bit and assigned in sequence to the output
variables in alphanumeric order. A zero bit for a variable indicates that for this
output variable at least one rule has fired. Hence, a return value of zero indicates
that for every output variable at least one rule has fired. The data type for FLAGS
represents an 8-bit unsigned char for the fuzzyTECH Edition MCU-HC05/08.
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 variable
correspond to variable A_Out…D_Out. All higher order bits are not used. A
return value of 5 evaluated in a specific control cycle now indicates that no rule
has fired for the second and the forth output variable.

261
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

8-bit FLAGS or Variables in Output


value ACCU B Output Interface Value
rv=5

MSB:7 0 not used -


6 0 not used -
5 0 not used -
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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 Output
Interfaces (8-bit FLAGS type or ACCU A)

RTRCD Communication Add the following call to the RTRCD module in your C source code to support
the communication mechanism.

#ifdef FT_RTRCD
rtrcd(); /* call the RTRCD module */
#endif

If your source code is written in assembler language add this call:

XREF _rtrcd ; declaration


JSR _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
your application has a kind of main control loop, this would be the best place to
insert the function call.

Note that the function rtrcd() or _rtrtcd should not interrupt the
computation of the fuzzy systems. This is important, in case you use a timer
interrupt to call this function.

Note that the function rtrcd() or _rtrcd is programmed in such a way that
it consumes as little time as possible. During an active online connection it
copies the maximum number of 76 bytes and sends an answer to fuzzyTECH
before it returns. If no active online connection is running, the function returns
immediately.

262
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 and
output values of the fuzzy system in real-time in your application. During an
online 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 trigger
events. Therefore the generated code exports two additional functions that
control the trace process. Call these functions in your source code to start or stop
the trace at arbitrary logical conditions. Note that once the Trace process has
been 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 assembler
XREF _StopTrace<Module Name> ;for assembler
JSR _StartTrace<Module Name> ;for assembler
JSR _StopTrace<Module Name> ;for assembler

Code Sample The following listing of pseudo C code illustrates the usage of the generated
assembler module. It uses two fuzzy systems with the names MYPROJ1.FTL
and 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 ... */

263
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 all
modules that are part of the fuzzy runtime system. Assuming you are firm in
using your tool kit and in adapting the locator instructions, that match with your
hardware, this section is a rather general description and not a step-by-step
guidance. It may be necessary to browse your tool kit manual to realize the
building steps.

Please follow the enumerated steps below if you implement a new application. If
you add a fuzzy runtime system to an existing application please proceed
analogously.
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).

264
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

• Add the directory …\RUNTIME\MCUHC05\LIB or


RUNTIME\MCUHC08\LIB with the corresponding fuzzy library
FTxyz.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 interrupt
addresses corresponds to their microcontroller version.
• Locate all sections in your or the delivered linking directive and add the
paths of the object files and libraries. As for HIWARE, the C language
interface 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 and
BUILD08.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. Please
use a copy of these files as basis for your own application. Note that the sample
can not give appropriate settings for your locator call. You have to adapt it due to
your hardware. Please refer to the manual of your tool kit for more details about
section 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 on
global variables. To avoid the loss of memory space, these variables can be used
outside the fuzzy controller as well.

265
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

For the M68HC08, import the variables from the fuzzyTECH library as follows:
XREF_var11 ;1 Byte
XREF_var12 ;1 Byte
XREF_var13 ;1 Byte
XREF_var14 ;1 Byte
XREF_var15 ;1 Byte
XREF_var16 ;1 Byte
XREF_var17 ;1 Byte

XREF_var21 ;2 Byte
XREF_var22 ;2 Byte
XREF_var23 ;2 Byte
XREF_var24 ;2 Byte

For the M68HC05, import the variables from the fuzzyTECH library as follows:
XREF_var1 ;1 Byte
XREF_var2 ;1 Byte
*
*
*
XREF_var9 ;1 Byte
XREF_var10 ;1 Byte

Restrictions The M68HC05 allows only 256 elements per rule block. Due to its 8-bit
registers, the M68HC05 data tables are restricted. For this reason, the generated
assembly code of a fuzzyTECH rule table cannot contain more than 256
elements. This code is compressed and not to be mistaken with the number of
elements in the fuzzyTECH development shell. If you have more than 256
elements and are thus not allowed to generate code, then comply this restriction
by splitting a large rule table into a few smaller ones. This can be done very
quick by using fuzzyTECH’s “Duplicate Rule Block” function.

The M68HC05 cannot generate assembly code, if the Online option is enabled. If
so, please deactivate in the menu Tools/Project Options/Code Generator the
option Online Code, since the M68HC05 library has no RTRCD function.

The M68HC05 is multi-system incapable, i.e. it does not support multiple


instances (or multi-clients). Not more than one fuzzy project can be integrated
within source code. This restriction allows the M68HC05 to process several rule
tables.

266
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

6.1.3.9. MCU-HC11/12 Edition

The fuzzyTECH MCU-HC11/12 Edition includes the RTRCD module and


generates assembler source code for the entire M68HC11 and M68HC12
families. You need the compiler/assembler tool kit from COSMIC, HIWARE,
IAR or MOTOROLA to build an application for this family. 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 up to four


modules:
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 specific
fuzzy logic system.
3. One or more of your own software modules either in C or assembler
language for implementing the application, that uses the fuzzy logic system.
4. A communication module that supports either the serial interface of the
M68HC11 / M68HC12 or the SDI™ of the M68HC12. Note that this applies
only, if you use the RTRCD option.

User Modules (*.C or *.S)


Fuzzy Fuzzy ... Fuzzy Module Fuzzy Library
Module 1 Module 2 N FTxyz.LIB:
*.S *.S *.S
Fuzzy Library FTxyz.LIB: RTRCD Module
Fuzzy Algorithms Communication
Module:
COMM.S or
COMM_BDM.S

Figure 160: Hierarchy of the Fuzzy Runtime Systems and RTRCD for M68HC11
and M68HC12 families

6.1.3.9.1. Fuzzy Library

The fuzzy library is delivered in binary form for different tool kits. It is highly
optimized for both speed and size. The location for the libraries is
…\RUNTIME\HC11\LIB or …\RUNTIME\HC12\LIB. Please refer to 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.

267
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Library Name CPU Tool Kit Tool Kit


Manufacturer Release
Number
FT11COS.LIB M68HC11 COSMIC 4.0 or more
FT11HIW.LIB M68HC11 HIWARE 2.7 or more
FT11IAR.LIB M68HC11 IAR 4.11or more
FT11MOT.LIB M68HC11 MOTOROLA 5.0 or more
FT12COS.LIB M68HC12 COSMIC 4.0 or more
FT12HIW.LIB M68HC12 HIWARE 2.7 or more
FT12IAR.LIB M68HC12 IAR 2.1 or more
FT12MOT.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 not
include the communication modules that access the serial interface or the SDI™
interface. They are delivered in assembler source code to allow changes of the
settings. 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 the
following 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 “Online
Communication Channel” in fuzzyTECH” select the channel ...\FTSDI.DLL...,
click the [Configuration] key and update the starting address of the
communication buffer on target. The communication buffer is called _BDM_Buf
and is located in the file COMM_BDM.S. You can get the starting address out of
the *.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 starting
address of the RAM array on target into the Setup dialog. fuzzyTECH starts its
search for the communication buffer from this address on. Further you must
verify a port and baud rate by clicking the [Configuration] key in fuzzyTECH’s
Online 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 “Online
Communication Channel”.

268
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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. Note
that the functions and variables defined in COMM.S and COMM_BDM.S are
fixed interfaces of the fuzzy library. Do not change these definitions.

6.1.3.9.3. Using the Generated Assembler Module


Generate the
Assembler Module This section shows how the assembler modules generated by fuzzyTECH can be
integrated into your own software modules. First select your tool kit
Manufacturer 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 the
current fuzzy logic project as assembler code. The code generator creates two
files 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 the
external symbol definitions of the fuzzy logic system. The *.H file contains the
export interface of this module for ANSI C language. For this reason no *.H file
will be generated for the tool kit of Motorola; a compiler is not available. Note
that the name of each exported function or variable ends with the name of the
fuzzy logic system. The generated modules 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 to
integrate 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.C
or the Example 7 at the end of this section.

269
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Integration from Assembler How to integrate a fuzzy system module into the source code of your software
module(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 source
code. 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.H
file.

Initialization Some initialization functions must be called only once during the startup of the
application. Users of the RTRCD module have first to initialize the RTRCD
module with the function initrtrcd() for C source code or JSR
_initrtrcd for assembler source code. It is important to do this before
initializing any fuzzy system modules. Afterwards each fuzzy system module
must be initialized. The initialization function follows the scheme:
void init<Module Name>(void); /* for ANSI C */
XREF _init<Module Name> ;for assembler
JSR _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 defined
by the code values in the Base Variable dialog. The *.S or the *.C file exports
all input and output variables of the fuzzy logic system with the correct data type
automatically. The *.H file contains the export interface to all input and output
variables of the fuzzy logic system for ANSI C language. Additionally the value
ranges are printed as comments in the files with the extension *.H and *.S. The
names of the exported variables are constant. They are derived from the names
you 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>

270
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 variables
in alphanumeric order. A zero bit for a variable indicates that for this output
variable at least one rule has fired. Hence, a return value of zero indicates that
for every output variable at least one rule has fired. The data type for FLAGS
represents an 8-bit unsigned char for the fuzzyTECH Edition MCU-HC11/12.
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 variable
correspond to variable A_Out…D_Out. All higher order bits are not used. A
return value of 5 evaluated in a specific control cycle now indicates that no rule
has fired for the second and the forth output variable.

8-bit FLAGS or Variables in Output


value ACCU B Output Interface Value
rv=5

MSB:7 0 not used -


6 0 not used -
5 0 not used -
4 0 not used -
3 0 A_Out calculated
2 1 B_Out default-value
1 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 Output
Interfaces (8-bit FLAGS type or ACCU B)

RTRCD Communication Add the following call to the RTRCD module in your C source code to support
the communication mechanism.
#ifdef FT_RTRCD
rtrcd(); /* call the RTRCD module */
#endif

If your source code is written in assembler language add this call:


XREF _rtrcd ; declaration
JSR _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

271
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

your application has a kind of main control loop, this would be the best place to
insert the function call.

Note that the function rtrcd() or _rtrtcd should not interrupt the
computation of the fuzzy systems. This is important, in case you use a timer
interrupt to call this function.

Note that the function rtrcd() or _rtrcd is programmed in such a way that
it consumes as little time as possible. During an active online connection it
copies the maximum number of 76 bytes and sends an answer to fuzzyTECH
before it returns. If no active online connection is running, the function returns
immediately.

Trace Control If the RTRCD option is enabled fuzzyTECH offers the option to generate code
supporting a trace 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 is controlled by the Trace Control dialog. The dialog offers an option to
start or stop the trace process by external trigger events. Therefore the generated
code exports two additional functions that control the trace process. Call these
functions in your source code to start or stop the trace at arbitrary logical
conditions. Note that once the Trace process has been 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 assembler
XREF _StopTrace<Module Name> ;for assembler
JSR _StartTrace<Module Name> ;for assembler
JSR _StopTrace<Module Name> ;for assembler

Code Sample The following listing of pseudo C code illustrates the usage of the generated
assembler module. It uses two fuzzy systems with the names MYPROJ1.FTL
and 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 */

272
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 */

273
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.3.9.4. Building an Executable File


Build Steps This section describes the compiling, assembling and linking process of all
modules that are part of the fuzzy runtime system. Assuming you are firm in
using your tool kit and in adapting the locator instructions, that match with your
hardware, this section is a rather general description and not a step-by-step
guidance. It may be necessary to browse your tool kit manual to realize the
building steps.

Please follow the enumerated steps below if you implement a new application. If
you add a fuzzy runtime system to an existing application please proceed
analogously.
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 linking
directive, 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 communication
module 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 interface
ANSIS.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, and
BUILDASM.BAT for your software module, written in assembler.

274
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

You find this files in the directory …\RUNTIME\HC11\SAMPLES\MYPROJ11


or …\RUNTIME\HC12\SAMPLES\MYPROJ12. 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 the sample can not give appropriate
settings for your locator call. You have to adapt it due to your hardware. Please
refer 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 the
function blocks of the SIEMENS S5 PLC. The devices supported by the
fuzzyTECH IA-S5 Edition are:
S5-95U
S5-100U CPU103
S5-115U CPU 941-944, 945
S5-135U CPU 928, 928B, 948, 948R
S5 155U CPU 928, 946, 947, 948

Due to their their limited computing capabilities, the S5-90U device as wwell as
the 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 can
be 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 and
the other tasks to be executed on the PLC is implemented via addresses entered
in the I/O-Mapping field in the Variables Properties/General dialog. fuzzyTECH
checks the plausibility of the addresses entered and highlights invalid characters.

Valid addresses are:


MWxxx (MERKERWORT) with xxx from 0-255
EWxxx (EINGANGSWORT) with xxx from 0-255
AWxxx (AUSGANGSWORT) with xxx from 0-255
PWxxx (PERPHERIEWORT) with xxx from 0-255
Dbyyy: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 function
block and the address of the first memory word (MERKERWORT: MW) that is
used by fuzzy routines.

275
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Code Generation The option “Tools /Compile to/S5” lets you generate the *.S5D file. Before code
generation, the system and all entries in I/O mapping and the S5 options are
checked for completeness and correctness. fuzzyTECH produces the following
function blocks within code generation that can be freely located in a valid
range:

DB xxx data block containing tables for fuzzification and


defuzzification 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 separate
data block.
FB yyy function block containing routines for the I/O-handling of the
fuzzy 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 on
the device,
MUL16: a multiplication routine. If MUL16 is required, one
more FB is generated. In this case, m is 1. For PLC’s without
the capability of 16-bit multiplying, m is 0.
FB yyy+2+c function blocks used to copy fuzzy values between the data
blocks. If more than 1 rule block exists, additional copy
function blocks are generated. c is the number of ruleblocks
minus one (-1).
MW xxx - yyy 16 memory words (32 bytes) are used internally for the fuzzy
calculations.

If the code generation is successfully completed, the number of generated


function and data blocks is displayed. The generated code file can now be
transferred to the programming device of the PLC. Do not change any addresses
in 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 the
application program. The number of this function block is the number specified
in the S5 option dialog. The activated function block initializes the loading of
the input values specified in the I/O mapping of the input interfaces, executes all
required fuzzy calculations, and writes the results to the addresses specified in
the I/O mapping field of the output interfaces. During fuzzy calculation, alarms
will be temporary deactivated. All calculations use a resolution of 15 bit
unsigned 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:

276
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

fuzzification linear memberships in 4-point definition (standard MBF)


inference minimum operator using FAM rules
defuzzification 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 data
blocks. However, a block limitation may occur. A check is executed during code
generation in fuzzyTECH. In addition, there are restrictions on the number of
interfaces, rule blocks and rules:

inputs 32 input variables each using max. 5 terms


outputs 8 output variables each using max. 5 terms
rule 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 remote
cross debugging function of the fuzzyTECH IA-S5 Edition, which connects
fuzzyTECH to a fuzzy controller running on the S5 PLC during runtime. Use a
serial cable containing a level converter for the connection. Note that fuzzyTECH
uses the AG-Link module by DELTALOGIC GmbH with copyright.

RTRCD-Limitations Although the complete functionality of the fuzzyTECH real time remote cross
debugger is realized on the S5, the trace function is especially limited. The
number of trace steps is restricted by the remaining space in the first generated
function block.
Example
Example:

FB 20 BIB=
NETZWERK 1
NAME :MAINLOOP
0005 :L KH 1000
0007 :T MW 100 Set 1. crisp value
0008 :
0009 :L KH 3000
000B :T MW 102 Set 2. crisp value
000C :
000D :SPA FB 30 Call fuzzy system
000E NAME :CRANE
000F :
0010 :L MW 104 Get 1. crisp output
0011 :T AW 32 Proceed output
0012 :
0013 :BE

277
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 for
which a C compiler exists. Any code generated by fuzzyTECH can be used
royalty-free. This applies also to the library, as long as it has not been modified
and 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 logic
system.
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 communication
channels supported by fuzzyTECH. Note that this applies only to the
fuzzyTECH Online Edition. Even for this edition the usage of a
communication module is optional.

Figures 162 and 163 illustrate the hierarchy of these modules:

User Modules

Fuzzy Fuzzy ... Fuzzy Module


Module Module N
1 2
fuzzyTECH C Runtime Library: Fuzzy Algorithms

Figure 162: Fuzzy Runtime Systems in C Language

User Modules

Fuzzy Fuzzy ... Fuzzy fuzzyTECH C


Module 1 Module 2 Module N Runtime Library:
fuzzyTECH C Runtime Library: Online Module

Fuzzy Algorithms Communication


Module
Figure 163: Fuzzy Runtime Systems And Online in C Language

278
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

The steps to get an application to run and compute one or more fuzzy logic
systems are described in this section as follows: Section 6.1.4.1 explains the
steps to build your own fuzzy library. Section 6.1.4.2 describes the integration of
the user interface of the fuzzy system modules into your own source codes.
Users of the fuzzyTECH Online Edition may need to integrate a communication
module to support the online connection between the fuzzy runtime system and
the fuzzyTECH Shell. Refer to Section 6.1.4.3 for more details. Section 6.1.4.4
describes the process of linking all modules together to get an application
running.

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 the
C Code based fuzzy runtime systems portable to any platform. Therefore you
have to create the binary form of the library yourself. Building your own
fuzzyTECH C Runtime Library allows you to use your favorite compiler with
your favorite compiler settings for your favorite target CPU.

Note: You can use any C compiler for any target CPU. Neither does the
fuzzyTECH C Runtime Library need other libraries nor does it include files of
your compiler.
Note: The fuzzyTECH C Runtime Library has to be built for your personal
environment only once. Afterwards, it can be used for all fuzzy runtime systems
on this environment.

Directory You should locate your library in the directory …\RUNTIME/C/LIB. All
necessary 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 general
description and not a step-by-step guidance. It may be necessary to browse your
compiler manual to realize the building steps. The library consists of many
modules. 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, the
integrated development environment (IDE) of your compiler. For some compiler
tool 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 only
some general hints. Some compilers offer options for optimizing the library

279
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

either for size or for speed. Note: Some compilers may support different memory
models (small, medium, large, ...). Make sure that the fuzzy library was compiled
for the same memory model as your application to be linked with the fuzzy
library. If you want to use different memory models you have to build separate
libraries for each memory model. Please refer to your compiler manual for more
details.

Sample The batch file FTMAKE.BAT creates the fuzzy library for the PC based C
compilers of Microsoft or Borland. It is based on the command line versions of
both 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 build
if-else-constructs that are evaluated at compile time. The same source code can
thus be used for multiple purposes. C programmers generally use preprocessor
definitions together with the statements: #define and #ifdef.
Why Is Their Usage
Essential? Different fuzzyTECH Editions need different fuzzyTECH C Runtime Libraries.
The building process for the different libraries is controlled by preprocessor
definitions. You have to set one or more preprocessor definitions to build a
library that matches the C code generated by your fuzzyTECH Edition. Some
Editions may generate C code for different computation resolutions. The
computation resolution is determined by the base variable type selected in the
Project Options dialog Global. These editions need two libraries, one for 8-bit
resolution 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 line
of 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 set
for which library and which edition.

Edition Library Name Preprocessor Definitions (optional)


Professional FTC16.LIB FTLIBC16 PRECOMPILER FT_KRC
FTC8.LIB FTLIBC8 PRECOMPILER FT_KRC
Online FTC16.LIB FTLIBC16 ONLINE FT_KRC
FTC8.LIB FTLIBC8 ONLINE FT_KRC
MCU-C, MCU-MP FTC16.LIB FTLIBC16
FTC8.LIB FTLIBC8
MCU-166, MCU-320, MCU-96 FTC16.LIB FTLIBC16
MCU-51, MCU-ST6, MCU-374, FTC8.LIB FTLIBC8
MCU-11/12

280
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 Visual
C/C++ Compiler. In order to create a library with 16 bit computation resolution
you may compile all C files in the directory RUNTIME/C/LIB/SRC with the
following command line call:

cl.exe -c -DFTLIBC16 -DPRECOMPILER *.C

where cl.exe is the call to the Microsoft compiler, -c is the compiler


command for generating object files only, -D is the command to set the
preprocessor definitions and *.C is the wildcard for all C source files in the
current 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 in
your own software modules. Select “Tools\Compile to...\C...” in the main menu
of fuzzyTECH to generate the current fuzzy logic project as C code. The code
generator creates two files with the same name as the fuzzy system, one with the
file extension *.C, the other one with the extension *.H. The *.C file contains
code and data of the fuzzy logic system, the *.H file contains the export
interface of this module. Note, that the name of each exported function or
variable in this *.H file ends with the name of the fuzzy logic system. Note that
the generated modules use the project independent fuzzy logic algorithms of the
fuzzy library. Assuming you want to integrate two different fuzzy logic systems
in your application. Furthermore the fuzzy logic systems have the names
MYPROJ1.FTL and MYPROJ2.FTL. Generating the C-Modules for both
systems will create the files:

MYPROJ1.C, MYPROJ1.H
MYPROJ2.C, MYPROJ2.H

Overview The following enumeration gives an overview about the steps necessary to
integrate a fuzzy system module into the source code of your software
module(s):

281
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 source
code. Users of the fuzzyTECH Online Edition have additionally to include the
file ONLINE.H which is located at RUNTIME\C\INCLUDE. Add the
following 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 the
application. The initialization function has no parameters and no return value.
Users of the fuzzyTECH Online Edition have to initialize the fuzzy online
module additionally. It’s important to do this before initializing the fuzzy system
modules. Add the following lines to the part of your source that contains the
startup sequence.

/*fuzzyTECH Online Edition only */


/*initialize the fuzzy online manager */
#ifdef FT_ONLINE
initonline(); /* must be done first */
#endif

/*all fuzzyTECH Editions */


/*initialize the fuzzy system modules */
initmyproj1();
initmyproj2();

282
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 fuzzy
system module. This option is controlled by the Public Input and Output
checkbox in the dialog “Project Options/Code Generator”.
Depending on your setting you get C code with a computation function using:
1. Function Parameters
2. Global Variables.

Note that global variables will probably be easier to handle, if you change the
number of input or output variables of your fuzzy logic system. The resulting
code may also be a little bit faster.
Fuzzy Computation:
Data Type and Range
of 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 radio
buttons Base Variable Data Type in the dialog “Project Options/Global”.
Depending on the setting in this dialog you get C code using variables with
1. 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 and
data type options the fuzzy computation function exported in the *.H file will
have 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 of
the fuzzy logic system with the correct data type automatically. The names of
these variables are constant. They are based on the names you have used in
fuzzyTECH and follow this scheme:
<Variable Name>_<Module Name>
<Term Name>_<Variable Name>_<Module Name>

283
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

If you use the function parameter interface, you have to declare variables in your
source code. One variable for each input and each output of the fuzzy logic is
recommended. You are free to use any names for these variables, but their data
type has to be either double or FUZZY. When calling the computation
function, you have to place your variables at the correct position that matches the
fuzzy logic system. In any case the function needs first the inputs. They are in
alphanumeric order sorted by the variable names used in fuzzyTECH. The
function expects call-by-reference parameters after the inputs. This is one pointer
for 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 type
FUZZY, 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 FUZZY
FUZZY 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 output
variable, starting with the lowest order bit and assigned in sequence to the output
variables in alphanumeric order. A zero bit for a variable indicates that for this
output variable at least one rule has fired. Hence, a return value of zero indicates
that for every output variable at least one rule has fired. The number of bits of
the data type FLAGS depends on the fuzzyTECH Edition:

284
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

fuzzyTECH Edition FLAGS


Professional, Online 32 bit integer
MCU-96, MCU-166, MCU-320 16 bit integer
MCU-C, MCU-ST6, MCU-MP, 8 bit integer
MCU-51, MCU-11/12

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 return
variable correspond to variable A_Output ... D_Output. All higher order bits are
not used. A return value of 5, evaluated in a specific control cycle, indicates that
no rule has fired for the second and the forth output variable.

32-bit FLAGS Variables in Output


value flags=5 Output Interface Value

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 calculated
2 1 B_Output default-value
1 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 Output
Variables (32-bit FLAGS type)

Online Communication The fuzzyTECH Online Edition has the option to enable an online connection
with your fuzzy runtime system. Add a call to the fuzzy online module in your
source code to support this communication mechanism.

/*fuzzyTECH Online Edition only */


#ifdef FT_ONLINE
online(); /* 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, if
your application has a kind of main control loop, this would be the best place to
insert the function call.

285
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Note that the function online() should not interrupt the computation of the
fuzzy systems. This is important, in case you use a timer interrupt to call this
function.

Note that the function online() is programmed in such a way that it consumes
as little time as possible. During an active online connection it copies the
maximum number of 76 bytes and sends an answer to fuzzyTECH before it
returns. If no active online connection is running, the function returns
immediately.

Trace Control The fuzzyTECH Online Edition offers the option to generate C code supporting a
trace 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 is
controlled by the Trace Control dialog. The dialog offers an option to start or
stop the trace process by external trigger events. Therefore the generated C code
exports two additional functions that control the trace process. Call these
functions in your source code to start or stop the trace at arbitrary logical
conditions. Note that once the Trace process has been started, multiple calls of
the 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_ONLINE
if((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 fuzzy
modules for different settings of the code generator options, i.e. base variable
data type and parameter passing.

286
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

/* 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 */

287
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

/* 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 */

288
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

/* 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 */

289
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.4.3. Online Communication Module

Online Communication
Channels The fuzzyTECH Online Edition offers the option to enable an online connection
with your fuzzy runtime system. The fuzzyTECH Shell is running on a MS
Windows operation system while your fuzzy runtime system may run on a
different hardware platform. If you want to connect both systems, you have to
decide, which communication channel is the best for your purpose. In every case
both applications must use the same communication channel with the same
settings.
Communication Channels
of fuzzyTECH fuzzyTECH supports different standard communication channels as the serial
interface, shared file systems and IPX/SPX. Note, that fuzzyTECH offers an open
interface. You may write your own DLL that uses other communication
channels. Refer to Section 7.2 for details.
Communication Channels
of 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 communication
channel. It is separated due to portability reasons. The module consists of two
files named COMM.C and COMM.H and has a fix interface that is used by the
fuzzy library. You will find source codes for some communication modules in
the sub-directories of …\RUNTIME\C\LIB\SRC\ONLINE\COMM. The file
README.TXT in this directory contains additional information. You will find
ready-to-go modules for:
1. MS DOS: Serial Interface
2. OS/2: Serial Interface
3. All: Shared File System

If you have decided which channel is the best for your target system, it may be
necessary to change the original source code to set your preferred parameters.
For example you may change the settings for the serial interface or you may
change the communication directory for shared file systems.

User Defined Modules If you use an other platform for your fuzzy runtime system, you have to
implement your own communication module. A prototype can be found in
…\RUNTIME\C\LIB\SRC\ONLINE\COMM\USER\COMM.C. It contains four
empty functions that
1. 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 you
should not change the function prototypes. If you need help or more information,
do not hesitate to contact our technical support.

290
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

6.1.4.4. Compiling and Linking

This chapter describes the compiling and linking process of all modules that are
part of the fuzzy runtime system. Due to the great number of different C
compilers, this section is a rather general description and not a step-by-step
guidance. It may be necessary to browse your compiler manual to realize the
building steps.

If you implement a new application please follow the steps of the enumeration
below. If you add a fuzzy runtime system into an existing application please
proceed 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 bit
fuzzy 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. Note
that all other editions do not need the communication module.

291
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 ) come


with at least one sample that shows the integration of the generated code in user
modules. The samples are located in the sub-directories of
…\RUNTIME\C\SAMPLES. More details about the samples can be found in
README.TXT.

MYMAIN Sample This sample aims only to illustrate the user interface between your own code and
the generated fuzzy module. Note, that most parts of the source code are
dummies. 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 system
MYMAIN.C your application code
MYPROJ.C fuzzy module
MYPROJ.H fuzzy module export interface
FTC16.LIB your fuzzy library

292
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Build Procedure For compilers of Microsoft or Borland the batch file BUILD.BAT demonstrates
all 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 the
fuzzyTECH COBOL Add-on. Also fuzzyTECH generates COBOL code only for
those fuzzy systems that have set '16 Bit unsigned integer' in “Tools/Project
Project 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. This
applies also to the fuzzyTECH COBOL Runtime Library, as long as it has not
been 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 least


three 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 data
which 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.

293
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.1.5.1. COBOL Runtime Library

The fuzzyTECH COBOL Runtime Library consists of the sub-programs


HFUZTECH.COB and BWOB.COB. This source codes contain the fundamental
fuzzy 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-Program


Generating a
COBOL sub-program This section demonstrates how to integrate the COBOL Code generated by
fuzzyTECH into your own COBOL programs. Click in the main menu of
fuzzyTECH on "Tools/Compile To.../COBOL...". This translates the fuzzy
system into COBOL source code. The code generator creates two files that have
the same name as the fuzzy system. One of the files has as extension *C.CPY
and contains the i/o variables of the fuzzy system as copy book. The second file
has the extension *.COB and contains code and data of the fuzzy system. This
COBOL sub-program can compute the corresponding fuzzy system by calling
the fuzzyTECH COBOL Runtime Library.

Overview The following enumeration gives a short overview how to integrate and use the
COBOL sub-program into your own source codes.
1. Copy the i/o interface
2. 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 for
each system. Now the steps are described more detailed. Let’s assume that the
name of the fuzzy system is ’TEST’. Then the fuzzyTECH COBOL code
generator writes the following files:

TEST.COB
TESTC.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 by
fuzzyTECH. Your source code should contain the following lines:

WORKING-STORAGE SECTION.
COPY TESTC.
Parameter Passing and
Fuzzy 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

294
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

variable names in the copy book to set values of your program to the input
variables of the fuzzy system. Then you can compute the fuzzy system by calling
the sub-program. This re-calculates the output variables of the fuzzy system.Next
you can read the values of the output variables in your program. For this your
COBOL source code should look similar to this:

MOVE ... TO IN1


MOVE ... TO IN2
CALL ’TEST’ USING BY CONTENT TEST-IN
BY REFERENCE TEST-OUT
MOVE OUT1 TO ...
MOVE OUT2 TO ...

Data Type and


Value 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 is
defined by the corresponding 'Code Values' settings in fuzzyTECH.

6.1.5.3. Example

The following example demonstrates a minimum main program that calls the
COBOL 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.

295
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

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 into
MATLAB®/SIMULINK®. Another way is to use the FTRUN add-on module for
integration as described in Section 6.1.2. Note: M-code does not allow access to
internal or external interfaces. Thus, system visualization and on-the fly
optimization can not be supported. In order to create a fuzzy task in M
applications:

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 different
extensions, the fuzzyTECH M-code generator creates *.M files.
3. Use the “Compile to/ M...” option in the Tools main menu, do not overwrite
built-in M functions.
4. Write an M user program (e.g., MYMAIN.M) that integrates the fuzzy
controller 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\… ). The
generated 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 M
code, 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 project
name. 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 flag
indicating either a value computed by fuzzy rules or the default value.
4. Peek the output values from the knowledge base memory. Use the predefined
index like in step 2: e.g.:
outputvalue = kbm(Variable1_myproj);

M-Code Example
%––---- M-Code-Example MYMAIN.M------------------
crane; % activate controller
kbm(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) );

296
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 fuzzyTECH


integrated computation kernel.
MS Excel, VisualBasic,
or other MS Windows
Applications In order to find the appropriate implementation technique for your fuzzy
solution, this section explains how to interface the fuzzyTECH computation
kernel to MS Excel, MS VisualBasic or other MS Windows applications by
using DDE, Serial Link and RCU.

Figure 167: fuzzyTECH Development Shell as server for fuzzy computations

297
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.2.1. DDE

DDE is one of the ways to connect fuzzyTECH with other MS Windows


applications.

What is DDE? DDE is the acronym for Dynamic Data Exchange. DDE is a communication
protocol designed by Microsoft to allow applications in the Windows
environment to send/receive data and instructions to/from each other. It
implements a client-server relationship between two concurrently running
programs. The server application provides the data and accepts requests from any
other applications interested in its data. Requesting applications are called
clients. Some applications (e.g. Microsoft Excel) can simultaneously be both a
client and a server.

DDE Address DDE uses so-called DDE addresses to identify data items. A DDE address
consists of three parts in the following notation: Server|Topic!Item.

fuzzyTECH can be used both as client or server. Also fuzzyTECH can be client
and server at the same time. In any case DDE is used to exchange the following
data items between fuzzyTECH and other applications:
1. The values of the fuzzy system’s input variables
2. 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 client
documentation to see where and how to enter the fuzzyTECH DDE addresses in
the client application. The fuzzyTECH DDE addresses are built as usual by the
three 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 open
in fuzzyTECH.

Debug Topic Client applications can use the debug topic only, if one of the debug modes is
activated in fuzzyTECH. Clients can link (hot, warm or cold) to all i/o variables
of 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), such
as:

298
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Additionally, fuzzy variables contain the name of a variable's term in the item
element, such as: FTWIN|CRANE!Angle.zero

Example Debug Topic The directory ..\DDE\Excel\Sample2 contains an example demonstrating, how
MS Excel as DDE client can use fuzzyTECH as DDE Server. First, open
SERVER.FTL into fuzzyTECH and activate a debug mode, then open
CLIENT.XLS into MS Excel.

System Topic Clients can address the System topic when fuzzyTECH is running. The following
items can be addressed with the topic FTWIN|System:

File The client gets name and path of the fuzzy system that is
open in fuzzyTECH (FTWIN|System!File).
Edition The client gets name and release number of the fuzzyTECH
Edition (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 client
must send the command as string. Each command must be enclosed by square
brackets.

Client applications can guarantee that the execution of several single commands
cannot be interrupted by user actions. For that purpose concatenate all single
command to one string.

Commands Parameter Description


Open "<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 the
folder specified by <Dest>.
Exit none fuzzyTECH will be terminated.

Refer to the fuzzyTECH Help system for a value list of the parameter
<CodeType>.

299
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Samples
Execute 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/o
variables of the fuzzy system open in fuzzyTECH can be linked with one (or
more) DDE clients. Nearly every MS Windows application can act as DDE
server. This way fuzzyTECH can use e.g. MS Access or MS Excel as DDE
server. The same applies to most software packages in process visualization ant
automation.

If the debug mode ’Interactive’ is enabled in fuzzyTECH, each i/o variable with a
DDE link connects itself with the corresponding DDE Server. The following
applies 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 is
re-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 that
some DDE servers don’t allow poke operations. In doubt refer to documentation
of the server.

Configuration Open the DDE Links dialog in fuzzyTECH (“Edit/DDE Links”) to map the i/o
variable to DDE server addresses. Figure 168 demonstrates the link to an MS
Excel Workbook. The DDE addresses of MS Excel are built from the scheme
Server|Topic!Item as follows: Server is fix 'Excel'. The Topic identifies a certain
sheet in a certain workbook, here [Server.xls]Sheet1. The item identifies a
certain cell in the sheet given by the topic. The items use the so-called R1C1
reference style.

300
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Figure 168: Set the DDE Address in the DDE Links dialog

Example The directory ..\DDE\Excel\Sample1 contains an example demonstrating, how


fuzzyTECH as DDE client can use MS Excel as DDE Server. Note that you have
to open a file into fuzzyTECH that matches the language of your MS Excel. Open
CLIENT_E.FTL for English Excel or open CLIENT_D.FTL for German
language Excel. Dependent on the language the items (cells) in MS Excel are
addressed with the R1C1 or Z1S1 notation.

6.2.2. fuzzyTECH Remote Control Unit (RCU)

Integration in VisualBasic applications, Access, Excel, VisSim and the


DataAnalyzer are all based on the fuzzyTECH Remote Control Unit (RCU). The
function of the RCU interface is contained in the FTRCU.DLL. This DLL is
located in the FTHOME directory of your fuzzyTECH installation. You can find
the 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.

301
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

6.2.2.1. C Code

Single Call (SCI) The SCI is the easiest way to request a fuzzy computation from fuzzyTECH. The
single 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 huge
amounts of data.

Standard Call Interface The STCI gives you remote control of the main operations in fuzzyTECH
through 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 or
by 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, RCU


has to know the location of the fuzzyTECH home directory. This information is
stored in the file WIN.INI, in the section [FTWIN] by the variable
FTWINPATH. This specification is obligatory for any kind of RCU
communication. The variable FTWINPATH points to the directory where
fuzzyTECH is installed. If you have problems with your installation or if you
change the path of the home directory, please check the WIN.INI for the
following section:

[FTWIN]
FTWINPATH=DRIVE:\PATH\FTxxx

302
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 following
listings:

/* +---------------------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: */

303
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

/* 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 use
them instead of the numbers they represent. If you use a different programming
language, please use similar concepts to declare the function modes.

304
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

/* +---------------------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 be
done with the functions listed above. The parameters used are:

Parameters: Value Description


Mode: 0 Terminate the fuzzyTECH application
1 Start fuzzyTECH as a window
2 Start fuzzyTECH as an icon
4 Enter debug mode (necessary for computing)
8 Leave debug mode
16 Normally fuzzyTECH is closed when the RCU
connection is destroyed. For this purpose,
fuzzyTECH holds a StayOpen-Flag which is initially
set to FALSE. A function call with the mode
RTESTD_STE_STAYOPENFLAG sets that flag to
TRUE.
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 be
replaced. The function can also initiate a "File New". The parameters used are:

Parameters: Value Description


Name: OL If the parameter is long zero: "File New"
nonzero The value is interpreted as a pointer to string. If
Name is an empty string: "File New"
Return: (Coded as a bitflag array)
LO-bit (2^0) 0 No error
1 Error

305
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

unsigned short FAR PASCAL FTWINRTE_GetProjectInfo(unsigned short Mode,


long Data,
long ExtData);
\*defines for FTWINRTE_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 loaded
fuzzyTECH project is also returned. The parameters used are:

Parameters: Value Description


Mode: 0 Single mode: With this mode it is possible to ask for
single units of information. No special data structure
is needed.
1 Compact mode: Here, the given data structure is
filled with all information available for this function.
2 Compact mode (prerequisite: no debug mode): This
mode is comparable to mode 1, except that the
computation indices of the input/output variables are
not transferred to the caller. For this reason, this
mode ignores the debug state of fuzzyTECH. For
further details see the header.
Data: The parameter data depends on the mode chosen for
the variable Mode.
0 In single mode: get project name
1 In single mode: get number of input variables
2 In single mode: get number of output variables
In compact mode: the parameter Data represents a
pointer to a structure in which all project
information will be set by the function.
ExtData: If single mode is selected, ExtData represents a
pointer to an appropriate data structure. If the
compact mode is selected, the parameter ExtData is
not used.
Return: (Coded as a bitflag array)
LO-bit (2^0) 0 No error
1 Error

306
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 Description


Mode: 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 defined
by a HIWORD and a LOWORD. The HIWORD of
Data determines the selection of a variable by setting
a bitflag. If the flag “Access mode” is chosen,
LOWORD contains an access index. LOWORD
remains unused in any other cases. The flag “reset”
lets you scroll back to the beginning of the variable´s
list, “next” lets you skip to the following variable. If
non of both flags is set, the currently highlighted
variable is read. If the compact mode is selected, the
LOWORD is ignored.
HIWORD: 1 Access mode
2 Reset Flag
4 Next Flag
8,16,32 Not Used
ExtData: 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);

307
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Usage: Retrieves the fast computation index for a defined variable. This function can be
useful if the interface variable names remain fixed and only the fast computation
index 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 development
system.

Parameters: Value Description


Reference: 0 Single value data transfer
1 Array value data transfer
Datatype: 0 Double
ParamMode: 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 input
parameter 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 Description


CMode: ----- Generated by FTWINRTE_SetConversation.
Value: pointer Depending on FTWINRTE_SetConversation.
ParamMode =0: pointer to WORD index(indices). If
this Reference is 1, Value expects all input values.
Otherwise, only one input can bet set.

308
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

ParamMode =1: pointer to string(s) pointer(s) of all


input 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 Description


Return: (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 fuzzy
logic system.

Parameters: Value Description


CMode: ----- Generated by FTWINRTE_SetConversation.
Value: pointer Depending on FTWINRTE_SetConversation.
ParamMode =0: pointer to double value(s). If this
reference is 1, Value refers to a set of output values.
Otherwise, only one output is passed.
ParamMode =1: pointer to string(s) pointer(s) of
output 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

309
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

Usage: Retrieves information about all fuzzy input/output variables in fuzzyTECH.

Parameters: Value Description


Mode: 0 Compact mode: The name of the data structure is
RCU_FUZZYLV and is defined in rcutypes.h. The
pointer is of the type LPRCUFUZZYLV.
1 Gets the number of terms of the linguistic variable
stored 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 Description


Mode: 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 interface
of the fuzzyTECH remote control unit. fuzzyTECH provides an Assistant in Excel
to create Excel function calls.

Installation Install fuzzyTECH and MS Excel separately.

310
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Integrate FTWIN32.XLA In Excel, call “Tools/Add-Ins…” and integrate the file FTWIN32.XLA (for
Excel 7.0) or FTWIN.XLA (for Excel 5.0 ) from the FTxxx\RCU\EXCEL
directory. fuzzyTECH is now automatically called when Excel is started. The
fuzzyTECH Assistant"fuzzyTECH:Excel Assistant" appears as a separate section
among the Excel toolbars. If Excel is not able to integrate the fuzzyTECH
Assistant, check the installation of the fuzzyTECH remote control unit. If Excel
asks you if you wish to copy your file into the Excel home directory it’s better to
answer “no”. This has a beneficial effect on upgrading your old fuzzyTECH
Edition. A new fuzzyTECH edition provides a new Assistant in Excel which may
require the elimination of the old one. By saying “no” you will save time since
the previous Assistant won’t have to be removed.

Fuzzy Function Call The assistant generates function calls in all cells assigned to the output interfaces
of a fuzzy project. The functions use parameters to determine the fuzzy project
used, the number of input and output interfaces used, the cell references of input
cells, and the number of the outputs used to compute the cell values. In the
following, some examples of valid function calls are provided.

Examples The first example shows a call to a fuzzyTECH project CRANE.FTL with two
inputs, one output, using the first (and only) output, which references input 1
from cell A1 and input 2 from cell B1 of Sheet1. The second example connects
the project BENCH4.FTL using eight inputs and four outputs. The function call
results in a value from output number 3 and uses the cell references A3 to H3 to
read input data from Sheet1.

=FTWIN32.XLA!FuzComp("DRIVE:\FTxxx\SAMPLES\CONTROL\CRA
NE\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 function
calls can be edited, overwritten or deleted if the fuzzy system must be
disconnected from the spreadsheet. Also, a function call can be typed directly
into a spreadsheet cell. The parameter syntax is nearly self explanatory within
the given examples. The macro function FUZCOMP has a variable parameter
list 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.

311
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

The index for specifying an output variable is determined by assigning index


numbers in alphanumeric order according to the output interface variable names
counting upward from 1. The cell references connecting the input interfaces are
sequenced alphanumerically according to the input variable input interfaces
variable names.

Interface The fuzzy functions in the spreadsheet require that the fuzzyTECH Assistant
interface (FTWIN.XLA or FTWIN32.XLA) is loaded in Excel. The macro
function FUZCOMP is enabled by this interface.
Worksheet Names in
Cell 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 no
blanks are used in the worksheet name. Although blanks can be used in Excel,
macro function calls fail when the worksheet name contains blanks.
Absolute and
Relative References The fuzzyTECH Assistant always uses absolute references as function
parameters. If you want to copy a fuzzy function by using relative cell references
or fill a cell area with the fuzzy function call, delete the $-signs from the
reference parameters.
How to deactivate the
fuzzyTECH 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 standard
interface as basic modules. This module can be added to your application by
using the [Add-File] item in the [File] menu of MS VisualBasic. The basic
module RCUFCNS.BAS is in the FTxxx\RCU\VB directory of your fuzzyTECH
installation. The module RCUXMPLE.BAS gives an example for the use of
interface procedures. The procedure enables the single call interface and the
standard call interface of the fuzzyTECH remote control unit. LoginRCU has to
be called before using the RCU interface. Afterwards, the variable RCUHandle
holds the access handle for the loaded RCU DLL. LogoutRCU has to be called
before 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 is


loaded appropriately, the global variable RCUHandle has a
value greater than 32.

312
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 the
referenced 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 determined
by assigning index numbers in alphanumeric order according to the output
variable names counting upward from 1.
• The SCI function has no variable parameter list. Thus, you must enter input
values for the maximum number of inputs supported by the function. In the
example, although the crane controller only has two inputs, you must include
two additional values in the parameter list of the SCI function, which are not
used.
Standard Call
Remote Interface The standard remote call interface allows a more efficient, but also more
sophisticated way to access information provided by fuzzyTECH. In addition to
the SCI functionality it allows you to get information about a specified project in
fuzzyTECH and to pass or retrieve arrays of data. The usage of the standard
interface can take place as follows:

Connect the FTRCU.DLL As already mentioned, first you have to initiate the connection to RCU by calling
LoginRCU.
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.

313
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======


Dim n As Integer
Dim ret As Integer
ret = FTWINRTE_State(RTESTD_STE_STARTNORMAL)
’ start fuzzyTECH
n = FTWINRTE_LoadProject("C:\FTWIN\TEST\CRANE.FTL")
’ load the project
n = FTWINRTE_State(RTESTD_STE_DEBUG)
’ enable debug mode

Retrieve Project Structure Before using a fuzzy system, you may check that the appropriate project is
loaded (or still loaded) in fuzzyTECH. Also, determining the number of input and
output interfaces is mandatory. This information about the project structure can
be requested via RCU functions.

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======


Dim PData As FUZZYSTRUCT ’ structure defined in RCUFCNS.BAS
n = 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 the
computation methods used in the interface to specify the interfaces in your fuzzy
project.

’==== STANDARD FUNCTION CALL REMOTE INTERFACE =======


Dim ITFCData As ITFCSTRUCT ’ structure defined in RCUFCNS.BAS
n = FTWINRTE_CMGetInterfaceInfo
(RTESTD_ITFC_COMPACT, RTESTD_ITFC_RESET * 65536,
ITFCData) ’ get information of the first interface
ITFCData.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

314
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Transfer and Compute


Values 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 Integer
n = 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 DOUBLESTRUCT
VData.LV1 = 4.09
n = FTWINRTE_NAMSetCrispInput(CMode, "Distance", VData)
’ sets the input variable Distance
n = FTWINRTE_Compute() ’ initiate a computing step
Dim OData As DOUBLESTRUCT
n = FTWINRTE_NAMSVGetCrispOutput(CMode, "Power", OData)
’ get output Power in OData.LV1

DOUBLESTRUCT allows to pass an array of output values to VisualBasic. The


structure 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 serial
communication port to fuzzyTECH to let you use the development shell as a
fuzzy 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 the
serial port.

315
Inform Software Corporation Chapter 6: Implementing Fuzzy Runtime Systems

• Write the values of the input variables to the serial port of the PC by using
the protocol format described in the next paragraph.

This will cause fuzzyTECH to compute the fuzzy system and to return the values
of the output variable via the serial interface to the client software. fuzzyTECH
stands by to receive the next set of input variable values. In order to end the
serial debug mode, either select [Serial Link] from the [Debug] pull down menu,
select a different debug mode, or close the Debug: Serial Link window that
always appears when Serial Link mode is active.

Protocol Format The communication protocol used by the Serial Link debug mode uses float data
types 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 computation
within fuzzyTECH.

Examples of accepted float values are:

123 123.5677433200 123


-123 0.0123 .0123
1.98E5 +1.98E+5 -.012E-19

If all outputs are computed, fuzzyTECH sends back all output variable values in
the same format. fuzzyTECH uses standard C formatting functions to convert the
fuzzy logic inference result into a float string. This conversion routine always
tries to minimize the number of bytes used for transfer. The sequence of the
output variables is alphanumeric, the same order as appears in the right list box
of 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 mode
to 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 received
from fuzzyTECH would be:

316
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

.34þ90.322þ^Z

Errors If fuzzyTECH finds an error in the protocol format (such as the wrong number of
inputs), 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 as
the 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 vice
versa. Simply make sure that the Shell values are set to the Code values for all
input and output variables (Variables Properties: Base dialog). Since fuzzyTECH
uses the exact same algorithm in all debug modes that is implemented in the
generated code, values of the output variables will always be integers.

317
Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

The fuzzyTECH Shell supports open interfaces that allow users to implement
new components. These new components will be integrated as user defined
extensions 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 Learn


Methods

fuzzyTECH provides an easy way to include a user defined learning method for
use with the NeuroFuzzy module. (Refer to Table 4 of Section 9.4 to find out
which editions are provided with the NeuroFuzzy module or for which editions it
can be delivered as add-on.) All methods are constructed as dynamic link
libraries (DLL).

Example Source The following two examples, delivered as source code, show how to use this
function 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 file
NFLEARN\C\SAMPLES\SAMPLES.MDP to compile the example provided.

318
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Registration You may program as many learning methods in as many different DLLs as you
like. Note, each library (DLL) can contain multiple learning methods but only
one specified selection mode. For the DLL with the name LEARN.DLL
containing the methods MyNewMethod and MySecondMethod, add the
following 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 the


LEARN.DLL MyNewMethod mentioned above.

Attention If you are not firm in handling the registry data base call your system
administrator.

If fuzzyTECH is started, it only searches for the LEARN.DLL in the fuzzyTECH


installation directory only. If the methods are found in the DLL, the specified
names MyNewMethod and MySecondMethod are now available in the method
list box of the Neuro Configuration dialog.

7.1.2. Code Example

Examples Two examples of user defined learning methods are included in the fuzzyTECH
NeuroFuzzy module. The example (learn_b.c) shows a batch learn method and is
commented on in detail in the source code. If you would like to compile and
include this method in fuzzyTECH, please refer to the source code comments,
too. The other example, LEARN.C, is used to explain how to program user
defined learning methods. Before implementing a new Learn DLL you should
read the header file NFLEARN\C\INCLUDE\NEUROLRN.H to get more
information about the functions and variables. A step-by-step guide for the
implementation can be found in the comments of the file
NFLEARN\C\SAMPLES\LEARN\LEARN.C.

Module LEARN.C This module demonstrates how to define new learning functions for the
fuzzyTECH NeuroFuzzy module. The module is divided into sections. First,
increment the value NUM_LEARN_FNCTNS (see Section 2 below). Then
specify the function name (see also Section 2). Next, program your learning
method (see Section 10). If you would like to program a special learning
example selection, program your SPECIFIED selection in Section 9.

319
Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

Sections to Touch In this file, you don’t need to touch any sections other than Section 2, Section 9
and Section 10. Add the function name of your learning function (as defined in
Section 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 new
function in fuzzyTECH.

Header File After these steps, you can use your new learning function the same way as the
standard learning functions provided with the NeuroFuzzy module. If you have
any questions on parameters in user defined learning methods or parameters
which can be defined by a user in the shell, please refer to the file
NEUROLRN.H.

Section 2: Definition of the module contents. Specify here how many learning functions are
available 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 called
before the learning function is started. That means, the learning process is a call
sequence of function pairs (1 -> selection and 2 -> computation).

320
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 (example
number)
// 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 Defined


Communication Channels

The fuzzyTECH Online Edition and the fuzzyTECH MCU Editions including the
RTRCD Module can use different communication channels to enable an online
connection to a fuzzy runtime system that was generated by one of the
fuzzyTECH code generators. If the application using the fuzzy runtime system
runs on a hardware that is not supported by the standard communication
channels, you may implement your own communication modules both for the
runtime system and fuzzyTECH. This chapter describes the implementation of an
online communication channel DLL as extension for fuzzyTECH. Refer to
Section 6.1 for more details on the communication channel for your fuzzy
runtime system.

321
Inform Software Corporation Chapter 7: User Extensions of the fuzzyTECH Shell

Functions Each fuzzyTECH online communication channel DLL (FTOCC) has to


implement and export the following functions:

LPSTR CALLBACK ftoccGetInfo (HWND hWndParent, BOOL


fLongInfo);
BOOL CALLBACK ftoccSetup (HWND hWndParent);
BOOL CALLBACK ftoccOpen (HWND hWndParent, DWORD
dwTimeout);
BOOL CALLBACK ftoccClose (HWND hWndParent);
BOOL CALLBACK ftoccTransmit(HWND hWndParent, LPBYTE
lpCommBuffer, BYTE
bNumToTransmit);
BOOL CALLBACK ftoccReceive (HWND hWndParent, LPBYTE
lpCommBuffer, BYTE
bCommBufferSize);

Sample FTOCC\FTOCC.DLL is a prototype for a user defined online communication


channel. The source code and a Microsoft Visual C make file of this DLL can be
found in the directory FTOCC\SRC. Please use a copy of these files as base for
your own implementation. More details on implementing the functions can be
found in the source code comments.

Registration You may implement as much communication channel DLLs as you want. Each
new 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 system
administrator for help.

You have to create an new subkey DllNameX, where X is the first unused
number. 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

322
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 object
linking and embedding.

DDE Dynamic Data Exchange, a technology that allows two software programs under
MS Windows to exchange data. fuzzyTECH supports a DDE interface.

DLL Dynamic Link Library, a file containing functions that can be called by a
program. fuzzyTECH uses DLLs internally to structure its code modules, but also
provides DLLs as interfaces to other software programs, e.g. the FTRUN.DLL
and FTRCU.DLL.

DoS Degree of Support. Adding an individual weight to each rule extends the concept
of “on/off” rules to a representation where rules themselves are “fuzzy”. This
allows for the rule base to be fine tuned during optimization. Since the mapping
of the input of the rules to the output now itself is fuzzy, this concept is often
referred 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 by
most software and hardware vendors of fuzzy logic solutions. Developed by Intel
Corp. and Inform Software Corp. in 1991, FTL allows for the exchange of fuzzy
logic systems between different software and hardware tools and platforms. All
fuzzyTECH Editions store their projects as FTL files. FTL is an ASCII
description language and can thus be read and edited using any text editor.

FTR fuzzyTECH Runtime, a file format generated by fuzzyTECH or FTRUN. A FTR


file is a binary data representation of a fuzzy logic system. Depending on the
options used, a FTR file can even contain all the necessary information for
fuzzyTECH to reconstruct an entire FTL file from it.

323
Inform Software Corporation Chapter 8: Glossary

FTRCU fuzzyTECH Remote Control Unit, an interface that allows you to tie in the
complete fuzzyTECH development system in other software programs. In every
fuzzyTECH installation from release 5.0 on, this file is located in the installation
directory of fuzzyTECH and can be used by any other program to "remote
control" fuzzyTECH. For example, all three simulations of the fuzzyTECH 5.0
Demo use this interface to start fuzzyTECH remotely, open the appropriate fuzzy
logic system, and let fuzzyTECH compute the output values of the fuzzy logic
system under simulation.

FTRUN fuzzyTECH Runtime Module, an interface that only integrates the runtime kernel
of 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, a
version of fuzzyTECH that can visualize any fuzzy logic system that is computed
by the Runtime Module. The fuzzyTECH Online Edition license comprises the
distribution license of the fuzzyTECH Viewer, thus you may include the
fuzzyTECH Viewer with any of your generated fuzzy logic systems freely if you
are a fuzzyTECH Online Edition user.

IPX/SPX Protocol The Internetwork Packet Exchange/Synchron Package Exchange protocol is a


netware 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 software
system into another, now called ActiveX.

PLC Programmable Logic Controllers are used in industrial automation. These


controllers are programmable, they can be used in an harsh industrial
environment and have integrated digital/ analog IO modules.

RTF Rich Text Format, a file format for documents supported by most word
processing software, such as MS Word, MS Wordpad (comes with Windows95),
WordPerfect, WordPro, and StarWriter. The documentation generator of
fuzzyTECH 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 the
Runtime Module run on the same PC. If fuzzyTECH and the Runtime Module run
on different PCs, this directory must either be located on a network server or on
one of the PCs as a shared directory.

324
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

This appendix contains various topics, such as installation guidance, required


memory size, essential files and directories, an overview of functions and
technical restrictions for all fuzzyTECH Editions, support addresses, a keyword
index and the license agreement.

9.1. Software Installation

This section guides you through the installation of the software on your PC. You
must 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 the
path 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 client
PCs. Because the setup procedure has to update the registry database of each
local PC, the setup routine must be started on each local PC overwriting previous
network drive installations. This overwriting procedure has no side effects on
other clients.

325
Inform Software Corporation Chapter 9: Appendix

Note: After installation, you may have to re-boot your PC before you can use
fuzzyTECH. If such a re-boot is required, you will be informed by the setup
routine’s windows and dialogs. Pay attention to notes displayed on screen during
installation.

Start Menu The setup procedure generates a new item “fuzzyTECH 5.3” in the MS Windows
Start menu. The new item contains the fuzzyTECH Editions, software
simulations, and help files. Since fuzzyTECH may be updated faster than this
manual, you should refer to the README.TXT file for latest release information
not 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/Remove
Programs. A tabbed dialog Add/Remove Programs Properties opens. In the listed
programs 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 protection
device is a small matchbox sized device with two 25-pin connectors on each
side. 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 a
printer, you may connect the printer cable to the rear end of the protection
device. The copy protection device does not disturb printer operations. You may
also use more than one protection device at the same time. The copy protection
device stores the licensing information of your software. fuzzyTECH will only
run on your PC if the protection device is plugged into the parallel port. You
may install the software without the protection device. This allows you to install
fuzzyTECH on more than one PC. However, you may only use fuzzyTECH on
one PC at a time, since the copy protection device must remain plugged in during
operation. Since fuzzyTECH needs the information stored in the protection
device at various design steps, it must be plugged in the entire time while using
fuzzyTECH.

Updates Because the protection device contains license information, you never need to
change the protection device when receiving an update. Always include your
license number in all update orders, so the new version will run with your
protection device.

Compatibility The protection device used with fuzzyTECH is carefully designed not to interfere
with any other software or hardware products using the parallel printer port. If
you are using copy protection devices from other vendors at the same time and
you are experiencing problems, try to change the sequence of the devices. If this
does not solve the problem, please contact Inform.

326
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

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 system
needs RAM space to store intermediate variables for the fuzzy logic algorithm.
While the library function code size is constant, the size of the rule and
membership function data segments and the size of the fuzzy system function
varies with the complexity of the system.

RAM Size Total RAM required by the fuzzy logic system generated may be computed as:

nI nO
SV = 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 code
C : 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.

327
Inform Software Corporation Chapter 9: Appendix

ROM Size The exact size of the knowledge base is computed by the fuzzyTECH compiler
and is printed as comments at the end of the generated code. In addition to the
calculated ROM sizes of the knowledge base, the size of the fuzzyTECH kernel
routines (refer to the .MAP file of your linker) selected from the library must be
considered. The sum of knowledge base size and size of fuzzy functions is the
required ROM space for the complete fuzzy task. The upper bound for the size of
the knowledge base (rule and membership segment) can be computed as:

nI nO nR
SF ≤ ∑4Nti + ∑Ntj + ∑( Ir+ 2ÂOr + 2 ) + nI
i=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 the
fuzzyTECH home directory. The location and the directory name suggested by
the installation procedure is “C:\Program Files\fuzzyTECH”. Depending on the
fuzzyTECH 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 generator
fuzzyTECH 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 allow
you to connect and remotely control fuzzyTECH from other MS Windows
applications.

328
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

RCU\EXCEL Contains the files used by MS Excel to integrate the fuzzyTECH Excel
Assistant by using the MS Excel Add-In Manager.
RUNTIME\C Contains the files required to generate an application using fuzzyTECH C-code
generation. 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 fuzzyTECH
release 3.x and higher. However, fuzzyTECH release 3.x (and higher) always
uses 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 NeuroFuzzy
optimization with the NeuroFuzzy module all require and support the use of the
fuzzyTECH 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.

329
Inform Software Corporation Chapter 9: Appendix

Data Formats Data files can be either of two format types. The data type can be selected in the
Project 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 be
terminated by a line feed (ASCII 13). All values in a line must be separated by
one 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 40
characters. Also, a timestamp can be entered here. The record name may not
contain any spaces or tabs.

The values of the input (and output) variables must be cited after the record name
in every line. The file may contain only input data, input and output data, or
computed output data using an additional flag variable.
Example Input
TYPE 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 Input
TYPE 2 An example of an input file or a pattern file in format TYPE 2 looks like this:

Input datafor Fuzzy Crane Control


Angle Distance
---------------------------------------
CRANE_#1 -45 22
CRANE_#2 -40 22
CRANE_#3 -35 22

330
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

In batch mode, there is no limit to the number of records in a file. Activate the
batch mode by selecting “Debug/Batch”. A prompt for the input and output file
names appears.
Sample Data File
TYPE 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 File


TYPE 2
Input data for Fuzzy Crane Control
Angle Distance Power
-------------------------------------------
CRANE_#1 -45 22 -9.2435
CRANE_#2 -40 22 -9.1976
CRANE_#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, starting
with the lower order bit and assigned in sequence to the output variables in
alphanumeric order. A zero 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 one rule fired. The data type for FLAGS depends
on the fuzzyTECH Edition. An example file is shown below:
Example Output
TYPE 1
# Angle Distance Power flags
-45 22 -9.2435 0
-40 22 -9.1976 0
-35 22 -8.9763 0

Example Output
TYPE 2
Input data for Fuzzy Crane Control
Angle Distance Power flags
---------------------------------------------------
CRANE_#1 -45 22 -9.2435 0
CRANE_#2 -40 22 -9.1976 0
CRANE_#3 -35 22 -8.9763 0

331
Inform Software Corporation Chapter 9: Appendix

9.4. Features Overview

Technical Restrictions fuzzyTECH is available in different editions to provide the most comprehensive
support for your target platform and application area. Due to differences in the
capabilities of the supported hardware platforms, technical restrictions apply to
the size of the fuzzy systems. Table 1 shows an overview of the maximum
number of interfaces, variables, terms, rule blocks and rules for the different
fuzzyTECH Editions. A "-" sign indicates that no practical limit exists. The total
number of Linguistic Variables (Total LV) represent the number of input, output
and intermediate variables of the entire fuzzy logic system. The columns Input
and Output show the maximum amount of input and output variables. Terms per
LV relates to the total number of terms for each linguistic variable. The column
Total Terms shows the maximum number of terms that may occur in one fuzzy
logic project. The Rules sections shows the maximum total number of Rule
Blocks and Rules that a fuzzy logic project may contain, as well as the maximum
total number of input variables (Inputs per RB) and output variables (Outputs per
RB) that can be assigned to a rule block.

Restrictions Linguistic Variables Rules


(LV)
Feature/ Total LV Input Output Terms Total Rule Blocks Inputs per Outputs Total Rules
Edition per LV Terms (RB) RB per RB
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 50
MCU-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 of
definition. Inverse MBFs (inverse terms) are useful for filling a rule part with the
negated form of an already existing term. The column MBF Shapes shows the

332
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

available approximation functions for membership functions. The column


Fuzzification Method lists the supported algorithms for the fuzzification step of
the fuzzy logic inference. Fuzzy Input indicates that variables are inputted as
fuzzy values (i.e. as vectors of membership degrees) instead of crisp values. For
Look-up-MBF fuzzification, MBFs are computed as look-up-tables by code
generators. This speeds up the computation on some microcontrollers and fuzzy
processors, but consumes considerable memory space. The standard fuzzification
method is computation at run time (Compute MBF). For most target hardware
implementations, this is the most efficient approach. On some microcontroller
families, the slope fuzzification method (Fast Computation of MBF) is faster.
Slope fuzzification is a variant of Compute MBF.

Membership Type Shape Fuzzification Methods


Functions
Feature/ Standard Arbitrary Inverse linear s- Fuzzy Look up Compute Fast MBF
Edition MBF MBF MBF shape Input MBF1) 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 x
MCU-96 x - - x - x - x -
MCU-166 x - - x - x - x -
MCU-320 x - - x - x - - x
MCU-51 x - - x - x x x x
MCU-374 x - - x - x - - x
MCU-ST6 x - - x - - - - x
MCU-MP x - - x - - - - x
MCU-HC11/12 x - - x - x - x x
MCU-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 and
Defuzzification 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 be
chosen for aggregation (Input aggregation) and result aggregation. Fuzzy
operators used for aggregation (Minimum or Maximum) combine the
preconditions of each fuzzy rule. Beside this standard operators, some
fuzzyTECH Editions support compensatory operators (Gamma, Min-Avg, Min-
Max), that help to compute relations between rules formulated with the logic
standard operators AND (Minimum) and NOR (Maximum). The second step of
the 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

333
Inform Software Corporation Chapter 9: Appendix

Associative Maps" and refers to individually weighted rules (Degree of Support


= DoS). The last step of fuzzy inference is the so-called result aggregation. Its
MAX operator selects the maximum firing degree of all rules matching to the
term. The BSUM operator uses a bounded sum. Thus, all firing degrees are
summed by using a bound of one. Note that BSUM result aggregation is
different from BSUM MoM and BSUM CoA. The bounds are zero and one. The
result of the fuzzy inference is a fuzzy value that has to be re-transformed into a
crisp value. This transformation is called Defuzzification. Different computation
methods 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 pattern
recognition, data analysis, and decision support. The defuzzification method
HyperCoM (see last column) is only available as add-on module for a few
editions. HyperCoM is a defuzzification method that takes both positive and
negative experience into consideration (e.g. in the form of recommendations and
warnings). A hyperdefuzzification strategy weights these recommendations and
warnings against each other and computes a membership function, from which
HyperCoM then computes the optimum based output value.

Inference/ Aggregation Operators Composition Result Defuzzification


Defuzzification Standard / Compensatory Agrregation
Feature Minimum/ Gamma Min- Min- Stan- FAM Max BSum CoM COA MoM Fuzzy Hyper
Maximum (γ) Avg Max dard Rules 1) Output CoM
2)
Edition
Business Prof. x x x x x x x x x x x x x
Business 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 x
Online x x x x x x x x x x x x x
IA-S5 x - - - x x x - x - - - -
Simulation x x x x x x x x x x x x x
Student 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 Optimization
and Analysis All fuzzyTECH Editions are fully equipped with graphical debuggers (Debug
Modes) and Analyzers that can be used for optimizing and debugging a fuzzy
system (Table 4). fuzzyTECH’s graphical analyzers are all internal and help you

334
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

to verify and analyze the behavior of the fuzzy system. The Trace Analyzer has
limited function for IA-S5 Edition and is not available for MCU-HC05 Edition.
However, remote debugging on external target platforms requires either Online
or RTRCD debug modes. Contrary to the Online debug mode, the RTRCD mode
(Real Time Remote Cross Debugging) runs only with basic cross debugging
functions, but more efficient in view of computation speed and code size. This
online development allows you to connect fuzzyTECH with a running fuzzy logic
system in real-time and to monitor and modify it on your PC via Communication
Channels.

Tools Debug Modes (internal) Communication Channels Add-Ons 1)


Feature Inter- File/ Serial RCU/ RTRCD On- TCP/IP Serial SDI SFS User-def. Neuro Hyper
active Batch Link DDE line IPX/SPX Inter- 5) (FTOCC) Fuzzy CoM
DDE face
Edition (RS232)
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 x
Student 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) that
have extended features. The NeuroFuzzy Module integrates artificial neural
network technology including its modified learning procedures into fuzzy logic.
It contains the FuzzyCluster Module that is suited for preparing training datas
and integrates data mining techniques into fuzzyTECH. HyperCoM is an add-on
module, that offers with its Hyperinference defuzzification method a fundamen-
tal expansion of fuzzy logic by allowing the definition of prohibitive rules.

335
Inform Software Corporation Chapter 9: Appendix

Code Generation Table 5 lists supported code generator options. The File Code option generates a
complete C source code for an executable program which accepts file data as
input and writes outputs to a file as well. Since fuzzyTECH generates the
complete fuzzy logic system as a single function, input and output values can be
transferred as function parameters (Function Call) over the system stack or as
global variables (Public I/O).

Some fuzzyTECH MCU Editions support only Public I/O, since passing variables
over the stack can be inefficient. All fuzzyTECH MCU Editions utilizing an
assembly library as a kernel support calling fuzzy logic functions from Assembly
code and from C code (C interface). The C Code column lists which C compiler
standard is supported. The columns Internal Resolution and Code Interface
Resolution show the computational resolution within the inference engine.
Besides, Code Interface Resolution indicates the data types of the interfaces, too.

Code Code-Options Hardware C-Code ActiveX COBOL Internal Code Interface


Generation specific / Resolution Resolution
Code FTRUN
Feature/ File Funct. Public C ASM ANSI K&R FTR COBOL 8-bit 16-bit 8-bit 16-bit double
Edition Code I/O
Call1) 2)
Business Prof. x x x - - x x x x x x x x x
Business - - - - - - - - - - - - - -
Professional x x x - - x x x x x x x x x
Online x x x - - x x x x x x x x x
IA-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)

336
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

9.5. Support Contact

USA and Canada Inform Software Corporation


2001 Midwest Bd.
Oak Brook, IL 60523, U.S.A.
Phone 1-630-268-7550
Sales 1-800-929-2815
Fax 1-630-268-7554
E-mail fuzzy@informusa.com

Europe and
Elsewhere INFORM GmbH
Pascalstrasse 23
D-52076 Aachen (GERMANY)
Phone +49-2408-945680
Fax +49-2408-945685
E-mail hotline@inform-ac.com

Internet: http://www.fuzzytech.com

337
Inform Software Corporation Chapter 9: Appendix

9.6. Index

COBOL Runtime Library 294


*.DAT Extension 91 Code Generation 336
*.EXP Extension 91 Code Range 60
*.IN Extension 91 Code Values 59, 60
*.OUT Extension 91 CoG Defuzzification 59, 174
*.PTN Extension 91 CoM Defuzzification 58, 173
*.TRC Extension 91 Communication Channel 103
Compensatory Operators 171
3D Plot Analyzer 18, 96 Competitive Learning 182
Composition 72, 161, 162
ActiveX 201 Operator 172
Add-on Modules 335 Compute MBF 58
Aggregation 161, 171 Container Crane Control 156
Analyzer Continuous Logic 146, 147
Rule Analyzer 94, 100 Copy Protection 326
Analyzer Tools 93 Cross Sections 95
AND 161, 171 Customizing fuzzyTECH 43
Applications of Fuzzy Logic 146
Approximate Logic 165 Data Files 329
Arbitrary MBF 170 Data Format 330
Average Error 182, 189 DDE 103, 298
Avg. Deviation 189 Debug Modes 86, 334
Decision Support Systems 147
Base Variable 60, 68, 153, 166 Default Value of Linguistic Variables 61
Batch Debug Mode 92 Defuzzification 58, 163, 166
Biomedical Fuzzy Systems Association 148 Defuzzification Methods 333
BMFSA 148 Degree of Membership 166
Boolean Logic 146, 148, 161, 176 Degree of Support 82, 172
Break Criteria 182, 189 Design Mode 13, 14
Build Procedure 293 Don’t Care Rules 77
Don't Care Rules 84
C Code 202 Dynamic Stop Condition 130
Center-of-Area Method 58, 174
Center-of-Gravity Method 59, 164, 174 Error Backpropagation 184, 188
Center-of-Maximum Method 58, 164, 173 Excel Assistant 311
Client 102 Extension .EXP 329
Clustering 135 Extension .IN 329
CoA Defuzzification 58, 174 Extension .OUT 329
COBOL Code 202 Extension .PTN 329
COBOL Code Generator 293 Extension .TRC 329

338
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Shell 43
FAM 172, 184, 187 Technical Restrictions 332
Inference 172 fuzzyTECH Preferences
Rules 77, 81 General 43
Fast Computation of MBF 167 Matrix Rule Editor 45
File Format 91 Save 44
File Names 91, 329 Serial Interface 46
File Recorder Mode 91 Text Editors 44
FLSI 148 Watch Window 44
FT38.LIB 230
FTMP.LIB 214 GAMMA Operator 72
FTOCC.DLL 104 Grid 68
FTRUN 203, 205, 207, 209
FTRUN.DLL 201 Hebbian Learning Rule 179
FTSDI.DLL 104 Hyper CoM Defuzzification 59
FTWIN.XLA 311
FTWIN32.XLA 311 IF Part 171
Fuzzification 158, 159, 165 Inference Methods 333
Fuzzification Methods 333 Information About the Current Project 109
Fuzzy Associative Map 172 Input Interfaces 58
Fuzzy Associative Maps 82, 184, 187 Input Variable 57
Fuzzy Control 165 Installation 325
Fuzzy Design Wizard 48 Interactive Debug Mode 48, 87, 89
Fuzzy Input 58 Intermediate Variable 57
Fuzzy Logic 123 Inverse Term 69
Comp. Fuzzy vs. Conventional Control 157 IPX/SPX 104
Inference 158, 160
Operators 161 Japan Society for Fuzzy Theory and Systems 148
Patents on 148
Rules 165 Keyboard Use 53
Fuzzy Logic Systems Institute Iizuka 148 Knowledge Base 327
Fuzzy Operators 79
Fuzzy Output 59 Labels 62, 166
Fuzzy Rule Inference 166, 171 Lambda-Type Membership Functions 167
Fuzzy Runtime System 102 Learning Rate 182, 188, 192
Fuzzy Set Theory 153 Library Function Code 327
Fuzzy System 102 LIFE 148
FUZZYLIB.ST6 210 Linguistic Control Strategies 157, 158
fuzzyTECH Linguistic Labels 159
Data Formats 329 Linguistic Terms 155, 159
fuzzyTECH Linguistic Variable 155, 159, 166
COBOL Runtime Library 293 Linguistic Variable Editor 62
Preferences 43 Look up MBF 21, 58
Runtime Control 202 Look-up Table 58
Runtime DLL 32 Lotfi Zadeh 147
Runtime Library 102 L-Shaped MBF 66

339
Inform Software Corporation Chapter 9: Appendix

MBF-Conversion 131
M Code Generation 202 Open Components 129
Margins 90 Record Sample Data 125
Matrix Rule Editor 24, 76, 80 Stop Conditions 130
Max 72 Training 131
Max Dev. Stop Condition 130 Training Control 132
MAX Operators 171 Training Method 188
Maximum Error 182 vs. Neural Nets 184
Maximum Operator 72, 161, 171 Neuron 176
MAX-Min Inference 172 Bias of a 177
MAX-PROD Inference 172 Mathematical Model of a 177
MBF 166, 332 NOT 161
Definition 66 Number of Iterations 182, 189
Type 66
MCU-HC05/08 258 Off-line Optimization 48
MCU-HC11/12 267 Online Connection 32
Mean-of-Maximum Method 58, 174 Online Optimization 48
Membership Online Timing 104
Degree of 154 Online Wizard 33
Function 66, 166 OR 161, 171
Membership Function 62, 154, 332 Output Interfaces 58, 59
Min 72 Output Variable 57
Min Operator 171
Min-Avg Operator 72 Pattern Generator 89
Minimum Operator 72, 161, 171 Pavlov’s Dogs 179
Min-Max Operator 72 Performance Evaluation with Gen. Data 89
Model-based Control 157 PID Control 157
MoM Defuzzification 58, 174 Pi-Type Membership Functions 167
Monitor Debug Mode 87, 102 Probability and Fuzzy Logic 151
Monitor&Modify 102 PROD 72
Monitor&Modify Debug Mode 39, 87 Product Operator 72
Online 103 Project Editor 12
RTRCD 102 Project Information 109, 110
Multi-Client 203 Prototyping 53
Multiple Instances 203 Psycholinguistics 150
Multi-Systems 203, 204, 266 Psycolinguistic Research 169
Multivalued Logic 147
RAM Size 327
Neural net behaviour 180 RCU 108, 301
Neural Net Structure 177 Real-Time Optimization 48
Neural Net Technology 176 Remote Control Unit 108
NeuroFuzzy 176 Reserved RAM 211
Configure Training of 129 Result Aggregation 171, 172
Defuzzification Methods 128 ROM Size 328
Iterations 132 Rule
Learning Methods 188 Complete and Incomplete 77

340
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

Completeness 95 Mathematical Principles of 149


Condition 171 Stochastic 149
Consequence 171 Updates 326
Don’t Care 77
FAM 77 Variable Type 57
Rule Analyzer 100 Variables 53
Rule Block 22, 53, 70 Verification of a Fuzzy Logic System 48
Properties 23, 75 View Main Menu 46
Utilities 78, 133
Wizard 71 Watch Window 88
Rule-based Fuzzy Logic Systems 155 Winner Neurons 182, 189

Sample Sequencing 183, 190 Z-Type Membership Functions 167


Serial Interface 103
Shared Filed System 103
Shell Values 59
Shell Values 60
Singleton Membership Functions 174
SOFT 148
Spreadsheet Rule Editor 76
S-shape functions 177
S-Shaped MBF 169
Standard MBF 167
Statistics Analyzer 28, 100
Statusbar 13, 47
Steps[%] Field 95
Structure of a Fuzzy Logic Controller 158
S-Type Membership Functions 167
Sucosoft S40 104
Synapse 177
System Analysis 334
System Optimization 186, 334

TCP/IP 103
Technical Restrictions 332
Term 62, 166
Text 53, 55
THEN Part 171
Time Plot 15, 97
Toolbar 13, 47
Trace Analyzer 29, 101, 335
Transfer Plot Analyzer 94
Treeview 12, 47

Uncertainty
Lexical 150

341
Inform Software Corporation Chapter 9: Appendix

9.7. License Agreement

Please read this agreement carefully prior to opening this package. By opening this sealed
package, you will be bound by the following terms and conditions. In the event that you
do not agree with any of them, you should promptly return the package unopened. Your
money will be refunded.

1. Term:
This Agreement is effective from the date on which you open the package containing the
program. You may terminate it at any time by destroying the program together with all
copies, modifications, and merged portions in any form. It will also terminate upon
conditions set forth elsewhere in this Agreement or if you fail to comply with any term or
condition of this Agreement. You agree upon such termination to destroy the program
together 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 any
replacement for that computer. In support of your use of the program on the single
computer, you may copy the program into any computer readable or printed form for
back-up or modification purposes. You may modify the program and/or merge it into
another program for your use on the single computer. YOU MAY NOT USE, COPY OR
MODIFY THE PROGRAM, IN WHOLE OR IN PART, EXCEPT AS EXPRESSLY
PROVIDED IN THIS AGREEMENT.

Any portion of this program merged into another program will continue to be subject to
the terms and conditions of this Agreement. If you transfer the program, you must at the
same time either transfer all copies whether in printed or computer readable form to the
same party or destroy any copies not transferred, including all modifications and portions
of the program contained or merged into other programs. You must also reproduce and
include the copyright notice on any copy, modification, or portion merged into another
program. IF YOU TRANSFER POSSESSION OF ANY COPY, MODIFICATION, OR
MERGED PORTION OF THE PROGRAM TO ANOTHER PARTY, YOUR LICENSE
IS AUTOMATICALLY TERMINATED.

You may not sublicense, assign, or transfer the license or the program except as expressly
provided in this Agreement. Any attempt to otherwise sublicense, assign, or transfer any
of 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 are
entitled 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 as
evidenced by a copy of your receipt, the diskette(s) on which the program is furnished,

342
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

under normal use will be free from defects in material and workmanship. This warranty is
limited to you and is not transferable.

During the 90-day warranty period, Inform’s sole liability and your exclusive remedy
under this warranty will be, at Inform’s option, to replace any diskette not meeting the
foregoing warranty which is returned to Inform or an authorized Inform dealer with a
copy of your receipt, or if Inform or the authorized dealer is unable to deliver a
replacement diskette that is free of defects in material or workmanship, to refund the
license fee and terminate this agreement.

The foregoing warranty does not extend to any diskette that has been damaged as a result
of accident, misuse, abuse, or as a result of service or modification by anyone other than
Inform or an authorized dealer.

Inform does not warrant that the operation of the program will meet your requirements or
that the operation of the program will be uninterrupted or error-free. You assume
responsibility for the selection of the program to achieve your intended results, and for the
installation, 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 bodily
injuries or property damages if these programs do not work properly, it is your duty to use
adequate safety devices, working separately and independently from the developed
programs and the controller-systems, in order to prevent such injuries or damages. It is
your duty to test the equipment under working conditions before using it.

EXCEPT FOR THE ABOVE EXPRESS LIMITED WARRANTIES, INFORM MAKES


NO OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO
THIS PROGRAM, INCLUDING, BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE PROGRAM IS LICENSED AS IS. INFORM EXPRESSLY
DISCLAIMS ALL WARRANTIES NOT STATED HEREIN. IN NO EVENT SHALL
INFORM’S LIABILITY FOR ANY DAMAGES OR LOSS TO YOU OR ANY OTHER
PERSON EXCEED THE LICENSE FEE PAID FOR THE PROGRAM. IN NO EVENT
WILL INFORM BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
DAMAGES, INCLUDING ANY LOSS OF DATA, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, EXPENSES, LOST PROFITS, LOST SAVINGS, OR
OTHER DAMAGES ARISING FROM THE USE OR INABILITY TO USE OUR
PROGRAM.

SOME STATES DO NOT ALLOW THE LIMITATION OR EXCLUSION OF


INCIDENTAL 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 MAY
ALSO HAVE OTHER RIGHTS WHICH VARY FORM STATE TO STATE.

5. General:
If you have any questions concerning this Agreement, including warranty service, you
should contact Inform.

343
Inform Software Corporation Chapter 9: Appendix

If any provision or portion of a provision of this Agreement is determined to be invalid


under any applicable law, it shall be deemed omitted and the remaining provisions and
partial 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 it
is the complete and exclusive statement of the Agreement between us which supersedes
any proposal or prior agreement, oral or written, and any other communications between
us relating to the subject matter of this Agreement.

Microsoft Windows, Microsoft C, and Microsoft DOS are registered trademarks of


Microsoft Corporation, Inc. Turbo C and Borland C are registered trademarks of Borland
international, Inc. MCS-96 and MCS-51 are registered trademarks of Intel Corporation,
Inc. fuzzyTECH is a registered trade mark of Inform Software Corporation.

344
Inform Software Corporation fuzzyTECH® 5.3 User’s Manual

345

Você também pode gostar