# FuzzyWeb - A Web-Based Approach to Fuzzy System Design

Page 15

## 2.1 Introduction to Fuzzy Logic

Lotfi Zadeh, a professor at the University of California at Berkley, conceived the concept of Fuzzy Logic in the mid-1960’s. Basically, Fuzzy Logic is an extension to the classical logic, which allows intermediate truth values to be defined between the conventional evaluations true and false. Kaehler S. D. (2003)

Fuzzy Logic provides a means of calculating intermediate values between absolute true and absolute false, with resulting values ranging between 0.0 and 1.0. With fuzzy logic, it is possible to calculate the degree to which an item is a member.

Fuzzy Logic allows us to describe a system using human language rules. The fuzzy systems convert these rules into their mathematical equivalents. It presents the possibility of creating a control mechanism based on explicit knowledge. The created model is empirically based, relying on an expert's experience rather than their technical understanding of the system. This simplifies the job of the system designer and the computer, and results in very accurate representations of the ways in which systems behave in the real world.

Page 16

Theoretical Background

Initially, this theory did not receive much attention. The first practical application did not appear until 1974, when Professor Mamdani and his student S. Assilianused fuzzy logic to regulate a steam engine. The next major commercial development occurred in 1985, when researchers at Bell laboratories developed the first fuzzy logic chip. This chip led to a wide range of products like cameras, camcorders and rice cookers. Today, fuzzy logic continues to be one of the fastest growing sectors of applied artificial intelligence technology. Krantz B. (2002)

## 2.2 Fuzzy Sets and Membership Functions

Classical logical thinking is based on two-valued propositional logic, sometimes called Boolean logic: this assumes that any predication is either true or false, with no other possibility. As a consequence, the relation between an element and a set is either that the element belongs to the set, or it belongs not; one and only one of these predications is true. Such sets in the strict sense of set theory are called crisp sets in fuzzy logic.

Unfortunately, this system imposes an inherent restriction on the representation of imprecise concepts. As an example, Boolean logic might be used to identify whether a room temperature is "hot" or "cold". Most people would agree that 35°C is a "hot" room temperature and 5°C is a "cold" room temperature. However, when the room temperature is at 18°C, it becomes much harder to

Page 20

Theoretical Background

## 2.2.1 Logical Operations on Fuzzy Sets

Since fuzzy logic rather deals with functions (or with their graphs) than with sets the fuzzy equivalent to the logical operators must deal with functions, too. For the logical AND operation respectively for the (equivalent) term of set theoretical intersection of sets the concept of t-norms (triangular norm) is introduced.

“A triangular norm or t-norm is a class t of binary operators on fuzzy sets that represents a large class of “and” operators.” H. Hörtlehner (2002)

Definition: A t-norm is a function t : [ 0 , 1 ] ´ [ 0 , 1 ] ® [ 0 , 1 ] with the following

For the logical OR operation respectively for the (equivalent) term of set theoretical union of sets the concept of t-conorms (or, synonymously, an s-norm) is introduced.

“An s-norm or t-conorm is a class s of binary operators on fuzzy sets that represents a large class of “or” operators.”

Page 25

Theoretical Background

## 2.2.2 Common Types of Membership Functions

In the following, we define the most common classes of membership functions of one dimension - which means, membership functions with a single input. (J.-S. R. Jang 1997)

Triangular Membership Functions

The triangular membership function triangle a,b,c : R ® [ 0 , 1 ] is specified by three

real parameters {a,b,c} with a < b < c as follows:

An alternative expression for the preceding equation is:

The parameters {a,b,c} with a < b < c determine the x coordinates of the three corners of the underlying triangular membership function.

Page 32

Theoretical Background

## 2.3 Linguistic Variables and Linguistic Terms

In control or decision problems, being the main field for fuzzy logic applications, one considers a finite number of input quantities, given by linguistic variables like “temperature”, “pressure”, “age”, “size”, etc. The linguistic variables usually take values in the set R of real numbers.

Assuming that the problem under consideration is characterized by n’ real input parameters, the set X of possible input values (the universe of discourse) is given by the set of all vectors (x 1 , x 2 , ..., x n’ ) Î R n’ . Now, instead of considering

decisions based on crisp input values, the input is transformed into linguistic terms, represented by membership functions respectively by their corresponding fuzzy sets. Usually, one has several linguistic terms for any linguistic variable, but only a finite number of them.

For a system controlling room temperature one could consider the only linguistic variable “temperature” with values in R or restricted to a finite real interval. Then the possible crisp input, such as:

Page 34

Theoretical Background

## 2.4 Fuzzy If-Then Rules

