You are on page 1of 87

PID Control of DC-Motors

By
Waleed Ahmed Mohammed Hussein Ahmed

(B.Sc.(HONOUR) in Telecommunication,
University of Khartoum 2003)

A thesis submitted to the University of Khartoum as a


partial fulfillment of the requirements for the degree of
M.Sc. in Computer Architecture and Networking

Supervisor:
Professor Sharief Fadul Babikir

Department of Electrical and Electronic Engineering


Faculty of Engineering

March 2014
ABSTRACT

The objective of this project is to design a discrete PID controller for DC-Motors
by using embedded systems techniques. To design a discrete PID controller a
microcontroller "ATMEGA 32A" was used accompanied with an electronic circuit.
The design tries to achieve technical objectives like small settling time value . A
performance evaluation study was done using the "ISIS Professional" simulator
and "MATLAB" for the designed discrete PID controller. The discrete PID-
controller during this study successfully maintained the DC-motor speed at a
constant value on the event of mechanical-load changes . The discrete PID
controller also correctly responded to the speed changes requests. The discrete
PID controller also showed small settling time when controlling medium size
DC-motors and it is anticipated to have smaller settling time when controlling
small size DC-motors.

i
‫اﻟﻤﺴﺘﺨﻠﺺ‬
‫ﻣﻮﺗﻮرات اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ ﻋﺎدة ﻣﺎ ﺗﺴﺘﻌﻤﻞ ﻓﻲ اﻟﺘﻄﺒﯿﻘﺎت اﻟﺘﻲ ﯾﺤﺘﺎج ﻓﯿﮭﺎ ﻟﻠﻤﺤﺎﻓﻈﺔ ﻋﻠﻰ ﺳﺮﻋﺔ اﻟﻤﻮﺗﻮر ﻋﻠﻰ‬
‫ﻗﯿﻤﺔ ﺛﺎﺑﺘﺔ ‪ .‬ﻣﺘﺤﻜﻤﺎت ال‪ PID‬ﺗﺴﺘﻌﻤﻞ ﻓﻲ اﻟﺘﺤﻜﻢ ﻋﻠﻰ ﺳﺮﻋﺔ ﻣﻮﺗﻮرات اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ ﻟﺠﻌﻞ اﻟﺴﺮﻋﺔ ﺗﺴﺘﻘﺮ‬
‫ﻋﻠﻰ ﻗﯿﻤﺔ ﻣﻌﯿﻨﺔ ھﺬه اﻟﻘﯿﻤﺔ ﯾﺨﺘﺎرھﺎ اﻟﻤﺴﺘﺨﺪم‪ .‬ھﻨﺎك ﻋﺪة اﻧﻮاع ﻣﻦ ﻣﺘﺤﻜﻤﺎت ال‪ PID‬ﺗﺴﺘﻌﻤﻞ ﻓﻲ ﻣﺨﺘﻠﻒ‬
‫ﺣﻘﻮل اﻟﺼﻨﺎﻋﺔ‪ .‬ﯾﮭﺪف ھﺬا اﻟﻤﺸﺮوع اﻟﺒﺤﺜﻲ اﻟﻰ ﺗﺼﻤﯿﻢ ﻣﺘﺤﻜﻢ ‪ PID‬ﻣﺘﻘﻄﻊ ﯾﺘﺤﻜﻢ ﻓﻲ ﺳﺮﻋﺔ ﻣﻮﺗﻮرات‬
‫اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ ‪ ,‬ﺗﻢ ﺗﺼﻤﯿﻢ اﻟﻤﺘﺤﻜﻢ ﺑﺎﺳﺘﻌﻤﺎل ﺗﻘﻨﯿﺎت ال " ‪ ." embedded system‬ﺗﻢ ﺗﺼﻤﯿﻢ اﻟﻤﺘﺤﻜﻢ‬
‫ﺑﺎﺳﺘﻌﻤﺎل اﻟ ﻤﺘﺤﻜﻢ اﻟﺪﻗﯿﻖ"‪ "ATMEGA 32A microcontroller‬وﻣﻌﮫ داﺋﺮة اﻟﻜﺘﺮوﻧﯿﺔ ﻣﺼﺎﺣﺒﺔ‪.‬‬
‫اﻟﺘﺼﻤﯿﻢ ﯾﺤﺎول ان ﯾﺤﻘﻖ ﺟﻤﯿﻊ اﻻھﺪاف اﻟﺘﻘﻨﯿﺔ اﻟﻤﺮﻏﻮﺑﺔ ﻣﺜﻞ ﺗﻘﻠﯿﺺ زﻣﻦ اﻻﺳﺘﻘﺮار)‪ (settling time‬ﻻﻗﻞ‬
‫ﺣﺪ ﻣﻤﻜﻦ‪ .‬ﺗﻢ ﻋﻤﻞ دراﺳﺔ ﻟﺘﻘﯿﯿﻢ اﻻداء ﻟﻠﺘﺼﻤﯿﻢ ﺑﺎﺳﺘﻌﻤﺎل ال" ‪ "ISIS Professional simulator‬و‬
‫"‪ "MATLAB‬و ﺗﺤﺎول اﻟﺪراﺳﺔ اﻟﺒﺤﺚ ﻋﻦ اﻟﻤﺸﺎﻛﻞ اﻟﻤﻮﺟﻮدة ﻓﻲ اﻟﺘﺼﻤﯿﻢ و ﻛﯿﻔﯿﺔ ﺣﻠﮭﺎ‪ .‬ﻣﻦ اﻟﺪراﺳﺔ‬
‫ﻣﺘﺤﻜﻢ ال ‪ PID‬اﻟﻤﺼﻤﻢ ﺣﺎﻓﻆ ﻋﻠﻰ ﺳﺮﻋﺔ ﻣﻮﺗﻮرات اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ ﻋﻠﻰ ﻗﯿﻤﺔ ﺛﺎﺑﺘﺔ ﻓﻲ ﺣﺎﻟﺔ ﺗﻐﯿﺮ اﻟﺤﻤﻞ‬
‫اﻟﻤﯿﻜﺎﻧﯿﻜﻲ‪ .‬ﻣﻦ اﻟﺪراﺳﺔ اﯾﻀﺎ ﻣﺘﺤﻜﻢ ال ‪ PID‬اﻟﻤﺼﻤﻢ اﺳﺘﺠﺎب ﻻواﻣﺮ ﺗﻐﯿﺮ اﻟﺴﺮﻋﺔ ﺟﯿﺪا‪ .‬ﻣﻦ اﻟﺪراﺳﺔ‬
‫اﯾﻀﺎ ﻣﺘﺤ ﻜﻢ ال ‪ PID‬اﻟﻤﺼﻤﻢ أظﮭﺮ زﻣﻦ اﺳﺘﻘﺮار ﺑﺴﯿﻂ ﻋﻨﺪﻣﺎ ﯾﺘﺤﻜﻢ ﺑﻤﻮﺗﻮرات اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ اﻟﻤﺘﻮﺳﻄﺔ‬
‫اﻟﺤﺠﻢ وﻣﻦ اﻟﻤﺘﻮﻗﻊ ان ﯾﻈﮭﺮ زﻣﻦ اﺳﺘﻘﺮار اﻗﻞ ﻋﻨﺪﻣﺎ ﯾﺘﺤﻜﻢ ﺑﻤﻮﺗﻮرات اﻟﺘﯿﺎر اﻟﻤﺴﺘﻤﺮ ﺻﻐﯿﺮة اﻟﺤﺠﻢ‪.‬‬

‫‪ii‬‬
ACKNOWLEDGEMENT
First of all I would like to express my intense gratitude and appreciation
to respect-worthy Professor Sharief Fadul Babikir for all his assistances,
supervision , and advices during the course of the project research.
Second I would like also to express my great appreciation to Engineer
Yasir Adam the chief of the electronics laboratory of the university of
khartoum. For his great help in the technical issues.

iii
Dedication

This thesis is dedicated to my Mother and Father and to all who have
supported me during the period of the project research.

iv
Table of Contents
ABSTRACT i
‫اﻟﻤﺴﺘﺨﻠﺺ‬ ii
ACKNOWLEDGEMENT iii
DEDICATION iv
TABLE OF CONTENTS v
LIST OF FIGURES viii
LIST OF TABLES x
ABBREVIATIONS x
CHAPTER 1: INTRODUCTION 1

1.1 Motivation 1

1.2 Problem Statement 1

1.3 Aims and Objectives 2

1.4 Research Methodology 2

1.5 Organization of the Study 2

CHAPTER 2: PID Control Mechanisms 3

2.1 Types OF PID control schemes 3

2.1.1 P- Controller(Proportional Controller) 3

2.1.2 PI-Controller (Proportional Integral Algorithm ) 5


2.1.3 PD-Controller(Proportional Derivative Algorithm) 6

2.1.4 PID-Controller( Proportional Integral Derivative Algorithm) 7

2.2 Topology of PID controllers 8

2.2.1 Parallel PID topology(Non-Interactive) 8

2.2.2 Serial PID Topology(Interactive) 11

2.3 Noise Filtering 11

2.4 Parameter Tuning of PID Controllers 12

2.4.1 Manual tuning 12

v
2.4.2 Ziegler-Nichols Method 12
2.4.2.1 Ziegler-Nichols Open Loop Method 12
2.4.2.2 Ziegler-Nichols Close Loop Method 14

2.4.3 Chien–Hrones–Reswick PID Tuning 15


2.4.4 Cohen–Coon tuning method 16

2.4.5 The Wang–Juang–Chan Tuning Formula 16

CHAPTER 3 : PID Control Of DC Motors 17

3.1 DC-Motor Modeling 19

3.2 Modeling a PID-Controller Controlling a DC-Motor 20

3.3 Examining of the Setting Point Value 21

3.4 Examining of Mechanical-Load Variations 23

3.5 Examining the Change in the Setting Point Value 29

CHAPTER 4: Computer Implementation of PID-Control 32

4.1 Different discrete PID algorithms 33

4.2 The Effect of The Sampling Frequency 34

4.3 The Effect of the Motor Mechanical Load 38

4.4 The Effect of Changing the Setting Point Value 41

4.5 Conclusion 43

CHAPTER 5: Implementation of a Discrete PID Controller for DC-Motors 44

5.1 The Digital to Analogue Converter(DAC ) 45

5.2 The Negative-Buffer 45

5.3 The High Voltage Amplifier 47

vi
5.4 The Microprocessor and The Analogue to Digital Converter(ADC) 48

5.5 The Designed Controller Performance 50

CHAPTER 6: Performance Evaluation and Conclusion 55

6.1 Evaluating the Mean Settling Time 55

6.2 Performance Evaluation and Conclusion 56

6.3 Recommendations for Future Work 57

REFERENCES 58

APPENDIX A MATLAB CODE 1 A-1

APPENDIX B MATLAB CODE 2 B-1

APPENDIX C ATMEGA32A CODE C-1

vii
LIST OF FIGURES
Figure 2.1 P-Mode Scheme. 4

Figure 2.2 PI-Mode Scheme. 5

Figure 2.3 PI-Mode Control system. 6

Figure 2.4 PID-Controller . 8

Figure 2.5 PI-D Form Parallel Topology. 9

Figure 2.6 I-PD Form Parallel Topology. 10

Figure 2.7 Serial (interactive) Topology. 11


Figure 2.8 Step response of Ziegler-Nichols Open loop method. 13

Figure 3.1 Pittman Part Number 6312S001-R1 (DC-Motor 1). 18

Figure 3.2 PMDC Motor Serial-Number TC-04-08-07(DC-Motor2). 18

Figure 3.3 Electrical and Mechanical parts. 19

Figure 3.4 Model of a PID-Controller controlling a DC-Motor. 20

Figure 3.5 PID-Controlling of Motor1 Speed results. 22

Figure 3.6 PID-Controlling of Motor1 Speed results. 22

Figure 3.7 PID-Controlling of Motor2 Speed results. 24

Figure 3.8 PID-Controlling of Motor2 Speed results. 24

Figure 3.9 PID-Controlling of Motor1 Speed results. 26

Figure 3.10 PID-Controlling of Motor1 Speed results. 26

Figure 3.11 PID-Controlling of Motor2 Speed results. 28

Figure 3.12 PID-Controlling of Motor2 Speed results. 28

Figure 3.13 PID-Controlling of Motor1 Speed results. 30

Figure 3.14 PID-Controlling of Motor2 Speed results. 30

Figure 4.1 PID-Controlling Scheme. 33

viii
Figure 4.2 Discrete PID-controlling of DC-Motor2. 35

Figure 4.3 Discrete PID-Controlling of Motor2 Speed results 1. 37

Figure 4.4 Discrete PID-Controlling of Motor2 Speed results 2. 37

Figure 4.5 Discrete PID-Controlling of Motor2 Speed results 3. 38

Figure 4.6 Discrete PID-Controlling of Motor2 Speed results 4. 40

Figure 4.7 Discrete PID-Controlling of Motor2 Speed results 5. 40

Figure 4.8 Discrete PID-Controlling of Motor2 Speed results 6. 42

Figure 4.9 Discrete PID-Controlling of Motor2 Speed results 7. 42

Figure 5.1 Discrete PID controlling of DC-motor2. 44

Figure 5.2 8bit- DAC. 46

Figure 5.3 Negative Buffer. 47

Figure 5.4 High Voltage Amplifier. 48

Figure 5.5 Microcontroller ATMEGA 32A . 49

Figure 5.6 Discrete PID controlling with setting point value of 5 rad/sec. 52

Figure 5.7 Discrete PID controlling with setting point value of 15 rad/sec. 53

Figure 5.8 Discrete PID controlling with setting point value of 22.5 rad/sec . 54

ix
LIST OF TABLES
Table 2.1 Ziegler-Nichols recommendations for Open loop test. 14

Table 2.2 Ziegler-Nichols recommendations for Closed loop method. 14

Table 2.3 CHR tuning formulae for set-point regulation. 15


Table 2.4 CHR tuning formulae for disturbance rejection. 15

Table 2.5 Controller parameters of Cohen–Coon method. 16

Table 6.1 Sample of the settling time. 56

ABBREVIATIONS
ADC Analogue to Digital Converter.

DAC Digital to Analogue Converter.

DC-Motor Direct Current Motor.

FOPMTD First Order Process Model With Transport Delay.

PID proportional- integrative- derivative.

PV Process Variable.

SP Setting Point.

x
Chapter One
Introduction
1. Introduction

Now-a- days , most feedback control systems deploy PID-controllers. PID-controllers are the
most essential elements in early control systems and became the standard tool when process
control commenced in the 1940s. In recent process control, more than 95% of the control
systems are PID type. PID controller is an important component of a distributed control
system. . PID controllers are also combined with logical, and sequential function blocks to build
up sophisticated automation systems . PID control is used at the lowest level of complicated
multivariable controlling systems. Thus PID controllers are said to be the “bread and butter’ of
control engineering. It is an important ingredient in every control engineer’s tool box.

This Research-Project discusses the use of PID-Controllers in stabilizing the speed of DC-
Motors at a selected value. PID controllers for DC-motors were subjected to many changes in
technology, from mechanics and pneumatics , to vacuum tubes, to transistors, and to
microprocessor integrated circuits (Embedded systems). The microprocessor has an intense
influence on the PID controllers for DC-Motors. Practically all the PID controllers for DC-
Motors are based today on microprocessors. This provides additional features to the controller
like automatic tuning, and continuous adaptation.

1.1 Motivation

PID controlling is widely used in DC-Motors systems in stabilizing the angular velocity of
DC-motors at a constant value. This kind of application is widely found in many areas of recent
industry. PID-controlling of DC-Motors is used in drilling machines , where the drilling speed
must be maintained at a specified value during digging through the ground layers. PID-
controlling of DC-Motors is used in packing industry to stabilize the Packing machines to a
constant speed during the packing process. It is also used in Water Pumpers in applications
where it is desired the pumper to work at a constant speed. It is also used in Liquid-
Centrifuges in maintaining the liquid speed to a constant value during the rotation. PID-
controlling of DC-Motors is used also in various applications in the industry and there are
different PID-Controller designs used by manufacturers. Since the importance of this kind of
motor controlling this Research-Project discusses the mechanisms, theorems , and schemes of
PID controlling of DC-Motors.

1.2 Problem Statement

The need of maintaining the angular speed of DC-Motors during operation at a specified
value becomes recently one of the major concerns of Control-Engineers. Since this type of
application is increasingly needed in recent industry. PID-Controllers are one of the techniques
that are used to control the angular speed of DC-Motors. This Research-Project shows how
PID -Controllers are very powerful in stabilizing DC-Motors speed at a specified value.

1.3 Aims and Objectives

There are different types of PID-Controllers. Different PID-Controllers adopt different PID-
algorithms and schemes to implement their functions. Now discrete PID-controllers that use
1
Embedded system techniques are commonly used for controlling DC-Motors. The main aim of
this Research-Project is to design and implement a discrete PID-Controller capable to control
the speed of DC-Motors and to stabilize the speed at a selected value.

The Objectives of this research are:

. To show using MATLAB as a simulating aid that PID-Controllers which use continuous
PID-algorithms are very powerful in stabilizing DC-Motors angular speed at a specified value.

. To also show using MATLAB as a simulating aid that discrete PID-Controllers which use
discrete PID-algorithms are very powerful in stabilizing DC-Motors angular speed at a
specified value.

. To design and implement a discrete PID-Controller capable to stabilize DC-Motors speed


at a selected value. The designed controller is desirable to have a low settling time and
"fluctuation offset" when controlling different DC-Motors types.

1.4 Research Methodology

The research was split to two parts. The first part tries to prove the efficiency of continuous and
discrete PID-Controllers in stabilizing the speed of DC-Motors at a selected value. Continuous
PID-Controllers use continuous PID algorithms, and discrete PID-Controllers use discrete PID
algorithms. The second part of the research tries to design and implement a discrete PID-
Controller capable to stabilize DC-Motors speed at a selected value. A performance
evaluation study was also made for the designed discrete controller to know the problems in
the design and to find the solutions.

1.5 Organization of the Study

In this thesis "Chapter 2 " discusses PID- controlling mechanisms and schemes ,and how to
tune up the PID-controller parameters. In " Chapter 3", modeling and simulating of a PID -
Controller controlling the speed of a DC-Motor using a continuous (not discrete) PID
algorithm. In " Chapter 4", modeling and simulating of a PID -Controller controlling the
speed of a DC-Motor using a discrete PID algorithm. " Chapter 5" introduces a total PID-
controller(for Dc-Motors) design ,the design adopts a discrete PID algorithm to implement the
controller function. " Chapter 6" is a performance evaluation study for the designed
controller . The evaluation considers the results obtained from simulations made.

2
Chapter Two
PID Control Mechanisms
2-PID Control Mechanisms

First starting by mentioning the main features of the PID controllers. The known
“textbook” version of the PID process is described in 2 equations[3],[4]:

( )= ( )− ( ) (2.1)

( )= ( )+ ∫ ( ) + (2.2)

Where PV is the Process variable to be controlled ,SP is the setting point the process must
output, e is the error desirable to be small. u is the PID control signal(used to drive the Process
directly). The control signal is the sum of three terms: the P-term which is proportional to the
error e, the I-term which is proportional to the integral of the error e, and the D-term which is
proportional to the derivative of the error 'e'. The KP ,KI , and Kd are the parameters of the PID
controller system that must be selected carefully to minimize the observed error e. The P-term,
I-term ,and D-term are connected to present , future ,and past respectively .

2.1 Types OF PID control schemes:

There are 4 basic behavior or types of PID controllers found in Industry and Processes :the P
Controller(proportional),PI Controller(proportional integrative),PID Controller(proportional
integrative derivative), and PD(proportional derivative) Controller. Each type has its own
characteristics and applications where it found. The prevalent scheme in industry is PID although
PI is wide found in industry where timing is no longer considered as a main factor.

2.1.1 P- Controller(Proportional Controller):

The relation here between the control signal u (used to drive the Process directly) and the error e
is depicted in Eq.(2.3) and Eq. (2.4) [3],[4] .

( )= ( ) (2.3)

( )= ( ); (2.4)

Fig. (2.1) depicts the P-Control scheme[4]. Where e is the error between the setting point SP
and the Process Output variable(PV). As noted before that this error e is desirable to be
eliminated. But the P-algorithm rather produces an amount of error in the steady state time
known as the' steady state error'[4], This Error drew smaller as the KP the proportional gain
became bigger and bigger.

The disturbance effects to the Process output also desirable to be eliminated by the Control
System .

The P-Controller can be summarized in the following points:

3
1- Simplicity in control design. And simple to tune up(selecting of the Kp gain).
2- Simplicity in Algorithm of implementation when using microcontrollers(Embedded
system).
3- But lack in performance .Since the disturbance effects to the Process output will not be
omitted completely.
4- The controlled system produces Steady state error that can be mitigated by increasing the
proportional gain KP .
5- Large selections of the K P will cause the system to oscillate and become unstable. This
issue doesn't exist if the Process is a first order process.
6- Choosing Kp as large as possible will make the system more responsive and dynamic to
changes in the Process Output. But will produce large over-shoot at the start point.

u-Control signal. PROCESS + PV


SP + Error
∑ KP ∑

- +

Disturbance

Figure 2.1 P-Mode Scheme.

The P-Controller is used in systems that can tolerate constant small steady state error (large
proportional gain KP). Such systems must be first order processes. Example of such system is
Controlling of liquid level in tanks[4].

2.1.2 PI-Controller (Proportional Integral Algorithm):

The relation here between the control signal u and the error e is depicted in Eq. (2.5) and
Eq.(2.6) [3],[4] ( Where u is the control signal to the Process, e is the error . Kp and KI are the
proportional ,and integrative gains. s is the Laplace variable) .

4
( )= ( ) + ∫ ( ) (2.5)

( )
( )= ( )+ (2.6)

Fig.(2.2) depicts the PI-controller system[4]. The Integrative action of the PI-Controller makes a
refinement to the P-Controller, since it eliminates the steady state error. As the coefficient KI
increases the system response increases, the settling time decreases(time from the start until the
error is 0) ,but the overshoot at start point increases[1].

.
+ e +
u + PV
∑ ∑ PROCESS

SP
- +
+
KP

Disturbance

Figure 2.2 PI-Mode Scheme.

The PI-Controller can be summarized in the following points :

1-The integrative action will eliminate also the disturbance effects to the Process output.

2-More complex in control design than P-controller and require complex tuning(selecting of the
Kp and K I gain).

3- Complexity in Algorithm of implementation when using microcontrollers(embedded system).

4-Increasing the KI coefficient makes the system more responsive and hence increasing
performance. Though increasing the KI to high values may cause the system to oscillate and
become unstable.

5
5-The integrative action has a negative effect on the speed of the response .

PI controllers are very often used in industry, especially when speed of the response is not an
important issue.

2.1.3 PD-Controller(Proportional Derivative Algorithm):

The relation here between the control signal u and the error e is depicted in Eq. (2.7) and
Eq.(2.8) [3],[4] ( Where u is the control signal to the Process, e is the error .Kp and Kd are the
proportional ,and derivative gains. s is the Laplace variable. e(0) is the error at the start point ) .

( )= ( ) + (2.7)

( )= ( )+ ∗ ( )− ∗ (0) (2.8)

Fig.(2.3) shows a PD scheme controlling a Process with disturbance[4].

+ + u + PV
e ∑ PROCESS
∑ ∑

- + +
KP

Disturbance
SP

Figure 2.3 PI-Mode Control system.

The derivative action makes the system more responsive to the Process output changes and thus
powerful in mitigation of the Process disturbances . It also decreases the settling time of the
system. Though these advantages for PD-Controllers for adopting derivative ,it resembles the P-
controller in the existence of steady state error and disturbances in the Process output . The PD-
controller doesn't eliminate the disturbances in the Process output, but it rather reduces it
according to the K p , and Kd gains selected. Choosing KP ,and Kd at high values reduces more
the disturbance effects in the Process output.

6
For Thermal processes with large inertia, since dynamics is slow, PD-control is required
for control of such processes. PI- control would slow the dynamics of the system.
PD-controller is often deployed in control of moving objects such as flying and
underwater vehicles, ships, and rockets . The reason is to make the system more responsive to
the speed(Process output variable) changes and to stabilize it.

2.1.4 PID-Controller( Proportional Integral Derivative Algorithm)

The relation here between the control signal u and the error e is depicted in Eq. (2.9) and
Eq.(2.10) [3],[4] ( Where u is the control signal to the Process, e is the error .Kp , KI ,and Kd are
the proportional ,Integrative and derivative gains. s is the Laplace variable. e(0) is the error at
the start point ) .

( )= ( ) + + ∫ ( ) (2.9)

( )
( )= ( )+ ∗ ( ) + − ∗ (0) (2.10)

Fig.(2.4) shows a PID scheme controlling a Process with disturbance[9].

The PID-Controller can be summarized in the following points:

1-The algorithm will eliminate the steady state error and the disturbance in the Process output.

2-More complex in control design than P-controller and PI-controller, and requires complex
tuning(selection of Kp , KI ,and Kd ) .

3- Complexity in Algorithm of implementation when using microcontrollers.

4-Its Performance is the best amongst the others.

5-The derivative action makes the system fast and responsive to changes in the Process
Variable output.

6-Increasing the gains Kp , KI ,and Kd will decrease the settling time(time from start point until
the error become 0). Though increasing these coefficients to high values would cause the
system to oscillate and become unstable.

7- PID controller is used when dealing with high order processes(other than first order
processes).
PID controller is often used in industry, and also used in the control of mobile objects .
Conventional autopilots are PID type controllers[4].

7
Figure 2.4 PID-Controller .

2.2 Topology of PID controllers

Problem of topology (structure) of PID controllers appears when:


Designing the PID-Control system .
Tuning the parameters(coefficients) of the PID-controller.
There are often two topologies used by manufactures for PID Controllers[4]:
1- Parallel topology (non-interactive).
Serial topology(interactive).

2.2.1 Parallel PID topology(Non-Interactive)

Parallel topology[4] is often found in textbooks, so it is called "ideal" or "textbook type". It is


called non-interactive topology since proportional, integral and derivative terms are
independent on each other. Parallel topology is very rare to found in market . That is because of
a historical reason. The first PID-Controllers were pneumatic and it was very hard to construct
a parallel topology deploying pneumatic parts. And because of conservatism in the process of
industry, most of the PID-controller used today are in serial topology. But now days electronic
PID-Controllers often use Parallel structures. In areas where tradition is not strong parallel
topology can be found also.
The first parallel topology found in industry is the "Ideal PID Form". Eq.(2.9) , Eq. (2.10) and
Fig.(2.4) show the components of the "Parallel Ideal PID " structure.
One disadvantage of this ideal Parallel topology is that a sudden change in the setting point
will cause the derivative term to become very large and thus provide the Process with a large

8
Control signal u . This is called “derivative kick” and desirable by manufacturers to be
removed.

An alternative implementation of Parallel PID -controllers is to remove the derivative from the
error signal e and to remain it to the Process Output . This topology is called "PI-D Form
Parallel Topology". Eq.(2.11), Eq.(2.12)[4], and Fig.(2.5)[4] show this method(Where u is the
control signal to the Process, e is the error , and PV is the Process Variable output. Kp , KI ,and
Kd are the proportional ,Integrative and derivative gains. s is the Laplace variable. PV(0) is the
Process Output at the start point.).

