           ---------------------------------------------------------
           Motor Control: Fuzzy Logic Wins Out Over Classical Method
           ---------------------------------------------------------

The TIL applications engineering staff has developed and implemented a motor
control system to explore the benefits and differences of fuzzy logic versus
classical methods.  Motor control was chosen as an example of a nonlinear
system.
 
Why Fuzzy Logic?
----------------

Nonlinear systems by definition encompass all systems that are not linear.
There are no general mathematical models for solving and analyzing such
systems.  Classical methods for solving nonlinear systems involve formulating
the system as a set of first-order differential equations.  Although there
are no general closed-form methods for solving nonlinear differential
equations, approximate solutions can be obtained by numerically integrating
the differential equations of motion.  In most cases it is very difficult and
sometimes impossible to generate mathematical models for nonlinear systems
using classical methods.

The fuzzy logic method, while not  solving nonlinear differential equations,
can still generate a solution to a  nonlinear system.  The nonlinear system
can be described using fuzzy logic in a clear and simple way that makes its
implementation easier for the user compared to the classical method.

A Fuzzy Motor Controller
------------------------

Fuzzy logic controllers have been used in a wide variety of systems, from video
cameras, plotters, scanners, optical inspection systems, to elevators and
subway trains.  In the case of a motor controller, the fuzzy system must
control motion position, control the motor speed and in some cases control the
motor acceleration.  In the classical method the system is described by
differential equations and an approximate solution is generated to fit limited
requirements.  If for some reason the system characteristics or the
requirements change, the differential equations will not adapt to those
changes and the system behavior will degrade in performance.

In contrast, the system model can be described using fuzzy logic, resulting in
a great improvement of accuracy and almost no effect on the system behavior as
a consequence of system characteristic changes.  The fuzzy logic method creates
a system that is robust and causes the system to adapt itself to physical
changes, i.e. load change, different sizes of step position, etc.  The use of
fuzzy logic reduces development time by an order of magnitude.
 
Motion Control Analysis
-----------------------

In general, motion control can be described by the following categories:
position, velocity and acceleration control.  Motor control can be one of these
categories or a combination.   Step movement, for example, requires either
position control, a combination of position control and velocity control,  or a
combination of all three controls.  Providing a step motion command to the
motor enables the motor to move from first starting position to a second given
position in a very accurate manner.  However, there are step motion phenomena
to be avoided, such as overshoot and undershoot.  Velocity control is another
motion control mode.  This is similar to the  position control mode.  The motor
is supposed to reach a certain velocity and maintain this velocity for a given
period of time.

One way of improving the undesired undershoot and overshoot problem is by
combining the higher order of the desired control mode (example: the desired
mode is the position and the higher order mode is the velocity.) Combining the
position control category with the velocity control category will alleviate the
overshoot and undershoot problem, but the elapsed time for step change from
position A to position B will be longer.  Similar observations can be expected
when velocity control is required and acceleration control mode is combined
with the velocity control mode.

Classical Methods of Motor Control
----------------------------------

The classical method models the motor, which is a nonlinear system, into a
linear system.  This enables the user to define equations that can describe the
system, at least within certain bounds.  Analytical methods for solving
nonlinear systems of equations are the exception rather then the rule.  Even
when solutions can be determined, approximations are often necessary.
Converting the nonlinear system into a linear system within certain boundaries
is the key issue. Values outside of the system description will force the
approximation to be incorrect and will result in undesired motor behavior.

The most well known classical control method is the PID method which involves
the proportional, integral, and derivative elements of the system. The PD
method involves the same elements without the integral element.  The Kalman
filter is another control method used to model nonlinear systems, along with
other types of filtering methods.
  
General Motor Control System
----------------------------

The motor control system presented in Figure 1 [not present in this text-only
version] is an example used to illustrate the principles involved in building
fuzzy control systems.  It is a simplified version of a fuzzy controller motor
designed to be used in a plotter table.  The system is based on three main
parts: 

  o IBM-PC Controller
  o Interface Board
  o Motor Assembly

The motor assembly is composed of two main elements, the motor itself and an
encoder.  The motor assembly receives varying input signals which affect the
motor motion.  The encoder part of the motor assembly senses the motor motion
and sends back pulses that relate to the motor motion.  

The controller is an IBM-PC compatible computer.  It controls the interface
board's hardware, and reads and writes  data via the interface board to the
motor assembly.  The interface board provides the linkage between the
controller and the motor assembly.  It  communicates with the PC via the AT
Bus.   The interface board counts pulses coming from the motor's encoder and
sends back voltage to the motor to control the motion.  

