Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DC Motor Speed C Bcontrol

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Real-Time Fuzzy Logic Speed Tracking Controller

for a DC Motor Using Arduino Due


H.R. Jayetileke1, W.R. de Mel2

H.U.W. Ratnayake

Dept. of Mechanical Engineering


The Open University of Sri Lanka
Nugegoda, Sri Lanka
hasithajayetileke@hotmail.com1
wrmel@ou.ac.lk2

Dept. of Electrical & Computer Engineering


The Open University of Sri Lanka
Nugegoda, Sri Lanka
udithaw@ou.ac.lk

AbstractDesigning and developing AI controllers on


separately dedicated chips have many advantages. This paper
reviews the development of a real-time fuzzy logic controller for
speed control of a dc motor using Arduino Due board. The
proposed fuzzy logic controller is based on Mamdani approach
and has been tested on the aforementioned high performance
microcontroller board and using MATLAB. During the real-time
operation the dc motor behavior and the fuzzy controllers
response were plotted and the data were stored in MATLAB
without interrupting the fuzzy logic controller. Based on these
observed information, the system settling time and the rise time
reduction were calculated for each input wave patent trajectories
while increasing the wave frequency. It was noted that the system
overshoot is negligible. Utilizing the aforementioned parameters
the Arduino Due board performance was analyzed with the fuzzy
logic speed control approaches of dc motors made by past
researchers as mentioned above. The system response shows a
satisfactory performance for this particular dc motor application
when the input signal (desired output signal) frequency is less
than 2 Hz, but further research is needed when identifying the
optimum performance of the Arduino Due board for different
fuzzy logic algorithms while increasing the desired input signal
frequency.
Keywordsartificial intelligence; fuzzy logic; fuzzy inference
system; fuzzification; defuzzification; linguistic fuzzy values;
controller; arduino due; servo motor; analog to digital converter;
pulse width modulation.

I. INTRODUCTION
Within industrial factory environment and in the field of
automobiles, high-performance advanced dc motor applications
are wildly used because of their reliability and ease of control
due to the decoupled nature of the field and armature magneto
motive forces. To achieve the optimum performance and
efficiency from a dc motor application or a system it needs to
control the speed and the position of the motor shaft accurately
[1-4]. In that case for optimum performance and efficiency of
an industrial redundant dynamic system (a dc motor Controlled
machine), the controller should have the ability to respond
quickly, recover quickly due to sudden load changes and to
robustly perform during the system parameter variations [5].
Traditional motor controllers or classical motor control
methods such as PID (Proportional-Integral-Derivative)

978-1-4799-4598-6/14/$31.00 2014 IEEE

controllers are still widely used due to simple structure, but to


achieve the optimum performance from the aforementioned
controller, it needs to use accurate and precise control
parameters of the system (such as tuned P, I, D values, back
e.m.f. constant, armature and field coil inductance and
impedance etc.) [6]. Through a well-tuned PID controller, the
same system responses could be achieved accurately but the
system performance is highly dependent on the governing
equations and the system mathematical model [6]. According
to classical methods, when modeling non-linear systems,
governing equations are very complicated and require the use
of sophisticated state observers.
By application of artificial intelligent techniques suitable
controllers can be created for most complex non-liner systems
where the mathematical modelling is uncertain. Intelligent
controllers are preferable since the controller for any system
can be developed without a mathematical model and in this
manner, efficiency and reliability of the controller are increased
[6].
In the past decade, fuzzy logic control techniques have been
tested in simulation environment (such as, MATLAB
simulation models) to control non-linear systems or plants in
real-time. However, when evaluating the system performance
based on these test results of the simulation model, it is
impossible to consider all real time disturbances in an actual
system. In that case the actual system performance and the
optimum efficiency will be completely different from the
simulation test results.
Fuzzy Logic Control (FLC) strategy, which is based on
fuzzy set theory and reasoning. During this research the fuzzy
logic controller was tested on a dc servo motor mechanism as
sown in Fig. 1. When designing and developing this fuzzy
logic controller for the aforementioned plant, the mathematical
model (such as the system transfer function in frequency
domain which is used in classical control strategies) was not
taken into account, because AI control strategies are based on
important characteristics of human intelligence.