( )= ( ) − + ∫ ( ) (2.11)

( )
( )= ( )− ∗ ( ) + + ∗ (0) (2.12)

.
+
+ u
Process PV
∑ +
e ∑

-
-
KP

SP

Figure 2.5 PI-D Form Parallel Topology.

The P-term (Proportional term) in the PID-Form and PI-D Form can cause damage to the
process if the set point signal consists of some discontinuities . If the Process transfer function
have a derivative behavior or composes of a derivative action, the discontinuity will produce a
high value at the process output , that will cause damage to the Process components. It is wise
to remove also the P-term from the error signal e and to remain it to the Process Output. This
Topology is called "I-PD Form Parallel Topology[4]".

( )= ∫ ( ) − ( ) − (2.13)

( )
( )= + ∗ (0)− ( )− ∗ ( ) + (2.14)

9
Eq.(2.13), Eq.(2.14)[4], and Fig.(2.6)[4] show this method(Where u is the control signal to the
Process, e is the error , and PV is the Process Variable output. Kp , KI ,and Kd are the
proportional ,Integrative and derivative gains. s is the Laplace variable. PV(0) is the Process
Output at the start point.).

u
+ e +
∑ . ∑ PROCESS

- - PV
-

KP
SP

Figure 2.6 I-PD Form Parallel Topology.

PI-D parallel form usually used by manufacturers ,though I-PD also used in such application
where Process- protection from setting point (SP) discontinuities is an essential issue.

2.2.2 Serial PID Topology(Interactive).

