Professional Documents
Culture Documents
BACHELOR OF TECHNOLOGY
in
Electrical Engineering
by
to the
Department of Electrical Engineering
I
CERTIFICATE
II
ABSTRACT
This project presents an autotuning method of the PID controller by using the
artificial neural network for the Brushless Direct Current (BLDC) motor drives. The
BLDC motor has some advantages compared to other types of motors. However, the
nonlinearity of this motor drive characteristics makes it difficult to handle using manual
tuning method of proportional-integral-differential (PID) controllers. In order to
overcome this main problem, an autotuning method of PID controller is introduced. The
controller result obtained is used to train an artificial neural network. This makes the
system to learn and keep getting better with time. This enhances the automaticity and
reliability of the system. The system is first operated using a PID controller to check its
efficiency. It is then operated under a PID controller with variations in operating
conditions. It is done through simulation models and comparison is done between these
two methods. The effectiveness of the proposed method is verified by the simulation
model in MATLAB-Simulink software. The simulation results show that the proposed
Artificial Neural Network, autotune the used PID controller and will provide better
speed control than the speed control by the manual tuning of the PID controller by an
individual.
III
ACKNOWLEDGEMENT
We wish to extend our thanks to teammates for their insightful comments and
constructive suggestions to improve the quality of this work. First and foremost our
utmost gratitude to my supervisor Prof. Kuldeep Sahay for his constant guidance
throughout B. Tech Major Project undertaken during B. Tech Final Year and I am also
thankful to Prof. Seethalakshmi K. Head of Department, Department of Electrical
Engineering, IET Lucknow for their constant support and guidance throughout the
course of my work. His sincerity, thoroughness and perseverance have been a constant
source of inspiration for me. It is only his cognizant efforts that my endeavour has seen
the light of the day. I also want to thank Dr. Shewta for her valuable support. I also do
not like to miss the opportunity to acknowledge the contribution of all faculty members
of the department for their kind assistance and cooperation during the development of
my project. Last but not the least, I acknowledge my friends for their cooperation in
completion of the project.
IV
Table of Content
Topic Page No.
Certificate II
Abstract III
Acknowledgement IV
1.1. Introduction 1
1.3. Scope 2
2.1.1. Proportional 3
2.1.2. Integral 3
2.1.3. Derivative 4
2.1.9. Stability 6
V
3.3. Speed control of BLDC Motor 8
4.2. Types 14
4.3.1. Neurons 14
5.3. Arduino 16
5.4. Microcontroller 17
5.4.1. Raspberry Pi 17
5.5. IR Tachometer 18
6.2. Python 22
VI
CHAPTER 7: IMPLEMENTATION 24-30
CONCLUSION 34
BIBLIOGRAPHY 35
VII
LIST OF FIGURES
VIII
PAGE
FIGURE NO. Description
NO.
Fig 1.1 Structure of PIDNN 2
List of Tables
IX
Page.
Table No. Table
No.
Table 3.1 Comparison between BLDC and other motors 7
LIST OF ABBREVIATION
X
BLDC Brushless Direct Current
DC Direct Current
PID Proportional-Integral-Derivative
P Proportional
PI Proportional-Integral
XI
CHAPTER 1
1.1. INTRODUCTION
The PID controller is by far the most common control algorithm. Today, PID
controllers can be found in virtually all control systems, with applications
ranging from process conditions regulation to precision motion control for
assembly and process automation. The importance of PID controllers cannot be
undermined as they provide the engines to millions of control systems operating
around the world.
Since the number of PID controllers that can be found in industry is so
overwhelming, the tuning of such devices is an important issue. Indeed, this issue
has received significant attention in the literature. Several methods have been
proposed for PID auto-tuning.
PID has wide application in industries due to their versatility and tuning
capabilities. They can be used in many ways: as stand-alone regulators or as a
distributed component of control systems. However tuning the parameter poorly
will deteriorate the performance of PID. We can tune the PID manually but it
may not give promising results every time. The current microprocessor
technology has powerful computation capabilities which provides an alternative
for autotuning of PID controllers. In this project we used auto tuning of PID
controllers using Neural Network. We have used BLDC motors as our plant and
will control the speed of the plant using PID.
1.2. AIM
1
will have hidden layers and their weights will modify until the error reaches
minimum threshold or zero.
The neural network will give the proportional (K p), integral (Ki) and
differential (Kd) constant as output. We will train our model online till the error
becomes zero. When error reaches zero, the output of the neural network will
give the tuned parameter of PID.
For hardware implementation we will take a BLDC motor of 1000 kV. The
motor will be given supply by Poly Lithium battery. We will use 30A ESC to
connect the motor and our microcontroller. The ESC will control the frequency
which in turn controls the speed of the motor. We will use raspberry pi 4 to
implement the neural network and PID. The Pi 4 will take the input as speed
error from the arduino and give the required PWM as output. To measure the
2
speed we will use a tachometer. We will design a tachometer using IR sensors
and an arduino. This measured speed (v) will be the output speed of the plant
which will be used to find the error. (e = V r-v). To adjust the reference speed we
will use 10 kΩ Potentiometer.
1.3. SCOPE
The future scope of this work is automatic speed control of closed loop systems
using Artificial Neural Network. Its scope also includes application of using
BLDC motors in electric vehicles and quadcopters.
3
CHAPTER 2
Controller
Mathematical form
4
The overall control function can be expressed mathematically as:
t
de(t )
u ( t )=K p e ( t )+ K i∫ e ( t ) dt + K d
0 dt
By measuring the position (PV), and subtracting it from the setpoint (SP), the
error (e) is found, and from it the controller calculates how much electric current
to supply to the motor (MV).
2.1.1. Proportional
2.1.2. Integral
An integral term increases action in relation not only to the error but also the
time for which it has persisted. So, if the applied force is not enough to bring the
error to zero, this force will be increased as time passes. A pure "I" controller
could bring the error to zero, but it would be both slow reacting at the start
(because the action would be small at the beginning, needing time to get
significant) and brutal (the action increases as long as the error is positive, even if
the error has started to approach zero).
2.1.3. Derivative
A derivative term does not consider the error (meaning it cannot bring it to
zero: a pure D controller cannot bring the system to its setpoint), but the rate of
5
change of error, trying to bring this rate to zero. It aims at flattening the error
trajectory into a horizontal line, damping the force applied, and so reduces
overshoot (error on the other side because of too great applied force). Applying
too much impetus when the error is small and decreasing will lead to overshoot.
After overshooting, if the controller were to apply a large correction in the
opposite direction and repeatedly overshoot the desired position, the output
would oscillate around the setpoint in either a constant, growing, or decaying
sinusoid. If the amplitude of the oscillations increases with time, the system is
unstable. If they decrease, the system is stable. If the oscillations remain at a
constant magnitude, the system is marginally stable.
The steady-state error is the difference between the desired final output and
the actual one. Because a non-zero error is required to drive it, a proportional
controller generally operates with a steady-state error. Steady-state error (SSE) is
proportional to the process gain and inversely proportional to proportional gain.
6
SSE may be mitigated by adding a compensating bias term to the setpoint and
output or corrected dynamically by adding an integral term.
The contribution from the integral term is proportional to both the magnitude
of the error and the duration of the error. The integral in a PID controller is the
sum of the instantaneous error over time and gives the accumulated offset that
should have been corrected previously. The accumulated error is then multiplied
by the integral gain (Ki) and added to the controller output.
The integral term is given by
t
I out =K i∫ e ( t ) dt
0
The integral term accelerates the movement of the process towards setpoint
and eliminates the residual steady-state error that occurs with a pure proportional
controller. However, since the integral term responds to accumulated errors from
the past, it can cause the present value to overshoot the setpoint value.
2.1.7. Derivative term
7
controllers– because of its variable impact on system stability in real-world
application.
2.1.8. LOOP TUNING
2.1.9. Stability
8
If the PID controller parameters (the gains of the proportional, integral and
derivative terms) are chosen incorrectly, the controlled process input can be
unstable, i.e., its output diverges, with or without oscillation, and is limited only
by saturation or mechanical breakage. Instability is caused by excess gain,
particularly in the presence of significant lag.
Generally, stabilization of response is required and the process must not
oscillate for any combination of process conditions and setpoints, though
sometimes marginal stability (bounded oscillation) is acceptable or desired.
Mathematically, the origins of instability can be seen in the Laplace domain.
The total loop transfer function is:
K ( s ) G(s )
H (s)=
1+ K ( s ) G( s)
9
CHAPTER 3
Speed Control of BLDC Motor
10
4. Higher speed ranges
5. Noiseless operation.
11
3.3. Speed Control of BLDC Motor
12
speed. This helps motor to commutate at appropriate time. Motor speed can be
controlled by either open loop method or closed loop method.
In this method, the actual motor speed does not affect the current speed of
motor. Hence, there is no feed-back mechanism. PWM duty cycle is changed in
order to change the speed of the motor. The advantages of this method is
simplified control algorithm and lower cost of implementation. The disadvantage
of this method is accuracy cannot be maintained and there is no way to track the
actual motor speed.
In this method, the motor speed is continuously measured and tracked and hence
the feed-back mechanism becomes important for speed control. Here both the
reference speed and the actual speed are used to control the motor speed by
changing the PWM duty cycle. The advantages of this method are the minimal
disturbances, system stability as compared with open-loop control and reduced
sensitivity for dynamic load variations.
13
Fig 3.2 Process with Feedback
Fig 3.3
Algorithms used for speed control
14
An algorithm is a set of well-defined instructions in sequence to solve a
problem. It must have following properties:
For the speed control of BLDC Motor following algorithms can be used:
1. Ziegler–Nichols method
2. Cohen–Coon parameters
3. Relay method
4. Genetic Algorithm
5. FUZZY LOGIC
6. Neural Network
15
3. Design Method - Compute the new parameters
16
CHAPTER 4
17
An ANN initially goes through a training phase where it learns to recognize
patterns in data, whether visually, aurally, or textually. During this supervised
phase, the network compares its actual output produced with what it was meant
to produce—the desired output. The difference between both outcomes is
adjusted using backpropagation. This means that the network works backward,
going from the output unit to the input units to adjust the weight of its
connections between the units until the difference between the actual and desired
outcome produces the lowest possible error.
4.2. TYPES
ANNs have evolved into a broad family of techniques that have advanced
the state of the art across multiple domains. The simplest types have one or more
static components, including number of units, number of layers, unit weights and
topology. Dynamic types allow one or more of these to evolve via learning. The
latter are much more complicated, but can shorten learning periods and produce
18
better results. Some types allow/require learning to be "supervised" by the
operator, while others operate independently. Some types operate purely in
hardware, while others are purely software and run on general purpose
computers.
Some of the main breakthroughs include: convolutional neural networks
that have proven particularly successful in processing visual and other two-
dimensional data; long short-term memory avoid the vanishing gradient problem
and can handle signals that have a mix of low and high frequency components
aiding large-vocabulary speech recognition, text-to-speech synthesis, and photo-
real talking heads;] competitive networks such as generative adversarial networks
in which multiple networks (of varying structure) compete with each other, on
tasks such as winning a game or on deceiving the opponent about the authenticity
of an input.
4.3.1. Neurons
19
4.3.2. Connections and weights
The propagation function computes the input to a neuron from the outputs
of its predecessor neurons and their connections as a weighted sum. A bias term
can be added to the result of the propagation.
CHAPTER 5
Hardware
20
Fig 5.1 Proposed Hardware Structure
As per the circuit mentioned above, the major component used in the
project are Arduino, ESC (Electronic Speed Controller), BLDC (Brushless DC)
motor, IR Tachometer, Battery and connecting wires.
LiPo (Lithium Polymer) batter is used to supply power to the whole project,
which is directly connected to the ESC unit. Here ESC unit is taking control
signal form the Arduino and varying the voltage level given to the BLDC motor
in order to control the speed of the BLDC motor.
Neural network has been uploaded in the Raspberry Pi microcontroller. All
the data and feedback is given to it which calcite the value of Kp, Ki, Kd and
generate signal which reaches ESC and works as control signal for it.
IR Tachometer is connected with the BLDC motor and it tells neural
network the current position of the motor this helps neural network to decide
which winding is to energised and for what time.
21
In our project BLDC motor is acting like a plant for our PID controller. The
output values will of ANN will give the PID parameters and these parameters
will be used to control the speed of motor.
5.3. Arduino
In our project we use the Arduino Mega as an interface between the python
and ESC. The output of our ANN is PWM which needs to be given to ESC for
speed control. This output is given to arduino mega through serial
communication and which is further given to ESC using servo library.
5.4. Microcontroller
22
A microcontroller is a small computer on a single metal-oxide-
semiconductor (MOS) integrated circuit (IC) chip. Microcontrollers are used
in automatically controlled products and devices, such as automobile engine
control systems, implantable medical devices, remote controls, office machines,
appliances, power tools, toys and other embedded systems. By reducing the size
and cost compared to a design that uses a separate microprocessor, memory, and
input/output devices, microcontrollers make it economical to digitally control
even more devices and processes. Mixed signal microcontrollers are common,
integrating analog components needed to control non-digital electronic systems.
In the context of the internet of things, microcontrollers are an economical and
popular means of data collection, sensing and actuating the physical world
as edge devices. In this Raspberry pi microcontroller is being used
5.4.1 Raspberry Pi
23
Fig 5.4 Raspberry Pi
5.4. IR Tachometer
24
speed in rpm using this frequency. The calculated speed is send to python
through serial communication for input to ANN.
Fig 5.5 IR
Tachometer
25
switching includes FETs. The BEC is a separation of the electronic speed control
that will transmit power back to your receiver after that to servos.
In our project ESC is providing variable voltage to the BLDC motor used
in the project. ESC gets a pulse signal from the Raspberry Pi through arduino
mega. ESC has MOSFET which also works as a voltage chopper in the project. It
reduces and increases the voltage level by changing the firing angle.
26
LiPo is used to power the whole set up of experiment. We are using 3S type
batteries each of which has 3.7 volts. It current rating is 2200mAh
CHAPTER 6
Software
27
and programming. It combines a desktop environment tuned for iterative
analysis and design processes with a programming language that expresses
matrix and array mathematics directly. It includes the Live Editor for creating
scripts that combine code, output, and formatted text in an executable notebook.
It is a high-level language for numerical computation, visualization and
application development and it also provides an interactive environment for
iterative exploration, design and problem solving.
28
6.2 Python
CHAPTER 7
Implementation
29
7.1. Architecture (Manual Tuning)
In the above Simulink model manual tuning of BLDC motor is done. For
this manually tuned PID Block is used which takes difference of reference speed
and current speed as input and generate a pulse in order to control the controlled
voltage source. This controlled voltage is given to the 3 phase inverter. The firing
angle of MOSFET is controlled by the gate signal given by decoder which is
detecting the position of rotor using Hall Effect Transducer. In this way the
correct winding is energized at correct time to get required speed and torque.
PID controller: This block is only used for manual tuning. We set the values of PID
parameters and input them along with error in reference speed and actual speed. The
output of this block is controlled voltage which is given to control voltage source block.
30
bundled and contains the Hall sensor output, stator current, rotor speed in rad/s, and
torque produced by the motor.
3-Phase Inverter Block: The 3-phase supply for the motor is provided by a 3-phase
inverter. It takes DC voltage and gate pulses as input. The block models a standard two-
leg, three-level inverter model.
31
7.3 Architecture (Auto-Tuning using ANN)
In the above Simulink model auto-tuning of BLDC motor is done. For this
Neural Network Block is used which takes current speed (present and last 2
values), reference speed, previous pulse given to voltage source, difference of
reference speed and current speed (present and last 2 values) as input and
generate a pulse in order to control the PID Block. This PID Block generate pulse
signal given to the controlled voltage source. This controlled voltage is given to
the 3 phase inverter. The firing angle of MOSFET is controlled by the gate signal
given by decoder which is detecting the position of rotor using Hall Effect
Transducer. In this way the correct winding is energized at correct time to get
required speed and torque.
32
reference speed and errors (along with delayed values up to two time cycles) The
delayed values of errors are used in backpropagation algorithm. Initial random
weights are also given to the block. The output is the kp ki and kd which is then
fed to the varying PID controller. The block also outputs the updated weights to
measure the adaptation of the controller on varied operating conditions.
PID controller: This block is only used for manual tuning. We set the values of
PID parameters and input them along with error in reference speed and actual
speed. The output of this block is controlled voltage which is given to control
voltage source block.
3-Phase Inverter Block: The 3-phase supply for the motor is provided by a 3-
phase inverter. It takes DC voltage and gate pulses as input. The block models a
standard two-leg, three-level inverter model.
In manual tuning, we have to tune the PID Controller for every time for
different values of Reference Speed and Load Torque whereas in auto-tuning
the Neural Network is trained it itself changes the value of PID Controller for
different value of Reference Speed and Load Torque.
Manual tuning takes more time in tuning whereas auto-tuning does it
quickly.
33
Accuracy in Manual tuning reduces but accuracy of auto-tuning is high.
Manual tuning is used where constant performance by motor is needed and
less precision required whereas auto-tuning is used where variable
performance and precise speed is required.
34
Ki = 5.0893
Kd = 0.038472e-2
In above graph the motor is running from 0 RPM to 2000 RPM (Reference
Speed). When motor reaches its minimum running speed, a peak is generated
at 1000 RPM and then again the speed increases and motor reaches the 99%
speed within 0.25 seconds.
35
Fig 7.5 Auto-Tuning using ANN (hardware implementation)
BLDC (Brushless DC) Motor: We use a 1000KV BLDC motor. The motor is
powered by a Poly-Lithium battery through ESC.
ESC (Electronic Speed Controller): ESC module (30A ESC) is providing the
variable voltage to the Motor. The input of ESC is given by computer through
Arduino Mega.
Arduino: One arduino is used for interfacing the motor with a computer
(Arduino Mega). The other one is used for measuring the speed of motor
(Arduino Uno).
Li-Po Battery: A 3S type battery, each cell with 3.7 volts rating is used to power
the whole setup. The current rating of this battery is 2200mAh.
36
7.5 Simulation Result
The mean of output speed in the above graph is 7117 rpm. (Ref speed =
7000rpm)
The values of PID parameters are-
Kp = .47783
Ki = 1.3656
Kd = 1.7949
37
CONCLUSION
Artificial Neural Network has its own advantages and disadvantages, but
its disadvantages like unexplained behaviour of the network, determination of
proper network structure etc are getting eliminated one by one, and their
advantages are increasing day by day. It means that ANN has become an
indispensable part of our lives increasingly important. Here we used the
autotuning of PID controllers using Artificial Neural Networks and then used the
same PID controller to control the speed of the BLDC motor.
The PID controller has only three parameters to adjust. In this we have done the
two parts- simulation and hardware implementation. In the simulation part, we
have trained the model online in such a way so that the error becomes nearly
zero, and the output of the neural network will give the tune parameter of PID.
For hardware purposes we tried to train ANN with real time data. We acquire and
send data using microcontrollers. Microcontrollers act as an interface between
our plant (motor) and ANN (in python). We also built our own tachometer for
speed measurements
For a more robust control of the BLDC motor and to fine tune the desired
output, an agent is used to achieve this goal in an uncertain potentially complex
environment. This mechanism of reinforcement learning can be done through
artificial neural networks.
Manual
1. 5000 RPM 0.018 30 0.0005
Tuning
38
Table 7.1 Result
BIBLIOGRAPHY
[1] S. Skogestad, 2000. Probably the Best Simple PID Tuning Rules in the World,
Journal of Process Control, September 2000, pp. 1-28.
[2] Laurene Fausett, 2004. Fundamentals of Neural Networks.
[3] C. Sheeba Joice, P. Nivedhitha, 2014. Simulation of Speed Control of Brushless
DC Motor,, International Journal of Electrical, Electronics and Data
Communication, ISSN: 2320-2084, Vol. 2, Issue 4, pp. 24-29, April 2014.
[4] J. Wang and B. Malakooti, “On training of artificial neural networks,” in Proc.
1989 Int. Joint Conk Neural Networks, vol. 2, 1989.
[5] A. Noregia Ponce, A. Aguado Behar, A. Ordaz Hernandez, V. Rauch Sitar.
”Neural Networks for Self-tuning Control Systems”, Acta Polytechnica
Vol.44,2004.
[6] Tayfun Gundogdu and Guven Komurgoz,” Self-Tuning PID Control of a
Brushless DC Motor by Adaptive Interaction”. IEEJ Transactions on Electrical
and Electronic Engineering,2014.
[7] Jagganathan Sarangapani, 2016. Neural Network Control of Nonlinear Discrete-
Time Systems, CRC Press.
[8] I E. Levin, R. Gewirtzman, and G. F. Inbar, “Neural network architecture for
adaptive system modeling and control,” in Proc. 1989 lnt. Joint Conk NeuraI
Networks, vol. 2.
[9] J. Kang, W. Meng , A. Abraham and H. Liu, An adaptive PID neural network
for complex nonlinear system control, Neuro computing.
[10] Changliang Xia, Zhiqiang Li, and Tingna Shi, ”A Control Strategy for Four-
Switch Three-Phase Brushless DC Motor Using Single Current Sensor”, IEEE
Transactions On Industrial Electronics, Vol. 56, No. 6, June 2009.
[11] Cui X., Shin K. G.: “Direct Control and Coordination Using Neural Networks.”
IEEE Transactions on Systems, Man and Cybernetics, Vol.23(1992).
[12] Bhat N., McAvoy T.J.: “Use of Neural Nets for Dynamic Modelling and Control
of Chemical Process Systems.” Computers on Chem. Engineering.
39