Beruflich Dokumente
Kultur Dokumente
PL7 FUZ
ENGLISH
Section Page
1 Introduction 1/1
Section Page
3.4 Confirm - Cancel 3/12
4 Performance 4/1
Memory usage 4/1
5 Appendix 5/1
___________________________________________________________________________
4
Section 11
Introduction
1 Introduction
ENGLISH
The "Fuzzy logic" function is designed to allow the integration of fuzzy rule databases
in TSX 37 and TSX 57 PLCs.
Simple to understand and easy to set up, it must allow a user with minimum knowledge
of fuzzy logic to integrate application-specific expertise into an application.
For this reason, the choices available when setting up the fuzzy logic function have
been reduced as far as is possible.
Moreover, this function can be used most of the time by selecting default configurations
and without specific knowledge of the various operators which can be used in fuzzy
logic.
___________________________________________________________________________
1/1
1.2 Installation
ENGLISH
PL7 FUZ should be installed on a development station which already contains PL7
Micro, Junior or Pro, version 3.0 minimum.
After inserting the disk into the drive, proceed with installation as follows :
• Open Windows Explorer, select the drive (A) then double-click on setup.exe or, in
Run from the Start Menu, type a:\setup then click on OK.
___________________________________________________________________________
1/2
Introduction 1
ENGLISH
• Enter your name and your organization
• Select the installation language
• To use this product, simply launch PL7 and then access the various components
required for fuzzy logic.
___________________________________________________________________________
1/3
ENGLISH
___________________________________________________________________________
1/4
The FUZ Section
function 22
2 The FUZ function
ENGLISH
Characteristics of the function :
• 5 inputs, 4 outputs,
• 25 rules maximum,
• 3 predicates and 2 conclusions per rule maximum,
• 20 membership functions maximum for inputs and 16 maximum for outputs,
• "Singleton" type outputs.
Operators :
For each stage of fuzzy reasoning, the function uses the following operators :
• composition operator : MAX/MIN,
• "AND" operator between predicates of a rule : MIN,
• implication operator : MIN,
• aggregate operator : MAX,
• defuzzification operator : center of gravity for singletons.
For further details on the operation of the fuzzy logic integrated in this function, see
section 5 "Appendix".
2.1 Prerequisites
The FUZ function operates on the application data, which it receives in the form of
parameters. It is not instantiated.
The function can only be executed by a call during processing of a task. By definition
it has no synchronized entry point in one or other of the PLC operating modes.
All parameters must be entered, the concept of optional parameters does not exist.
___________________________________________________________________________
2/1
ENGLISH
If the function is conditioned, it will not be able to detect a cold restart and will therefore
be unable to perform its initializations (and in particular check the validity of the
knowledge base).
Using Ò Û , the user can call the function library which offers help with entering
function parameters. Simply select :
• the family of the function : "Fuzzy logic",
• the name of the function : FUZ,
then update the entry zone with the required parameters.
FUZ (
word, word, word, word, word, cst word[217],
IN IN IN IN IN IN
Input 1 Input 2 Input 3 Input 4 Input 5 Knowledge
base :
217 elements
Example of a call :
FUZ ( %MW0, %MW1, %MW2, %MW3, %MW4, %KW1000:217,
%MW200, %MW201, %MW202, %MW203, %M100, %MW1000:240,
%MW50)
Reminder : All the parameters used in a function must be entered. The concept of
optional parameters does not exist.
___________________________________________________________________________
2/2
The FUZ function 2
ENGLISH
2.2-2 Description and use of parameters
Parameter Type Description
Inp1 WORD Input 1
Inp2 WORD Input 2
Inp3 WORD Input 3
Inp4 WORD Input 4
Inp5 WORD Input 5
Csts AR_W Knowledge base : 217 elements
Out1 WORD Output 1
Out2 WORD Output 2
Out3 WORD Output 3
Out4 WORD Output 4
Berr EBOOL Error bit
Work AR_W Work space : 240 elements
StCm WORD Status/command word
Status/Command Word :
R : Read access
Writing to the reserved bits of the Status/Command word may cause the function
to malfunction.
When the function is initialized, the Status/Command word is initialized with the values
stored in the knowledge base.
• Knowledge base :
The FUZ function must handle a knowledge base which belongs to it. Otherwise the
functions will not have remanent data (conserved whatever the state of the PLC). To
save the knowledge base, "constant" type variables are used, whose values are saved
simultaneously in the application and the PLC (even when stopped).
This concerns the Csts table.
This constants zone, which represents the knowledge base, must be protected
against any incorrect modifications.
• Work space :
The FUZ function must, for internal calculation, operate in a work space which is
represented by the Work table.
This zone, like the knowledge base, must also be protected against modifications.
___________________________________________________________________________
2/4
The FUZ function 2
ENGLISH
To help with entering parameters, a dialog box can be accessed from the library (List
button).
If the user has entered any incorrect parameters before selecting the list, a dialog box
signals the errors and the necessary corrections. If no parameters have been entered
this box does not appear.
If some (or all) of the words or constants are outside the configuration, a message
advises the user once the data has been entered. In addition, the size of the tables is
fixed (cannot be modified).
___________________________________________________________________________
2/5
ENGLISH
Parameters to be entered :
1) the two internal parameter tables (constants and words),
2) the 5 word type input variables,
3) the Error bit,
4) the 4 word type output variables,
5) the status/command word.
Global confirmation is performed at the end of data entry (by pressing "OK").
___________________________________________________________________________
2/6
Section
The fuzzy logic tool 33
3 The fuzzy logic tool
ENGLISH
The Fuzzy logic tool is used to configure the fuzzy logic functions for the application.
It can be used to create and format the knowledge base associated with this function
and to simulate its behavior. Finally it allows online adjustment of the function.
At first the tool searches for all the fuzzy logic functions present in the application. The
following three scenarios are possible :
• no function is found, a message advises the user of this and the tool does not open,
• only one function is found in the application (the most common case), the tool opens
directly on this function,
• there are several fuzzy logic functions in the application, so the following dialog box
is displayed :
To configure the function, select it then load it by clicking on the "Configure" button or
by double-clicking on the line selected in the list.
___________________________________________________________________________
3/1
ENGLISH
If a fuzzy logic function is referenced several times in the same statement (or sequence
or rung), its number in the statement is indicated at the end of the line in the list. To see
the list of parameters, simply select the function then click on "Parameters". A message
containing the list of parameters for the selected function is displayed :
The validity of the parameters and the knowledge base, if there is one, is checked
during this phase. If the knowledge base is invalid, a message suggests that the user
open the tool on an empty base.
If one of the parameters is not valid, the tool does not open.
___________________________________________________________________________
3/2
The fuzzy logic tool 3
ENGLISH
When it opens, the PL7 FUZ display is either a predefined size (size of the views) or full
screen if the other tools open are using this mode. It respects standard PL7 operation.
On Request mode :
The function will be executed on the user’s request (in this case, a single inference is
launched). This is the default mode.
Continuous mode :
Continuous execution of the function.
If this mode is selected the user must enter an activation period which represents the
execution period of the function in tenths of a second (this value will be rounded off to
a multiple of the task period in which the function is programmed). Using this period could
be useful for processes in which the function does not need to be executed on each scan.
If the period is 0, the function executes on each PLC scan.
Default value : 10 (one second).
___________________________________________________________________________
3/3
ENGLISH
The list of linguistic variables for inputs and outputs is displayed with an indication of the
type (I for input, O for output). To enter the list of membership functions associated with
a variable, simply select the variable from the list.
The "Del." button is used to delete the selected term from the list.
It is possible to access a predefined term more quickly by entering the first few
characters. The list displayed will then be sorted according to these characters.
___________________________________________________________________________
3/4
The fuzzy logic tool 3
ENGLISH
List of linguistic terms
The list of linguistic terms is made up of predefined terms (manufacturer) and user
terms.
All of the terms (manufacturer and user) are stored in the application.
The maximum number of terms contained in the list is 255 (manufacturer and user).
___________________________________________________________________________
3/5
ENGLISH
xA xB
xA xB xC
xA xB xC xD
xA xB
xA
___________________________________________________________________________
3/6
The fuzzy logic tool 3
ENGLISH
The > character appears in front of a linguistic term when a membership function has
been associated with it (automatically for an output).
Then, simply enter the values of the points of inflection xA, xB, xC and/or xD.
All of the membership functions associated with a linguistic variable are displayed (thin
line for each function, bold line for that corresponding to the linguistic term selected).
Default value : This must be entered for an output : this is the default value assigned
to this output if no active rule calculates it (this field does not exist for an input).
___________________________________________________________________________
3/7
ENGLISH
Data Entry
The rules entry zone consists of drop-down lists of variables and linguistic terms. To
write a rule, simply enter the predicates and the conclusions using these drop-down
lists.
A list of linguistic terms gives only the terms defined for the variable selected
from the list of variables.
A negation can be selected on predicates. In the drop-down list, simply select the
linguistic term preceded by "!". There is no negation for conclusions.
Once the rule has been described, simply add it ("Add" button) to the list of rules. It will
be inserted at the end of the list. If the maximum number of rules is exceeded, a
message advises the user.
A number is associated with each rule. Rules are displayed in the order of their
numbers. Browser buttons can be used to change the order of the rules.
A rule must have at least one predicate and one conclusion. If this is not so, a message
advises the user of this.
One click on the "Initialize" button deletes all the fields in the "Rule Entry" group,
allowing entry on an empty rule.
Modifying - Deleting
To modify a rule, simply select it from the list. It is then displayed in the "Rule Entry"
zone. Once modifications have been made, select "Modify".
To delete a rule, select it from the list and delete it ("Delete" button).
___________________________________________________________________________
3/8
The fuzzy logic tool 3
ENGLISH
This tab is used in two ways :
• in offline mode for simulation,
• in online mode for debugging.
3.3-1 Simulation
In offline mode, this tab is used to simulate the operation of the function. This simulation
has three main advantages :
• activation of the rules for all the operating points is checked,
• the degree of activation of the rules is tested to improve/adapt the knowledge base,
• a PLC is not required (the knowledge base can be validated in the design office, for
example).
To activate simulation, simply enter the input values (forced inputs entry zones) then
launch the inference with <Start>. The simulated outputs are displayed. The degree of
truth of the rules contained in the knowledge base is displayed in the table.
All activated rules have a degree of truth displayed in red.
The drop-down list of rules located below the table summarizes this information and
gives a description of the rules.
___________________________________________________________________________
3/9
ENGLISH
All the other entry and check zones, which are not used in offline mode, are grayed out.
In this mode, the words “Simulation Commands” appear above the block of commands.
Force inputs
Inputs can be forced to simulate the operation of the function and therefore test it, then
to validate the associated knowledge base online.
Boxes 1,2,3,4,5 : Selection of forced inputs.
Force inputs : Forces the inputs selected in boxes 1,2,3,4,5. In this case, the true
inputs are not taken into account and only the values entered in the Forced Inputs are
used.
___________________________________________________________________________
3/10
The fuzzy logic tool 3
ENGLISH
When the error bit is at 1, the output parameters are no longer updated, they maintain
their state. The application program must therefore test this bit to impose a
fallback position if necessary.
Force Commands : Selecting this box permits direct commands from this screen
(the status/command word is inhibited).
In this mode, only initialization (“Init” button) can still be controlled by the status/
command word (ie the program can reinitialize the function even if the user is in the
debug phase). The status/command word informs the program of the user’s actions.
For the commands to be taken into account, the PLC must be in RUN.
Disconnecting or exiting the debug screen (changing tab or closing the tool) cancels
command forcing while retaining the current operating mode.
Automatic : The calculated outputs are assigned to the real outputs of the function.
Manual : Restart in manual mode. The manual outputs are assigned to the real
outputs of the function.
Operation on request - Continuous operation - Activation period (see section 3.2-1)
Start : Launches an inference. This button is active when the function is in operation
on Request.
Init : Reinitialization of the function. The knowledge base is copied into the work space.
Adjustment commands (force inputs, etc) are reinitialized.
Rules : This zone is used to display the degree of truth for instantiated inputs of each
of the rules contained in the knowledge base of the function. It is expressed as a %.
___________________________________________________________________________
3/11
3.4 Confirm - Cancel
ENGLISH
3.5 Archiving
On each confirmation, the knowledge base is automatically archived in the application,
for the FUZ function identified by its address in the program.
The knowledge base is restored via the “Utilities/Restore” menu.
Restoration can be requested to reload the knowledge base from the function just
archived.
Restoration is still possible even after the tool or the application has been closed.
This command can also be used to :
• retrieve the knowledge base after constants have been modified (handling error in the
variables editor).
• move the knowledge base (having moved the knowledge base from a language editor,
simply apply the restore command),
Example : Changing the “Knowledge base” parameter from a language editor :
• Old knowledge base : %KW0 : 217
• New knowledge base : %KW112 : 217
From the tool select the "Restore" command from the "Utilities" menu.
• copy the knowledge base to another function : with the language editor, enter the
same address for the table of constants in the target function as is used in the source
function and confirm. Then request the table of constants to be moved as indicated
above.
___________________________________________________________________________
3/12
The fuzzy logic tool 3
ENGLISH
PL7 is a workshop made up of tools. It is therefore possible, during configuration of the
function, to activate another tool or to switch to an editor in which the configured
function is referenced, then delete this function or modify its parameters and confirm.
Moreover, the main menu common to all the tools can still be accessed and it is
therefore possible to modify the PLC operating mode or switch from offline to online
mode, for example.
The table below summarizes all possible situations and describes the behavior of the
tool in each of them.
___________________________________________________________________________
3/13
3.7 Printing
ENGLISH
ENGLISH
FUZZIFY %MW1501;
TERM Raised := (0,1) (1000,0);
END_FUZZIFY
FUZZIFY %MW1503;
TERM Raised := (0,1) (1000,0);
END_FUZZIFY
FUZZIFY %MW1501;
TERM Raised := (0,1) (100,0);
END_FUZZIFY
FUZZIFY %MW1505;
TERM Slow := (-10,1) (0,0);
TERM Bad := (-10,1) (0,1) (0,0);
TERM Big Negative := (0,0) (0,1) (10,0);
TERM N := (0,0) (10,1);
END_FUZZIFY
DEFUZZIFY %MW1511;
METHOD : COGS;
TERM Median := 0;
TERM Correct := 600;
DEFAULT := 0;
END_DEFUZZIFY
DEFUZZIFY %MW1512;
METHOD : COGS;
TERM Slow := -50;
TERM Bad := -10;
TERM Upper := 0;
TERM Big Negative := 10;
DEFAULT := 0;
END_DEFUZZIFY
RULEBLOCK No 1
AND : MIN;
ACCU : MAX;
RULE 1 : IF %MW1501 IS Raised THEN %MW1511 IS Median
RULE 2 : IF %MW1501 IS NOT Raised AND %MW1505 IS NOT N THEN %MW1511
IS Correct
RULE 3 : IF %MW1505 IS Slow THEN %MW1512 IS N
RULE 4 : IF %MW1505 IS Bad THEN %MW1512 IS Big Negative
RULE 5 : IF %MW1505 IS Big Negative THEN %MW1512 IS Bad
RULE 6 : IF %MW1505 IS N THEN %MW1512 IS Slow, %MW1511 IS Median
END_RULEBLOCK
___________________________________________________________________________
3/15
ENGLISH
___________________________________________________________________________
3/16
Section 44
Performance
4 Performance
ENGLISH
Memory usage
Program space 1608 words
• 1 input, 2 outputs,
• 3 rules,
• 9 membership functions.
7 ms 5.5 ms 7 ms 4.8 ms
• 4 inputs, 3 outputs,
• 13 rules,
• 19 membership functions.
• 5 inputs, 4 outputs,
• 25 rules,
• 36 membership functions.
___________________________________________________________________________
4/1
ENGLISH
___________________________________________________________________________
4/2
Section 55
Appendix
5 Appendix
5.1 Operating principle of the function
ENGLISH
5.1-1 Fuzzy inference algorithm
The FUZ function calculates fuzzy inferences by performing the following steps :
• reading numerical values of the input variables,
• evaluating each membership function (Fuzzification),
• evaluating each rule,
• calculating the resulting output membership functions,
• calculating the numerical values of the output variables (Defuzzification).
Fuzzy rules
The fuzzy rules used are based on the "Mamdani" type rules.
There is only one rules base, which means that the rules are all activated at the same
time.
Each rule has a maximum of three predicates (conditions) and two conclusions.
Membership functions
Membership functions can be defined relative to the inputs and outputs of the function.
They are all "standardized", meaning that the minimum and maximum degrees of
membership reached by the function are 0 and 100(%). Standardization is not applied
between 0 and 1 as calculations are made in whole numbers.
Input membership functions are represented in the function in the form of abscissae
xA, xB, xC, xD of four consecutive characteristic points. Output membership functions are
represented by the single value of the corresponding singleton, xS.
___________________________________________________________________________
5/1
ENGLISH
B C 1 00%
100 %
A D xS O utpu t
In put
Method of inference
The FUZ function uses Mamdani fuzzy rules with the following operators :
Defuzzification
The FUZ function uses the defuzzification method by calculating the center of gravity
of singletons.
Fuzzification
Direct correspondence between the numerical value of the input and the degree of
membership :
Av era ge
D e gr ee
o f me mbe r sh ip
V alue of inp ut
___________________________________________________________________________
5/2
Appendix 5
ENGLISH
Rules
Average S m all
V alue
r etain ed
Inpu t1 I nput2
Va lue of inpu t1 V alue of input2
Weak
100%
1
D egree of activation
Output
100%
D egree of activation
rule 1
rule 2
O utput
___________________________________________________________________________
5/3
ENGLISH
Defuzzification
The numerical value calculated for the output corresponds to the center of gravity of
all the singleton values of the output.
x1 x2 x Output
3
V alue calculated
Σ ( xi . y i )
Value calculated =
Σy i
5.2 Example
Membership functions
% % %
Small Av e rage A v e rage B ig S mall A v e rage Big
100 100 100
In p u t X In p u t Y O u tp u t Z
Rules
___________________________________________________________________________
5/4
Appendix 5
ENGLISH
Calculating the inference
% %
Sm all Big
100 100
75
R u le 1
% % %
A v er age B ig Sm all
100 100 100
R u le 2 50
25
15 85
%
Sm all Big
75
D e fu z z i fy
25
100 900 Z
700
___________________________________________________________________________
5/5
ENGLISH
___________________________________________________________________________
5/6