In this topology the PID Controller comprises of two cascaded transfer functions as shown in
Eq.(2.15), Eq.(2.16) ,Eq.(2.17)[4] and Fig.(2.7)[4].(Where u is the control signal to the Process, e
is the error , and PV is the Process Variable output. Kp , KI ,and Kd are the proportional
,Integrative and derivative gains. s is the Laplace variable . e(0) is the error at the start point.).
From Eq.(2.16) the P-term(proportional) ,I-term(Integrative), and D-term(derivative ) have
relations with each other .That is deemed to the relations between their Coefficients. So this
scheme is said to be "Interactive".

( )= ( + 1) ( ∫. + ) ∗ ( ) (2.15)

( )= + ∫ +( + ) ( ) − (0) (2.16)

( ) ( )
( )=( + ) ( )+ ∗ ( ) + − − (0) (2.17)

10
.
+ + + u PV
∑ e ∑ ∑ PROCESS

- + +

SP

Figure 2.7 Serial (interactive) Topology.

2.3 Noise Filtering

A very important issue in a noisy environment , is the Setting point (SP) input value would be
provided with noise. Usually such noise exhibits high frequency. The pure derivative action for
high frequency noise will produce large signals in the output of the controller to the' Process'.
That will impair the 'Process' Components. Usually in such cases the derivative function would
be designed with a noise filtering transfer function[1],[4] (Low pass filter)as shown in Eq.(2.18) ,
Eq.(2.18) and Eq.(2.19)[1], u is the control signal to the Process, and e is the error . Kp ,and KI
are the proportional , and Integrative gains. s is the Laplace variable .Td is the derivative time.
N is the filter coefficient.)
= (2.18)
( )
( )= ( )+ + ( ) (2.19)
Eq.(2.19) manifests the PID-Controller transfer function in the Laplace domain with adopting
the new derivative function. Typical values of N(filter coefficient) used by manufacturers are 8
to 20.

2.4 Parameter Tuning of PID Controllers

Tuning a PID controller loop is the adjustment of its (proportional gain, integral gain,
derivative gain) to the optimum values so as the desired control response be achieved.
PID tuning is a hard issue, because the tuning must satisfy complex criteria , constraints, and
objectives. There are many methods for tuning , this section describes some methods found in
literature and industry.

11
2.4.1 Manual tuning
This method for setting the parameters of a PID-mode controller manually[9]. First a PID
Controlling loop for the targeted Process is constructed. Then the KI, and Kd values are set to
zero. Then increasing the KP value until the output of the loop oscillates, then the KP value is
set to approximately half of this value . Then increasing KI until the steady state error is
eliminated in sufficient time(the time must be as small as possible). Finally, increasing Kd
until a small settling time(time from the start point until the error e is 0 in the loop) is
observed.

2.4.2 Ziegler-Nichols Method


Ziegler-Nichols tuning method is used for P, PI and PID controllers. This method is used for
disturbance rejection not for tracking the setting point . Thus controllers with parameters
tuned according to this method will perform poor in tracking of reference changes. Ziegler-
Nichols method gives us two ways to tune up the required parameters :
Open loop method .
Closed loop method .

2.4.2.1 Ziegler-Nichols Open Loop Method

Many of the Processes in industry are stable and have a monotonous transfer function with
transport delay. The transfer function of such Processes can be fitted to the First Order
Process Model With Transport Delay(FOPMTD) shown in Eq.(2.20).Where FP is the
transfer function of (FOPMTD),KP is the Process gain, TP is the time constant., and τ is the
transport delay.

= ( . )
+

The open loop method [4],[5] is to apply directly a step signal to the targeted Process input. And
then monitoring the open system response through time. Then fitting the Process to (FOPMTD:
First Order Process Model With Transport Delay). Then obtaining the parameters of the model
shown in Eq.(2.20). A way of obtaining the parameters graphically is shown in Fig.(2.8) . Where
y(t) is the response of the targeted Process when applying a unit step of magnitude A to the
targeted Process input. KP can be obtained from Eq.(2.21). TP ,and τ can be obtained
graphically as in Fig.(2.8) .

( ( ))
= ( . )

12
Figure 2.8 Step response of Ziegler-Nichols Open loop method.

= μ, μ= ( . )

After obtaining KP,TP, and τ, the constant a is obtained by the Eq.(2.22). Defining the P, PI,
and PID parameters as:{K for Proportional term ; for Integrative term ; K*Td for Derivative
term}. The recommended values of the parameters K,TI ,and Td for the Controllers types of
P, PI, PID respectively can be obtained from table 2.1 after computing the constant a , and τ.

2.4.2.2 Ziegler-Nichols Close Loop Method

Here first a P-type Controlling loop for the targeted Process is constructed [4],[5]. Next , the
gain of the P-controller (Ku) is set to a small value. Then increasing the gain Ku of the Closed
loop system until a constant oscillations at the Process output is observed. This gain Ku that
causes the system to oscillate constantly is named the "ultimate gain" and the time of
oscillations is denoted by Tu. Defining the P, PI, and PID parameters as:{K for Proportional
term ; for Integrative term; K*Td for Derivative term}. And considering the values Ku(ultimate
gain) and Tu(time of oscillations at the ultimate gain) the recommended values of the
parameters K,TI, and Td for each controller type (P,PI, and PID) can be obtained from table 2.2.

13
Table 2.1 Ziegler-Nichols recommendations for Open loop test.

Table 2.2 Ziegler-Nichols recommendations for Closed loop method.

2.4.3 Chien–Hrones–Reswick PID Tuning

The Chien-Hrones-Reswick[4],[5](CHR) method concerns the two objectives set-point regulation,


and disturbance rejection. Using the same method of Ziegler-Nichols Open loop method the
values of the parameters of the FOPMTD for the targeted 'Process' can be obtained (FOPMTD:
First Order Process Model With Transport Delay). Define T as the time constant of the
FOPMTD , L as the transport delay of the FOPMTD, and K as the process gain of the FOPMTD
(recall Eq.(2.20)). Defining the P, PI, and PID Parameters as:{KP for Proportional term ; for
Integrative term ; KP*Td for Derivative term}. Considering the values of the FOPMTD "a= ",
T , and L the recommended values of the parameters K P,TI, and Td for each controller
type(P,PI, and PID) can be obtained from table 2.3 and table 2.4.

14
Table 2.3 CHR tuning formulae for set-point regulation.

Controller with o% overshoot with 20% overshoot


type KP TI Td KP TI Td

P 0.3/a 0.7/a

PI 0.35/a 1.2T 0.6/a T

PID 0.6/a T 0.5L 0.95/a 1.4T 0.47L

Table 2.4 CHR tuning formulae for disturbance rejection.

Controller with o% overshoot with 20% overshoot


type KP TI Td KP TI Td
P 0.3/a 0.7/a
PI 0.6/a 4L 0.7/a 2.3L
PID 0.95/a 2.4L 0.42L 1.2/a 2L 0.42L

2.4.4 Cohen–Coon tuning method


Using the same method [4],[5] of Ziegler-Nichols Open loop method the values of the
parameters of the FOPMTD for the targeted 'Process' can be obtained (FOPMTD: First Order
Process Model With Transport Delay). Define T as the time constant of the FOPMTD , L as
the transport delay of the FOPMTD, and K as the process gain of the FOPMTD (recall
Eq.(2.20)). Defining the P, PI, and PID Parameters as:{KP for Proportional term ; for
Integrative term; KP*Td for Derivative term}. Considering the values of the FOPMTD "a= ",
L, and " = " the recommended values of the parameters KP,TI, and Td for each controller
type(P,PI, and PID) can be obtained from table 2.5 .

15
Table 2.5 Controller parameters of Cohen–Coon method.

Controller KP TI Td
type

P .
( + )

. . 3.3 − 3
PI ( + )
− 1 + 1.2
PID .
( +
.
)
2.5 − 2 0.37 − 0.37

1 − 0.39 1 − 0.81

2.4.5 The Wang–Juang–Chan Tuning Formula


The tuning algorithm was proposed by Wang, Juang, and Chan[5] . It is a simple, fast and
powerful method for selecting the PID-mode parameters. Using the same method of Ziegler-
Nichols Open loop method the values of the parameters of the FOPMTD for the targeted
'Process' can be obtained (FOPMTD: First Order Process Model With Transport
Delay).Define T as the time constant of the FOPMTD , L as the transport delay of the
FOPMTD, and K as the process gain of the FOPMTD (recall Eq.(2.20)). Defining the P, PI, and
PID Parameters as:{KP for Proportional term ; for Integrative term; KP*Td for Derivative
term}. Considering the values of the FOPMTD , ,and T the recommended values of the
parameters KP,TI, and Td for PID controllers can be obtained from Eq.(2.23) , Eq.(2.24), and
Eq.(2.25).
( . . )( . )
= (2.23)
( )
= + . (2.24)
.
= (2.25)
.

16
Chapter Three
PID Control of DC-Motors
3-PID Control of DC-Motors

In this section discusses and examine how powerful the PID scheme in controlling the speed of
DC-motors. The PID controller was examined when controlling DC motors in these situations:

1- Fixing the Setting -point and observing the steady state angular velocity of the DC-motor, and
observing the steady state error(error between the selected Setting-point value and the motor
angular velocity), and observing the Settling time( time from the start point until the Motor
rotates with the Setting-point value as angular velocity).

2- Examining the PID-controlling scheme when changing the Mechanical load of the DC-Motor
during the operation of the controlled motor with fixed Setting -point value. Here the steady
state angular velocity, the steady state error , and the Settling time all are observed prior and
after the load variation.

3-Examining the PID-controlling scheme when changing the Setting point value during the
Motor operation with fixed Mechanical load. Here the steady state angular velocity, the steady
state error , and the Settling time all are observed prior and after the Setting-point variation.

The PID algorithm that is used here and controls the DC-motors is continuous through the
time (not discrete as in Chapter 4) . This algorithm is discussed in details in section (2.1.4
Chapter 2).

Since the examinations were done using simulation -aid and practical examination can be
very hard in such situations , first the DC-Motor and the PID-controller must be modeled in the
time and Laplace domains. The examinations were done using MATLAB, since it is very
powerful in simulation of control systems.

The examination were performed to 2 types of DC-motors according to size . Small size and
Medium size DC-Motors. The reason is to monitor the performance of the PID controlling
algorithm in different sizes of DC-Motors. And how the efficiency of the algorithm can be
affected by the size of the motor.

The examinations were done to 2 DC-Motors :

1. Pittman / Series 6000 LO-COG 22mm Brush Commutated DC Motor Part


Number(6312S001-R1 ) 12 volt, 8260 RPM(No load speed) . Denoted in the study by DC-
Motor1. This motor represents small size Motor type (Figure 3.1).

2- PMDC Motor Model TM110 200W ,200 volt ,1.2 Ampere, 2000 RPM(No load speed) serial
Number TC-04-08-07.Diameter 60.5mm. Denoted in the study by DC-Motor2. This motor
represents medium size Motor type(Figure 3.2). {We note this motor resides in the Lab of power
and machinery of University of Khartoum}

17
Figure 3.1 Pittman Part Number 6312S001-R1 (DC-Motor 1).

Figure 3.2 PMDC Motor Serial-Number TC-04-08-07.

DC-Motor2

18
3.1 DC-Motor Modeling

Modeling of DC-Motors for all sizes can be split to 2 parts. Mechanical Part ,and Electrical
Part(Fig(3.3))[7].
( )
( )= ( )+ ( )+ { } (3.1)

( )
= ( )− ( )− ( ) { ℎ } (3.2)

( )= ( )+ ( )+ ( )− (0) { ℎ } (3.3)

( )= ( )− ( )− ( ) { ℎ ℎ } (3.4)

Eq. ( 3.1), Eq. ( 3.2) , Eq. ( 3.3) , and Eq. ( 3.4)[7],[8] show the electrical and mechanical parts in
the time and Laplace domains for any DC-Motor type. Where V is the applied voltage in volt,
W is the motor angular velocity in rad/sec , i is the current flowing in amps , R is the armature
resistance in ohm, L is the Motor inductance in hennery , KE is the Back-EMF constant, KI is
the torque constant, J is the Motor armature inertia (=0.5*mass(in Kg)*r2(radius in meter)), TL is
the applied mechanical load , B is the Viscous friction constant , i(0) is the flowing current
through the armature coils at the start point, and s is the Laplace variable.

Joining Eq. ( 3.3) and Eq. ( 3.4) the overall transfer function of DC-Motors can be obtained.
Eq. ( 3.5) [7],[8] shows the overall Motor transfer function (MO(s)). Eq. ( 3.6) [7],[8] gives the
angular velocity W response in term of the input entities {input voltage response V(s),
Mechanical Load TL(s)}. Eq. ( 3.6) can be derived easily from Eq. ( 3.3), and Eq. ( 3.4). The
term { ( + ) ( )∗ ( )} represents the contribution of the Mechanical load to the
resultant angular velocity W . Whereas the term { (0) ∗ ( ) } represents the transient of
the angular velocity W . . ( )= (3.5)

( )= ( )∗ ( )−( + ) ( )∗ ( )+ (0) ∗ ( ) (3.6)

Figure 3.3 Electrical and Mechanical parts.

19
3.2 Modeling A PID-Controller Controlling a DC-Motor

The PID-Controller and the DC-Motor can be modeled in the Laplace domain using the
theorem of PID controllers in section (2.1.4 Chapter 2), and the Motor model in section (3.1).
Here a continuous PID algorithm through the time is used to control the DC-motors(not
discrete as in Chapter 4) . This algorithm was discussed in details in section (2.1.4 Chapter
2). Using Eq. ( 2.10) , Eq. ( 3.5) and Eq. ( 3.6) the overall controlling system can be modeled
in the Laplace domain. Then the model shown in Fig.(3.4) [5] can be constructed. Where the
parameters of the model were discussed previously. KP ,KI, and K d are the PID-Controller
Proportional, Integrative ,and Derivative gains respectively. MO(s) is the DC-Motor transfer
function mentioned in section (3.1). u is the motor control signal(input voltage). e is the error
signal for the PID-controller(mentioned in Chapter 2). e(0) is the error value at the start point
(mentioned in Chapter 2). SP(s) is the setting point for the controller given in the Laplace
domain. The Mechanical-Load Term(denoted by ML), and the Motor -Transient Term(denoted
by MT) were discussed in section (3.1).The PID-Controller Transient term was mentioned in
section (2.1.4 Chapter 2). W(s) is the response in the Laplace domain of the angular velocity of
the motor.

Mechanical-Load Term' ML(s)'

( + ) ( )∗ ( )

KP

e + -
+ + u-control DC-MOTOR W(s)
∑ ∑ ∑
Transfer Function: MO(S)
+ - + +
-
(0) ∗ ( )
∗ (0)

PID-Controller Transient Term Motor -Transient Term 'MT(s)'.

SP(s)
Figure 3.4 Model of a PID-Controller controlling a DC-Motor