dc Servo Motor
Mechanism
Host-PC

Function Generator to
generate desired trajectories
DAQ System
dc Motor Driver

Fuzzy Controller

Fig. 2. Block diagram of the overall system

Fig. 1. The experimental hardware setup

Due to non-linearities and time-varying uncertainties in the


plant (shaft r.p.m. of the dc motor), classical control approach
mechanisms must have well-tuned parameters. Therefore in a
Fuzzy Logic controller, well defined fuzzy rules should take
place as mentioned in table II for the optimum performance of
the system. The fuzzy logic controller was implemented on a
high performance Arduino Due 32-bit ARM core
microcontroller board. The system consists of two controllers,
one is the fuzzy logic controller and the other one is the realtime data acquisition system (to communicate with MATLAB)
which was synchronized with each other (the fuzzy logic
controller and the data acquisition system). The main purpose
behind the use of two separate microcontroller boards is to
avoid interrupting the fuzzy logic controller during its
operation in order to not increase the response time of the
controller.
This paper is organized as follows; Section II describes the
overall design, Section III explain the hardware agent of the
system and Sections IV, V and VI are focused on software
agent of the system, the fuzzy logic controller, test results and
conclusion respectively.
II. OVERALL SYSTEM DESIGN
The fuzzy logic controller was implemented with-closed
loop control strategies as shown in Fig. 2. Where x, y, e
and ce are the desired speed or the reference speed, actual
speed, error between the desired and actual speeds and the rate
of changing error of the speeds respectively. The fuzzy logic
controller computes the system error and the changing error,
between the desired and actual speeds for every sampling
instant k, as in (1) and (2),
ek = xk yk

(1)

cek = ek e(k 1)

(2)

A host computer with MATLAB running in real-time is


used to acquire the real-time data (the desired speed, error and
the changing error etc.) via the selected communication
protocol, RS-232 serial with a baud rate of 115200 bits per
second of the DAQ board (Arduino Due micro-controller

board) into the system data base and to plot the desired speed
and the actual speed behavior of the dc motor in real-time as
given in Figures Fig. 8 - Fig. 16. The error correction due to
time varying uncertainties is made by the fuzzy logic
controller. Based on this amount of error correction and the
desired speed the controller drives the dc motor through the
motor driver.
III. HARDWARE AGENT OF THE SYSTEM
The fuzzy logic controller and the DAQ system was
implemented on two separate Arduino Due boards as
mentioned in section I. Table I shows some of the important
specifications of this Arduino Due board and Fig. 3 shows the
Arduino Due board [7].
A. Fuzzy Logic Controller
The fuzzy logic controller is developed on a separate
Arduino Due microcontroller board. To control the dc motor
speed accurately within a minimum steady state error, the most
accurate information such as the desired speed and actual speed
of the dc motor into the fuzzy controller board (Arduino Due)
needs to be fed, and based on these information, the decision of
the fuzzy controller should be accurately generated and fed into
the dc motor driver to drive the servo motor mechanism in an
efficient way.

TABLE I.

SPECIFICATIONS OF ARDUINO DUE BOARD

Microcontroller
Operating Voltage
Input Voltage (recommended)
Input Voltage (limits)
Digital I/O Pins
Analog Input Pins
Analog Outputs Pins
Total DC Output Current on all I/O
lines
DC Current for 3.3V Pin
DC Current for 5V Pin
Flash Memory
SRAM
Clock Speed

AT91SAM3X8E
3.3V
7-12V
6-16V
54 (of which 12 provide
PWM output)
12
2 (DAC)
130 mA
800 mA
800 mA
512 KB all available for
the user applications
96 KB (two banks: 64KB
and 32KB)
84 MHz

Fig. 4. Membership function for error

Fig. 3. Arduino Due 32-bit microcontroller board

In that case to acquire this accurate continuous information