Fuzzy logic lets you describe complex systems using your knowledge and experience in simple, English language based rules. It does not require any system modelling or complex mathematic equations governing the relationship between inputs and outputs. Fuzzy rules are very easy to learn and use, even for non-experts. It typically takes only a few rules to describe systems. The common form of knowledge presentation is the fuzzy if-then rule, also known as a fuzzy rule, fuzzy implication, or fuzzy conditional statement.

The general form for a rule with a single antecedent is:

IF X IS A THEN Y IS B

Where A and B are linguistic terms (represented by fuzzy sets) and on X and Y are linguistic variables. The left part of the rule (X IS A) is called the condition, antecedent, or premise, whilst the right part (Y IS B) is called the consequence or conclusion.

Most fuzzy control systems will have multiple input values. Therefore the condition of the rules can contain a combination, such as union (OR), or an intersection (AND) of several inputs.

An example for such a rule with multiple antecedents is:

Page 35

Theoretical Background

## 2.5 Fuzzy Inference Systems

Fuzzy inference systems are powerful and all-purpose tools used to resolve different problems. They have been successfully applied in fields such as automatic control, data classification, decision analysis, expert systems, and computer vision. The basic idea is to integrate expert’s knowledge and experience when the option of building an exact mathematic model takes a lot of time, or is simply not possible due to its complexity.

“To summarise the concept of fuzzy inference depicted in this figure (Figure 2-9), fuzzy inference is a method that interprets the values in the input vector and, based on some set of rules, assigns values to the output vector.”

Page 36

Theoretical Background

## 2.5.1 Detailed Flow of Fuzzy Inference Systems

Since all the fuzzy sets and the linguistic rules are designed, the system follows five process steps, as described below.

Fuzzification

The first step is to evaluate to what degree each input belongs to each of the appropriate input fuzzy sets. Therefore, the first part of the development of a fuzzy logic controller must be to develop the membership functions to translate each “crisp” input (which can be any number depending on the input signal), into a “fuzzified” variable which is contained between 0 and 1.

Figure 2-10 shows an example, where the crisp input 2.2 ft is fuzzified to 85 % near and 15 % good.

Page 46

MyFuzzy.pm - The Fuzzy Library

When a resolution for a fuzzy term is to be found, it needs to be considered whether maximum precision or maximum performance is required. If the resolution is low, all fuzzy operations work very fast, but the level of precision for the membership values is not very high. If precision is more important than performance, a high resolution value should be taken.

## 3.1 Definition of a Fuzzy Set

To define the fuzzy set A ~ from the example above using MyFuzzy.pm the following code is needed.

For larger fuzzy terms, especially with a higher resolution, defining all the values would be a lot of work. With the function interpolate this work can be reduced to a minimum. Only the prominent values of the fuzzy set need to be defined. The in-between values will be filled out automatically by linear interpolation. The result of the following code is exactly the same as that of the last example.

The number of value pairs is unlimited. For this reason you cannot only define standard fuzzy sets like triangles or trapezoids.

Page 48

MyFuzzy.pm - The Fuzzy Library

## 3.2 Applying the Fuzzy Inference System

When all fuzzy sets are defined and transformed, the fuzzy rules have to be applied. A fuzzy rule contains a condition and a conclusion. The condition is a single fuzzy term or a combination of fuzzy terms, such as union (OR) or intersection (AND).

The following example demonstrates how a simple fuzzy rule is applied. The procedure has to be done for every rule of the fuzzy system.

Room temperature = 25 °C Facts: Outside temperature = 30 °C Rule: IF room_temperature IS hot

## 3.2.1 Fuzzification

In this example we use the fuzzy set of the previous example again. To keep the example simple, the same fuzzy set is used for both the inside and outside temperature. Assumed that it is still transformed into x-values of the interval [0,n] with a resolution of n=100 again. The name of the fuzzy sets in the Perl code example is: \$room_temperature_hot and \$outside_temperature_hot. It is also necessary to transform the input values. The function transform_value is used to transform the temperature values (inside: 25°C, outside: 30°C) to the internal representation - a natural number in the interval [0,n].

Page 49

MyFuzzy.pm - The Fuzzy Library

The new “internal” room temperature value is now 75, outside temperature is 80. The following command returns the corresponding membership values.

The variables now contain the fuzzified temperature:

m room_hot (75) = 0.33 => \$mv_hot_room_temperature = 0.33

m outside_hot (80) = 0.66 => \$mv_hot_outside_temperature = 0.66

## 3.2.2 Aggregation

Because the antecedent of the rule combines two statements using the AND operator, aggregation is necessary. This is done with the function fuzzy_aggregation. The specified parameters are the logical operator and the membership values taken from the fuzzification statements.

For the antecedent “room_temperature IS hot AND

outside_temperature IS hot” the following Perl statement is needed to get the activation level of the rule:

From this we get the following degree of activation:

