Cours
Cours
W
Student:
IE
Khalid Boudane - a46640
EV
Supervised by:
Bragança 2021
Dedication
It is with great pleasure that I dedicate this work to my dearest parents and sisters,
W
Your love, the values transmitted, your support in the most difficult moments and your
constant attention for your children. I boast, every day since the beginning of my life,
IE
even without words, of the pride I take in being your child. No matter what happens,
making you proud is also one of my goals.
EV
To the whole mechatronics and Industrial family,
Our paths crossed for the first time when we entered the IPB, keeping the friendship and
international relation that unites us and the memories of all the moments we spent
PR
together, nothing to say, I treasure each and every one of the moments we spent with
you.
I
Acknowledgements
I am pleased to express my sincere thanks to all the IPB team for their welcome and the
trust they have placed in me.
W
My sincerest thanks to our dears Dr José Gonçalves and Dr Joào Paulo Coelho, my
university supervisors, for the enriching and interesting experience they gave me during
IE
the period of the project and for the autonomy they gave me throughout the project.
EV
Our thanks also go to all the IPB staff who contributed to the running of my final
project. I have the honour to express my special thanks to the members of the jury for
giving me the honour of judging this modest work. Finally, I would like to thank the entire
PR
teaching team of the IPB for having ensured a good training during the period of research
master in the department of Technology and Management (ESTIG) of IPB Bragança.
II
Abstract
The control of the speed of a (direct current) DC motor is very important as any change
can lead to instability of the closed loop system. The aim of this project is to show how
W
a DC motor can be controlled using a PID controller and the CDM Coefficient Diagram
method in MATLAB/Simulink. The DC motor will be interfaced to MATLAB using an
IE
Arduino Mega 2560. The speed of the motor will be set by creating a Simulink model for
the PID controller and CDM Coefficient Diagram Method in MATLAB. This last will
EV
send a serial command to the DC motor using the PWM pins on the Arduino board. The
DC motor will run at the speed defined by the user. The velocity of the DC motor will
be measured using the encoder. From the encoder, the output is sent to the controller
PR
(PID/CDM) in Simulink via Arduino. The controller compares the actual velocity of the
motor with the setpoint velocity.
Keywords:
Matlab/Simulink, Arduino, Regulation PID, CDM Coefficient Diagram Method, Encoders,
PWM
III
Resumo
O controlo da velocidade de um motor CC (corrente contínua) é muito importante, uma vez que
uma estratégia de control errada pode levar à instabilidade do sistema em malha fechada. O
objectivo deste projecto é mostrar como um motor de corrente contínua pode ser controlado
utilizando um controlador PID e o método CDM em MATLAB/Simulink. O motor CC será
interligado ao MATLAB usando um Arduino Mega 2560. A velocidade do motor será controlada
através da criação de um modelo Simulink para o controlador PID e para o CDM. O software
enviará um comando série ao motor DC usando os pinos PWM na placa Arduino fazendo com
que o motor de corrente contínua opere à velocidade definida pelo utilizador. A velocidade do
W
motor de corrente contínua será medida utilizando um codificador incremental. A partir dos
pulsos gerados pelo codificador, a velocidade do motor é derminada sendo usada pelo
IE
controlador (PID/CDM) em Simulink via Arduino..
EV
Palavras-chave:
Matlab/Simulink, Arduino, Regulamento PID, Método do Diagrama de Coeficiente CDM,
Codificadores , PWM
PR
IV
Contents
General Introduction 1
W
1 State Of The Art 3
1.1 DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IE 5
1.1.1 Types of DC motors . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.2 Construction of DC motor . . . . . . . . . . . . . . . . . . . . . . . 8
EV
1.1.3 Armature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1.4 Commutator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1.5 Brushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
PR
V
2.0.2 Open loop control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.0.3 Open-loop characteristics . . . . . . . . . . . . . . . . . . . . . . . . 32
2.0.4 Closed loop control . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.0.5 Closed-loop characteristics . . . . . . . . . . . . . . . . . . . . . . . 33
2.0.6 Difference between open loop and closed loop operation of DC motor 33
2.0.7 Controlling the speed of DC motor . . . . . . . . . . . . . . . . . . 34
2.0.8 DC motor speed controller (PWM of ARDUINO) . . . . . . . . . . 34
2.0.9 The Impact of DC Motors Control . . . . . . . . . . . . . . . . . . 35
W
2.0.10 Mathematical model of DC motor . . . . . . . . . . . . . . . . . . . 36
2.0.11 The model mathematical of the EMG30 DC motor . . . . . . . . . 36
IE
2.0.12 System simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.0.13 PID Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
EV
2.0.14 PD Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.0.15 PI Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.0.16 Design a PID controller using an Bode plot reshape . . . . . . . . . 44
PR
VI
3 Interpreting the realization of a DC Motor Control 62
3.0.1 Development of the synoptic diagram . . . . . . . . . . . . . . . . . 62
3.0.2 Hardware part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.0.3 EMG30 DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.0.4 Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.0.5 Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.0.6 Connectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.0.7 EMG30 mounting bracket . . . . . . . . . . . . . . . . . . . . . . . 66
3.1 Motor encoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
W
3.1.1 What is a motor encoder . . . . . . . . . . . . . . . . . . . . . . . . 67
3.1.2 DC motor encoders . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
IE
3.2 Motor driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.2.1 L298N block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 69
EV
3.3 Arduino controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.3.1 Arduino mega 2560 . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.3.2 Arduino Mega 2560 pin diagram . . . . . . . . . . . . . . . . . . . . 71
PR
VII
3.6.7 Result and discussion . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.6.8 CDM real time experience closed loop results . . . . . . . . . . . . 84
3.6.9 Advantages of PID and CDM method . . . . . . . . . . . . . . . . . 88
B Electronics Components B1
W
IE
EV
PR
VIII
List of Tables
W
3.1 Connection of arduino with DC motor with motor drive . . . . . . . . . . . . 77
3.2
IE
Advantages of PID and CDM method . . . . . . . . . . . . . . . . . . . . . 88
EV
PR
IX
List of Figures
W
1.2 DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Permanent magnet motor [3] . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Series DC motor [3] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Shunt DC motor [3]
IE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 Compound DC motor [3] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
EV
1.7 Construction Of DC Motor [4] . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.8 Pole Cores And Pole [4] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.9 Field winding Of DC motor [4] . . . . . . . . . . . . . . . . . . . . . . . . 10
PR
X
1.19 More the number of the coils, smoother will be motor rotation; to enhance
magnetic flux interaction, coils are put between steel layer poles [5] . . . . 15
1.20 An electromagnet is used most of the time in DC motor [5] . . . . . . . . . 16
1.21 A shunt and a series motors [5] . . . . . . . . . . . . . . . . . . . . . . . . 16
1.22 A shunt motor provides a constant speed-torque characteristics [5] . . . . . 17
1.23 The Back E.M.F [5] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.24 flux control method [6] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.25 Rheostat control method [6] . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.26 Linear control [8] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
W
1.27 PWM control [8] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.28 : 5V Pulses with 0% Through 100% duty cycle [6] . . . . . . . . . . . . . . 23
IE
1.29 DC motor speed control using PWM [6] . . . . . . . . . . . . . . . . . . . 24
1.30 Robot with DC motor [9] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
EV
1.31 Brushed DC Motor actuators for industrial robots [10] . . . . . . . . . . . 26
1.32 Gear DC motor are used in a variety of medical device [11] . . . . . . . . . 27
1.33 DC Motors for Home Application [12] . . . . . . . . . . . . . . . . . . . . . 27
PR
XI
2.12 PID controller block diagram [18] . . . . . . . . . . . . . . . . . . . . . . . 43
2.13 The structure of the control system closed loop . . . . . . . . . . . . . . . 45
2.14 Bode diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.15 Step Response with Proportional Gain = 0.76 . . . . . . . . . . . . . . . . 48
2.16 Block Simulink of model in closed loop . . . . . . . . . . . . . . . . . . . . 49
2.17 Closed loop result of model simulation . . . . . . . . . . . . . . . . . . . . 51
2.18 Standard CDM block diagram [19] . . . . . . . . . . . . . . . . . . . . . . 53
2.19 Equivalent block diagram of CDM [19] . . . . . . . . . . . . . . . . . . . . 53
2.20 Mathematical model [21] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
W
2.21 CDM simulation of closed loop system . . . . . . . . . . . . . . . . . . . . 59
2.22 CDM simulation result of closed loop without disturbance . . . . . . . . . 59
IE
2.23 CDM simulation result of closed loop with step disturbance . . . . . . . . . 60
EV
3.1 System block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2 EMG30 motor [22] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.3 Measurements of EMG30 motor [22] . . . . . . . . . . . . . . . . . . . . . 64
PR
3.4 Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.5 EMG30 mounting bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.6 DC motor encoder [6] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.7 Principe of work Dc motor encoder [6] . . . . . . . . . . . . . . . . . . . . 68
3.8 L298N-dual H-bridge motor driver [23] . . . . . . . . . . . . . . . . . . . . 68
3.9 L298N-pin out [23] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.10 L298N-voltage [23] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11 L298N block diagram [23] . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.12 Arduino Mega2560 [24] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.13 Arduino mega 2560 pin diagram [24] . . . . . . . . . . . . . . . . . . . . . 71
3.14 Power Supply 12v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.15 wheel 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.16 Read, write, and analyze data from Arduino [26] . . . . . . . . . . . . . . . 74
XII
3.17 Ploading Tthe Adioes Program to the Arduino Interface . . . . . . . . . . 75
3.18 Evelop Algorithms That Run Standalone on The Arduino [26] . . . . . . . 75
3.19 Connection Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.20 Diagram of the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.21 Simulink Block of Velocity Measurement without control . . . . . . . . . . 79
3.22 Result of real time motor in open loop test in 130rpm qnd 2s simple time 79
3.23 Result of model with motor real time in open loop . . . . . . . . . . . . . . 80
3.24 PID control system based on Arduino . . . . . . . . . . . . . . . . . . . . . 81
3.25 Real experience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
W
3.26 PID result of real time experience in closed loop . . . . . . . . . . . . . . 82
3.27 steady state error of PID control of real time system in closed loop
IE . . . . 82
3.28 PID closed loop result in real time with load disturbance . . . . . . . . . . 83
3.29 steady state error of PID control in real time at closed loop result with
EV
load disturbance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.30 CDM real time simulation closed loop . . . . . . . . . . . . . . . . . . . . 85
3.31 CDM closed loop result real time experience . . . . . . . . . . . . . . . . . 85
PR
XIII
Introduction
Control is one of the most fundamental factors that enables us to use devices to their
maximum potential and with the highest accuracy, where we can achieve high efficiency,
W
total control of the dc motor, and improved precision.
In this project, we would use a PID controller and CDM method to manipulate the
IE
velocity of a (direct current) DC motor using an encoder signal. The encoder allows us
to read the direction and the speed of the shaft and calculate the actual speed, which we
EV
will enter the result into the controller to get the desired speed depending on the PID
controller’s feedback. Then, as a theoretical analysis, we will simulate the modilisation
of DC motor mathematically in Matlab/simulink software and preview the effects before
PR
1
Arduino board and Matlab/Simulink software. After that, we have to go over the model
of simulink that control DC motor via Arduino and compare the real velocity with the
desired velocity, and Test results of control is presented and performance is explained in
detail.
After that, we’ll go through the results of the speed control testing in the graph
and analyze them, and then we’ll go over the Speed Regulation of DC Motor with PID
Controller and CDM Coefficient Diagram Method conclusions.
For future study, we should add different controller methods to this work, such as
(Neuro-Fuzzy controller, LQR, and LGG optimal controller), and compare the precision,
W
feedback, and characteristics of each method which provide best control and high precise.
IE
EV
PR
2
Chapter 1
W
The history of (direct current) DC motors extends way back into the 19th century. From
IE
initial testing and development to widespread use across global industries, DC gear motors
have evolved significantly into the present day.
EV
Being a trusted electric motor manufacturer for over 70 years means have seen how
the DC motor has changed and adapted to new technologies over time. Always intrigued
about how it will continue to evolve and succeed in new industries in the future [1].
PR
The invention of the DC motor came about in the early 1800s, with initial developments
made in 1832 by British scientist William Sturgeon. Sturgeon created the very first
commutator DC motor, with the ability to turn machinery, however sturgeon’s idea was
developed and built upon by Thomas Davenport, an American inventor. Davenport is
more widely known to have officially invented a working DC motor, which he went onto
patent a few years later in 1837. Initially, davenport struggled with issues surrounding
the expensive costs of battery power whilst running the motors, which made the very first
DC motor fairly incapable of withstanding the test of time [1].
After Davenport’s initial invention of the DC motor came to light, many other inventors
and engineers became inspired to develop their own concepts. In 1834, russian engineer
Moritz Von Jacobi went on to invent the very first rotating DC motor. His invention
became famous for being incredibly powerful, which later set a world record. Incredibly,
he broke his own world record in 1838 with a new and improved version of his DC motor
3
invention. This motor motivated others to produce DC motors of the same powerful
standard, with the ability to drive a boat with a capacity of 14 people across a river. The
year of 1864 saw an amazing breakthrough in the history of DC motors, with the very
first recognition of the ring armature by Antonio Pacinotti. This has become a vital piece
of equipment within the DC motor’s design, which carries current through coils grouped
together [1].
With all of these developments in mind, the 1800’s had still not seen a more practical
DC motor with greater speed control. This came in 1886, where Frank Julian Sprague
W
invented a motor that could maintain constant speed under variable loads. His invention
lead to wider commercial use of the DC motor, such as the first electric elevator and
powered trolley system. The practicality of this DC motor caused high demand to surge
IE
in both commercial and more residential settings, such as in factories and within the
homes [1].
EV
PR
4
1.1 DC motor
A direct current (DC) motor is a fairly simple electric motor that uses electricity and a
magnetic field to produce torque, Which causes it to turn. At its most simple, It requires
two magnets of opposite polarity and an electric coil, which acts as an electromagnet.
The repellent and attractive electromagnetic forces of the magnets provide the torque
that causes the motor to turn Anyone who has ever played with magnets knows that they
are polarized, With a positive and a negative side. The attraction between opposite poles
W
and the repulsion of similar poles can easily be felt, even with relatively weak magnets. A
DC motor uses these properties to convert electricity into motion. As the magnets within
the motor attract and repel one another, the motor turns [2].
IE
EV
PR
A DC motor is powered by direct current, which converts electrical energy into mechanical
energy. This mechanical energy causes rotational movement within the motor, helping to
power a vast majority of industry applications [1].
5
1.1.1 Types of DC motors
The permanent magnet motor uses a magnet to supply field flux, permanent magnet DC
motors have excellent starting torque capability with good speed regulation, a disadvantage
of permanent magnet DC motors is they are limited to the amount of load they can drive,
these motors can be found on low power applications [3].
Another disadvantage is that torque is usually limited to 150%, of rated torque to
prevent demagnetization of the permanent magnets [3].
W
IE
EV
PR
Series motors
In a series DC motor the field is connected in series with the armature, the field is
wound with a few turns of large wire because it must carry the full armature current. A
characteristic of series motors is the motor develops a large amount of starting torque.
However, speed varies widely between no load and full load. Series motors cannot be used
where a constant speed is required under varying loads. Additionally, the speed of a series
motor with no load increases to the point where the motor can become damaged, Some
load must always be connected to a series-connected motor. Series-connected motors
generally are not suitable for use on most variable speed drive applications [3].
6
Figure 1.4: Series DC motor [3]
W
Shunt motors
IE
EV
In a shunt motor the field is connected in parallel (shunt) with the armature windings, the
shunt-connected motor offers good speed regulation, The field winding can be separately
excited or connected to the same source as the armature. An advantage to a separately
PR
excited shunt field is the ability of a variable speed drive to provide independent control of
the armature and field, the shunt-connected motor offers simplified control for reversing.
This is especially beneficial in regenerative drives [3].
7
Compound motors
Compound motors have a field connected in series with the armature and a separately
excited shunt field, the series field provides better starting torque and the shunt field
provides better speed regulation, however the series field can cause control problems in
variable speed drive applications and is generally not used in four quadrant drives [3].
W
IE
EV
Figure 1.6: Compound DC motor [3]
8
The construction generally consists of:
Yoke
This is the outer part of the DC motor. It provides the mechanical supports for the
poles and acts as a protecting cover for the whole machine. It carries the magnetic flux
produced by the poles. Yokes are made out of cast iron or cast steel [4].
Field pole
W
The field poles are mounted inside the yoke, are made of thin lamination stacked together,
It consist of pole cores and pole shoes as shown in figure below [4].
IE
EV
PR
Field winding
The field coils are wound on the poles. There are two types of field windings:
• a: Shunt field winding: large number of turns of small section copper conductor
is used (fine wire), It is connected in parallel with the armature windings [4].
• b: Series field winding: few turns of heavy cross section conductor is used. It is
connected in series with the armature windings, A DC motor may have both field
9
windings wound on the same pole.
• Compound DC motor: motor with both field windings (shunt series) [4].
W
IE
EV
PR
1.1.3 Armature
Armature core: it carries the armature winding, is made of sheet-steel lamination’s. The
lamination’s are stacked together to form a cylindrical structure as shown in figure below
[4].
10
Reproduced with permission of copyright owner. Further reproduction prohibited without permission.