When you use a washing machine, you generally select the length of wash time
based on the amount of clothes you wish to wash and the type and degree of
dirt you have. To automate this process, we use sensors to detect these parameters
(i.e. volume of clothes, degree and type of dirt). The wash time is then
determined from this data. Unfortunately, there is no easy way to formulate a precise
mathematical relationship between volume of clothes and dirt and the length
of wash time required. Consequently, this problem has remained unsolved until very
recently. People simply set wash times by hand and from personal trial and
error experience.
Washing machines were not as automatic as they could be.
To build a more fully automatic washing machine with self determining wash
times, we are going to focus on two subsystems of the machine: (1) the sensor
mechanism and (2) the controller unit. The sensor system provides external
input signals into the machine from which decisions can be made. It is the
controller's responsibility to make the decisions and to signal the outside world by some
form of output. Because the input/output relationship is not clear, the
design of a washing machine controller has not in the past lent itself to traditional methods of
control design. We address this design problem using fuzzy logic.
To implement our fuzzy logic controller, we use many of the commands from the
Fuzzy Logic Pack. The Fuzzy Logic Pack contains numerous functions for
working with fuzzy sets and fuzzy logic, and this notebook only demonstrates
a few of the functions which it provides.
First we need to load the necessary routines. We do this with the following
command.
![[Graphics:Images/washing_machine_gr_1.gif]](Images/washing_machine_gr_1.gif)
If the package loading command fails, verify that the directory containing
the Fuzzy Logic directory is on Mathematica's $Path. You can use the command
AppendTo[$Path, "directory"]. For convenience, this should be in your
init.m file.
Design a washing machine controller which gives the correct wash time even
though a precise model of the input/output relationship is not available.
Figure 1 shows a diagram of the fuzzy logic controller. There are two inputs:
(1) one for the degree of dirt on the clothes and (2) one for the type of
dirt on the clothes. These two inputs can be obtained from a single optical sensor. The
degree of dirt is determined by the transparency of the wash water. The
dirtier the clothes, the lower the transparency for a fixed amount of water. On the other
hand, the type of dirt is determined from the saturation time, the time it
takes to reach saturation. Saturation is the point at which the change in water transparency
is close to zero (below a given number). Greasy clothes, for example, take
longer for water transparency to reach saturation because grease is less water soluble
than other forms of dirt. Thus a fairly straightforward sensor system can
provide the necessary inputs for our fuzzy controller.
Figure 1. Fuzzy Controller
One of the first questions to ask when designing a fuzzy logic controller is
the following: What are my inputs and outputs? Once this question is
answered, the next item to address is the range of the inputs and outputs.
When talking about fuzzy sets, this range is referred to as the universal
space.
Before designing the controller, we must determine the range of possible
values for the input and output variables. These are the membership functions
used to translate real world values to fuzzy values and back. Figures 2a-c
show the labels of input and output variables and their associated membership
functions. Values for the input variables DIRTINESS and TYPEOFDIRT are
normalized (range of 0 to 100) over the domain of optical sensor values.
Note that WASHTIME membership functions are singletons (crisp numbers) in
this example. We can use fuzzy sets or singletons for output variables.
Singletons are simpler than fuzzy sets. They need less memory space and work
faster. If we could not be satisfied by the result when output values are
given by singltons we could change them into fuzzy sets.
We group all the output membership functions under the name DIRTINESS, which
is our first input.
![[Graphics:Images/washing_machine_gr_3.gif]](Images/washing_machine_gr_3.gif)
Next, we plot the membership functions for our first input with the FuzzyPlot
function. The PlotJoined option is set to True to produce the line graph
shown.
![[Graphics:Images/washing_machine_gr_4.gif]](Images/washing_machine_gr_4.gif)
Figure 2a. Labels and Membership Functions of Input Variable DIRTINESS
We group all the output membership functions under the name TYPEOFDIRT,
which is our second input.
![[Graphics:Images/washing_machine_gr_6.gif]](Images/washing_machine_gr_6.gif)
Next, we plot the membership functions for our secondt input with the
FuzzyPlot function. The PlotJoined option is set to True to produce the line
graph shown.
![[Graphics:Images/washing_machine_gr_7.gif]](Images/washing_machine_gr_7.gif)
Figure 2b. Labels and Membership Functions of Input Variable TYPEOFDIRT
In our example, the output time ranges from 0 to 60 minutes. To simplify the
later construction of membership functions we set the default universal space
now to be the desired range, 0 to 60, with the following command.
![[Graphics:Images/washing_machine_gr_9.gif]](Images/washing_machine_gr_9.gif)
We group all the output membership functions under the name WASHTIME , which
is our single output.
![[Graphics:Images/washing_machine_gr_10.gif]](Images/washing_machine_gr_10.gif)
![[Graphics:Images/washing_machine_gr_11.gif]](Images/washing_machine_gr_11.gif)
Here we see what our output membership functions look like.
![[Graphics:Images/washing_machine_gr_12.gif]](Images/washing_machine_gr_12.gif)
Figure 2c. Labels and Membership Functions of Output Variable WASHTIME
The final item needed for a fuzzy logic controller is a set of rules or a rulebase. The decision making capabilities of a fuzzy controller are codified by this set of rules. In general, the rules are intuitive and easy to understand, since they are qualitative statements written in English like if-then sentences. Rules for our washing machine controller are derived from common sense, data taken from typical home use, and experimentation in a controlled environment. A typical intuitive rule is as follows:
if SATURATION TIME is long and TRANSPARENCY is bad,
then WASH TIME should be long.
From different combinations of these and other conditions, we write the rules necessary to build our washing machine controller.
if DIRTINESS is Large and TYPEOFDIRT is Greasy then WASHTIME is OVeryLong;
if DIRTINESS is Medium and TYPEOFDIRT is Greasy then WASHTIME is OLong;
if DIRTINESS is Small and TYPEOFDIRT is Greasy then WASHTIME is OLong;
if DIRTINESS is Large and TYPEOFDIRT is Medium then WASHTIME is OLong;
if DIRTINESS is Medium and TYPEOFDIRT is Medium then WASHTIME is OMedium;
if DIRTINESS is Small and TYPEOFDIRT is Medium then WASHTIME is OMedium;
if DIRTINESS is Large and TYPEOFDIRT is NotGreasy then WASHTIME is OMedium;
if DIRTINESS is Medium and TYPEOFDIRT is NotGreasy then WASHTIME is OShort;
if DIRTINESS is Small and TYPEOFDIRT is NotGreasy then WASHTIME is OVeryShort
![[Graphics:Images/washing_machine_gr_14.gif]](Images/washing_machine_gr_14.gif)
A convenient way to examine a two input one output control strategy is to
look at a control surface. This is a 3D graph in which the inputs form the
base of the graph, and the output is represented by the height of the graph
above each input pair. We have constructed such a surface here.
The ControlTable is essentially the fuzzy logic controller. i and j represent
the two inputs to the controller, the DIRTINESS and TYPEOFDIRT. The tabel's
entries will be a crisp output which is the controller's recommended WASHTIME
in minutes.
![[Graphics:Images/washing_machine_gr_15.gif]](Images/washing_machine_gr_15.gif)
![[Graphics:Images/washing_machine_gr_17.gif]](Images/washing_machine_gr_17.gif)
Figure 3. Input/Outpt Response Surface
![[Graphics:Images/washing_machine_gr_19.gif]](Images/washing_machine_gr_19.gif)
![[Graphics:Images/washing_machine_gr_20.gif]](Images/washing_machine_gr_20.gif)
A more fully automatic washing machine is straightforward to design using
fuzzy logic technology. Moreover, the design process mimics human intuition,
which adds to the ease of development and future maintenance. Although this particular
example controls only the wash time of a washing machine, the design process
can be extended without undue complications to other control variables such as water
level and spin speed. The formulation and implementation of membership
functions and rules is similar to that shown for wash time.
[1] FuzzyNet (URL: http://www.aptronix.com/fuzzynet/applnote/wash.htm), Aptronix Incorporated, email: fuzzynet@aptronix.com
[2] Mathematica,Fuzzy Logic, Introduction and User`s Guide, Wolfram Research
[3] Mathematica,Fuzzy Logic, Printed Version of the Notebooks, Wolfram Research