act Rule = min(0.33,0.66) = 0.33 => \$activation = 0.33

Page 50

MyFuzzy.pm - The Fuzzy Library

## 3.2.3 Implication

The implication is done with the function fuzzy_implication. The first parameter of the function is the used t-norm. In the example, the minimum operator is used. The second parameter is the fuzzy set is given by the conclusion; in this case: “aircondition IS full”. The last parameter is the degree of rule activation, multiplied by the degree of support.

## 3.2.4 Accumulation

If there are multiple rules, a result fuzzy set exists for each of them after their implication. These fuzzy sets now need to be accumulated to a single result fuzzy set for the whole fuzzy inference system.

The output accumulation is done with the function fuzzy_accumulation, which combines two fuzzy sets using an s-norm. We start with an output fuzzy

Page 51

MyFuzzy.pm - The Fuzzy Library

set following the membership function m (x) = 0. The initialisation is done with the

function init_fuzzyterm.

\$aircond_result_fuzzyset = init_fuzzyterm(0);

Following this, the accumulation can take place. The following statement has to be done for every rule with a conclusion concerning the linguistic variable “aircondition”. The parameters describe the used s-norm, the result fuzzy set, and the fuzzy set to be accumulated (the result of the implication).

After applying all the rules of the fuzzy system in this way, the variable \$aircond_result_fuzzyset contains the result fuzzy set.

## 3.2.5 Defuzzification

The last step is to defuzzify the output fuzzy set \$aircond_result_fuzzyset. This can be done with the function defuzzify. The first parameter needed, specifies the defuzzification method to use. The second parameter is the fuzzy set to be defuzzified.

The variable \$aircond_crisp now contains a natural number within the interval [0,n], where n is the resolution of the fuzzy set. To get the real value required to regulate the air condition, a retransformation is needed.

Page 54

FuzzyWeb - The Shell

## 4.1 System Structure

Gather input

Figure 4-1: FuzzyWeb - System Overview

A fuzzy project is created and administrated via a graphical user interface (GUI)in this case it is a web browser. The web server stores all the information in a relational database.

For the generation of the code, the web server reads all the relevant data from the database and writes the complete Perl source code onto the file system. During execution of the Perl code, crisp input values for the simulation come either from the database (simulation data) or from certain sensor devices. The

Page 55

FuzzyWeb - The Shell

results of each simulation cycle are stored in the database, with the option of sending the data to any control devices.

Analysis of the result is possible via the FuzzyWeb GUI on a web browser. For more detailed analysis, the data can be exported to Microsoft Excel.

## 4.2 Software Requirements

To run the FuzzyWeb, certain software requirements must be fulfilled: see tables 4-1 and 4-2. The system was tested the system under Windows NT, Windows 2000, Windows XP and Linux. For a short installation guide for FuzzyWeb on a Windows system see appendix E.

4.2.1 Server Side Requirements

Page 56

FuzzyWeb - The Shell

## 4.3 Database Design

As previously mentioned, all data concerning the fuzzy system is stored in a database. In case of FuzzyWeb, a MySQL 4.0 database is used. There are several reasons, why MySQL was chosen:

· MySQL is a relational database management system. · MySQL is Open Source software. This means that it is possible for anyone to use and modify it. · MySQL is very fast, reliable and easy to use. · Communication interfaces exist on MySQL for Perl, PHP · MySQL runs on Linux and Windows platforms

Page 57

FuzzyWeb - The Shell

## 4.3.1 Entity Relationship Diagram

The data model for the FuzzyWeb consists of nine tables. The figure 4-2 shows the tables used to store the fuzzy system definitions, the simulation-input values,

and the results of a fuzzy system currently operational.

Page 58

FuzzyWeb - The Shell

## 4.4 Program Features and Handling

The web interface is structured into two frames. The left frame contains a link for each fuzzy project already defined in the shell, and the link new to create a new project. If a project is selected, a compact project overview appears in the right frame.

4.4.1 Project Overview

Page 59

FuzzyWeb - The Shell

This project overview contains the following data:

· The title of the project

· A brief description

· The names of all of the input variables and their linguistic terms · The names of all of the output variables and their linguistic terms · The most important master data of the project, such as the inference model and the variable resolution · A link to the rule editor · Code generation functionality (Perl and FCL)

· Output analysis capabilities (a graphical presentation of results via web and Excel export)

## 4.4.2 Project Master Data

By selecting the link edit next to the project title, the screen form to edit the following master data for the project is made available:

Project Name

Only the letters a..z and A..Z, the numbers 0..9 and the underscore are valid characters, and the first character of the name has to be a letter. The reason for these restrictions is that the code generator creates a file using this name, and the naming restrictions guarantee a valid file name.

Page 62