(the analog input signals which were received from the tacogenerator and which is proportional to the actual speed of the
dc motor in the feedback path and the desired speed or the
desired trajectory proportional analog signals) into the Arduino
Due, the ADC (analog to digital converter) registers were
configured into 12-bit resolution mode. In this resolution mode
it has 4095 step values and each step is about 0.8089 mV. This
is the smallest analog value or the variation that the Arduino
Due could acquire in this fuzzy logic controller. In the fuzzy
logic controller this input range (0 to 4095) was mapped into
the range of 0 to 100. For the optimum performance of the
system a variable gain controller was included in the feedback
path.
Another significant factor is providing a most suitable and
accurate PWM (pulse width modulation) value into to the dc
motor driver. As the ADC register the PWM module is also
configured into a 12-bit resolution mode. This PWM value is
mapped into the range of 0 to 100.
When considering the rule base of the fuzzy logic controller
as mentioned in table II, positive values need to produce
negative PWM values to drive the dc motor into the opposite
direction. That means when the fuzzy logic controller generates
a negative PWM value, the modulus of the PWM value will be
take into account in the PWM configuration registry. Based on
these negative and the positive signs of this generated PWM
values, the fuzzy controller will generate another two logic
values (two outputs which is logic 0 and 1 is 0V and 3.3V
respectively) to utilise to drive the dc motor into clockwise
(CW) direction or into counterclockwise (CCW) direction.
During the active mode of the fuzzy logic controller,
desired speed or the set point should be directly fed into
motor driver, and finally the generated PWM value from
fuzzy logic controller should be added or subtracted from
final PWM value as mentioned in (3),

the
the
the
the

Final PWM = (Desired Speed Fuzzy Output)

(3)

IV. IMPLEMENTATION OF THE FUZZY LOGIC CONTROLLER


In this research a fuzzy logic controller was designed and
developed in an Arduino due board and as the software agent
Arduino 1.5.7 open source software and MATLAB 2014a were
used to control the non-linear, rotational speed behavior of the
dc motor.

For this purpose the fuzzy logic controller was


implemented with a fuzzification process, a rule base which is
based on human common sense, the fuzzy inference system
(FIS) and with the defuzzification process. The FIS and
defuzzification process are based on MAX-MIN composition
and the method of Center of Area (CoA) or Center of Gravity
(CoG), respectively.
During the active mode of this fuzzy logic controller, the
performance are highly dependent on the fuzzy rule base.
At each time instance based on the fuzzy inputs (error and
the rate of changing error) which was calculated with respect to
the desired speed and the actual speed of the dc motor,
knowledge and experience in the fuzzy sets, the fuzzy rule base
collects the control rules, which was designed in the rule base.
From the aforementioned numerical inputs (error and the
rate of changing error) and from the rule base during the
fuzzification process, the FIS will produce all the related
linguistic fuzzy values. From these fuzzy values and as the
previous procedure of the FIS, linguistic control fuzzy values
will be produced, and through the defuzzification process these
linguistic control fuzzy values will produce the required output
PWM values into the motor driver through the Arduino due
board at each time instant.
A. Input/Output Membership Functions for Fuzzy Logic
This fuzzy logic controller has two inputs and one output.
Error (error), rate of changing error (c_error) and the PWM
duty cycle (pwmout) are the inputs and the output of the fuzzy
controller, respectively. The error and c_error which have
set to zero when there is no difference between the desired
speed and actual speed of the dc motor. The maximum and the
minimum amounts of these inputs and output are limited to 100
and 100, respectively. To develop this fuzzy logic controller
as the inputs and output membership functions, triangular
membership functions was utilized.
Fig. 4 shows the triangular membership functions for
the error with all the fuzzy sets.
Fig. 5 shows the triangular membership functions for
the c_error with all the fuzzy sets.
Fig. 6 shows the triangular membership functions for
the pwmout or the speed with all the fuzzy sets.

Fig. 5. Membership function for c_error


Fig. 7. Surface viewer of the fuzzy logic controller

aforementioned fuzzy rules. For each fuzzy rule and for each
related input (error and the changing error) the FIE produce or
generate outputs and these multiple outputs are converted into a
crisp output by the defuzzification process which was used as
the PWM value in the Arduino Due board to drive the dc motor
through the dc motor driver for every sampling instant k.

