Tikrit Journal of Engineering SciencesVol.19No.2June 2012, ( 71-81) [601280]

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
Real Time Implementation of PID and Fuzzy PD Controllers for DC –
Servo Motor Based on Lab View Environment

Safaa M. Z. Al -Ubaidi Maher M. F. Algreer
Assistant Lecturer Lecturer
Department of Clinical Pharmacy Department of Computer Eng ineering
Mosul University

Abstract
This paper presents an implemen tation of conventional PID (CPID) controller using
Ziegler -Nichols rules and fuzzy PD (FPD) controller for position servo motor control
based on Lab View (Laboratory Virtual Instrument Engi neering Workbench
Environment ) through Data Acquisition (DAQ) Device PCI – 6521 of National
Instrument's and Data Acquisition Accessory Board Model (CB-68LP). CPID controller
is perhaps the most well -known and most widely used in industrial applications.
How ever, it has been known that CPID controller generally don’t work well for non –
linear systems, higher order and time -delayed linear system and particularly complex
and vague system. To overcome t hese difficulties, this paper propose s to use the FPD
control ler for a servo motor system instead of CPID. The parameters of servo motor
used are completely unknown. The FPD structure has two -input single -output and fairly
similar characteristic to its conventional counterpart and provides good performance.
Simple r ules base are used for FPD (nine rules only). Performance evaluation was
carried out via a comparison study for the proposed control scheme and other existing
control scheme, such as CPID controller. The critical point for this experiment on
position syste m is a steady state error and settling time. The performance showing that
the FPD has less settling time and zero steady state error over its CPID. The algorithms
of FPD and CPID controllers are implemented using PID, Fuzzy Logic and simulation
toolkits o f the Lab View environment .
Keywords: Fuzzy Logic Control, Conventional PID Control, Servo Motor System,
Fuzzy PD, Lab View Environment, Ziegler -Nichols Rules.

تطبيق الوقت الحقيقي لزمن العينة PID وأجهزة السيطرة الضبابية PD لمحركات التيار
المستمر مستندة على برامج المحاكاة المختبر ية
الخالصة
في هذا البحث تم تنفيذ وحدة التحكم التقليدية PID ( CPID ) باستخدام قواعد زيلفر – نيكولز ومتحكم FPD
ألجهزة التحكم في المح ركات الموضعية استناداً الى عرض المختبر االفتراضي لآلالت الهندسية وكذلك من خالل
جهاز اكتساب البيانات (DAC) بواسطة االلـة PCI-6521 ونمـوذج لوحـة جمع البيانات المُساعد ( CB-68 LP .)
يعتبر جهاز السيطرة CPID ربما االكثر شهرة واالكثر استخداماً على نطاق واسع فيالتطبيقات الصناعية. ومع
ذلك ، فقد كان معروفاً ان جهاز CPID عموماً ال يعمل بشكل جيد لألنظمة غير الخطية ، وارتفاع الطلب وزمن
التأخير لألنظمة الخطية وخاصة النظام المعقد والغامض. للتغلب على هذه الصعوبات ، تم في هذا البحث اقتراح
استعمال جهاز سيطرة FPD لنظام محر كات servo بدال من CPID . ان خصائص محركات ال servo
المستخدمة هي مجهولة تماما. وان تركيب FPD له ادخالين واخراج واحد وخصائصه مماثلة جدا لنظيره التقليدي 71

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
ويقدم اداءً جيدا. تم استخدام قواعد بسيطة ل FPD (تسع قواعد فقط). واجري تقييم االداء من خالل دراسة مقارنة
لنظام الرقابة المقترح وغيرها من مخطط السيطرة القائمة، مثل وحدة تحكم CPID . ان النقطة الحرجة لهذه التجربة
على نظام الموقع هو خطأ ثابت ويحل وقتيا. من خالل اداء النظام نالحظ بان FPD لديه وقت اقل والخطأ
للحالة المستقرة تساوي صفر بالنسبة ل CPID . وتم تطبيق خوار زميات FPD و اجهزة السيطرة CPID
باستخدامPID , .المنطق الضبابي و برامج المحاكاة المختبرية
الكلمات الدالة: التحكم المنطقي الضبابي ، وحدة التحكم التقليدية PID، نظام محركات التيار ، االجهزة الضبابية
PD ، برامج المحاكاة المختبر ية ، قواعد زيلفر – نيكولز.