FuzzyWeb - The Shell

Before Store Value

If any operations are needed, before the output values will be stored into the database (and optionally a device file) they can be implemented here.

An example of this would be the rounding of an output value (which has been defuzzified into a real number), for a device that requires natural numbers: \$output_var = round(\$output_var);

## 4.4.3 Designing Fuzzy Sets

The following chapter describes how to define linguistic variables and linguistic terms. The membership functions representing the linguistic terms are illustrated graphically.

Page 66

FuzzyWeb - The Shell

Some examples clarify this:

## 4.4.4 Rule Editor

The fuzzy rules are uncomplicated to define. All input terms can be combined by AND or OR to the antecedent of the rule. Every term has the option of being negated. For the consequence part of the rule, any output term may be selected. Finally, a degree of support between 0 and 1 can be specified for each rule - the default value is 1.

Page 67

FuzzyWeb - The Shell

## 4.4.5 Perl Code Generation

Once the fuzzy system is completely defined, the Perl code can be created automatically. The created program uses the library MyFuzzy.pm. The following links associated with Perl code generation can be found in the project overview:

· Generate: Creates the Perl program and stores it to the file system · Display: Displays a previously generated Perl code · Run: Executes the program with a Perl 5 interpreter. The crisp values

· Logfile: If logging is enabled, this displays the log file of the last execution of the program.

All these functions are only available for privileged users. Authentication is required. Protection mechanisms are used from the web server.

If anything in the design of the fuzzy system changes, then the code has to be generated again. Of course, the code can be downloaded and modified or integrated into a larger project by anybody that has Perl knowledge. The code is well formatted and easy to understand. The code can be run independently from the FuzzyWeb. A complete code example is attached in appendix C.1.

Page 70

A more extensive example is attached in appendix C.2.

## 4.4.6 Data Gathering and Distribution

As mentioned above, input variables in device file mode receive their input values from a device file. Output variables in device file mode store their result values onto a device file.

For the input variables a Data Gathering Daemon is needed to read data from a sensor device, e.g. a temperature sensor, and store them onto the device file. As a result, the fuzzy system always finds the actual value.

For output variables in device file mode, a Data Distribution Daemon is needed to transfer the output value from the device file into the control device, e.g. a servo or heating valve.

Page 78

FuzzyWeb - The Shell

Microsoft Excel Export Interface

The last and most powerful means of result analysis is the Microsoft Excel Export Interface. All of the input and output values for each step, including the step number and a timestamp, can be exported into a single Microsoft Excel Table. Further data interpretation and data presentation can be done here. Microsoft Excel provides a wide range of diagram styles and statistical methods.

## 4.5 Popular Fuzzy Shells

Various fuzzy software development tools exist on the market. However, it is important to consider that there are some criteria such a tool should meet:

· Support of all development phases such as design, simulation, optimisation, verification and implementation · Support of multiple hardware platforms such as microcontrollers and PC’s

· Support of standardised interfaces such as a the serial port Harju T. (1999)

This chapter concentrates on two of the most popular fuzzy shells: fuzzyTECH from Inform Incorporated and Matlab Fuzzy Logic Toolbox from The Mathworks Incorporated. Both will be presented and compared to FuzzyWeb in the following chapters.

Page 79

FuzzyWeb - The Shell

## 4.5.1 INFORM GmbH - fuzzyTECH

“fuzzyTECH is the world leading family of software development tools for fuzzy logic and neural-fuzzy solutions. The fuzzyTECH Editions are specialised for technical applications while the fuzzyTECH for Business products are specialised for applications in business and finance.”

fuzzyTECH follows the familiar layout of popular Microsoft Windows applications such as Microsoft Office.

The Linguistic Variable Editors enable the adjustment of various types of membership functions using a mouse. In debug mode, the Linguistic Variable Editor also visualises the degree of activation. Moving a red arrow with the mouse simulates input conditions. fuzzyTECH provides three different rule block editors: the Spreadsheet Editor is shown in figure 4-13. Alternatives are the Matrix Rule Editor and entering rules in Fuzzy Technology Language (FTL).

Page 80

FuzzyWeb - The Shell

fuzzyTECH can be integrated with other software products via standard interface techniques such as DDE, DLL, and ActiveX. Interfaces with popular software products such as Microsoft Excel are provided.

## 4.5.2 The MathWorks, Inc. - Matlab Fuzzy Logic Toolbox

“The Fuzzy Logic Toolbox supports the design and analysis of fuzzy logic based systems. It supports all phases of the process, including development, research, design, simulation, and real-time implementation. Built-in graphical user interfaces (GUIs) provide an intuitive environment to guide you through the steps of fuzzy inference system design. Functions are provided for many fuzzy logic methods, such as fuzzy clustering and adaptive neuro-fuzzy learning.” The Mathworks (2003)(a)

