FUZZY LOGIC MICROCONTROLLER IMPLEMENTATION
FOR DC MOTOR SPEED CONTROL
Yodyium Tipsuwan Mo-Yuen Chow
IEEE Student Member IEEE Senior Member
[email protected] [email protected] Department of Electrical and Computer Engineering
Box 791 1, North Carolina State University
Raleigh, NC 27695-7911, USA
ABSTRACT: This paper described an alternative method to On the other hands, using an off-the-shelf microncontroller
implement a fizzy logic speed controller for a DC motor to implement a FLC is inexpensive and the physical size of
using a fizzy logic microcontroller. The design, the system is small, but the FLC requires longer processing
implementation, and experimental results on load and no- time. One way to improve the response time in
load conditions are presented. The controller can be microcontroller implementation approach is to use a look-
implemented by using only a small amount of components up table, but this method needs much more memory to
and easily improved to be an adaptivefizzy controller. The store a table.
controller also provides high pe$ormance with compact An alternative method to implement a FLC is using a
size and low cost, fuzzy logic chip. The fuzzy logic chip is first developed in
1985 by Togai and Watanabe [18]. It has been developed
and improved continuously to be a commercial fuzzy logic
I. INTRODUCTION microcontroller by many companies. The main feature of
DC motors used in many applications such as steel this chip is its capability in hardware level to execute fuzzy
rolling mills, electric trains, and robotic manipulators computation. Fuzzy d e s and membership functions are
require speed controllers to perform tasks. Major problems defined and stored in RAM or ROM by specific formats
in applying a conventional control algorithm in a speed that make a designer's job easier. This feature could reduce
controller are the effects of nonlinearity in a DC motor. The developing time and bypass the need of a high speed yet
nonlinear characteristics of a DC motor such as saturation expensive system to develop a FLC. The designer can also
and friction could degrade the performance of conventional utilize other features included in a fuzzy logic
controllers [I-31. Many advanced model-based control microcontroller to reduce the size and to improve the
methods such as variable-structure control [4] and model system performance.
reference adaptive control [5] have been developed to In this paper, a FLC is implemented for DC motor
reduce these effects. However, the performance of these speed control on a fuzzy logic microcontroller. Heuristic
methods depends on the accuracy of system models and knowledge is applied to define fuzzy membership functions
parameters. Generally, an accurate non-linear model of an and rules. The membership functions and rules are
actual DC motor is difficult to find, and parameter values modified after initially borrowing the knowledge from a PI
obtained from system identification may be only controller developed from a simple linear model [ l l , 141.
approximated values. The hardware interface circuit and software algorithm are
Emerging intelligent techniques have been developed described. The results from real-time experiments with load
and extensively used to improve or to replace conventional and no-load conditions are also included in this paper.
control techniques because these techniques do not require
a precise model. One of intelligent techniques, fuzzy logic
developed by Zadeh [6, 71 is applied for controller design 11. SYSTEM DESCRJPTION
in many applications [8, 91. A fuzzy logic controller (FLC)
was proved analytically to be equivalent to a nonlinear PI A simple DC motor linear model is firstly used for the
controller when a nonlinear defuzzification method is used motor controller design as shown in equation (1).
[lo]. Also, the results from the comparisons of
conventional and fuzzy logic control techniques in the form
of a FLC [ l l , 121 and fuzzy compensator [13, 141 showed
fuzzy logic can reduce the effects of nonlinearity in a DC
motor and improve the performance of a controller.
A FLC has been implemented on many platforms such
as digital signal processor (DSP) [15], PC [16], or off-the- where control U is the armature voltage of the dc motor,
shelf microcontroller [171. These platforms have different
advantages and disadvantages. The FLC developed on DSP state variable x = [ia 0IT, where is and CO are the
or PC can quickly process fuzzy computation to generate armature current and shaft rotational speed, respectively,
control efforts, but the physical size of the system may too d is the disturbance on the DC motor system. All motor
big and quite expensive for a small DC motor application.
0-7803-5735-3/99/$10.00 01999 IEEE 1271
parameters in this paper are obtained by standard system initially borrowed as a-priori knowledge in the design
identification as shown in Table 1. process. The performance of the FLC is then improved by
adjusting the rules and membership functions. These design
TABLE 1
procedures are described as follows.
DC MOTOR PARAMETERS
Parameter Procedure 1: Defining inputs, outputs, and universe of
4.67 52
discourse
Armature inductance 17Oe-3 H To apply heuristic knowledge in the FLC, inputs,
Moment of inertia
outputs and universe of discourse are defined first. The
14.7e-3N-mlA inputs are the error (E) between the reference (U,) and
Back-EMF constant 14.7e-3 V-sedrad actual speed (U,), and the change in error (CE). The output
is the change in armature voltage ( C o . The inputs and
An experiment, as shown in Fig 1, is set up to identify output illustrated in Fig 2, are described by:
the characteristic of the motor by measuring the real-time
data of shaft rotational speed and armature voltage by E = e(k) =o,(k) - o a ( k ) (2)
decreasing the armature voltage from the rated voltage to CE = e ( k ) - e(k - 1)
zero. The experimental result shows the actual motor in this (3)
paper has several nonlinear characteristics including cu = u(k) - u(k - 1) (4)
deadzone, friction, and saturation, as shown in Fig 1. The where k is the time index.
lowest armature voltage to overcome deadzone and static
friction for starting the motor is 4.5 V, while at least 4 V
armature voltage can sustain the rotation. The effect of
-
K
saturation obviously happens when the armature voltage is , molar 3
higher than 11.3 V. The method to reduce these effects will rysam
be discussed in section 111.
shan r n l a k d 464(radl.1
Q ,
6 * ,
6 e ,6 0 ,ob %, 6
, 6
,
*Imam- w (v)
Fig 1. DC motor steady-state input-output relationship.
Experimental setup
The armature voltage for driving the motor spans
between -15 V and +15V. When the motor rotates, the
tachometer attached on the motor will generate the velocity
signal in +/- 13.5 V range. The limited maximum and
minimum voltage levels represent the highest angular
velocity at 500 ra&s in different duection.
III. CONTROLLER DESIGN
While conventional controllers depend on the accuracy
of the system model and parameters, FLCs use a different
approach to control the DC motor speed. Instead of using a
system model, the operation of a FLC is based on heuristic
knowledge and linguistic description to perform a task. The
effects from inaccurate parameters and models are reduced
because a Fu3 does not require a system model. However,
building a FLC from the ground-up may not provide good
results or sometime even a worse result than a conventional
controller if there is not enough knowledge of the system.
Therefore, in this paper, the result from a PI controller is
1272
TABLE 2 As observed from the PI control surface, the initial rules
FLJZZYLINGUISTIC TERMS are constructed as showed in Table 3. Because the FLC
uses the knowledge from the PI controller, the performance
obtaining from the FLC is simiIar to the PI controller. The
efficiency can be improved by adjusting the membership
functions and rules in procedure 3.
TABLE 3
INITIAL RULES
trapezoidal because these shapes are easy to represent
designer's ideas and require low computation time. For
performing fine-tuning to improve the efficient of the
controller, the adjacent of each fuzzy set value should
overlap about 25% [19]. The initial membership functions
are illustrated in Fig 3.
A
' NB NM NS Ps PM PB
To send out the armature voltage output, the output in
the form of fuzzy sets must be converted to a crisp value.
6
I
NE NM NS ZE Ps PM PB
This process is called defuzzification. In this paper, the
center of gravity method is chosen. The formula of this
method is
0
m 2SiF
hI
Fig 3. Initial membership functions.
Instead of using mathematical formulas, a FLC uses
fuzzy rules to make a decision and generate the control where z is the output from defuzzification, Si is the specific
effort. The rules are in the form of IF-THEN statements. position at ith fuzzy set, and Fi is the membership degree at
For example, IF the error ( E ) is equal to positive big (PB) the position [lo].
and the change in error (CE) is equal to positive medium Procedure 3: Adjusting fuzzy membership functions
(PM) THEN the change in armature voltage (Ccr) is and rules
negative medium (NM). The matters in defining rules are
how many rules should be used and how to determine the In order to improve the performance of the FLC, the
relation in IF-THEN statements. Actually, the solutions are rules and membership functions are adjusted. The
based on the experience of a designer or the previous membership functions are adjusted by making the area of
knowledge of the system. The critical point is if there is not membership function near ZE region narrower to produce
sufficient knowledge applied in the design, the result could finer control resolution. On the other hands, making the
be drastically bad. Therefore, in this paper, the knowledge area far from ZE region wider gives faster control response.
from a PI controller is borrowed first to help to define rules. Also, the performance can be improved by changing the
The velocity transfer function and PI controller equation seventy of the rules [ll]. After adjusting the membership
are [ll] functions and rules, the final membership functions and
rules are obtained as shown in Fig 4, and Table 4,
respectively.
IV.CONTROLLER IMPLEMENTATION
A. Hardware Aspects
The fuzzy microcontroller, Motorola 68HC812A4 used
where K P= 0.12 and Ki = 0.264 for the implementation is 16-bit microcontroller with full
1273
NM NS ?€ PS PM w
0
4.1
m
I
N B N M NS ZE ps PM w
0
-1.1
Fig 4. Final membership functions.
TABLE 4
FINAL RULES
NM I NB I NB I NB I NB I PS I PM
NB I NB I NB 1 NB 1 NB I PS I PS
16-bit data paths, 8-channel 16 bit timer, 8-channel 8-bit
analog to digital converter (AID), 4K EEPROM, 1K RAM,
and multiple inpuUoutput ports. In this paper, 68HC812A4
runs at an internal clock speed of 8 MHz with an external converted to digital data and computing E and CE. After
16 M H z oscillator. The special feature of 68HC812A4 is the controller executes fuzzy computation, it provides the
the fuzzy logic instruction set which can perform a fuzzy I T L level PWM output signal to adjust the shaft angular
logic task. velocity and direction to the reference speed that can be
The complete controller set is composed of Kevin Ross changed by using the keypad. The reference speed and
68HC812A4 microcontroller board, input condition circuit, speed error are displayed on LCD display, Optxex DMC-
LCD display, and power supply. The block diagram of the 16204. The PWM signal is 3-time amplified by a level
controller, microcontroller board, and the complete setup shifter circuit before sent to the motor driver. The
controller box are shown in Fig 5(a), 5@), and 5(c), schematic diagram of input condition and level shifter are
respectively. shown in Fig 6 and 7 respectively.
-
Fig 6. Input condition circuit.
Fig 5(a). Hardware block diagram.
The input condition circuit is comprised of four stages
The controller receives the actual motor speed input in @-Amp using the +/-15 V reference voltage. The first
voltage form from the tachometer attached on the DC stage, voltage follower presents a high-impedance input to
motor. This input is preprocessed by the input condition the tachometer and low impedance output to the inverting
circuit for adjusting voltage offset and gain before amplifier at the next stage by remain the same voltage from
1274
*
Positive PWM
NeQative PWM
ICL7667
Shifted-positive PWM
Shilterhegative PWM
Fig 7. Level shifter circuit.
the tachometer. The inverting amplifier is used for scaling
the +/-13.5V signal from the first stage to the +/-2.5V
signal. This signal is buffered by the third stage buffer. This
Main
Program
1st timer
interrupt
2nd timer
intempt
buffer works similarly to the first stage buffer, but input is
from the second stage and the output is sent to the fourth
stage. finally, the signal is adjusted to the 0-5V signal that
could be applied for AID unit on the 68HC812A4. In this
circuit, the Burr-Brown OPA132 Op-Amp is chosen for the
first and second stage because of its ability to handle high
voltage. For the third and fourth stage, the Burr-Brown
OPA27 is selected because it provides low noise level and
inherently low offset voltage.
The level shifter shifts the PWM signals at port F of the
microcontroller from the l T L level to the +/- 15V level
that is the motor driver input level. For this propose,
ICL7667 MOSFET driver is selected.
U
B. Software Aspects
A speed control and direction control of the motor is Fig 8. Flowchart of the algorithms running on the FLC.
used in this paper to illustrate the FLC design. In this
implementation, the controller software program is
separated to two parts. The first part is the main program V. EXPERIMENTALRESULTS
running as an infinite loop. This loop contains procedures In this section, an experiment is set up to demonstrate
performing different tasks. To setup the reference speed the performance of the FLC. The controller is tested on
and direction, the program has to monitor the keypad. different velocity tracking performance both load and no-
When the reference speed and direction are assigned via load conditions with a given speed. The motor load is
keypad, the program obtains the current speed from the generated by applying a magnetic load on the rotational
A/D unit and computes E and CE to apply with the fuzzy disk attached on the motor shaft. This procedure is
computation routine. After the defuzzification process, the equivalent to adding fiiction load to the motor. In this
duty cycle of the PWM signal and the direction are Set via paper, the motor is operated at 93 radls. The voltage signal
the interrupt service routines, and then the current speed from the tachometer without load in forward direction is
and error shown on the LCD display are updated. shown in Fig 9(a) and the real-time PWM signal is
The second part is composed of two timer interrupts.
illustrated in Fig 9(b). respectively.
The timers are set to perform as counter. The first timer The results show the FLC could regulate the angular
represents the frequency of the PWM signal and remains
velocity of the DC motor in no-load condition by adapting
constant at 14.5 kHz since initialized. When the timer is the duty cycle of the PWM signal. The results of the DC
expired, the first interrupt service routine is invoked to set motor operated at the same speed under load condition are
the direction of the DC motor and to reload initial value on shown in Fig 9(c) and 9(d). These results shows even the
second timer to set the duty cycle of the PWM signal. The load is applied, the DC motor can be regulated by the
duty cycle and direction of the PWM signal have been controller and still rotates at the same speed with the duty
determined by the fuzzy logic sequence in the main cycle of the PWM signal extended to maintain the required
program. When second timer is expired, the second
speed.
interrupt service routine is called to turn off the PWM
output for starting the next cycle. The flowchart of the VI. CONCLUSION
operation is shown in Fig 8.
To perform these tasks efficiently, the implemented This paper has demonstrated the implementation of a
program on FLC has to operate at high speed to minimize FLC for the velocity control of a DC motor by using a
the response time and the size of the program must be small fuzzy microcontroller. The FLC is easy to implement and
enough to store in on-chip memory. Therefore, the program requires a small amount of inexpensive components in
is coded by using assembly language. The membership compact size. The controller showed good velocity tracking
functions and rules are stored with the programs on ROM, performance under load and no-load condition. The size of
and then the membership functions are transferred to the the FLC can be reduced for a smaller application by
RAM for easy modification in future research. removing some redundant components such as LCD
1275
[8] M. Chow and H. Tram, “Application of fuzzy logic
technology for spatial load forecasting,” LEEE Trans.
Power Syst., vol. 12, no. 3, pp. 1360-1366, 1997.
[9] M. Chow, J. Zhu and H. Tram, “Application of fuzzy
i i
multi-objective decision making in spatial load
forecasting,” IEEE Trans. Power Syst., vol. 13, no. 3, pp.
1185 - 1190, 1998.
[IO] H. Ying, W. Siler, and J. J. Buckley, “Fuzzy control
theory: A nonlinear case,” Automatica, vol. 26, no. 3, pp.
513-520,1990.
[ l l ] M. Chow and A. Menozzi, “On the comparison of
emerging and conventional techniques for DC motor
control,” Proc. IECON, pp. 1008-1013, 1992.
[12] J.-H. Kim, J.-H. Park, S.-W. Lee, and E. K. P. Chong,
“A two-layered fuzzy logic controller for systems with
deadzones,” IEEE Trans. Ind. Electron., vol. 41. no. 2, pp.
155-162,1994.
(C) (d)
1131 J.-H. Kim, K.-C. Kim, and E. K. P. Chong, “Fuzzy
Fig 9. (a) Shifted-positive PWM output without load,
precompensated PID controllers,” LEEE Trans. Contr. S ys.
(b) Tachometer output from (a), (c) Shifted-positive PWM
Tech., vol. 2, no. 4, pp. 406-411, 1994.
output with load, (d) Tachometer output from (b).
[14] J. T. Teeter, M. Chow, and J. J. Brickley Jr., “A novel
display or redesigning the board layout. Because the fuzzy friction compensation approach to improve the
memberships are stored in a small size of RAM, the performance of a DC motor control system,” IEEE Trans.
controller performance could also be easily improved by Ind. Electron., vol. 43, no. 1, pp. 113-120, 1996.
adding the feature of neuro-fuzzy or adaptive fuzzy logic
algorithm. 1151 C.-S. Liu, J.-C. Yang and J.-S. Chen, “A normalized
smoothing control scheme based on fuzzy modeling for the
ACKNOWLEDGMENT control of DC brushless servo drives,“ Proc. AMC ‘96-
MIE, vol. 1, pp. 29-34, 1996.
The authors are grateful to Scott Elliot, Jeff Strang,
Daniel Wang and Kevin Ross for their helps in this project. [16] P. I. Lin and C. Ellsworth, “Design and
implementation of a PC-based universal fuzzy logic
REFERENCES controller system,” Int. Conf. E m s , pp. 399-408,
1995.
[l] B. J. Chalmers, “Influence of saturation in brushless
permanent-magnet motor drives,” LEE Proc. B, Electr. [17] P. Guillemin, “Fuzzy logic applied to motor control,”
Power Appl., vol. 139, no. 1, pp. 51-52, 1992. IEEE Trans. Ind. Applicat., vol. 32, no. 1, pp. 51-56, 1996.
[2] C. T. Johnson and R.D. Lorenz, “Experimental [181 M. Togai and H. Watanabe, “Expert system on a chip:
identification of friction and its compensation in precise, An engine for real-time approximation reasoning,” LEEE
position controlled mechanisms,” IEEE Trans. Ind. Expert Syst. Mag., vol. 1, pp. 55-62, 1986.
Applicat., vol. 28, no. 6, pp. 1392-1398, 1992.
[19] B. Kosko, Neural nemorks and- systems, Prentice
[3] C. Canudas, K. J. Astrom, and K. Braun, “Adaptive Hall, 1991.
friction compensation in DC-motor drives,” IEEE J.
Robot., Automat., vol. RA-3, no. 6, pp. 681-685, 1987.
[4] J. Y. Hung, W.Gao, and J. C. Hung, “Variable structure
control: A survey,” LEEE Trans. Ind. Electron., vol. 40, no.
1. pp. 2-22, 1993.
[SI H. Butler, G . Honderd, and J. V. Amerongen, “Model
reference adaptive control of a direct-drive DC motor,”
IEEEMag. Contr. Sys., vol. 9, no. 1, pp. 80-84, 1989.
[6] L. A. Zadeh, “Fuzzy sets,’’ Informat. Control, vol. 8, pp.
338-353,1965.
[7] L. A. Zadeh, “Outline of a new approach to the analysis
complex systems and decision processes,” IEEE Trans.
Syst. Man Cybem., vol. SMC-3, pp. 28-44, 1973.
1276