Fig. 6. Membership function for speed

B. Rule base for Fuzzy Logic


In a real-time fuzzy logic controller, the knowledge about
the control process or the system behavior could be formed into
a number of fuzzy rules as shown in table II. As mentioned in
section V this fuzzy logic controller contains two inputs and
with one output. For this each fuzzy inputs and output, the
linguistic variables are defined as negative big (NB), negative
medium (NM), negative small (NS), zero (ZE), positive small
(PS), positive medium (PM) and positive big (PB).
All the aforementioned linguistic variables are fuzzy, and
by utilizing these fuzzy values through the procedure as
mentioned in section V, all the related linguistic control fuzzy
values are obtained. Finally through the defuzzification
process, the control value (the PWM output value) applied to
the dc motor driver are precise (crisp).

Fig. 7 shows the surface viewer of the fuzzy logic


controller.

C. Defuzzification of Fuzzy Logic


The fuzzy inference engine (FIE) or the FIS make decisions
or produce outputs during the real-time operation based on the
TABLE II.

RULES OF THE FUZZY LOGIC CONTROLLER

ce
e

NB

NM

NS

ZE

PS

PM

PB

NB
NM
NS
ZE
PS
PM
PB

PB
PB
PB
PM
PM
PS
ZE

PB
PM
PM
PS
PS
PS
NS

PB
PM
PS
ZE
ZE
NS
NS

PS
PS
ZE
ZE
ZE
NS
NM

PS
PS
ZE
ZE
NS
NS
NB

PS
ZE
NS
NS
NS
NS
NB

ZE
NS
NS
NS
NM
NM
NB

In this defuzzification method, the controller first calculates


the area under the related membership functions and within the
range of the output variable. When f(x)-denotes each
membership function, x-denote the value of the linguistic
variable, xmin and xmax represent the minimum and the
maximum ranges of linguistic variables, and then CoA
calculates as in (4).
X max

CoA =

f ( x) xdx

X min
X max

(4)

f ( x)dx

X min

V. EXPERIMENTAL TEST RESULTS


The fuzzy logic controllers response and the algorithm
which was implemented on the Arduino Due, was verified by a
real-time experimental setup as shown in Fig. 1.
Fuzzy logic controller is used to produce a crisp or precise
effective controlled output PWM signal into the dc servo motor
mechanism [8].
To analyse the performance of the controller in real-time
various kind of trajectories, were used, a step, sinusoid, ramp
and a square wave. The dc motor speed responses are obtained
and compared with respect to the reference trajectories with
and without the fuzzy logic controller as shown in figures Fig.
8 - Fig. 16.
Fig. 8 shows the system response for a step wave
without the fuzzy logic controller
Fig. 9 shows the system response for a sinusoid wave
without the fuzzy logic controller under load variations.
Fig. 10 shows the system response for a ramp wave
without the fuzzy logic controller under load variations.

A. System responses without the fuzzy logic controller


Actual Output Signal

Desired Output Signal


Desired Output Signal

Actual Output Signal

Fig. 12. With the fuzzy controller for a step wave


Fig. 8. Without the fuzzy controller for a step wave

Desired Output Signal


Desired Output Signal

Actual Output Signal

Actual Output Signal


Fig. 13. With the fuzzy controller for a sinusoid wave
Fig. 9. Without the fuzzy controller for a sinusoid wave

Actual Output Signal

Desired Output Signal

Actual Output Signal

Desired Output Signal

Fig. 14. With the fuzzy controller for a ramp wave


Fig. 10. Without the fuzzy controller for a ramp wave

Desired Output Signal

Actual Output Signal

Desired Output Signal


Actual Output Signal
Fig. 15. With the fuzzy controller for a square wave
Fig. 11. Without the fuzzy controller for a square wave

Fig. 11 shows the system response for a square wave


without the fuzzy logic controller under load variations.
B. System responses with the fuzzy logic controller
Fig. 12 shows the system response for a step wave with
the fuzzy logic controller.