The most outstanding features of the Matlab Fuzzy Logic Toolbox are:

· Support of Mamdani and Sugeno-type Inference

· Neuro-adaptive and fuzzy clustering learning techniques · C code generator and stand-alone C code fuzzy logic engine · Integration in the Matlab product family, with huge functionality concerning Simulation, Presentation, etc.

Page 81

FuzzyWeb - The Shell

The following screenshots demonstrate how to build the rules set, define the membership functions, and analyse the behaviour of the fuzzy inference system.

## 4.5.3 Comparison to FuzzyWeb

FuzzyWeb is a web application, providing functionality for design and analysis of fuzzy logic based systems. Like the other shells described here, FuzzyWeb supports all phases of the process, including development, design, simulation, real-time implementation and data analysis. Web Applications are web sites that offer more to the user visiting them than normal, static web sites. The difference is interactivity.

Page 85

Fuzzy Controlled Heating Using FuzzyWeb

## 5 Fuzzy Controlled Heating Using FuzzyWeb

“Temperature control is widely used in various processes. These processes, no matter they are is in a large industrial plant, or in a home appliance, share several unfavorable features. These include non-linearity, interference, dead time, and external disturbances, among others. Conventional approaches usually do not result in satisfactory temperature control.” Zhang W. (1996)

A typical problem with traditional techniques is in finding the golden happy medium between the controller’s response time and the overshoot. The aim of the system illustrated in figure 5-1 would be to reach the desired temperature as fast as possible with no overshoot.

Page 86

Fuzzy Controlled Heating Using FuzzyWeb

The grey and the red curve in figure 5-1 are based on linear approaches. This implies that the interrelationship between actual temperature and heating energy is assumed to be linear. The black curve is the result of a simple fuzzy inference system, very similar to the system designed for the following simulations (a oneinput temperature controller).

## 5.1.1 Input Fuzzy Sets

The only input for the fuzzy system comes from a temperature sensor inside the heated room. The linguistic variable temp consists of three linguistic terms: cold, cool and reached.

## 5.1.2 Output Fuzzy Sets

The output of the system is the heating energy. This is a value between 0 and 100, representing a percentage of the maximum heating energy. The linguistic variable heating consists of three linguistic terms: zero, medium and max.

Page 87

Although the x-values of the fuzzy set zero start at -50 and the x-value of the fuzzy set max goes up to 150, the defuzzified output value can only be between 0 and 100, because of the behaviour of the supported defuzzification methods.

## 5.1.3 Fuzzy Rules

Only three rules are needed to describe the connection between temperature and heating energy.

## 5.1.4 Heating Function

The result of this fuzzy inference system using Mamdani inference and centre of gravity defuzzification, is the function heating = f(temp) represented by the graph in figure 5-4.

Page 88

## 5.1.5 Simulation Model

To run a simulation based on this fuzzy system a simulation model has to be defined. This model describes the change in temperature according to the heating energy used.

For these experiments, it is not necessary to find a model that includes all the characteristics. It has to fulfil only the following conditions:

· If heating energy increases, the temperature increases too. · If heating energy decreases, the temperature decreases too.

Therefore, the following simplified model was used:

Page 89

Fuzzy Controlled Heating Using FuzzyWeb

## 5.1.6 Result Analysis

FuzzyWeb supports three different inference models (Mamdani, Larsen, Mizumoto) and three different defuzzification methods (centre of gravity, centre of area, mean of maxima). The simulation was executed with all nine possible combinations. The initial room temperature was set to 10°C. The results are illustrated as line charts and as a table below (Figure 5-5, Table 5-1). The blue line represents the temperature and the red line represents the heating energy.

Page 92

Fuzzy Controlled Heating Using FuzzyWeb

Although, there are significant differences in the heating curve, the temperature curves are almost congruent.

The experiment shows that for this simple fuzzy control system, the choices of the inference and defuzzification methods are not hugely significant. The design of the fuzzy sets and fuzzy rules is much more important.

## 5.2 Real-Time Two-Input Temperature Controller

The design of this fuzzy control system is similar to the simulation example above. The major difference is that this system has two temperature inputs: inside temperature and outside temperature.

## 5.2.1 Input Fuzzy Sets

Both input variables consist of four linguistic terms, cold, cool, reached and hot, where the fuzzy set hot is a subset of the fuzzy set reached.

Page 93

Fuzzy Controlled Heating Using FuzzyWeb

## 5.2.2 Output Fuzzy Set

The output of the system is the heating energy. It is a value between 0 and 100, representing a percentage of the maximum heating energy. The linguistic variable heating consists of three linguistic terms, zero, medium and max.

## 5.2.3 Fuzzy Rules

