Anda di halaman 1dari 8

Implementation of Fuzzy Controller for DC-Servo Drive Using a

Low-cost Microcontroller

Sinan Pravadalioglu Eyüp Akpinar


Dokuz Eylül University Dokuz Eylül University
I.M.Y.O., Control Sys. Dept. Dept.of Electrical and Electronics
Menderes cad, Istasyon sok 5 Engineering, Kaynaklar Kampusü,
Buca, 35170 Izmir, Turkey Buca, 35160 Izmir, Turkey
e-mail: pravadalioglu@deu.edu.tr e-mail:eyup.akpinar@deu.edu.tr

Keywords
Fuzzy logic, Servo drives

Abstract
New fuzzy microcontroller chips are available on the market and able to execute fuzzy rules very fast
with their mask programmed algorithms which has some drawbacks such as restricting to choose
desired algorithms. Most of the DSP integrated circuits (IC) do not contain some peripherals such as
Analog to Digital (A/D) converter and Pulse Width Modulation (PWM) circuits on chip and need to be
added externally. This paper introduces a fuzzy logic controller (FLC) for a permanent magnet dc
motor drive using a low-cost microcontroller. The presented FLC application calculates the duty cycle
of the PWM chopper drive, has a good performance and can be used to dc-dc converters as well. The
Matlab simulation and experimental test results are given . The contribution of this paper is to present
the feasibility of a high performance nonlinear controller which can be inexpensively implemented
with a low cost microcontroller.

1. Introduction
The fuzzy controller has a wide spread application on the non-linear and complex systems as well as
linear systems due to its capability to control the systems might not have a transfer function between
input and output variables. Various FLC applications for dc-dc converters and electrical drives have
been published and can be found in the literature [1-5]. In the mean time, new fuzzy microcontroller
chips are available on the market and able to execute fuzzy rules very fast with their mask
programmed algorithms which has some drawbacks such as restricting to implement any desired
algorithm. Digital signal processing (DSP) integrated circuits are capable to compute and process the
system variables very quickly within high precision. But most of the DSP integrated circuits are
expensive and do not contain peripherals such as A/D and D/A circuits for conversion and PWM
generator on chip and need to be added externally.
A fuzzy controller application among the others on dc-dc converters used a DSP TMS320C50 and
fuzzy controller with an evaluation module in addition to some external chips which were an A/D
converter for feedback signal evaluation, a Digital to Analog (D/A) converter for converting the
calculated quantity into a control output and PWM chip to generate the appropriate duty cycle for the
semi-conductor switching elements [3-4]. An implementation of a FLC with 8-bit conventional
microcontroller is presented in [5] for dc to dc converters and a modified centroid method for
defuzzification process is used to to reduce the processing time of 8-bit microcontroller. However, this
modified defuzzification technique increases the settling time of the system. A detailed simulation and
experimental study on the closed-loop control of dc motor drive with FLC is carried out in [6] and a
PC computer with an evaluation board is employed for FLC. The transient response of proportional
integral (PI) type current and speed controllers is compared to that of the FLC.
The aim of study presented in this paper is to implement a FLC in a cost effective way in order to
control the rotor speed of permanent magnet dc motor, using a low cost microcontroller which has an
A/D converter and PWM generator on chip. This microcontroller is used without making the
assumptions for the modification of defuzzification process. The experimental results are also
compared to the simulation result obtained from Matlab.

2. Permanent Magnet DC Motor and Class C Chopper


A permanent magnet dc motor (PMDCM) fed via class C chopper can be described by the state-space
form in the continuous time as follows,

d ia (t )   − Ra / La − K aϕ / La  ia (t )  1 / La 0  Va (t ) 


dt  w(t ) =  K ϕ / J ⋅ +
− Bv / J   w(t )   0

− 1 / J  TL (t ) 
   a (1)

where R a is armature resistance (Ohm), La is armature inductance (Henry), K a ϕ is back


electromotive force and torque constant (Volt/rd/sec or Nt-m/Ampere), J is total moment of inertia
(kg-m2) and Bv is viscous friction constant (Nt-m/rd/sec). Va (t ) represents the voltage applied to
armature by a class C type of chopper given in Figure 1. The average value of armature voltage is a
function of t on , period of chopping and the level of dc input voltage as being shown in Figure 2.

The sawtooth waveform is compared with the control signal to generate the PWM gate signals to the
MOSFETs employed in the chopper. The duty cycle is equal to the ratio between control signal and
the peak of sawtooth waveform.

Figure 1. DC Motor and Class C Chopper


Figure 2. Voltage waveforms of class C type of chopper

3. Fuzzy Controller
The speed feedback and fuzzy control algorithm block diagram are given in figure 3. The tacho-
generator that measures the actual rotor speed supplies input to the A/D converter at the beginning of
every kth switching cycle and the reference rotor speed wref is compared with the actual rotor speed
wact . The error ( e(k ) ) and change of error ( ce(k ) ) values of rotor speed are fed to fuzzy control
algorithm that computes the change of duty cycle.
e(k ) = wref − wact (2)