Introduction
A special subset of continuous
motors is the servo motor, which in
ty99pical cases combines a continuous
dc motor with feedback loop to ensure
the accurate positioning of the motor [1].
Servo motor are generally controlled by
conventional Propo rtional – Integral –
Derivative (PID) controller [2].
The simplicity in the design and
implementation, the robustness of the
system, and flexibility, make the
conventional PID controller (CPID) as a
most controller used in the industry,
where it estimat ed that, 90% of the
controllers employed in the industry are
PID controller [3]. However, if the
model (transfer function) of the
controlled system (plant) is not
available or is difficult to estimate,
therefore, a complex design steps may
be involved in the controller designing,
as well as the final control target is not
guarantee [3]. For that reason, other
strategies should be employed to control
uncertain system knowledge. One
example, expert systems strategies can
be used, since accurate models are n ot
essential in this type of controller [3].
Nowadays, fuzzy controller is one
successful methods of expert system
and it is widely used in different
application; one example is unknown
system model.
Generally, fuzzy control has number
of advantages, com pare with
conventional controller, such as PID controller, that make it a particularly
attractive choice for number of
applications [4]. Summaries some this
advantages as flow:

1. Fuzzy logic is inherently robust,
where, it can be programmed to fail
safely i f a feedback signal quits or
lost.
2. It is development the user -defined
rules, and it can be modified
change easily to improve system
performance.
3. It can be developed for multi -input –
multi -output system, since it is
operation, depend on rule -based.
However, the system becomes
complicated and more complex if
many inputs and outputs are chosen.
4. Fuzzy controller can be employed
for non -linear systems that would be
difficult or impossible to model
mathematically.
This paper presents the FPD scheme
instead of the conventional PID
controller for a dc servo motor system
through DAQ device PCI – 6521 of
National Instrument's. The control
algorithm of FPD and CPID controllers
were implemented using Lab View
Environment.
Lab View is a graphical program
designed to make interfacing with any
measurement hardware. Lab View
provides assistances which make data
acquisition quite simple [5]. As well as,
Lab View provides functions those are 27

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
designed to extract useful information
from the acquired data to analyze
measurements and processing signals.
Lab View environment can be used for
data visualization, user interface design,
and software connectivity . Thus , Lab
View can create applications which can
be used to collect, analyze and share
data with ease and with hi gher
accuracy. Lab View makes it easier to
connect to I/O and integrate with
software which makes easier to
compare data from a process with the
theoretical models [5].
Conventional PID Controller
The transfer function of a PID
controller is often express ed in the ideal
form [6]:

sTSTK GD
IP PID 11(
………..(1)
Where GPID(s) is the control signal
acting on error signal E(s), K P is the
proportional gain, T I is the integral time
constant, T D is the derivative time
constant, and s is the argument of the
Laplace transform. The control signal
can also be expressed in three terms as :

)(1)( )( ssEKsKsEKsUD I P 
….(2)

Where K I= K P / T I is the integral gain
and K D is the derivative gain. The three –
term functionalities include [6]:
1) The proportional term provides an
overall control action proportional to
the error signal through the all pass
gain factor.
2) The integral term reduces steady –
state errors through low -frequency
compensation.
3) The derivative term improves
transient response through high –
frequency compensation.
Ziegler – Nichols Tuning Methods [7]
Again, the mathematical model of a
controlled is essential to design the
controller and tune the gains. On the
other hand, if the system model cannot
be modeled, systematic and analytical
design methods cannot be used.
Therefore, well known Ziegler -Nichols
tuning methods can be used to find the
optimal gains and design the overall
controllers. The procedure to tune the
PID controller in (1) is pretty easy using
Ziegler approach. Firstly, the derivative
and integral coeff icients are set to zero;
and the proportional gain is increased
from zero to critical gain value (K c)
where the system exhibits sustained
oscillations . Then, based on oscillation
period of oscillation (P c) and critical
gain (K c) value the parameters K P, T I,
TD can be determined according to the
formulas given in Table (1):
Fuzzy Logic Control Design
Fuzzy logic control developed here
as shown in Fig.1.a is a two – input
single – output controller. The two inputs
are derivation from set point error (e)
and ch ange of error (Δe).The error is
defined as:

)( )( )( t t tec r
……………….(3)

Change of error as follows:

)( )( tedtdte
…………………….(4)

Where θ r(t) is the reference input signal,
θc(t) is the output signal.
The tracking error signal (position)
and change of the error signal (velocity)
are converted into information that the
rule based mechanism can easily use to
activate.
The fuzzy controller is composed of the
following three -elements as shown in
Fig.1.b [8]: 73

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
1) Fuzzification: This converts
input data into suitable linguistic values.
The third triangular input and output
member ship functions of the fuzzy
logic control are shown in the Fig. (2).
For the system under study the universe
of discourse for both e(t), Δe(t) and for
output may be normalized from [ -1 , 1],
and the linguistic labels are{ Negative,
Zero , Positive }, and are referred to in
the rules base as {N, Z, P }.
2) Rule base: A decision making
logic which is, simulating a human
decision process, int ers fuzzy control
action from the knowledge of the
control rules and linguistic variable
definitions. For given input and output
linguistic label table (2) shows the
control rules base that used for FPD. The computation of the fuzzy
control action signal composed many
steps. These steps can be all combined
together in what is called control
surface because the system has two
inputs and one output. The shape of this
surface shows how the output value
varies with different combination of the
two inputs value s. Fig (3) shows the
rule surface viewer of the FPD [8].
3) Defuzzification: The input for
defuzzification is the member ship
(certainty) µ(u i) from implied fuzzy
sets resulted from premise rules and
the output is a crisp number. The
most popular method, cen ter of
gravity or center of area is used for
defuzzification [8]:
i in
in
i i i
fU

)()(
11


..…………(5)

Where μ(u j) member ship grad of the
element u j, U ƒ is the fuzzy control
output, n is the number of discrete
values on the universe of discourse.
Derivative of the Fuzzy PD Structure
Derivative controller is an intelligent
part of PID controller, where it c an
predict the changes in the error signal
and it can improve closed -loop stability,
where the phase margin of the system
may be increased by aid of derivative
gain. The basic structure of a PD
controller is can be present as [9]:

) (1
Sn n
d n P nTeeTeK u
……….(6)

As describe in (6), the control action
of derivative part is relative to the
prediction of the error signal. Now, for
Td= 0, the control action is conversional
proportional gain, and when T d is
gradually increased, the system start to damply oscill ations. If T d becomes too
large the system becomes over damped
[9] and it will start to oscillate again.
Input to the FPD controller is the error
and derivative of error [8]:





Sn n
Teene1)(
…..…………(7)

This is a discrete approximation to the
differential quotient using a backward
difference. Other approximations are
possible. The controller output is a
nonlinear function of error and change
of error [9]:

f e n e f Kne KeKf nU ))(* *( )(  
..(8)

Where ƒ is input -output map of fuzzy
controller, using the l inear
approximation K e* e n + K Δe* Δe(n),
then[9]:

f e n e f Kne KeK nU ))(* *()( 
…(9)



 )( * * )( neKKen KK nU
ee
f e f
..(10)
74

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
By comparison, the gain in (4) and (7)
are related the following way:

R f e K KK *
………… ……(11)

d
eeTKK
…………… ..……(12)

The FPD controller may be applied
when the performance of the system is
not enhanced using proportional part
only. Finally, derivative term improves
response; and it can reduce overshoot,
however, it is more sensitive to noise [9];
in addition, fast changes in the system,
such as abrupt change in target signal;
can be leads to derivative kick in
control action. However, number of
method can be apply to overcome this
limitation, for instance output signal can
be used in derivative part instead of the
error [9].

Hardware, Software Setup and
System Description
The experiment part can be divided
into two levels:
Hardware Level Design
The apparatus of the servo control
system shown in Fig (4) consists of an
interna l A/D and D/A conversions
based computer by using NI PCI -6251
DAQ device, which is connected to the
plant (servo motor). The positing was
sensing by using a potentiometer. The
potentiometer and gear box are
embedded into a dc motor. The
parameters of this dc motor are
completely unknown.
The feedback signal will pass to the
A/D converter of a DAQ device, and
into the computer, where will be used to
control the position of the servo motor.
Upon the software design o f control
algorithm in Lab View, The output
signal will sent to the plant (servo
motor) from the computer through D/A
converter of the DAQ device. DAQ Device Specifications
To create a communication
between the process and the computer
National Instruments provides different
input/output cards whic h are further
supported by DAQ assistance. DAQ
assistance is a simulation of data
acquisition device. The DAQ assistance
creates different channels for
measurement and transfer signals from
one form to other so that a computer can
process [5]. In this expe riment the
National Instrument PCI -6251DAQ
device is used.
This device has the following
specifications:
1- 16 Channels Analog Input.
2- 1.25 MS/s Sample Rate.
3- 16 Bits Resolution.
4- (-10V to 10 V) Maximum I/O Voltage
Range.
5- (-100 to 100 mV) Minimum Input
Voltage Ranges.
6- Two Channels Analog Output.
7- (-5V to 5V) Minimum Output
Voltage Ranges.
8- 24 Digital I/O Channels.
9- Two Counter/ Timers.
10- 80 MHz Maximum Source
Frequency.
Positing Sensor Calibration
The sensing signal for feedback
is a potentiometer. The signal was
calibrated to convert the voltage signal
to position. The feedback rang (voltage
input) from -2 V to 2 V and it was
digitized by a DAQ device. 2V
corresponding to 20 degree and -2 V to
340 degree. Regression equation was
deriv ed as follows:

Position=
20420 340*)2 ( feedbackV
…..(13)
Where V feedback is a potentiometer
signal .

75

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
Software Level Design
Lab View Environment was used in
order to develop the system software
and I/O signal process[5]. Lab View
programs are called vi rtual instruments
or VI because their appearance and
operation imitate physical instruments,
such as oscilloscopes and multi meters.
A Lab View VI contains three main
components[5]:
• Front panel.
• Block diagram.
• Icon/connector panel.
The front panel is the user interface
for the VI. Front panel contains the
interactive input and output terminals of
the VI. The block diagram contains
graphical source codes. These codes are
added using the graphical presentation
of functions to control the front panel
objects. Icon/connector panel is used to
use a VI inside the other VI, which is
called a sub VI .The upper right corner
of the front panel and block diagram
displays an icon, which can contain
both texts and images . An icon
identifies a sub VI on the front pa nel of
a VI. To use a VI as a sub VI there is a
need of a connector panel. Connector
panel is a set of terminals that
corresponds to controls and indicators
of that VI [5].
Control experiment to the servo
motor can be achieved by implementing
CPID and FPD using PID, Fuzzy Logic
and simulation toolkits of the Lab View
Environment. The software level of this
experiment consisted of two front panel
VI parts: one for CPID controller as
shown in Fig.5 and other for FPD
controller as shown in Fig.(6).
The user enters desired position of
the servo motor from the front panel
(manual or automatic). And when
executed the program, the sub VI reads
the user specified desired position of the
motor, and apply the control algorithm
(FPD or CPID) also the front panel of the VI display the real current position
of the motor by gauge indicator and
graph the position response. The desired
position may be changes on line. The
graphical presentation of function to
control the front panel objects are
shown in Figs. (7,8) for CP ID and FPD
Controllers respectively.

Experimental Results
Real time comparison between FPD
and CPID controllers are designed and
implemented for dc servo motor based
on Lab View Environment through
Data Acquisition (DAQ) Device PCI –
6521 of National Ins trument's and Data
Acquisition Accessory Board Model
(CB-68LP) .
Initially, the CPID controller is
designed and the PID gains are
optimally tuned using Ziegler Nichols
rules. Again, the parameters of this
motor are completely unknown. For this
reason Zi egler Nichols rules is
employed in this paper. CPID
parameters are founded as follow: K c =
3.5, T I = 0.08, and T D = 0.02. Flowing
that, the FPD gains are tuned several
times till to get the best possible results
for fair comparison with CPID. Where,
FPD controller gains are K e = 1, K Δe =
0.3, Kƒ = 6.
The aims of the controller designed
are: minimum of overshoot and
oscillation, and minimum steady state
error.
Now, to evaluate the robustness of
the system and asses the overall
dynamic behavior of the system for both
type of controller (CPID and FPD); the
reference signal (desired angular
position) has been changing abruptly in
both direction (clockwise and antilock
wise). Initially, the reference signal was
set to 20o and then moved quickly to
180o in clockwise direction; as shows in
Fig. (9, and 11) for both controller
(CPID and FPD). Then, we assumed 76

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
that the controller will change abruptly
again as depicts in Fig. (10, and 12) in
opposite direction (anti clockwise).
Therefore, those results clearly
demonstrated that, both controller s are
robust against change in the system and
they have the ability to track the sudden
changes in the system, in both
directions. However, the overshoot and
the steady state error using FPD are
better than CPID. However, the integral
part that leads to ze ro error is not
included in FPD.
More validation is carried out for
FPD and CPID as presents in FIG. (13,
14, 15, and 16), with different angular
position; and again it demonstrates that,
FPD have a zero steady state error in a
short time, less settling time, and no
overshot while in the CPID, if zooming
the figures we can see that the steady
state error is not equal to zero and it has
a small overshoot.
Finally, the tracking performance for
FPD and CPID controller has been
evaluated as well by varying the desired
angular positions into different location;
as shows a fast tracking can be achieved
with both controllers, however in FPD
is faster and accurate.

Conclusions
In this paper, servo motor system
was controlled the using two control
methods. CPID and FPD controllers; a
FPD and CPID controller were designed
and implemented using Lab View
Environment for automatic position
control system, through DAQ device
PCI- 6521 of National Instrument's . The
FPD structure has two -input single –
output and fairly simi lar characteristic
to its conventional counterpart and
provides good performance. Simple
rules base are used for FPD (nine rules
only) to make the position response
faster. The investigated scheme has
been tested depending on different position by running the servo motor to
forward and backward directions.
According to the results; it could be
concluded that the FPD controller as
compared with the CPID controller, has
no overshoot, zero steady state error and
less settling time.
References
[1] Gordon Mc Comb's and Myke
Predko's, "The Robot Builder's
Bonanza", Mc Graw -Hill, 2006.
[2] Tank K.S., Kim Fung Man, and
Guanrong Chen, " An Optimal
Fuzzy PID Controller ", IEEE
Trans. on Industrial Electronics,
Vol. 48, No.4, pp. 757 -765, August
2001.
[3] M. Santos, J. M. de la Cr uz, S.
Dormido and A.P.de Madrid,
"Between Fuzzy -PID-Conventional
Controller: a Good Choice", IEEE
Conference of the North American
Fuzzy Information Processing
Society -NAFIPS, pp. 123 -127.
Berkeley, 1996.
[4] Devendra P. Garg and Manish
Kumar, "Genetic Algori thm Based
PD Control and Fuzzy
Logic Control of a Two Link
Robot", International Mechanical
Engineering Congress & Exposition
(IMECE'02), ASME, November
2002.
[5] Vivek Sharma, "Development of
Control Lab Interface for Data
Acquisition Using Lab VIEW" ,
Automatic Control, School of
Electrical Engineering, KTH,
Stockholm , Sweden, MSC thesis,
February 2007.
[6] Kiam Heong Ang, Gregory Chong
and Yun Li, "PID Control Syst em
Analysis, Design, and Technology",
IEEE Trans. on Control Systems
Technology, Vol.13, No.4, pp.559 –
576, July 2005. 77

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
[7] Robert P. Copeland and Kuldip S.
Rattan, "A Fuzzy Supervisor for PD
Control of Unknown Systems",
IEEE International Symposium on
Intelligent Control, August 1994.
[8] F. H. Ali and Maher M. F. Algreer,
"Fuzzy PID Control for Positioning
Plants With Uncertain Parameters
Variation", The 2nd IEEE
International Conference on
Information & Communication
Technologies: From Theory to
Application s (ICTTA'06), April
2006.
[9] Jan Jantzen, "Tuning of Fuzzy PID
Controllers", Technical University
report o f Denmark: Dept. of
Automation, www.iau.dtu/jj/pubs.,
September 1998.

Figure (1.a): Closed loop fuzzy PD
Structure Proposed
Figure (3): Rule Surface viewer
of the FPD controller
Figure (1.b): Fuzzy logic control
Figure (2): The input and output
membership function for FPD
controller
78

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)

.

Figure 4: Hardware level block
diagram 79
Figure 5: Front panel of Lab View
(Vi) for CPID controller
Figure 6: Front panel of Lab View
(VI) for FPD controller
Figure 7: Circuit d iagram of Lab
View (sub VI) for CPID Controller
Figure 8: Circuit diagram of
Lab View (sub VI) for FPD
Controller
Number of sampling Position in degree Start 20 Degree
Target 180 Degree
Output Desired
Position
Figure 9: Position response for FPD

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)
Figure 12: Position response for CPID
Figure 13: Position response for FPD
Figure 1 5: Position response for CPID

80
Number of sampling Position in
degree Start 180 Degree
Target 45 Degree
Start 20 Degree
Target 180 Degree
Number of sampling Position in degree
Number of sampling Position in degree Figure 10: Position response for FPD
Figure 11: Position response for CPID
Start 20 Degree
Target 180 Degree Output Desired
Position Start 200 Degree
Target 45 Degree Position in degree Start 200 Degree
Targe t 45 Degree
Figure 14: Position response for CPID Number of sampling
Number of sampling Position in degree

Tikrit Journal of Engineering Sciences/Vol.19/No.2/June 2012, ( 71-81)

Table (1): Ziegler -Nichols tuning rules
Controller KP TI TD
P 0.5 K c ∞ 0
PI 0.45 K c 1/1.2 P c 0
PID 0.6 K c 0.5 P c 0.125 P c

Table (2): Rules base for fuz zy PD
controller
e(t)/Δe(t) N Z P
N N N Z
Z N Z P
P Z P P

Position in degree Position in degree Position in degree Figure 16: Position response for CPID Start 180 Degree
Target 300 Degree Position in degree
Number of sampling Position in degree
Figure 17: Tracking performance for FPD Number of sampling
Position in degree
Figure 18: Tracking performance for
CPID Number of sampling 81

Similar Posts