The fuzzy rule set is a bit more complicated than for the one-input heating system. All of the features of the FuzzyWeb rule editor are used in this case. Rules with multiple antecedents are present, combined with AND (rule 4, 5) and OR (rule 3). The rules 4 and 5 have negated antecedents, and the rules 1 and 4 have a degree of support less than 1. The latter has the effect that the outside temperature has less influence on the heating than the inside temperature.

Page 94

Fuzzy Controlled Heating Using FuzzyWeb

## 5.2.4 Heating Function

The result of this fuzzy inference system with Mamdani inference and centre of gravity defuzzification is the function heating = f(inside_temp, outside_temp) represented by the surface chart in figure 5-10.

## 5.2.5 Hardware and Software Components

The room being heated is a laboratory in HTL Spengergasse, a technical school in Vienna. There is a web cam situated in the room, so it can be viewed via the Internet. The URL is

Page 96

Fuzzy Controlled Heating Using FuzzyWeb

FuzzyWeb server. The data distribution daemon sends this value back to the TINI board using the Device Communication Protocol (DCP) based on http. The TINI passes the heating value on to a Microchip PIC16F877 microcontroller via the serial port. The used protocol is DCP again. The microcontroller operates the heating valves via a special hardware constructed by Dr. Herbert Hörtlehner.

## 5.2.6 Result Analysis

The FuzzyWeb controlled heating has been active since March 2003. The fuzzy system has only been running for a few weeks, but what has been seen in this short period is that the system works well. The heating power is adjusted according to the measured temperatures.

Usually in March and April, the outside temperature in Vienna fluctuates noticeably. In the last few weeks values have been measured from -5.45 °C to +24.1 °C. As a result, the system could be put to the acid test.

The system worked from the beginning. The proportion of the weighting between the inside and the outside temperature was suboptimal when the outside temperature fell below about +5 °C. A combination of adjusting the degree of support for the rules, and tuning of the membership functions, improved the system’s behaviour noticeably.

Page 99

## 6.1 Fuzzy versus Mathematical Modelling

Fuzzy logic seems to be a good choice for implementing facility automation tasks, such as the regulation of a heating system. Even complex non-linear control behaviour can be implemented without extensive mathematical knowledge, although some time has to be spent on tuning the system. Neuro-fuzzy technologies might provide ways of substantially reducing this effort involved in tuning a system.

## 6.2 Conventional versus Web-Based Fuzzy Shell

Compared to conventional fuzzy shells, a web based fuzzy shell has the advantages of platform independence, comparative ease of installation, location independence and collaborative development. On the other hand, more time has to be spent on security considerations and infrastructure planning. The serious shortcomings of the web application concern its restricted handling.

Page 100

Conclusions

## 6.3 Communication and Data Exchange

For real-time applications, the means of communication between the program and the sensor/control devices has to comply with some basic requirements, such as simplicity, efficiency, multiple device support, symmetry, support of variable data sizes, and flexibility. FuzzyTECH’s Serial Link debug mode, a quite popular protocol used in this area, has some significant shortcomings in these areas. To overcome these shortcomings I developed my own protocol, called Device Communication Protocol (DCP) that fulfils all of the requirements mentioned above. In real-time heating control, the DCP works well between a PC, a TINI board, and a PIC microcontroller.

## 6.4 Fuzzy System Tuning

Experiments with different fuzzy inference models and defuzzification methods have shown that they do not have a significant influence on the overall system behaviour. For tuning purposes, the most interesting factors are the designs of the membership functions and fuzzy rules, with their subsequent degrees of support.

Page 112

Page 114

Appendices

## A.2 FYP Interim Report

The timetable didn’t change until now and there have not been any major problems yet. For a more detailed listing of progress see below:

Still Finished

· Background reading concerning fuzzy methods and algorithms

· Knowledge acquisition in suitable development tools

· Decision of the appropriate tools

· Setting up the development environment

· Planning of the functionality of the fuzzy library and developing the algorithms

· Programming and testing of the fuzzy library (maybe I’ll implement some additional features

later)

· Designing the application structure (web, database, ...) and defining the functionality in detail

· Part 1 of developing and testing the web application: Defining a fuzzy project (variables,

terms, rules)

In Progress

· Background reading concerning code generation (until mid Jan 03)

· Part 2 of developing and testing the web application: Implementing the code generator (until

mid Jan 03)

· Part 3 of developing and testing the web application: Expand and test simulation functionality

(e.g. chart and table representation of values at each step, possibility to define simulation inputs) (until end Jan 03)

Not Yet Started

· Comparison to existing systems (end Feb 03)

· Final software tests with concrete fuzzy examples, bug fixing if necessary (until mid Mar 03)

· Finalisation of the Report (based on the documentation of the particular steps above) (until

end Mar 03)