ce(k ) = e(k ) − e(k − 1) (3)


The fuzzy control algorithm is divided into three modules: 1) Fuzzification, 2) Decision making or
inference 3) Defuzzification. In fuzzification module, fuzzy inputs are evaluated by fuzzy singletons
and their numerical values are converted to linguistic variables. The fuzzification module classifies the
inputs into seven linguistic subsets: PB (Positive Big), PM (Positive Medium), PS (Positive Small),
ZE (Zero), NB (Negative Big), NM (Negative Medium) and NB (Negative Small). The fuzzification
module calculates the degree of membership of every linguistic variable for a given real values of
error and change of error. The triangular shapes as given in Figure 4 are used for smooth operation on
membership functions.

Figure.3. The block diagram of drive circuit


Figure 4. Membership functions for error and change of error

The calculated values of fuzzy variables are used in the decision making process. There are seven sets
for the error and seven sets for the change of error, and thus total 49 rules take place for the whole
control surface which are given in Table I. Decision making is inferring from control rules and
linguistic variable definitions.

Table I. Control Rules

ce
e
NB NM NS Z PS PM PB
NB NB NB NB NB NM NS Z
NM NB NB NB NM NS Z PS
NS NB NB NM NS Z PS PM
Z NB NM NS Z PS PM PB
PS NM NS Z PS PM PB PB
PM NS Z PS PM PB PB PB
PB Z PS PM PB PB PB PB

For each error and change of error, there are two overlapping memberships, therefore, all linguistic
variables except two has zero membership. Two overlapping memberships of error and change of
error will create four combinations as inference results. The maximum of these four inference results
will have two parts, namely, the weighting factor wi and the degree of change of duty cycle y i The
min fuzzy implication rule of Mamdani is used to obtain the weighting factors wi which gives the
membership degree of every relation and y i is obtained from the Rule Table I. The inferred output
u i of each rule is the linguistic result.
u i = wi y i (4)

where,
wi = min{µ e (e), µ ce (ce)} (5)
Figure 5. Membership functions of change of the duty cycle

In defuzzification module a crisp value for output is performed. Although the defuzzification has
many methods, the weighted average method is selected in this application. Because, the operation of
this method is computationally rather simple and takes less time in the computation process of
microcontroller. This method is valid for symmetrical output membership functions given in Figure 5
[7].

∑u
i =1
i
∆d (k ) = 4
(6)
∑w
i =1
i

The inferred output results and the weighting factors from each of four rules are used in the equation
given below to obtain the change of duty cycle. This crisp value is calculated by defuzzification
module. It is obvious that this calculation is the most time consuming part of FLC and has
computational complexity. The fuzzy controller output is the duty cycle and defined as,

d (k ) = d (k − 1) + ∆d (k ) (7)

4. Simulation Results

The simulation of the closed-loop system was performed on a permanent magnet dc motor fed via
class C chopper having the following parameters; Ra = 0.271 ohm, La = 0.41 mH, J =0.00074 kgm2,
Bv =0.0013 Nt-m/rd/sec, K aϕ =0.0527 V/rad/sec. The sampling period of analog to digital converter
T =1 msec, DC input voltage V = 24 and reference speed wref = 188.5 rad/sec. The load torque TL
was defined as a linear function of rotor speed wr having the operating point ( TL = 0.26 Nt.m, wr =
188.5 rad/s). KE1 in the block diagram given in Figure 6 is the gain of tacho-generator, Wref1 and
Wref are the step functions to change the sign of change of error in first sampling. The block of signal
generator supplies 2 kHz sawtooth waveform having the magnitude of one, hence, the control signal
generated by the FLC will be equal to the duty cycle of the gate signals applied to the power switches.
Figure 6. Block diagram of the PMDCM motor drive with FLC in Matlab

Figure 7 shows the variation of actual rotor speed and armature current in time, when the load torque
is increased at the amount of 0.17 Nt.m. at 0.4 sec. The actual rotor speed deviates from the reference
speed and comes back to the reference after transients are damped out. The increase of armature
current is the response to increase of load torque.