Fig. 13 shows the system response for a sinusoid wave


with the fuzzy logic controller.
Fig. 14 shows the system response for a ramp wave
with the fuzzy logic controller.
Fig. 15 shows the system response for a square wave
with the fuzzy logic controller.

Desired Output Signal

Actual Output Signal

Fig. 16. With the fuzzy controller for a sudden overshoot

Fig. 16 shows the system response for a sudden


overshoot wave with the fuzzy logic controller.
Table III shows the tabulated test results settling time (Ts)
and rise time (Tr) when the system response for a sinusoidal,
square and for a step wave when the input signal frequency is
less than 2 Hz. As shown in figures (Fig. 12 - Fig. 16) the
system overshoot (OS) is negligible. All the aforementioned
parameters ware calculated considering the positive portion of
each waveform and the time was measured in seconds.
VI. CONCLUSION

ACKNOWLEDGMENT
This work is supported by The Open University of Sri
Lanka and we thank O. A. P. C. Oruthota for providing motor
drive unit.
RESULTS OF THE FUZZY LOGIC CONTROLLER

Input Signal Wave


patent (<< 2 Hz)
Sinusoidal Wave
Square Wave
Step Wave

Without Fuzzy
Controller

REFERENCES
[1]

[2]

[3]
[4]

In this research, a fuzzy logic control strategy has been


tested for a dc servo motor mechanism. Because of this fuzzy
control strategy and the use of Arduino Due 32-bit
microcontroller board, the experiment was not limited only for
a computer simulation but also for obtaining the system
responses through a real-time experimental setup. Performance
of the Arduino Due board has been tested utilizing five
different types of reference trajectories, (step, sinusoid, square,
ramp and sudden overshoot signals). To analyze the system
performance a square wave reference trajectory was utilized
and with the fuzzy logic controller the settling time has been
reduced by 25 times and the rise time has been reduced by 12
times when the reference trajectory frequency is less than 2 Hz.
But further research is needed, such as the system response for
neuro-fuzzy algorithms or fuzzy-genetic algorithms with more
information. For very higher frequency, set point trajectories
could be utilized and tested for efficient driving of dc motor
applications.

TABLE III.

Fig. 17. Linguistic variable values in fuzzification

With the Fuzzy


Controller

Ts

Tr

Ts

Tr

0.40
0.25
1.75

0.025
0.125
0.500

0.010
0.010
0.125

0.02
0.01
0.01

[5]

[6]

[7]
[8]

K. Premkumar, B.V. Manikandan, Adaptive Fuzzy Logic Speed


Controller for Brushless DC motor, IEEE International Conference on
Power, Energy and Control, 2013, pp. 290.
M.A. Rahman, P. Zhow, Analysis of brushless permanent magnet
synchronous motors, IEEE Transactions on Industrial Electronics, vol.
43, 1996, pp. 256-267.
I. Boldea, S.A. Nasar, Vector Control of AC Drivers, CRC Pres, New
York, 1992.
M. Gokbulut, Adaptive control of brushless DC motors using neural
networks, Erciyes University Kayseri, 1998.
B.S.K.K. Ibrahim, N.A.M. Azubir, N.H.M. Ishak, M.K. Hassan, S.F.
Toha, M.A.Z. Abidin, H.F. Ismail and H. Zamzuri, PI-Fuzzy Logic
Control for 3 Phase BLDC Motor for Electric Vehicle Application
IEEE UKSim-AMSS 6th European modelling Symposium, 2012, pp.
84-85.
H. Aloui, A. Ben Jridi, N. Chaker and R. Neji, Fuzzy Control for Speed
Tracking of an Electrical Vehicle enclosing an Axial-Flux Synchronous
Motor, IEEE 14th International Conference on Sciences and
Techniques of Automatic Control & Computer Engineering, 2013, pp.
36-42.
www.http://arduino.cc/en/Main/ArduinoBoardDue
J.R. Timothy, Fuzzy Logic with Engineering Applications, 3 ed, A John
Wiley and Sons, Ltd., 2010, pp. 95-110.

You might also like