· Preparing a presentation (until mid Apr 03)

· Last revision and finalisation of the FYP (until mid Apr 03)

Page 115

Appendices

## A.3 FYP Progress Report

Date: 23.9.2002 Meeting-No.: 1

Next meeting: 30.9.2002

Page 130

Appendices

## round (number)

Description:

Parameters:

Return value:

Example:

min (val_1,..,val_n)

Description:

Parameters:

Return value:

Example:

max (val_1,..,val_n)

Description:

Parameters:

Return value:

Example:

fuzzy_aggregation (operator, val_1,..,val_n)

Description:

Parameters:

Return value:

Example:

Page 131

Appendices

transform_value (min, max, val)

Description:

Parameters:

Return value:

Example:

retransform_value (min, max, val)

Description:

Parameters:

Return value:

Example:

## init_fuzzyterm (val)

Description:

Parameters:

Return value:

Example:

Page 132

Appendices

transform_fuzzyterm (min,max,fuzzyterm)

Description:

Parameters:

Return value:

Example:

## interpolate (fuzzyterm)

Description:

Parameters:

Return value:

Example:

fuzzy_and (fuzzyterm_1, …, fuzzyterm_n)

Description:

Parameters:

Return value:

Example:

fuzzy_or (fuzzyterm_1, …, fuzzyterm_n)

Description:

Parameters:

Return value:

Example:

fuzzy_accumulation (s-norm, fuzzyterm_1, …, fuzzyterm_n)

Description:

Parameters: Return value:

Example:

Page 133

Appendices

fuzzy_implication (t-norm, fuzzyterm, val)

Description:

Parameters:

Return value:

Example:

## defuzzify (method, fuzzyterm)

Description:

Parameters:

Return value:

Example:

Description:

Parameters:

Return value:

Example:

write_dev_file (filename, \$value)

Description:

Parameters: Return value:

Example:

Page 135

Appendices

## C.1 Generated Perl Code Example

The following Perl code was generated by FuzzyWeb and describes a two-input

heating system. #!/usr/bin/perl

#################################################

# # # # # # #

#################################################

################################################# # include MyFuzzy library ################################################# use MyFuzzy;

################################################# # set global variables

#################################################

\$mode = shift; \$prj{'resolution'} = 1000; \$prj{'iterations'} = 50; \$prj{'delay'} = 60; \$prj{'logging'} = 0; \$pk_prj = 5;

################################################# # define fuzzy variables #################################################

);

);

);

################################################# # individual functions for simulation ################################################# sub simulation { }

sub before_store_value { \$output_heating = max(0,\$output_heating); \$output_heating = min(100,\$output_heating); }

Page 139

Appendices

## C.2 FCL Example

The following FCL was generated by FuzzyWeb and describes a two-input

heating system.

Page 140

Appendices

## D.1 Simple Data Gathering Daemon#!/usr/bin/perl

################################################## # # DATA GATHERING DAEMON #

# Gathers Temperature Data via a HTTP Connection # # R. Stelzer # Univeristy of Derby, 2003 #

##################################################

use LWP::Simple;

# Data Source

\$url = 'http://www.tini.atrox.at/control.php';

# Delay between Gathering Cycles \$delay = 30; # seconds

# Device File Specification \$dev_file[0] = '27.dev'; # inside_temp \$dev_file[1] = '28.dev'; # outside_temp

# Gathering Loop (Endless) while () {

'http://tini.wien.atrox.at:88/_user_user/actor/insideTemp/get/lastTstr?valueonly'; \$status = getstore(\$url,\$file.".tmp"); rename(\$file.".tmp", \$file);

'http://tini.wien.atrox.at:88/_user_user/actor/outsideTemp/get/lastTstr?valueonly'; \$status = getstore(\$url,\$file.".tmp"); rename(\$file.".tmp", \$file);

# delay sleep \$delay;

}

Page 141

Appendices

## D.2 Data Gathering and Distribution Daemon Using DCP#!perl -w

################################################## #

# DATA GATHERING/DISTRIBUTION DAEMON USING DCP #

# Distributes and Gathers Device Data # via a HTTP or Serial Connection # # R. Stelzer # Univeristy of Derby, 2003 #

##################################################

BEGIN { require 5.004; }

# Libraries

use Win32::SerialPort 0.14; use IO::Socket; use strict;

# Global Variables

my \$delay = 10; # delay between distribution cycles (sec) my \$debug = 0; # debug mode: 0..off, 1..on my \$handle;

# Communication Type my \$type = 'TCP'; # for sending: COM or TCP

# Connection Preferencies for Serial Mode my \$comport = "1"; # 1..COM1, 2..COM2

# Connection Preferencies for TCP Mode