20
If the DC-Motor parameters mentioned in section(3.1) was known and the PID controller gains
was selected , the overall control system can be simulated using the model in Fig.(3.4) and
MATLAB.

The disturbance to this system is a Mechanical load to the DC-motor . So the disturbance is
included to the term TL in Eq. ( 3.6), and Fig.(3.4). So TL stands for the Motor Mechanical
load plus the disturbance.

Going forward and from Fig.(3.4 ) the total response of the angular velocity of the motor W(s)
can be obtained .Deploying the theorem of the Feed Back Control System W(s) is found by
the Eq. ( 3.8)[5] . PID(s) is the transfer function of the PID-Controller as shown in Eq. ( 3.7)[5].

( )= + + (3.7)

( )∗ ( ) ( ) ( ) ( ) ( )∗ ( )
( )= − + − (3.8)
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

Eq. ( 3.8) and Fig.(3.4) are very valuable in simulating the total control system.

3.3 Examining of the Setting Point Value

This section examines a PID-Controller driving DC-Motors with fixed Setting point value .
First consider a PID-Controller controlling the speed of Motor1(small size) in Fig.(3.1). The
PID controller is stabilizing the DC-Motor speed at a fixed value(setting point) . The previous
controlled Motor- system was simulated using MATLAB , the model in Fig.(3.4), and Eq. (
3.8) . Motor 1 parameters used in the simulation were known from the manufacturer. The
measured item that was desired to obtain from the simulation is Motor1 angular Velocity
W(t) versus time. The simulation time was taken from the start point of the control system until
Motor1 angular velocity is stable. The control system was simulated using MATLAB program-
code shown in Appendix( A). Firstly , the simulation was done with PID-controller
parameters{KP= 70, K I=1,K d=1}, and fixed setting point value 380 rad/sec and Motor 1
Mechanical Load equals 40% of the maximum torque. Then Motor1 angular velocity was
monitored versus time and Fig.(3.5) was achieved. From Fig.(3.5) the steady state value of
the velocity is 380 rad/sec with error 0 from the setting point value. The settling time is 133
msec. Secondly the previous simulation was repeated but now fixing the Setting point value at
750rad/sec and Motor1 mechanical load equals 80% of the maximum torque, and using the
same PID parameters Values. Then Fig.(3.6) of Motor 1 Angular velocity versus time was
achieved . From Fig.(3.6) the steady state value of the velocity is 750 rad/sec with error 0 from
the setting point value. The settling time is 149 msec.

It is concluded from the first experiment that the PID-Controllers are very powerful in

21
X: 0.1327
400 Y: 380

350
Motor 1 Velocity rad/sec VS Time Sec,
at SP=380 rad/sec;
300 Load=40% Maximum Torque;
Pr=70;Dif=1;Int=1.
Steady state Velocity 380 rad/sec
Motor 1 Angular Velocity in rad/sec

Settling time 133 msec


250

200

150

100

50

-50
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
Time in sec
Figure 3.5 PID-Controlling of Motor1 Speed results.

X: 0.1494
800
Y: 750

700

600
Motor1 Angular Velocity rad/sec

500

400 Motor 1 Velocity rad/sec VS Time Sec,


at SP=750 rad/sec;
Load=80% Maximum Torque;
300 Pr=70;Dif=1;Int=1.
Steady state Velocity 750 rad/sec
Settling time 149 msec

200

100

-100
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
Time sec.
Figure 3.6 PID-Controlling of Motor1 Speed
22
controlling the speed of small size DC-Motors. The selected Setting Point value was realized
at the Motor Angular velocity at a very small time (settling time). Even though the settling time
can be reduced more by increasing the values of the PID parameters{KP, KI , Kd}(this point
mentioned in section 2.1.4 Chapter 2).

The experiment was repeated but now PID-controlling of Motor(2) that represents medium
size DC-Motors(Fig 3.2). The PID controller is stabilizing the DC-Motor speed at a fixed
value(setting point) . The controlled system was simulated using MATLAB , the model in
Fig.(3.4), and Eq. ( 3.8) . Motor 2 parameters used in the simulation were known from the
manufacturer. The measured item that was desired to obtain from the simulation is also here
the Motor2 angular Velocity W(t) versus time. The simulation time was taken from the start
point of the controlled system until the Motor2 angular velocity is stable. The controlled
system was simulated using MATLAB program-code shown in Appendix(A ). Firstly the
simulation was done with PID-controller parameters{KP= 500, KI=1,Kd=900}, and fixed setting
point value 40.02 rad/sec and Motor Mechanical Load equals 30% of the maximum torque.
Then Motor2 angular velocity was monitored versus time and Fig.(3.7). was achieved . From
Fig.(3.7) the steady state value of the velocity is 40.02 rad/sec with error 0 from the setting
point value. The settling time is 23.3 sec. Secondly the previous simulation was repeated but
now fixing the Setting point value at 150.1 rad/sec and Motor mechanical load equals the
maximum torque, and using the same PID parameters Values. Then Fig.( 3.8) of Motor 2
Angular velocity versus time was achieved . From Fig.( 3.8) the steady state value of the
velocity is 150.1 rad/sec with error 0 from the setting point value. The settling time is 14.87 sec.

It can be observed from the experiment that the PID-algorithm eliminates the error between the
Setting point value and Motor2 angular velocity in a quite small time(less than half minute ).
This time when compared to the high inertia of the motor it appears small. Even more the
settling time can be decreased by increasing the values of the PID parameters{KP, KI , Kd}(this
point is mentioned in section 2.1.4 Chapter 2).

This section demonstrates how powerful the PID algorithm in controlling the speed of DC-
Motors irrespective of their size.

3.4 Examining of Mechanical-Load Variations

This section examines the effect of the variation of the Mechanical load of a DC-Motor
controlled by a PID-Controller , meanwhile the setting point value is fixed during the operation
of the system. Commonly the disturbance to Motor systems is a variable Mechanical- Load to the
Motor. The role of the PID-controller is to stabilize the Motor speed at a fixed value irrespective
to the exerted disturbance . The disturbance will vary the motor speed, if the PID doesn't act
adaptively to the speed. This section manifests how the PID controller can eliminate the
disturbance effects on the Motor speed.

23
45
X: 23.3
Y: 40.01
40

35 Motor 2 Angular Velocity rad/sec Vs Time sec


Sp=40.02 rad/sec;
Load=30% of Maximum Torque;
Motor2 Angular Velocity rad/sec

30 Pr=500;Dif=900;Int=1.
Steady state angular Velocity 40.02 rad/sec
Settling time 23.3 sec.
25

20

15

10

0
0 10 20 30 40 50 60 70 80 90 100
Time sec
Figure 3.7 PID-Controlling of Motor2 Speed
results.

160 X: 14.87
Y: 150.1

140
Motor 2 Angular Velocity rad/sec Vs Time sec
Sp=150.1 rad/sec;
Load=100% of Maximum Torque;
120
Pr=500;Dif=900;Int=1.
Steady state angular Velocity 150.1 rad/sec
Motor 2 Angular Velocity rad/sec

Settling time 14.87 sec.


100

80

60

40

20

0
0 10 20 30 40 50 60 70 80 90 100
Time sec.
Figure 3.8 PID-Controlling of Motor2
Speed results. 24
The examination was done to Motor 1(small size) , and Motor2(medium size) as to monitor
the effects of the size on the control system.

First consider a PID-Controller controlling the speed of Motor1(small size) in Fig.( 3.1). The
PID controller is stabilizing the DC-Motor speed at a fixed value(setting point). The previous
controlled Motor- system was simulated using MATLAB , the model in Fig.(3.4), and Eq. (
3.8 ). Motor 1 parameters used in the simulation were known from the manufacturer. The
measured item that was desired to obtain from the simulation is Motor1 angular Velocity
W(t) versus time. The simulation time was taken from the start point of the controlled system
until the Motor angular velocity is stable after changing the DC-Motor mechanical load. The
controlled system was simulated using MATLAB program-code shown in Appendix(A ).
Firstly , the simulation was done with PID-controller parameters{KP= 700, KI=580,Kd=5}, and
fixed setting point value 800 rad/sec and Motor Mechanical Load changes as in Eq. ( 3.9)
.That comprises of a sudden mechanical load Increase at 7 sec from the start of the operation.

Motor Mechanical Load = 0N. M; 0 ≤ time < 7

= 70 . ; ≥ 7 (3.9)

Then from the simulation Motor1 angular velocity was monitored versus time and Fig.(
3.9) was achieved. From Fig.(3.9) the steady state value of the velocity before and after
the load changing is 800 rad/sec with error 0 from the setting point value. The settling time
is 4.166 sec before the load change, and 7.21 sec after the change. Secondly, the previous
simulation was repeated but now with PID-controller parameters{KP= 700, KI=900,Kd=5}, and
fixing the Setting point value at 800 rad/sec, and Motor mechanical load as in Eq. ( 3.10).
That comprises of a sudden mechanical load decrease at 7 sec from the start of the operation.

Motor Mechanical Load = 50N. M; 0 ≤ time < 7

= −950 . ; ≥ 7 (3.10)

Then Fig.(3.10) of Motor 1 Angular velocity versus time was achieved. From Fig.( 3.10) the
steady state value of the velocity before and after the load changing is 800 rad/sec with
error 0 from the setting point value. The settling time is 4.227 sec before the load changing,
and 6.68 sec after the changing.

From the two simulations the Motor angular velocity will stabilize first at the setting point
value at a small settling time, and then changes its value at the same time the Mechanical-load
changes. The motor speed will increase if the mechanical load decreases and will decrease if
vice -versa. And the motor speed no longer stabilizes again at the setting point value after
changing. The 2nd settling time for the motor after Mechanical-load changing in the 2 cases is
less than 8 sec. It is desirable from design point to minimize this time as we could . That is
achievable by increasing the PID-controller parameters values{KP, KI, Kd}.

25
900
X: 4.166
Y: 800.1
800

700

Velocity rad/sec Vs Time sec.


Motor1 Angular Velocity rad/sec

600 Sudden Load 70 N.M at Setting point Velocity=800 rad /sec,7 sec
Pr=700;Dif=5;Int=580.
Settling time before load 4.166 sec.
500 Settling time after load 7.21 sec.

400

300

200

100

0
0 2 4 6 8 10 12 14 16
Time sec.
Figure 3.9 PID-Controlling of Motor1 Speed
results.

1800

1600

1400
Motor1 Angular Velocity rad/sec

1200

1000
X: 13.68
Y: 800.1
800
Motor 1 Angular velocity VS Time sec
Load at [0,7)sec 50N.M
600 Load at[7,16]sec -950N.M
Setting point 800 rad/sec;
Pr=700;Dif=5;Int=900
400 Settling time before load variation 4.227sec
Settling time after load variation 6.68sec

200

0
0 2 4 6 8 10 12 14 16
Time sec.
Figure 3.10 PID-Controlling of Motor1 Speed
results.
26
The experiment was repeated but now PID-controlling of Motor(2) (medium size) in Fig.(3.2).
The PID controller is stabilizing the DC-Motor speed at a fixed value(setting point). The
previous controlled Motor- system was simulated using MATLAB , the model in Fig.( 3.4),
and Eq. ( 3.8) . Motor 2 parameters used in the simulation was known from the manufacturer.
The measured item that was desired to obtain from the simulation is Motor2 angular Velocity
W(t) versus time. The simulation time was taken from the start point of the controlled system
until the Motor angular velocity is stable after changing the DC-motor mechanical load. The
controlled system was simulated using MATLAB program-code shown in Appendix(A). Firstly
, the simulation was done with PID-controller parameters{KP= 50, KI=20,Kd=2}, and fixed
setting point value 45 rad/sec, and Motor Mechanical Load changes as in Eq. ( 3.11) .That
comprises of a sudden mechanical load Increase at 20 sec from the start of the operation.

Motor Mechanical Load = 0 N. M; 0 ≤ time < 20 sec

= 4.5836 . ; ≥ 20 (3.11)

Then from the simulation Motor2 angular velocity was monitored versus time and
Fig.(3.11) was achieved. From Fig.(3.11) the steady state value of the velocity before and
after the load changing is 45 rad/sec with error 0 from the setting point value. The settling
time is 8.078 sec before the load changing, and 14.47 sec after the changing. Secondly , the
previous simulation was repeated but now with PID-controller parameters{KP= 50,
KI=20,K d=5}, and fixing the Setting point value at 45 rad/sec, and Motor mechanical load as
in Eq. ( 3.12). That comprises of a sudden mechanical load decrease at 20 sec from the start
of the operation.

Motor Mechanical Load = 4.5836 N. M; 0 ≤ time < 20 sec

=0 . ; ≥ 20 (3.12)

Then Fig.(3.12) of Motor 2 Angular velocity versus time was achieved . From Fig.(3.12)
the steady state value of the velocity before and after the load changing is 45 rad/sec with
error 0 from the setting point value. The settling time is 13.24 sec before the load changing,
and 14.18 sec after the changing.

The last two simulations show that the Motor angular velocity will stabilize first at the setting
point value at a small settling time, and then changes its value at the same time the Mechanical-
load changes. The motor speed will increase if the mechanical load decreases and will decrease
if vice -versa. And the motor speed no longer stabilizes again at the setting point value after
changing. The 2nd settling time for the motor after changing in the 2 cases is less than 15 sec. It
is also desirable here from design point to minimize this time as we could . That can be made
by increasing the PID-controller parameters values{KP, KI, Kd}.

27
50
X: 34.47
Y: 44.99

Velocity rad/sec Vs time sec.


40
[0,20) sec 0 N.m Load.
[20,100] sec 4.5836 N.m load
SP=45 rad/sec;
Pr=50;Dif=2;Int=20;
Motor2 Angular Velocity rad/sec

30 Settling time before load variation 8.078sec


Settling time after load variation 14.47sec

20

10

-10
0 10 20 30 40 50 60 70 80 90 100
Time sec.
Figure 3.11 PID-Controlling of Motor2 Speed
results.

50
X: 34.18
Y: 45.01
45

Velocity rad/sec Vs time sec.


40 [0,20) sec 4.5836 N.m Load.
[20,100] sec 0 N.m load
SP=45 rad/sec;
35 Pr=50;Dif=5;Int=20;
Motor2 Angular Velocity rad/sec

Settling time before load variation 13.24 sec


Settling time after load variation 14.18sec
30

25

20

15

10

0
0 10 20 30 40 50 60 70 80 90 100
Time sec
Figure 3.12 PID-Controlling of Motor2 Speed
28
It can be concluded from this examination that the PID-controller stabilizes the speed of DC-
Motors at a the selected Setting point value irrespective to the Mechanical-load applied , and
the size of the machine.

3.5 Examining the Change in the Setting Point Value