Figure 7. Variation of speed ( upper trace ) and armature current ( lower trace )
5. Experimental Results
The hardware set up for the proposed fuzzy logic algorithm was implemented in assembler using 8-bit
RISC core microcontroller AT90S8535. It has 8K bytes of programmable flash memory, 512 bytes
of internal random access memory, 8 channel 10 bit ADC, 10 bit PWM output, 16 different interrupt
sources, an analog comparator, 32 programmable I/O lines, a bi-directional serial interface and has
ability to execute assembler instructions in a single clock cycle. The processing speed is one million
instructions per MHz crystal.
The universe of discourse for error and change of error are extended from –1024 to +1024 and their
memberships values are evaluated from 0 to 1024. The centroids of each membership functions are not
stored in order to determine the locations of inputs, the locations and their memberships are calculated
with using 10 bit mathematical routines. Therefore, processing the on-chip 10 bit A/D converter
sampling values and setting up the on-chip 10 bit PWM output for semiconductor switches are directly
achieved. The total system resolution is extended to 1/1024 instead of 1/256 and better performance is
obtained.
A table is created for defuzzification process and stored as a look-up table containing the mean values
of membership functions of output which are used according to the weighted average method. A final
crisp value for the change of duty cycle is calculated from the equation (6). The calculated change of
the duty cycle is used to determine the new duty cycle by using (8).

d (k ) = d (k − 1) + [512 − ∆d (k )] (8)

This calculated value is used to update the PWM output by an interrupt routine at every one milli-
second (msec). Membership functions of calculated change of the duty cycle for proposed algorithm is
presented in Figure 5. In this implementation, a D/A converter, which might be needed for output
variable, is eliminated by directly controlling the on-off periods of semiconductor switches via the
PWM generator built in the microcontroller. When the motor is started from standstill, the error and
change of error are estimated positive at first sampling of rotor speed since the initial value of them at
standstill are taken to be zero. The trend of change of error from the standstill to steady state of rotor
speed is negative, therefore, by changing the sign of change of error from positive estimated at first
sampling to negative reduces the settling time of the rotor speed.

a.) b.)
Figure 8. Experimental results
a.) speed and armature current versus time
b.) speed and load current versus time
Another identical machine was coupled to the motor via their shafts and operated as generator for
loading. Two different loading conditions were applied on the motor. In the first loading condition, the
generator terminals were closed to the resistive load of 2 ohms and, the rotor speed and armature
current variations in time during this loading case were recorded. These results are given in Figure 8a
(Upper trace: 1 V/div., Lower trace: 0.2 V/div and 100 mV/Amper., Time base: 200 ms/div.). In the
second loading condition, the resistance of 2 ohms was connected to the generator terminals while the
rotor is running at reference speed, after the transients were damped out the resistor was disconnected.
The variations of actual rotor speed and generator output current during this case were recorded and
are given in Figure 8b (Upper trace: 1 V/div., Lower trace: 0.2 V/div. and 100 mV/Amper, Time
base: 500 ms/div.). It can be observed from the waveforms that the fuzzy logic controller responds to
the step change on the load properly and brings the actual rotor speed back to the reference speed.

7. Conclusions
Fuzzy logic controller is implemented by using a low-cost microcontroller for the speed control of a
permanent magnet dc motor. All the tasks are carried out by a single chip reducing the cost of the
system and program code optimization is achieved. Simulation and experimental results are obtained
in order to show the response of the FLC under loading conditions.. The rise and settling times are
reasonably smaller and there is no significant overshoot on the experimental results. The effect of
saturation is not included into the motor and generator models, therefore the simulation results deviate
from the experimental results within a small percentage during loading transients. The weighted
average method for the defuzzification has advantage over the other techniques in the case of limited
memory structure of low cost microcontrollers.

Acknowledgement
Authors would like to thank the Turkish Scientific Research Council supporting research on ASD at
Dept. of Electrical&Electronics Engr. at Dokuz Eylül University under the contract EEEAG-101E004.

References

[1] So W.C., Tse C.K. and Lee Y.S., Development of a fuzzy logic controller for dc-dc converters: Design,
Computer Simulation and Experimental Evaluation. IEEE Trans. on Power Electronics, Vol.11,No.1, Jan.
1996
[2] Mattavelli P., Rossetto L., Spiazzi G. and Tenti P. General Purpose fuzzy controller for dc-dc converters
IEEE Trans. on Power Electronics, Vol.12, No.1, Jan.1997
[3] So W.C., Tse C.K., and Lee Y.S., An experimental fuzzy controller for dc-dc converters. IEEE Power
Electronics Specialist Conf.Rec.1995, pp. 1339-1345
[4] Brandsetter P., Sedlak P., Fuzzy control of electric drive using DSP, PEMC’96 ,Budapest, Hungary, pp.
3/462-3/466
[5] Gupta T., Boudreaux R.R., Nelms R M. and .Hung J Y, Implementation of a Fuzzy Controller for dc-dc
converter using an Inexpensive 8-b Microcontroller. IEEE Trans. on Industrial Electronics, Vol. 44., No.5,
Oct. 1997
[6] Zakharov A., Investigation of DC Servo Drive with Fuzzy Logic Control, Master of Science Thesis,
Technical University of Budapest, Department of Electrical Machines and Drives 1996
[7] Ross T.J., Fuzzy Logic With Engineering Applications, McGraw-Hill, Inc., 1995.

Anda mungkin juga menyukai