my \$tcp_host = '192.189.51.164'; my \$tcp_port = 6942;

# Device Configuration ######################

# Output Devices

'29.dev' => [17,1] # dev_file => [did,len] );

my \$devcount = 1; # number of devices (number of values to send)

# Input Devices

my %input_dev = ();

\$input_dev{1} = '20.dev'; # input_dev{did} = dev_file

my @devices = (); my @lengths = (); my @values my \$PortObj; my %received = (); my \$message;

Page 145

Appendices

## D.3 DCP Implementation in PIC-C

Developed 2003 by P. Pickering.

#define SSC_STATE_SEND 0 #define SSC_STATE_RECV 1

int1 ssc_state = SSC_STATE_RECV;

if (ssc_state == SSC_STATE_RECV) return 0;

printf("%c",device << 2 | (lng & 0x03));

int buffer; // koennte vielleicht noch mit packet.device optimiert werden if (ssc_state == SSC_STATE_SEND) return 0;

buffer = getch();

Page 146

Appendices

## E. FuzzyWeb - Server Installation

The following installation instructions describe my experience with setting up the

FuzzyWeb environment on Windows XP.

## Apache Web Server Installation

2. You will be asked for some Server Information:

3. Choose Setup Type Complete

4. Select any Destination Folder (<apachedir>)

5. Check URL http://localhost: The Apache welcome page will be displayed.

## MySQL Database Installation

QL-4.0%2Fmysql-4.0.12-win.zip&pick=mirror and extract it to any

temporary folder.

2. Run setup.exe there.

3. You will be asked to select a Destination Folder (<mysqldir>).

4. Choose Typical Installation.

5. For starting the database the first time, execute:

<mysqldir>\bin\mysqld-max -standalone Next times:

<mysqldir>\bin\mysqld

## Installing PHP

installer.exe/from/a/mirror and execute it.

1. Select Installation Type Standard

2. Select a Destination Location (<phpdir>)

3. Server Type: Apache

4. Ignore the popup: “Apache Configuration: Sorry, … you will have to

configure apache manually … see install.txt file for more details.”

Win32.zip/from/a/mirror and extract it.

6. Copy the content of the extracted (using folder names) php-4.2.3-

Win32.zip into <phpdir> (overwrite -> yes to all)

Page 147

Appendices

## Installing Perl

Windows Installer.

1. Select the Destination Directory (<perldir>).

2. All other questions answer with the default values.

## Configuring PHP as Module for Apache

1. Add the following lines to <apachedir>\conf\httpd.conf:

2. copy php4ts.dll to c:\winnt\system32\ (from p:\php\)

3. Restart Apache Service

## Install Perl Database Interface

For the following steps you have to be connected to the Internet:

1. Run <perldir>\bin\ppm

2. When the ppm prompt appears, type in the following commands:

install DBI

install DBD::mysql

exit

## Installing MySQL Front

and execute it.

1. Choose an Installation Directory <mysqlfrontdir>

2. For everything else, commit the default values.

3. Run MySqlFront and Connect to the Database:

Page 148

Appendices

1. Double-click the file Fuzzy.sql (from the installation CD) to start MySQL

2. Create Database “fuzzy” with MySqlFront.

3. Change to the MySQL Front query window and run the script (F9).

## Web Content

Content of the original apache htdocs directory (<apachedir>\htdocs\*) can be

deleted.

Extract fuzzyweb.zip (from the installation CD) to htdocs directory.

## Serial Port Communication in Perl

Use PPM to install Win32-API (Internet connection for PPM necessary): 1. Run <perldir>\bin\ppm

2. When the ppm prompt appears, type in the following commands:

http://search.cpan.org/author/BBIRTH/ and extract it into any directory. Then

switch into the directory and run:

Perl Makefile.PL

Perl test.pl

Perl install.pl

149 of 149 pages

Details

Title
FuzzyWeb - A Web-Based Approach to Fuzzy System Design
College
University of Derby
Course
Computer Studies
A+ (1)
Author
Year
2003
Pages
149
Catalog Number
V109082
ISBN (eBook)
9783640072675
File size
1061 KB
Language
English
Notes
This project provides a web-based method of design for fuzzy control systems operating independently of real location, without the requirement of installing any special software on the client computer. In addition it generates readable and adaptable source codes for a simple, graphically designed fuzzy system. The advantages and disadvantages of this method will be discussed in this project. To demonstrate the use and practicality of the system, several analysed experiments, based on simulatio
Keywords
FuzzyWeb, Web-Based, Approach, Fuzzy, System, Design, Computer, Studies
Quote paper
Roland Stelzer (Author), 2003, FuzzyWeb - A Web-Based Approach to Fuzzy System Design, Munich, GRIN Verlag, https://www.grin.com/document/109082