This section examines the effect of changing the Setting Point value during the operation of a
DC-Motor controlled by a PID-Controller .The examination was done to different sizes of
motors to observe the effect of size .

First consider a PID-Controller controlling the speed of Motor1(small size) in Fig.(3.1). The
PID controller is stabilizing the DC-Motor speed at a fixed value(setting point The previous
controlled Motor- system was simulated using MATLAB , the model in Fig.( 3.4), and Eq.
(3.8) . Motor 1 parameters used in the simulation was known from the manufacturer. The
measured item that was desired to obtain from the simulation is Motor1 angular Velocity
W(t) versus time. The simulation time was taken from the start point of the controlled system
until the Motor angular velocity is stable after changing the Setting Point value .T he controlled
system was simulated using MATLAB program-code shown in Appendix(A). The simulation
was done with PID-controller parameters{KP= 150, KI=1,Kd=1}, and Motor Mechanical Load
of 80% of maximum torque, and the Setting Point value as Eq. ( 3.13).

Setting Point = 750 rad/sec; 0 ≤ time < 1.5 sec

= 150 / ; ≥ 1.5 (3.13)

Then from the simulation Motor1 angular velocity was monitored versus time and
Fig.(3.13) was achieved. From Fig.(3.13 the steady state value of the velocity before and
after the Setting Point changing is 750 rad/sec and 150 rad/sec respectively with error 0
from the setting point value. The settling time is 61 msec before the Setting Point changing,
and 13 msec after the changing.

Secondly , the previous simulation was repeated but now with PID-controlling of
Motor2(medium size ).PID-controller parameters{KP= 500, KI=1,Kd=900}, and Motor
mechanical load equals the maximum allowed torque to Motor2, and the Setting Point value
as Eq. ( 3.14).

Setting Point = 50.1 rad/sec, 0 ≤ time < 20 sec

= 155.1 / ; ≥ 20 (3.14)

Then Fig.(3.14) of Motor 2 Angular velocity versus time was achieved . From Fig.( 3.14) the
steady state value of the velocity before and after the Setting Point changing is 50.1
rad/sec , and 155.1 rad/sec respectively with error 0 from the setting point value.

29
X: 0.0609
800
Y: 749.9

700

600
Motor 1 Angular Velocity rad/sec

500

400

300

200

Motor 1 Angular velocuty rad/sec VS Time sec


100 1st setting point 750
2nd setting point 150
Settling time before setting point changing 61 msec.
0 Settling time after setting point changing < 13 msec
Pr=150;Dif=1;Int=1.
Load is 80% of maximum torque.
-100
0 0.5 1 1.5 2 2.5 3 3.5
Time sec.
Figure 3.13 PID-Controlling of Motor1 Speed results.

160

140

120 Motor 2 Angular velocuty rad/sec VS Time sec


1st setting point 50.1
Motor 2 Angular Velocity rad/sec

2nd setting point 155.1


Settling time before setting point changing 14.61 sec.
100 Settling time after setting point changing 470 msec.
Pr=500;Dif=900;Int=1.
Load = maximum allowed torque.
80

60 X: 20
Y: 49.91

40

20

0
0 10 20 30 40 50 60 70 80 90 100
Time sec
Figure 3.14 PID-Controlling of Motor2 Speed results.

30
The settling time is 14.61 sec before the Setting Point changing, and 470 msec after the
changing.

From the results of the examination that changing the Setting Point value will not affect the
controlled system and the PID-Controller will always stabilize the DC-Motor speed at the
selected Setting Point value irrespective to the machine size. The settling time can also be
minimized by increasing the PID-controller parameters values{KP, K I, Kd}.

31
Chapter Four
Computer Implementation of
PID-Control
4-Computer Implementation of PID-Control

This chapter discusses the implementation of PID-Controllers using computer systems. The
controlled device in this chapter is also a DC-Motor (as in Chapter 3). Computer systems
means microprocessor Embedded systems usually accompanied by sensors , Analogue to
Digital Converters(ADC), Digital to Analogue Converter (DAC), and amplifiers. The
microprocessor implements the PID-mode(section 2.1.4 Chapter 2) algorithm in a discrete
fashion . And outputs the control signal to the controlled device(The Process) through a DAC (
and Amplifiers if necessary). The discrete PID algorithms use samples of the error to
implement the proportional, integrative, and derivative terms(error between the setting point
value and the controlled Process output variable , discussed in details in Chapter 2). There are
different PID discrete algorithms and all use the error signal , and the controlled- Process
output variable. The PID discrete algorithms can be described in the following sequence:

1-Wait for timer interrupt(sampling)

2. Read analog input through ADC{analogue inputs are the error , and the controlled-Process
output variable}

3. Compute the control signal

4. Output the control signal to the Process through DAC , and Amplifiers

5. Return to (1.)

All the above steps are done by the microprocessor . The microprocessor ,ADC, DAC, and
amplifiers all collectively form a discrete PID controller.

The subject of study in this chapter is to observe the performance of Discrete PID-Controllers
in controlling DC-motors. This chapter discusses the following points:

1-Different discrete PID algorithms.

2-Examining the performance of a discrete PID-controller controlling a DC-Motor when the


sampling frequency of the discrete PID -controller is increased.

3- Examining the performance of a discrete PID-controller controlling a DC-Motor when the


DC-motor mechanical load is changed during operation .

4- Examining the performance of a discrete PID-controller controlling a DC-Motor when the


Setting Point Value is changed during operation.

4.1 Different discrete PID algorithms.

Considering the PID-mode controlling scheme mentioned in section 2.1.4(Chapter 2). The PID-
algorithm used there is a continuous PID-algorithm . This section introduces number of

32
discrete algorithms capable to implement the same PID mechanism. All text-books and authors
gave us 3 types of PID discrete algorithms:

Type A: often called "textbook discrete PID algorithm". It uses the same scheme as Ideal
Parallel PID -mode discussed in section 2.2.1(Chapter 2) and Eq.( 2.9) , and Eq.(2.10) and
Fig.(2.4). It starts by differentiating Eq.(2.9) in time(t), and approximating the first and the 2nd
derivatives terms in the differential equation to difference terms as shown in Eq.(4.1).
( ) ( ) ( )
( ) = ( − 1) + ( ) − ( − 1) + ( )+ (4.1)

Where u is the control signal driving the Process. e is the error signal between the Setting
Point(SP) value and the Process output variable(PV). T is the sampling period. The difference
equation shown in Eq.(4.1) is called type A discrete PID algorithm[1].

Type B: often used in the industry. It uses the same scheme as Parallel PI-D mode discussed
in section 2.2.1(Chapter 2) and Eq.(2.11) , and Eq.(2.12) and Fig.(2.5). It starts by
differentiating Eq.(2.11) in time(t), and approximating the first and the 2nd derivatives terms in
the differential equation to difference terms as shown in Eq.(4.2).
( ) ( ) ( )
( ) = ( − 1) + ( ) − ( − 1) + ( )− (4.2)

T is the sampling period. PV is the Process output variable .

∫.

+ 'e' + 'PV'
+ 'u' control signal PROCESS


- (DC_MOTOR)
+

e= Error signal

'SP'
Figure 4.1 PID-Controlling Scheme

33
The difference equation shown in Eq.(4.2) is called type B discrete PID algorithm[1]. It removed
the derivative term from the Setting Point value to eliminate the Derivative Kick (mentioned in
section 2.2.1 Chapter 2).

Type C: also often used in the industry. It uses the same scheme as Parallel I-PD mode
discussed in section 2.2.1(Chapter 2) and Eq.(2.13) , and Eq.(2.14) and Fig.(2.6). It starts by
differentiating Eq.(2.13) in time(t), and approximating the first and the 2nd derivatives terms in
the differential equation to difference terms as shown in Eq.(4.3).
( ) ( ) ( )
( ) = ( − 1) − ( )− ( − 1) + ( )− (4.3)

T is the sampling period. PV is the Process output variable . The difference equation shown in
Eq.(4.3) is called type C discrete PID algorithm[1] .It removed the proportional term from the
Setting Point value to eliminate the effects of the Setting Point discontinuities on the Process
components (mentioned in section 2.2.1 Chapter 2).

Practically manufacturers deploy other discrete algorithms. We will introduce an algorithm


denoted here by Fast Ideal Parallel Discrete PID-algorithm[1]. This algorithm will be used in
Chapter 5 to design a discrete PID-controller. This algorithm also uses the scheme of Ideal
Parallel PID -mode discussed in section 2.2.1(Chapter 2) and Eq.(2.9) , and Eq.(2.10) and
Fig.(2.4). It uses directly Eq.(2.9) , and approximates the derivative and integrative terms to
difference terms as shown in Eq.(4.4)[1].
( ) ( )
= + ; In is the accumulative integrative term.

( ) ( )
( )= ( )+ + (4.4)

Where u is the control signal driving the Process. e is the error signal between the Setting
Point(SP) value and the Process output variable(PV). T is the sampling period. The difference
equation shown in Eq.(4.4) is the Fast Ideal Parallel Discrete PID-algorithm. This algorithm
( ) ( )
uses the most near approximation for the integrative term({ }) . Where KP,KI, and Kd
are the PID-controller proportional, integrative, and derivative parameters respectively .

4.2 The Effect of The Sampling Frequency

The aim of this section is to study the performance of a discrete PID -controller controlling
DC-Motor 2(the motor is shown in Fig.(3.2)). The discrete controller adopts the Fast Ideal
Parallel Discrete PID-algorithm discussed in the previous section. The control signal u will
drive Motor 2 . A problem would arise is that Motor 2 has constraints in the input voltage
applied to. More than 224.4 volts and negative voltages are prohibited. So the control signal u
generated by the discrete controller will be passed to a voltage limiter as shown in Fig.(4.2).

34
Voltage Limiter
'Vi' Input Voltage
=0 ; <0 DC-MOTOR 2

= ; 0≤ ≤ 224.4
Angular Velocity 'W'
= 224.4 ; > 224.4

'u' control signal

'SP' Setting Point 'Fast Ideal Parallel Discrete PID-algorithm'

Discrete PID controller

Figure 4.2 Discrete PID-controlling of DC-Motor2.

The discrete controller works according to the following repeated sequence:

1-Read Motor 2 angular velocity through sensors and ADC

2-Compute the control signal u using Eq.(4.4) where e is the error between the Setting Point
value (SP) and Motor2 angular velocity(W){e=SP-W}. e(n) is the present error, e(n-1) is the
error in the previous sample.

3-Generate the computed control signal u in voltage format, and output the voltage signal to
the DC-Motor2 for T seconds(sampling time) through the voltage limiter.

4-Return to step 1.

The overall system shown in Fig.(4.2) was simulated using MATLAB ,since MATLAB is very
powerful in simulating control systems . The MATLAB program code simulating the system is
shown in appendix(B). It was desired to monitor from the simulation the angular velocity of
DC-Motor 2 .

DC-Motor 2 parameters used in the simulations were known from the manufacturer. The
discrete PID-controller parameters {KP, KI,Kd} must be selected as large as possible to reduce the
system settling time(time from the start point until the Motor angular speed stabilizes at the

35
selected Setting-point value , mentioned in Chapter 2 and 3). Practically the parameters must
satisfy Eq.(4.5)[5] for the control system stability.

≫4 (4.5)

The discrete controller parameters were selected as {KP=7e15,KI=100, Kd=100}, and the
Setting Point value was fixed to 50 rad/sec, and the sampling frequency to 20 hertz. Then
the simulation was done using MATLAB program code shown in appendix(B) for the control
system shown in Fig.(4.2). From the simulation results the relation between the DC-Motor 2
angular velocity and time was obtained . The relation is shown in Fig.(4.3). From the figure it
can be observed that the speed values fluctuate around the selected Setting Point value after
460msec . The speed values after 460 msec can be given as {50 rad/sec + Fluctuation Offset
}. The Fluctuation Offset can be positive or negative according to the results. From Fig.(4.3)
the maximum Fluctuation Offset is small when compared to the Setting Point value 50
rad/sec, it can be said that the settling time is 460msec .

The simulation was repeated (with MATLAB program code shown in appendix(B)) using the
same discrete controller parameters{KP=7e15,KI=100, Kd=100}. And also fixing the Setting
Point value to 50 rad/sec but increasing the sampling frequency to 70 hertz. From the
simulation results the relation between the DC-Motor 2 angular velocity and time was obtained.
The relation is shown in Fig.(4.4). From the figure it can be observed that the speed values
also fluctuate around the selected Setting Point value after 455 msec . After 455 msec the
speed values can also be given as {50 rad/sec + Fluctuation Offset }. The Fluctuation Offset
can also be positive or negative according to the results. The Fluctuation Offset in this time is
very small when compared to the previous one, that is shown in Fig.(4.4). The maximum
Fluctuation Offset is very small when compared to the Setting Point value 50 rad/sec, it can
also be said that the settling time is 455 msec .

The simulation was repeated (with MATLAB program code shown in appendix(B)) using the
same discrete controller parameters{KP=7e15,KI=100, Kd=100}. And also fixing the Setting
Point value to 50 rad/sec but increasing the sampling frequency t0 250 hertz. From the
simulation results the relation between the DC-Motor 2 angular velocity and time was
obtained. The relation is shown in Fig.(4.5). From the figure it can be observe that the speed
values also fluctuate around the selected Setting Point value after 456 msec . After 456 msec
the speed values can be given as {50 rad/sec + Fluctuation Offset }. The Fluctuation Offset
can also be positive or negative according to the results. The Fluctuation Offset this time is
very small when compared to the previous one, that is shown in Fig.(4.5). The maximum
Fluctuation Offset is very very small when compared to the Setting Point value 50 rad/sec, it
can also be said that the settling time is 456 msec .

For the discrete PID controller it is desirable from a design perspective to eliminate the The '
fluctuation offset'.

36
60

50

Motor2 Velocity rad/sec Vs time sec


Setting Point=50 rad/sec;
40 Pr=7e15;Dif=1e2;Int=1e2;
Motor 2 Angular Velocity

frequency of sample 20hz.


Settling time=0.46 sec

30

20

10

0
0 0.5 1 1.5 2 2.5 3
Time sec
Figure 4.3 Discrete PID-Controlling of Motor2 Speed
results 1.

60

50
Motor2 Angular Velocity rad/sec

40
Motor 2Velocity rad/sec Vs time sec.
Setting Point=50 rad/sec;
Pr=7e15;Dif=1e2;Int=1e2;
frequency of sample=70hz.
30 Settle down time =0.4549 sec

20

10

0
0 0.5 1 1.5 2 2.5 3
Time sec
Figure 4.4 Discrete PID-Controlling of Motor2 Speed

37
60

50

Motor 2 Velocity rad/sec Vs time sec


Setting Point =50rad/sec;
Pr=7e15;Dif=1e2;Int=1e2;
Motor2 Angular Velocity rad/sec

40 frequency of sample 250hz.


Settle down time 0.4575 sec

30

20

10

Figure 4.5 Discrete PID-Controlling of Motor2 Speed results 3.


0
0 0.5 1 1.5 2 2.5 3
Time sec

It can be observed from the 3 simulations results :

1- That the settling time is approximately the same in the 3 sampling frequency situations.

2- The Fluctuation Offset will decrease as the sampling frequency increases until it becomes
negligible at sampling frequency 250 Hz.

Various simulations was done as the 3 previous simulations and the same previous 2 points
was realized. It can be concluded that discrete PID controllers must be designed with large
sampling frequencies (to eliminate the Fluctuation Offset) and large PID- parameters {KP,
KI,Kd} (to reduce the settling time).

4.3 The Effect of the Motor Mechanical Load

Consider also a discrete PID-controller controlling DC-Motor 2 (the motor is shown in


Fig.(3.2)) as in Fig.(4.2) . This section examines the overall system when the motor
mechanical load is changed during the operation. The system shown in Fig.(4.2) was simulated
by MATLAB program code shown in appendix(B). First the system was simulated with PID

parameters{KP=7e15,KI=1e10 , Kd=100}, and fixed Setting Point value of 120rad/sec, and


sampling frequency 1KHZ, and mechanical load as Eq.(4.6) . DC-Motor 2 parameters used in
the simulation were known from the manufacturer.

38
ℎ =0 . 0≤ < 1.5

= ≥ 1.5 (4.6)

From the simulation results the relation between the DC-Motor 2 angular velocity and time was
obtained. The relation is shown in Fig.(4.6). From Fig.(4.6) the speed first stabilizes at the
Setting point value with small Fluctuation Offset , that is before the load variation. At the
sudden large increase in the motor mechanical load it is anticipated that Motor 2 speed to
decrease by a large value. But the discrete controller compensates the effects of the load
variation and the speed only first decreases by a small value and then stabilizes at a value very
close to the Setting point value (shown in Fig.(4.6)).

Then the simulation was repeated but using PID parameters{KP=7e15,KI=100 , Kd=100},
and fixed Setting Point value of 50rad/sec, and sampling frequency 70HZ, and mechanical
load as Eq.(4.7). DC-Motor 2 parameters used in the simulation were known from the
manufacturer.

ℎ = 0≤ < 1.5

=0 . ≥ 1.5 (4.7)

From the simulation results the relation between the DC-Motor 2 angular velocity and time
was obtained. The relation is shown in Fig.(4.7). From Fig.(4.7) the speed first stabilizes at the
Setting point value with small Fluctuation Offset , that is before the load variation. At the
sudden large decrease in the motor mechanical load it is anticipated that Motor 2 speed to
increase by a large value. But the discrete controller compensates the effects of the load
variation and the speed only first increases by a small value and then stabilizes at a value very
close to the Setting point value (shown in Fig.(4.7)).

From the 2 simulations and other various simulations that was done for the same control
system with different PID parameters , different sampling frequencies , and different Motor2
mechanical load changing conditions(increasing or decreasing) . It can be concluded that the
discrete PID controller always stabilizes DC- Motor 2 angular speed to the selected Setting
Point value irrespective to motor 2 mechanical load changes. The problem of the settling time
(time from the start point until the Motor angular speed stabilizes at the selected Setting-point
value , mentioned in Chapter 2 and 3) can be solved by increasing the PID- parameters {KP,
KI,Kd}.

39
120.5

120

Motor 2 Velocity rad/sec Vs time sec.


[0,1.5]sec :No load.
Motor 2 Angular Velocity rad/sec

119.5 [1.5,3.5]sec: 100% of maximum load


Setting Point=120rad/sec;
Pr=7e15;Dif=1e2;Int=1e10;
frequency of sample 1 Khz.

119

118.5

118

117.5
1 1.5 2 2.5 3 3.5
Time sec

Figure 4.6 Discrete PID-Controlling of Motor2 Speed


results 4.
60

50
Motor 2 Angular Velocity rad/sec

40

Motor 2 Velocity rad/sec Vs Time sec.


[0,1.5]sec 100% of maximum load.
[1.5,3.5]sec 0 load.
30 Setting Point=50rad/sec;
Pr=7e15;Dif=1e2;Int=1e2;
Frequency of sampling=70 hz

20

10

0
0 0.5 1 1.5 2 2.5 3
Time sec
Figure 4.7 Discrete PID-Controlling of Motor2 Speed
40
4.4 The Effect of Changing the Setting Point Value

Consider also a discrete PID-controller controlling DC-Motor 2(the motor is shown in


Fig.(3.2)) as in Fig.(4.2) . This section examines the overall system when the Setting Point
value is changed during the operation. The system shown in Fig.(4.2) was simulated by
MATLAB program code shown in appendix(B). First the system was simulated with PID
parameters {KP=7e15,KI=100, Kd=100}, and fixed motor mechanical load equals 60% of the
maximum torque , and sampling frequency 125KHZ, and Setting Point value as Eq.(4.8). DC-
Motor2 parameters used in the simulation were known from the manufacturer.

= 40 / 0≤ < 1.5

= 120 / ≥ 1.5 (4.8)

From the simulation results the relation between the DC-Motor 2 angular velocity and time was
obtained. The relation is shown in Fig.(4.8). From Fig.(4.8) the speed first stabilizes at the first
Setting point value with settling time(time from the start point until the Motor angular speed
stabilizes at the selected Setting-point value , mentioned in Chapter 2 and 3) 350 msec. And
after changing the Setting Point value at 1.5 sec the discrete controller causes the DC-Motor 2
angular velocity to stabilize at the 2nd Setting Point value with settling time 1.16 sec.

Then th e simulation was repeated using the same PID parameters{KP=7e15,KI=100 ,


Kd=100}, and fixed motor mechanical load equals 60% of the maximum torque , and sampling
frequency 125KHZ, and Setting Point value as Eq.(4.8). DC-Motor 2 parameters used in the
simulation were known from the manufacturer.

= 100 / 0≤ < 1.5

= 40 / ≥ 1.5 (4.9)

From the simulation results the relation between the DC-Motor 2 angular velocity and time was
obtained. The relation is shown in Fig.(4.9). From Fig.(4.9) the speed first stabilizes at the
first Setting point value with settling time 1.12 sec. And after changing the Setting Point value
at 1.5 sec the discrete controller causes the DC-Motor 2 angular velocity to stabilize at the 2nd
Setting Point value with settling time 733 msec.

From the previous two simulations and various simulations that were done ,the discrete PID
controller always stabilize the motor speed at the selected Setting Point value. The settling time
parameter can be decreased by increasing the PID- parameters {KP, KI,Kd}.

41
140
Motor 2 Velocity rad/sed Vs TIme sec
in[0,1.5]sec Setting Point=40 rad/sec
X: 2.657
in[1.5,4]sec Setting Point=120 rad/sec
Y: 120
Mechanical load=60 %of maximum torque
120 Pr=7e15;Dif=100;Int=100;
first Settling time 350 msec
2nd Settling time 1.16 sec

100
Motor 2 Angular Velocity rad/sec

80

60

40

20

0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time sec
figure 4.8 Discrete PID-Controlling of Motor2 Speed results 6.

120
Motor 2 Velocity rad/sed Vs TIme sec
in[0,1.5]sec Setting Point=100 rad/sec
in[1.5,4]sec Setting Point=40 rad/sec
Mechanical load=60 %of maximum torque
Pr=7e15;Dif=100;Int=100;
100
first Settling time 1.12 sec
2nd Settling time 733 msec
Motor 2 Angular Velocity rad/sec

80

60

X: 2.233
Y: 40
40

20

0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time sec
Figure 4.9 Discrete PID-Controlling of Motor2 Speed

42
4.5 Conclusion

It can be concluded from the study in this section and various simulations that the discrete PID
controllers are very influential in controlling the angular speed of DC-Motors. This study was
chosen to be made on medium DC-motors(DC-motor 2) since these motors exhibit slow
dynamics when controlled by discrete PID-controllers. So if discrete PID-controllers perform
well in medium motors , it will perform more when controlling small size motors. The two
parameters that affect the performance of discrete PID-controllers are:

1-Sampling Frequency.

2-The PID- parameters {K P, KI, Kd}.

From design perspective these parameters must be as high as possible to achieve high
performance.

43
Chapter Five
Implementation of a Discrete
PID-Controller for DC-
Motors

32
5- Implementation of a Discrete PID Controller for DC-Motors

As said practically all the PID controllers for DC-Motors or different processes are
designed today with embedded systems and microprocessors. Embedded systems and
microprocessors are used to implement discrete PID algorithms. This chapter introduces a
complete design of a discrete PID controller used to control DC-motors.

First the designed discrete PID controller will be introduced in functional blocks and then
each functional block will be described in details.
Then the performance of the designed discrete PID controller will be monitored when it is
controlling DC-Motor 2(medium size motor shown in Fig.( 3.2)). We chose DC- motor 2 since
medium size motors exhibit slow dynamics when controlled by discrete PID-controllers. So if
the designed discrete PID-controller performs well in medium motors , it will perform more
when controlling small size motors.

Digital to Analogue Negative- High Volt u DC-Motor 2


Converter (DAC) Buffer
Amplifier (in figure 3.2)

Data Bus
Motor 2 speed
Analogue to Digital tachometer voltage
Microprocessor
output
Converter
(Microcontroller)
(ADC)

Discrete PID controller


'u' is the control signal

Setting Point Figure 5.1 Discrete PID controlling of DC-motor2

The total design components of the discrete PID controller are shown in Fig.( 5.1). The designed
discrete PID controller function can be summarized in the following steps:

1-The microprocessor reads Motor 2 speed- tachometer voltage value through the
ADC(Analogue to Digital Converter).

2- And then depending on the tachometer reading and the selected Setting Point value the
microprocessor computes the control signal u that is used to drive DC-Motor 2 shaft. The

44
microprocessor adopts any of the discrete PID algorithms to evaluate the control signal u
(discrete PID algorithms are discussed in Chapter 4).

3- The microprocessor outputs the computed control signal u to Motor 2 as shown in Fig.( 5.1)
through the DAC(Digital to Analogue Converter) and the High Voltage amplifier.

4- The microprocessor waits for T seconds(sample time).And then repeat 1.

Each component of the designed discrete PID controller will be described in the following
sections.

5.1 The Digital to Analogue Converter(DAC )

The DAC(shown in Fig.( 5.2)) and the High volt Amplifier are the most crucial components in
our design. As said the microprocessor is used to compute the control signal u . The DAC and
the High volt Amplifier generate the control signal u in an electrical format and output it
directly to DC-Motor 2 . The DAC receives the computed control signal u in digital
format(shown in Fig.( 5.1)) from the microprocessor through the data bus . The DAC then
converts the computed control signal u from digital format to electrical-voltage format. Usually
DACs are implemented with small analogue output voltages. The DAC was designed as
shown in Fig.( 5.2) to generate an analogue output range of {0~12.47}volts and digital input
range of{0 volt for logic 0, 5 volt for logic 1}. The computed control signal u range is
{0~224.4}. So the DAC alone can't generate this signal in electrical-voltage format. So the DAC
output-voltages after buffering are passed to the High Voltage Amplifier to generate the required
voltage range{0~224.4}volts. The DAC was designed using R/2R resistor ladder network
(R=1 M ohm) and UA741CN- OPAMP as shown in Fig.( 5.2)(OPAMP means operational
amplifier). The designed DAC is 8bit that accepts 8 digital input signals and outputs a single
analogue signal at range{0~12.47}volts depending on the digital inputs. The DAC 8digital
inputs are connected to the microprocessor data ports.

5.2 The Negative-Buffer

The Negative Buffer is necessary for 2 points(see Fig.( 5.1)):

1-Usually High Voltage Amplifiers possess low input resistance , they can 't be connected
directly to DACs. Because the DACs can 't work with small output load resistors. The output
load resistor for the DAC must be as large as possible to achieve normal results. Thus it is
necessary of a sort of buffering between the designed DAC and the High Voltage Amplifier.

45
15 v
2

8
In p u t 1

In p u t

In p u t

In p u t

In p u t

In p u t

In p u t

In p u t

15 v
R6
R2 R4 2M R8 R10 R12 R14 R16 U1
2M 2M 2M 2M 2M 2M 2M

7
3
6
R1 R3 R5 R7 R9 R11 R13 R15 2
2M 1M 1M 1M 1M 1M 1M 1M

4
1
5
R17 741

2.5M

-1 5 v
R means Resistor.

U1 is UA741CN- OPAMP.
-15 v

Figure 5.2 8bit- DAC

2-Usually DACs generate negative voltages in their output . The designed DAC generates
electrical analogue signal with negative range{0~ -12.47}volts. This analogue signal can't be
input directly to the High Volt Amplifier ,since the amplifier will amplify only positive signals.
The solution is to insert a negative buffer between the DAC and the amplifier. The negative
buffer role is to reverse the DAC output voltage polarity and pass the resultant positive voltage
to the High Volt Amplifier.

The negative buffer was designed as shown in Fig.( 5.3). First a simple negative buffer named
"BufferNeg" was designed in Fig.( 5.3). As shown in Fig.( 5.3) "BufferNeg" uses LM324
OPAMP with 2 power supplies{+15dc volts,-15dc volts}, and the OPAMP was configured to
be negative amplifier with unity gain. Then 12 blocks of "BufferNeg" were connected in
parallel to form a low output resistor Negative Buffer. The inputs of the blocks were connected
together and the outputs of the blocks were connected together as in Fig.( 5.3). Since the LM324
chip contains 4 OPAMPs within its body ,3chips will be needed to form the 12 blocks connected
network in Fig.( 5.3). This scheme for negative buffers manifests a very low output resistor

46
15 volt

BufferNeg BufferNeg BufferNeg


4
U5:A

3
1 Output BufferNeg BufferNeg BufferNeg
Input
R30 2
10K
11

LM324
-15 volt
BufferNeg BufferNeg
BufferNeg
R31
10K

BufferNeg BufferNeg BufferNeg


BufferNeg

Input Output Input signal


Output Buffered signal
BufferNeg
Figure 5.3 Negative Buffer

buffer. So as to connect the "High Voltage Amplifier" to the DAC we need a high input resistor
and low output resistor Negative Buffer in between. The Negative Buffer in this situation act
sa s a transparent link. So in the design we tried to minimize the Negative Buffer output
impedance, and to maximize the buffer input resistor as we could.

5.3 The High Voltage Amplifier

"High Voltage Amplifier" is an amplifier capable to amplify low voltage electrical signals to
high voltage electrical signals. As said that the computed control signal u evaluated by the
microprocessor is in the range between{0~224.4}(the signal u is used to drive the motor shaft
as in Fig.( 5.1)). The DAC can only generate a signal with voltage in range(0~12.47)volts. So in
order to generate the control signal u in electrical analogue format with range(0~224.4) volts,
the DAC generated signal must be amplified by a High Voltage Amplifier.

The High Voltage Amplifier was designed as shown in Fig.( 5.4). First a simple amplifier was
designed named "AmpH" in Fig.( 5.4). "AmpH" uses a bipolar power transistor 2N3773 , 225
volts dc power supply, and 5 volts dc biasing voltage. The configuration of "AmpH" is shown in
Fig.( 5.4). The amplifier "AmpH" possesses a large output impedance of 224 ohm. The problem
is when connecting this amplifier to DC- motors ,the driving current will be very small to drive
the motor s to high speed. Six blocks of " AmpH " were connected in parallel to form a low
output resistor amplifier. The inputs of the blocks were connected together and the outputs of
the blocks were connected together as in Fig.( 5.4). The network configuration of " AmpH"
blocks depicted in Fig.( 5.4) is a voltage amplifier with low output impedance of 37.3 ohm. This
amplifier is used as a High Voltage Amplifier with range of voltage {0~224.4} volts.

47
225 dc volt

R24
5 dc volt biasing 224 AmpH AmpH
R25
Output
2.5K

Q8 AmpH AmpH
2N3773

Input
R26
240
AmpH AmpH

" AmpH"
Input Signal
Input Output Amplified Signal
AmpH

Figure 5.4 High Voltage Amplifier

5.4 The Microprocessor and The Analogue to Digital Converter(ADC)

The Microprocessor and the ADC function is in the following repeated steps:

1-The microprocessor reads Motor 2 speed- tachometer voltage value through the ADC.

2- Relying on the tachometer reading and the selected Setting Point value the microprocessor
evaluates the control signal u that will be used to drive Motor 2 shaft. The microprocessor
uses any of the different discrete PID algorithms to compute the control signal u (discussed in
Chapter 4).

3- The microprocessor outputs the computed control signal u to Motor 2 as shown in Fig.( 5.1)
through the DAC ,Negative Amplifier, and the High Volt amplifier.

4- The microprocessor waits for T seconds(sampling time).And then goes to step1 again.

The ADC role is to convert the motor speed tachometer reading from electrical voltage format to
digital format and dispatch the digital value to the microprocessor. Usually recent
microcontrollers are provided with ADCs enclosed within the same package. Hence
microcontrollers can perpetrate the microprocessor and the ADC roles at the same time. The
microcontroller ATMEGA 32A was used to implement the Microprocessor and the ADC
function mentioned previously. The microcontroller ATMEGA 32A is depicted in Fig.( 5.5).
The microcontroller ATMEGA 32A has 4 data -ports to exchange data with other external
peripheral devices{PORT A,PORT B,PORTC,PORTD}. Each data port constitutes of 8 external
pins. Port D of the microcontroller is connected with the designed 8bit- DAC(Fig.( 5.2)) via

48
Figure 5.5 Microcontroller ATMEGA 32A

an 8wires data bus. The microcontroller ATMEGA 32A computes the control signal u and then
dispatch it in digital format to the designed 8bit-DAC through Port D and the data bus.

The microcontroller ATMEGA 32A adopts the Fast Ideal Parallel Discrete PID-algorithm
(discussed in Chapter 4) and uses Eq.( 4.4) to compute the value of the control signal u and uses
PID parameters as {KP=7e24,K d=1e16,KI=3e1}.Where KP,Kd ,and KI are the proportional,
derivative, and integrative parameters respectively.

The microcontroller ATMEGA 32A has a 10 bit ADC with maximum input voltage of 5volt,
and reads Motor 2 speed-tachometer voltage value through its 10bit-ADC .

A program code was constructed in 'C' language for the microcontroller ATMEGA 32A to
implement the Microprocessor and the ADC function mentioned previously. The program is
shown in appendix(C) .

The microcontroller program algorithm could be described in the following steps:

1- Set the microcontroller Timer to 125KHZ.

49
2- Wait for the timer interrupt. The timer interrupt activates 125000 time per second.

3-The microcontroller reads Motor 2 speed- tachometer voltage value through its 10-bit-ADC.

4- Relying on the tachometer reading and the selected Setting Point value the microcontroller
evaluates the control signal u that will be used to drive Motor 2 shaft. The microcontroller
uses the Fast Ideal Parallel Discrete PID-algorithm (discussed in Chapter 4) and uses Eq.(4.4)
to compute the value of the control signal u and uses PID parameters as
{KP=7e24,Kd=1e16,KI=3e1}.Where KP,Kd ,and K I are the proportional, derivative, and
integrative parameters respectively.

5- The microprocessor outputs the computed control signal u to Motor 2 as shown in Fig.( 5.1)
through the DAC ,Negative Amplifier, and the High Volt amplifier.

5.5 The Designed Controller Performance

This section monitors the performance of the designed discrete PID-controller when it is
controlling DC-motor 2(medium size motor shown in Fig.( 3.2)). As said we chose DC-
motor 2 because medium size motors show slow dynamics when controlled by discrete PID-
controllers. If the designed discrete PID-controller functions well in medium motors , it will
function more when controlling small size motors.

90% of the designed discrete PID-controller was constructed practically . That was
constructed:

1- The microcontroller ATMEGA 32A circuit.

2- The 8bit-DAC.

3-The Negative Buffer.

4-The tachometer circuit.

Unfortunately the High Voltage Amplifier wasn't constructed completely, due to the lack of
some electronic pieces in this country. So the performance of the designed controller when it is
controlling the DC-motor 2(in Fig.( 3.2)) was examined using an electronic simulation program
"ISIS Professional" was used to simulate the designed controller when it is controlling DC-
Motor 2 as in Fig.( 5.1) . The "ISIS Professional" simulator is capable to simulate sophisticated
electrical/mechanical system in a real time fashion. Various electronic/electrical/mechanical
companies deploy this simulator for designing their products. It is very powerful in simulating
electromechanical systems.

Typically all the electrical/mechanical system depicted in Fig.( 5.1) was simulated by the "ISIS
Professional" . First in the simulation the PID parameters was set in the microcontroller
ATMEGA 32A program code to {KP=7e24,Kd=1e16,KI=3e1}. Where KP, Kd, and KI are the

50
PID proportional, derivative, and integrative parameters respectively .The DC-motor 2
parameters used in the simulation were known from the manufacturer. The DC-motor 2
mechanical load was set in the simulation to variable value in the range {0~2.203N.M}. The
Setting Point value in the microcontroller ATMEGA 32A program code was set to5 rad/sec .
From the simulation results the relation between motor 2 angular velocity and time was obtained
as in Fig.( 5.6). From Fig.( 5.6) it can be observed that motor 2 angular speed stabilizes at the
Setting Point value with small Fluctuation Offset and with settling time of 60 msec (the
Fluctuation Offset is described in Chapter 4) . The settling time is the time elapsed between the
start point and until the motor angular speed stabilizes at the "Setting Point" value.

Then the simulation was repeated with the same previous parameters but with setting the
Setting Point value in the microcontroller ATMEGA 32A program code to 15 rad/sec . Then
from the simulation results the relation between motor 2 angular velocity and time was obtained
as in Fig.( 5.7). From Fig.( 5.7) it can be observed that motor 2 angular speed stabilizes at the
Setting Point value with small Fluctuation Offset and with settling time of 240 msec.

Then the simulation was repeated with the same previous parameters but with setting the
Setting Point value in the microcontroller ATMEGA 32A program code to 22.5 rad/sec . From
the simulation results the relation between motor 2 speed velocity and time was obtained as in
Fig.( 5.8). From Fig.( 5.8) it can be observed that motor 2 angular velocity stabilizes at the
Setting Point value with small Fluctuation Offset and with settling time of 680 msec.

From the simulations it could be seen obviously that the designed discrete PID controller always
stabilizes the motor speed at the selected Setting Point value with small settling time
irrespective to the variable motor mechanical load.

In the next chapter we will evaluate more the performance of the designed discrete PID
controller.

51
Figure 5.6 Discrete PID controlling with setting point value of 5 rad/sec.
52
Figure 5.7 Discrete PID controlling with setting point value of 15 rad/sec.
53
Figure 5.8 Discrete PID controlling with setting point value of 22.5 rad/sec.

54
Chapter Six
Performance Evaluation and
Conclusion
6-Performance Evaluation and Conclusion

This chapter tries to do a performance evaluation study to the discrete PID controller that was
designed in chapter 5. As known from the previous chapters that the most crucial parameter
which affects the performance of a PID controller controlling a DC-Motor is the settling time.
The settling time is the time elapsed between the start point and until the motor angular speed
stabilizes at the "Setting Point" value. Consider a PID-Controller controlling a DC-Motor ,the
settling time of the system changes according to the selected "Setting Point" value and the DC-
motor mechanical-load. Thus each pair of {"Setting Point" value and DC-motor mechanical-
load} have a corresponding settling time. The small the " mean settling time " of a PID
controller controlling the speed of a DC-motor the more performance can be achieved from
such controller.

A statistical approach will be used to evaluate the "mean settling time" of the designed discrete
PID controller (in Chapter 5) when it is controlling DC-motor 2(figure 3.2).

6.1 Evaluating the Mean Settling Time

First various simulations were done using the "ISIS Professional" simulator and "MATLAB"
for the designed discrete PID controller(discussed in Chapter 5) when it is controlling DC-motor
2 (medium size motor shown in figure 3.2). In each simulation different "Setting point" value
and different motor mechanical load were used, and in each simulation from its results the
"settling time" was obtained. Thus there is a "settling time" value for each pair of{"Setting
point" value ,motor mechanical load}. Then the sampling table depicted in table 6.1 was
constructed. The table gives a sample for the settling time of size of 24 elements. DC- motor2
(medium size motor shown in figure 3.2) was chosen for this study because medium size
motors exhibit slow dynamics when controlled by discrete PID-controllers. If the designed
discrete PID-controller performs well in medium motors , it will perform more when
controlling small size motors.

From sampling theorem prospective the average of the sample gets closer to the population
mean as the sample size increases. From the study we have a sample for the settling time of size
of 24 elements. Presume that the sample size of 24 is large enough ,the mean of the population
of settling times can be estimated by the average of the 24-size sample (table 6.1). The sample
average from table 6.1 is 6.7120 sec. The mean settling time can be estimated by 6.7120 sec.
Other point that confirms the correctness of our estimate is the sample taken in table 6.1
distributes along the possible values of the "Setting point" and the motor mechanical load. The
sample taken in table 6.1 is not concentrating in a specific values of the "Setting point" and the
motor mechanical load.

55
Table 6.1 Sample of the settling time.
Setting point value Motor2 Mechanical Load Settling time in sec
rad/sec in N.M
8 0.8118 0.1307
68 0.4968 1.1286
126 0.1614 2.137
185 0.4335 7.9218
58 0.6461 1.0217
118 0.144 1.9094
176 0.6 12.5519
234 0 13.6397
69 0.1051 0.915
136 0.4883 3.2005
196 0.3111 7.7472
225 0.1 15.6451
28 0.3893 0.3813
88 0.3423 1.4265
146 0.9204 12.6647
205 0.2901 11.31
35 1.0633 0.7611
98 1.0693 3.3516
156 0.7756 8.7812
215 0.0513 6.8046
98 0.6228 2.0432
158 0 .7528 8.7216
216 0.1976 19.4561
230 0.05 17.4379

6.2 Performance Evaluation and Conclusion

The key elements in the design of discrete PID controllers as grasped from chapter 4 are:

1- The sampling frequency.

2- The PID parameters{ KP, Kd, and KI }. Where KP, Kd, and KI are the PID proportional,
derivative, and integrative parameters respectively .

Choosing the sampling frequency as large as possible will reduce the "Fluctuation offset"
(discussed in Chapter 4). And increasing the PID parameters will reduce also the "Settling
time"(discussed in the previous Chapters). In the design of the discrete PID controller in
chapter 5 we tried to maximize the sampling frequency and the PID parameters as we could . But
the designed controller has mean settling time of 6.7120 sec when controlling DC-motor
2(medium size motor shown in figure 3.2) as known from the previous study. The mean settling
time is large though we used very large PID parameters . That is deemed to 2 points:

56
1- The large inertia of DC-motor 2. The motor shows slow dynamics when speed-controlled.

2-The motor can't accept voltage level in its input more than 224.4 volt(discussed in Chapter 4).

The previous 2 points cause the mean settling time to increase and are hard to be solved. Mean
settling time of 6.7120 sec is large but can be observed small when compared to the very small
dynamic of DC-motor 2. In the other hand the deigned discrete PID controller (in Chapter 5)
from the simulations reduces the "Fluctuation Offset" (discussed in Chapter 4) to a subtle value.

When considering small size motors the designed discrete PID controller will have a small mean
settling time less than 6.7120 sec, since small size motors exhibit fast dynamics when speed-
controlled. If the designed controller has mean settling time of 6.7120 sec when controlling DC-
motor 2(medium motor with slow dynamics), it will have a mean settling time very lower than
this value when controlling small motors( that have smaller inertia and fast dynamics).

6.3 Recommendations for Future Work

The PID-Control methods were examined and discussed in this Research-Project when the
methods are used in controlling the speed of DC-Motors. The methods were used in the
Research-Project to stabilize the speed of DC-Motors at a user selected value(Setting Point).
The PID-Control methods can also used to stabilize the speed of AC-Synchronous Motors,
and AC-Induction Motors at a user selected value(Setting Point). PID-Control methods can
also be implemented using embedded systems and microcontrollers and used to control the
angular velocity of AC-Motors, the previous controlling method resembles the Direct Torque
Control(DTC)[11] method which is used to control the torque and speed of 3-Phase AC motors.
As a future work it can be recommended to monitor ,examine, and evaluate the performance
of various PID methods(Continuous and discrete methods) when the method are used to
control the speed of AC-Motors.

57
REFERENCES

[1] Karl Johan Astrom, Control System Design, 2010.

[2] Araki M. , "PID Control", in Encyclopedia of Life Support Systems (EOLSS), 2011.

[3] M.J. Willis , lectures on Proportional-Integral-Derivative Control, University of

Newcastle Dept. of Chemical and Process Engineering, 2010.

[4] Zoran Vukic, Lectures on PID Controllers , The University of Texas Automation and

Robotics Research Institute, 2011.

[5] Dingyu Xue, YangQuan Chen, and Derek P.Atherton , Linear Feedback Control,The

Society for Industrial and Applied Mathematics in US, 2007.

[6] John A.Shaw, The PID Control Algorithm how it works how to tune it and how to use it ,

2nd Edition, 2010.

[7] Tajrin Ishrat, Hasib Bin Liakat, "DC Motor Position Control Drive State-Space Design", in

Canadian Journal on Electrical and Electronics Engineering Vol. 2/No.11, 2011.

[8] Edward Hughes, John Hiley, Keith Brown, Ian McKenzie-Smith, Electrical and

Electronic Technology, Pearson, 2012.

[9] "PID controller", From Wikipedia, 2010, http://en.wikipedia.org/wiki/PID_controller,

[Accessed:2014].

[10] "Atmega32 Datasheat", From Atmega manufacturer, 2011,

http://www.atmel.com/Images/doc2503.pdf, [Accessed:2014].

[11] "Direct Torque Control", 2011, http://en.wikipedia.org/wiki/Direct_torque_control,

[Accessed:2014].

58
APPENDIX A
MATLAB CODE 1
MATLAB Code simulating a PID-Controller controlling a DC-Motor . The PID-
Controller uses a continuous PID Algorithm.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
%%%%%DC Motor Parameters %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%_____________%%%%%%%%%%%%%%%%%%%
Ra= 7.75;% ohm:Armature (rotor) resistance.
La=4.05e-3 ;%H:Armature inductance.
KT= 0.013 ;%Torque constant.
KE=0.013;%(emf constant).
J=5.2E-07;%DC Motor inertia.
BV =4.9E-7;%Viscous friction.
TL=0.0057*1.0;%Motor load.
TL1=0;% Sudden load
TL2=0;%-005.7*0.5;% Sudden load
TL3=0;%005.7*0.4;% Sudden load
Vin=12;%Input Voltage;'
VSTR=0;%Start Spead.
%%%%%%%%%%%%%%% Motor DC Transfer Function Parameters and load
characteristics%%%%%%%%%%%%%%
b=[La*J/KT, Ra*J/KT+La*BV/KT, Ra*BV/KT+KE];
a1=1;%Vin;
a2=-Ra*TL/KT;C1=-Ra*TL1/KT;C2=-Ra*TL2/KT;C3=-Ra*TL3/KT;
s = tf('s'); % Create Laplace variable
W = tf(a1,b); w=tf(b,1);
LO=tf(a2,b)/s+tf(-TL*La/KT,b);
CS1=tf(C1,b)/s+tf(-TL1*La/KT,b);CS2=tf(C2,b)/s+tf(-
TL2*La/KT,b);CS3=tf(C3,b)/s+tf(-TL3*La/KT,b);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PID%%%%%%%%%%%%%%%%%%
SP=750;
SP2=0;
Pr=150;
Dif=1;
Int=1;
PID=Pr+Dif*s+Int/s;
WPID=(SP*PID*W/s-SP*Dif*W)/(1+PID*W)+LO/(1+PID*W);
WP2=SP2*PID*W/s/(1+PID*W);
CS1=CS1/(1+PID*W);CS2=CS2/(1+PID*W);CS3=CS3/(1+PID*W);%CS1=C1/(PID*s+w*s);
WO=W*Vin/s+LO+b(2)*VSTR*W;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
P=pole(WO);%W*Vin/s-+LO);
display('poles=');
display(P);
[num,den] = tfdata(WO,'v');%W*Vin/s+LO,'v');
[numC1,denC1]=tfdata(CS1,'v');
[numC2,denC2]=tfdata(CS2,'v');
[numC3,denC3]=tfdata(WP2,'v');
display('num=');
A-1
display(num);
display('den=');
display(den);
[A,PP] = residue(num,den);
%*****************************
[AC1,PPC1]=residue(numC1,denC1);
[AC2,PPC2]=residue(numC2,denC2);
[AC3,PPC3]=residue(numC3,denC3);
%******************************
display('A=');
display(A);
display('P=');
display(PP);tt=1:35000;Value=1:35000;LOD=1:35000;
for jj=1:35000,
tt(jj)=(jj-1)*1e-4;
Value(jj)=0;LOD(jj)=TL;
for i=1:length(PP),
Value(jj)=1*(Value(jj)+A(i)*exp(PP(i)*tt(jj)));
end

%************************************
if tt(jj)>=7 ,
for i=1:length(PPC1),
Value(jj)=1*(Value(jj)+0*AC1(i)*exp(PPC1(i)*(tt(jj)-7)));
end
LOD(jj)=LOD(jj)+TL1;
end
if tt(jj)>=1 ,
for i=1:length(PPC2),
Value(jj)=1*(Value(jj)+AC2(i)*exp(PPC2(i)*(tt(jj)-1)));
end
LOD(jj)=LOD(jj)+TL2;
end
if tt(jj)>=1.5 ,
for i=1:length(PPC3),
Value(jj)=1*(Value(jj)+AC3(i)*exp(PPC3(i)*(tt(jj)-1.5)));
end
LOD(jj)=LOD(jj)+TL3;
end
%**************************************
end

plot(tt,Value)

A-2
APPENDIX B
MATLAB CODE 2
MATLAB Code simulating a PID-Controller controlling a DC-Motor . The PID-
Controller uses a discrete PID Algorithm.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
%%%%%DC Motor Parameters %%%%%%%%%%%%%%%%%%%%
Ra=87.2564;% ohm:Armature (rotor) resistance.
La=0;%4.05e-3 ;%H:Armature inductance.
KT= 0.9549;%0.013 ;%Torque constant.
KE=0.9549;%0.013;%(emf constant).
J=0.0261;%5.2E-07;%DC Motor inertia.
BV =0;% 4.9E-7;%Viscous friction.
TL=0.05;% 3.8197*0.4*0.6;%392;%0.01034;%0.0057*0.00;%Motor load.
TL1=-1000;% Sudden load
TL2=0;%-005.7*0.5;% Sudden load
freqS=125e3;
SimulET=25;%sec
Vin=0;%Volt
SP=230;
Pr=7e24;
Dif=1e16;
Int=3e1;
%%%%%%Motor Transfer%%%%%%%%%%%%%%%%%
s = tf('s');
b=[La*J/KT, Ra*J/KT+La*BV/KT, Ra*BV/KT+KE];
W = tf(1,b);
[num,den] = tfdata(W/s,'v');
[A1,PP1] = residue(num,den);
[num,den] = tfdata(W,'v');
[A2,PP2] = residue(num,den);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EEE=ceil(SimulET*freqS)+1;
tt=1:EEE;%ceil(SimulET*freqS)+1;
Value=1:EEE;%ceil(SimulET*freqS)+1;
Err=1:EEE;%ceil(SimulET*freqS)+1;
MM=1:EEE;%ceil(SimulET*freqS)+1;
Err(1)=SP;IntS=0; Value(1)=0;
for ii=1:1:EEE,%ceil(SimulET/freqS)+1,

tt(ii)=(ii-1)/freqS;
% if(tt(ii)>=1.5), TL=3.8197*0.4*0;end
% if(tt(ii)>=1.5), SP=40;end

if ii==1,
MM(ii)=200;
end
if(ii>1),
Err(ii)=SP-Value(ii);
B-1
IntS=IntS+(Err(ii)+Err(ii-1))/freqS*Int*0.5;
MM(ii)=(Err(ii)-Err(ii-1))*freqS*Dif+Pr*Err(ii)+IntS;
if(MM(ii)>224.4) MM(ii)=224.4;end
if(MM(ii)<0) MM(ii)=0;end
end

if (ii<EEE),
Value(ii+1)=0;
a1=-Ra*TL/KT;
%VALTR=(MM(ii)/s+a1/s+b(2)* Value(ii))*W;
OK=MM(ii)+a1;%[num,den] = tfdata(VALTR,'v');
%[A,PP] = residue(num,den);
for j=1:length(PP1),
Value(ii+1)=Value(ii+1)+OK*A1(j)*exp(PP1(j)/freqS);
end
for j=1:length(PP2),
Value(ii+1)=Value(ii+1)+b(2)* Value(ii)*A2(j)*exp(PP2(j)/freqS);
end

end
end
plot(tt,Value)

B-2
APPENDIX C
The ATMEGA32A Code
The program of the microcontroller ATMEGA32A which is used in the designed discrete
PID-controller in chapter 5. The program is written in C language.

#include <mega32a.h>

#include <delay.h>

#include <math.h>

float yy=0;

unsigned char getportv(float VAL){

float PV; unsigned char OO;;

if(VAL<0.2904) PV=0 ;

if((VAL>=0.2904)&&(VAL<14.35)) PV=(0-16)/(0.2904-14.35)*(VAL-14.35)+16;

if((VAL>=14.35)&&(VAL<28.41)) PV=(16-32)/(14.35-28.41)*(VAL-28.41)+32;

if((VAL>=28.41)&&(VAL<42.47)) PV=(32-48)/(28.41-42.47)*(VAL-42.47)+48;

if((VAL>=42.47)&&(VAL<56.54)) PV=(48-64)/(42.47-56.54)*(VAL-56.54)+64;

if((VAL>=56.54)&&(VAL<70.60)) PV=(64-80)/(56.54-70.60)*(VAL-70.60)+80;

if((VAL>=70.60)&&(VAL<84.66)) PV=(80-96)/(70.60-84.66)*(VAL-84.66)+96;

if((VAL>=84.66)&&(VAL<98.72)) PV=(96-112)/(84.66-98.72)*(VAL-98.72)+112;

if((VAL>=98.72)&&(VAL<112.8)) PV=(112-128)/(98.72-112.8)*(VAL-112.8)+128;

if((VAL>=112.8)&&(VAL<126.8)) PV=(128-144)/(112.8-126.8)*(VAL-126.8)+144;

if((VAL>=126.8)&&(VAL<140.98)) PV=(144-160)/(126.8-140.9)*(VAL-140.9)+160;

if((VAL>=140.98)&&(VAL<155)) PV=(160-176)/(140.98-155)*(VAL-155)+176;

if((VAL>=155)&&(VAL<169)) PV=(176-192)/(155-169)*(VAL-169)+192;

if((VAL>=169)&&(VAL<183.1)) PV=(192-208)/(169-183.1)*(VAL-183.1)+208;

if((VAL>=183.19)&&(VAL<197.1)) PV=(208-224)/(183.1-197.1)*(VAL-197.1)+224;

if((VAL>=197.1)&&(VAL<211.2)) PV=(224-240)/(197.1-211.2)*(VAL-211.2)+240;

C-1
if((VAL>=211.2)&&(VAL<=224.4)) PV=(240-255)/(211.2-224.4)*(VAL-224.4)+255;

if(VAL>224.4) PV=255;

if(PV-floor(PV)>=0.5) OO= ceil(PV);

else OO=floor(PV);

return OO;

// Timer 0 overflow interrupt service routine

#define ADC_VREF_TYPE 0x40

// Read the AD conversion result

unsigned int read_adc(unsigned char adc_input)

ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);

// Delay needed for the stabilization of the ADC input voltage

delay_us(10);

// Start the AD conversion

ADCSRA|=0x40;

// Wait for the AD conversion to complete

while ((ADCSRA & 0x10)==0);

ADCSRA|=0x10;

return ADCW;

C-2
// Declare your global variables here

double SP=5,Mot=220;

double Pr=7e24,Dif=1e16,Int=3e1;

unsigned char Strt=0;double freqs=1;

double Er1=0,Er2=0,Ints=0;

interrupt [TIM0_OVF] void timer0_ovf_isr(void)

double aaa=0;

// Place your code here

if(yy==0){

if(Strt==0){

PORTD=getportv(Mot);

Er1=SP;

Strt=1;

else {

aaa= read_adc(1);aaa=aaa*5/1024*5;

Er2=SP-aaa;

Ints=Ints+0.5*(Er1+Er2)/125000*freqs*Int;

Mot=Ints+(Er2-Er1)*125000/freqs*Dif+Pr*Er2;

if(Mot>224.4) Mot=224.4;

if(Mot<0) Mot=0;

Er1=Er2;

PORTD=getportv(Mot);

yy=yy+1 ;

C-3
if(yy>=freqs) yy=0;

void main(void)

// Declare your local variables here

// Input/Output Ports initialization

// Port A initialization

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T

PORTA=0x00;

DDRA=0x00;

// Port B initialization

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T

PORTB=0x00;

DDRB=0x00;

// Port C initialization

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T

PORTC=0x00;

DDRC=0x00;

// Port D initialization

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

C-4
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T

PORTD=0x00;

DDRD=0xFF;

// Timer/Counter 0 initialization

// Clock source: System Clock

// Clock value: 125 kHz

// Mode: Normal top=0xFF

// OC0 output: Disconnected

TCCR0=0x03;

TCNT0=0x00;

OCR0=0x00;

// Timer/Counter 1 initialization

// Clock source: System Clock

// Clock value: Timer1 Stopped

// Mode: Normal top=0xFFFF

// OC1A output: Discon.

// OC1B output: Discon.

// Noise Canceler: Off

// Input Capture on Falling Edge

// Timer1 Overflow Interrupt: Off

// Input Capture Interrupt: Off

// Compare A Match Interrupt: Off

// Compare B Match Interrupt: Off

TCCR1A=0x00;

TCCR1B=0x00;

C-5
TCNT1H=0x00;

TCNT1L=0x00;

ICR1H=0x00;

ICR1L=0x00;

OCR1AH=0x00;

OCR1AL=0x00;

OCR1BH=0x00;

OCR1BL=0x00;

// Timer/Counter 2 initialization

// Clock source: System Clock

// Clock value: Timer2 Stopped

// Mode: Normal top=0xFF

// OC2 output: Disconnected

ASSR=0x00;

TCCR2=0x00;

TCNT2=0x00;

OCR2=0x00;

// External Interrupt(s) initialization

// INT0: Off

// INT1: Off

// INT2: Off

MCUCR=0x00;

MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization

C-6
TIMSK=0x01;

// USART initialization

// USART disabled

UCSRB=0x00;

// Analog Comparator initialization

// Analog Comparator: Off

// Analog Comparator Input Capture by Timer/Counter 1: Off

ACSR=0x80;

SFIOR=0x00;

// ADC initialization

// ADC Clock frequency: 1000.000 kHz

// ADC Voltage Reference: AVCC pin

ADMUX=ADC_VREF_TYPE & 0xff;

ADCSRA=0x83;

// SPI initialization

// SPI disabled

SPCR=0x00;

// TWI initialization

// TWI disabled

TWCR=0x00;

// Global enable interrupts

C-7
#asm("sei")

delay_ms(10);

while (1)

// Place your code here

C-8

You might also like