The interface board includes a decoder and a digital to analog convertor (D/A)
for the motor assembly.  It receives the pulses from the encoder motor
assembly, and the pulses are counted by the decoder  and sampled by the
controller.   The samples are made by interrupt  request, generated in a
constant interval period.  The data received from the decoder is analyzed by
the fuzzy controller  and correction data is generated back to the D/A on the
interface board.  The D/A is interfaced with the motor assembly and supplies
the correction voltage to the motor.

System Characterization for Fuzzy Implementation
------------------------------------------------

The first step in modeling motor control using the fuzzy control method is to
determine the input and output variables.  The output variable is the signal
that drives the motor.  We define the name of this variable as:

  o correction value - voltage sent to the motor. 

The input variables are the by-product of the motor's encoder pulses.  We count
the pulses at constant intervals.  Data is received by the end of each sample
which indicates the motor motion.  The encoder readout provides, for example,
the motor position as each sample is taken.  The difference between the current
sample readout and the previous sample readout can indicate the motion
direction.   In order to use the fuzzy control method as a position control we
can use two input variables:

  o position error - the difference in counts between the desired count
    position and the current count readout

  o error rate - the difference between the current position error and the
    previous position error.
 
The second step is to define the input and output membership functions that
describe these variables.  We start by defining three membership functions for
each variable. 

We can define the membership functions for the position error variable as
Negative, Zero and Positive.  This enables the computer to categorize the count
readout it receives from the encoder for each sample to be either Negative (has
not yet reached the desired position), Positive (has passed the desired
position) or Zero (is close to the desired position.)  It could be that more
then one membership function will represent a crisp count value when a sample
is taken.

The third step is to define the rules for the system.   These rules describe
the relationship between the input variables and the output variables. 

An example rule might be: "If position error is Negative and error rate is
Positive, then the correction value is Positive."  In other words, if we are
far from the desired position,  a large signal should be applied to drive the
motor toward the desired position.

The maximum number of rules is the number of membership functions for the
position error input variable times the number of membership functions for the
error rate input variable.  In this case there are three membership functions
for each input, so the maximum number of rules is nine.

The last step is to tune the system. Tuning the system means providing the
optimal shape and location for the membership functions.  This step can be done
by simulation.  

How to Generate a Fuzzy Control System
--------------------------------------

TIL provides tools to generate and implement fuzzy control systems.  The
TILShell provides a graphical way to describe fuzzy logic expert systems and
then compile this description into the output code necessary to implement the
system.  The output code from the TILShell can  be used to define a complete
application or can be integrated into an existing application.    

The TILShell supports compilation modules, such as the Fuzzy-C Development
System (FCDS) and the MicroFPL Development System for embedded microcontrollers
or FC110 DFP based systems.  The FCDS generated the C code for this example.

Evaluation Results
------------------

A classical PID can be tuned to an optimum for a certain boundary of step
position size.  Applying a smaller step position size will result in an
undershoot, while a larger step position size will result in an overshoot.
Undershoot and overshoot will be proportional to the step size.  Using
different types of filters is a compromise solution.  Filters compensate for
the undershoot and overshoot motor response, but significantly affect the motor
response time.
  
The evaluation results (see Graphs 3 and 4) proved the following attributes:

  o The time response of the motor to step position change utilizing the fuzzy
    method was faster than the time response when the PID method was applied.
    The motor achieved the desired position faster when utilizing the fuzzy
    control method.  The delay in response time is directly proportional to the
    size of the position change.

  o Any change in system characteristics when utilizing the PID method results
    in a large degradation of system performance.  The effects of changes in
    system characteristics on a system utilizing the fuzzy method were
    negligible.

  o Applying different loads on the motor with the PID control method results
    in overshoot or undershoot, depending on the load.  The fuzzy method did
    not manifest this behavior when applying different loads.

  o The PID controller yielded a small displacement error, while the fuzzy
    control method achieved a higher level of accuracy.

Summary
-------

Converting a nonlinear system into a linear system within certain boundaries
has been the classical method of modeling nonlinear systems.  Classical methods
of solving nonlinear systems depend on how closely the equations can model the
system behavior and  leads to solutions that are approximations rather than
accurate reflections of system behavior.  These approximations are based on a
given behavior and are correct only within narrow boundaries.

Fuzzy logic, on the other hand, represents the nonlinear control system
heuristically.  The motor control is handled with excellent results over broad
parameters.  Fuzzy technology possesses inherent adaptive features.  The
evaluation results of the fuzzy logic method were superior to the classical
method in every aspect of this application.
--
Copyright (c) Togai InfraLogic, 1992.  All rights reserved.
Permission to freely distribute this document, provided that it remains
complete and intact, is hereby granted.
