Вы находитесь на странице: 1из 40

Senior Design 2

THAI NGUYEN UNIVERSITY OF TECHNOLOGY


FACULTY OF INTERNATIONAL TRAINING

REPORT OF PROJECT II
SETTING THE PID COEFICIENT FOR
SPEED CONTROL OF DC MOTOR USING
PARTICLE SWARM OPTIMIZATION

SUPERVISOR : NGUYỄN MINH Y,Ph.D


STUDENT ID : 1. LÊ MỸ ANH
- K145520320005
2. QUYỀN VĂN TOÁN
- K145520201228
CLASS : K50APE

Thai Nguyen, August 2018

Supervisor: Nguyen Minh Y Page 1


Senior Design 2

Acknowlegement
First of all We would like to express our special thanks of gratitude to our
lecture Mr.Nguyen Minh Y, who gave us the opportunity to explore an interesting
field of power engineering.
Who also helped us in completing our project. We came to know about so
many new things We are really thankful to them.
Secondly We would also like to thank our parents and friends who helped
us a lot in finalizing this project within the limited time frame

Supervisor: Nguyen Minh Y Page 2


Senior Design 2

Contents
ACKNOWLEGEMENT .................................................................................................................................................................................. 2
ABSTRACTS.................................................................................................................................................................................................... 4
CHAPTER 1: INTRODUCTION.............................................................................................................................. 5
1.1 INTRODUCTION TO THE PROJECT ......................................................................................................................................... 5
1.2 MOTIVATION ................................................................................................................................................................................ 6
1.3 CONTRIBUTION ............................................................................................................................................................................ 6
1.4 REVIEW........................................................................................................................................................................................... 6
CHAPTER 2: BACKGROUND ................................................................................................................................ 7
2.1 DC MOTOR .................................................................................................................................................................................... 7
2.1.1 Operating principle of DC Motor .......................................................................................................... 7
2.1.3 Construction of DC Motor ..................................................................................................................... 9
2.2 H-BRIDGE CIRCUIT ..................................................................................................................................................................... 9
2.2.1 General ................................................................................................................................................... 9
2.2.2 Operation.............................................................................................................................................. 10
2.3 PROPORTINAL INTEGRAL (PID) CONTROLLER ...........................................................................................................12
2.4 PULSE WIDTH MODULATION (PWM) ....................................................................................................... 16
2.4.1 Duty cycle ............................................................................................................................................. 16
2.5 PARTICAL SWARM OPTIMIZATION (PSO) ................................................................................................ 18
2.5.1 Introduction ......................................................................................................................................... 18
2.5.2 The Algorithm ...................................................................................................................................... 19
CHAPTER 3: SYSTEM AND CONTROL DESIGN ............................................................................................ 24
3.1 HARDWARE .................................................................................................................................................................................24
3.1.1 Hardware Block Diagram.................................................................................................................... 24
3.1.2.2 Controller (Arduino MEGA 2560) ............................................................................................................ 25
3.1.2.3 Motor Driver (L298N) ................................................................................................................................ 26

CHAPTER 4 : SIMULATION AND EXPERIMENT ........................................................................................... 31


4.3 RESULTS .......................................................................................................................................................................................36
CHAPTER 5 : CONCLUSION AND FUTURE WORK....................................................................................... 38
5.1 CONCLUSION ............................................................................................................................................ 38
5.2 FUTURE WORK ......................................................................................................................................... 38
REFERENCE ........................................................................................................................................................... 39
APPENDIX ............................................................................................................................................................... 40

Supervisor: Nguyen Minh Y Page 3


Senior Design 2

Abstracts
The aim of this work is to design a speed controller of a DC motor by selection of
PID parameters using bio-inspired optimization technique i.e. Particle Swarm
Optimization (PSO). Here, model of a DC motor is considered as a second order
system for armature voltage control method of speed control. In this work bio-
inspired optimization technique in controllers and their advantages over
conventional methods is discussed using ARUDINO, MATLAB/Simulink.
Aiming at the problem that it is difficult to confirm the parameters of the
PID controller and the parameters can not be changed once identified, an
intelligent PID control method is proposed. According to the size of the system
error, this algorithm controls the system with different subsections of different
parameters, by using the particle swarm optimization (PSO) to optimize the
parameters of the PID controller to solve the problems, such as lag, time-variety
and nonlinearity. A new evaluation function including the system adjusting time,
rise time, over-shoot, and system error is defined. A group of parameters of the
PID controller that minimize the evaluation function is calculated rapidly by
searching in the given controller parameters area. Numerical simulations show that
the controller can easily be applied to the first-order and second-order systems with
time delay and its performance is also better than the classic PID optimized by
PSO.

Supervisor: Nguyen Minh Y Page 4


Senior Design 2

CHAPTER 1: INTRODUCTION

1.1 Introduction to the project


In spite of the development of power electronics resources, the direct current
machine became more and more useful. Nowadays their uses isn‟t limited in the car
applications (electrics vehicle), in applications of weak power using battery system
(motor of toy) or for the electric traction in the multi-machine systems too.
The speed of DC motor can be adjusted to a great extent as to provide
controllability easy and high performance. The controllers of the speed that are
conceived for goal to control the speed of DC motor to execute one variety of
tasks, is of several conventional and numeric controller types, the controllers can
be: PID Controller, Fuzzy Logic Controller; or the combination between them:
Fuzzy-Neural Networks, Fuzzy-Genetic Algorithm, Fuzzy Ants Colony, Fuzzy-
Swarm,..

Supervisor: Nguyen Minh Y Page 5


Senior Design 2

1.2 Motivation
Intrinsically motivated particle swarm optimisation can be used for adaptive
task allocation when the nature of the target task is not well understood in advance,
or can change over time. We first present a general framework in which a
computational model of motivation generates a dynamic fitness function to focus
the attention of the particle swarm.
1.3 Contribution
The main contributions are the optimization approach based on the
minimization of an objective (cost) function based on different indexes including
the Harris index, and the on-line serialization of the parallel PSO optimization
scheme.
Over the last few years, particle swarm optimization (PSO) has been
extensively applied in various geotechnical engineering including slope stability
analysis. However, this contribution was limited to two-dimensional (2D) slope
stability analysis.
1.4 Review
PID controller with its three terms functionality covering treatment for transient
and steady-state response offers the simplest and gets most efficient solution to
many real world control problems. In spite of the simple structure, optimally
tuning gains of PID controllers are quite difficult. Recently, the computational
intelligence has proposed Particle Swarm Optimization (PSO) technique for the
same purpose.
To search the optimal PID controller, the PSO algorithm is applied. Here the
potential solutions called particles, where it is metaphor of fish in fish schools or
bird in bird flocks. These particles are randomly initialized and fly through multi-
dimensional space. During the flying, these particles update its velocity and
position based on the experience of its own and the whole population.
The updating procedure will drive the particle swarm to move toward region with
better fitness function and every particle is gathered around the point with the best
fitness functions. In the proposed PSO method each particle contains three
members kp, ki and kd. It means that the search space has three dimensions and
particles must fly in a three dimensional space.

Supervisor: Nguyen Minh Y Page 6


Senior Design 2

CHAPTER 2: BACKGROUND
2.1 DC motor

A motor is a class of electrical machines that converts electrical power to


mechanical power. A DC motor uses direct current for conversion of electrical
energy to mechanical energy.
2.1.1 Operating principle of DC Motor
A common actuator in control systems is the DC motor. It directly provides
rotary motion and, coupled with wheels or drums and cables, can provide
translational motion. The electric equivalent circuit of the armature and the free-
body diagram of the rotor are shown in the
following figure.
The physical parameters are:

 (J) moment of inertia of the rotor kg.m2


 (b) motor viscous friction constant N.m.s
 (Ke) electromotive force constant V/rad/s
 (Kt) motor torque constant N.m/Amp
 (R) electric resistance Ohm
 (L) electric inductance H

2.1.2 Equivalent circuit diagram of DC motor


In general, the torque generated by a DC motor is proportional to the
armature current and the strength of the magnetic field. In this example we
will assume that the magnetic field is constant and, therefore, that the motor
torque is proportional to only the armature current i by a constant factor Kt
as shown in the equation below. This is referred to as an armature-
controlled motor.
T = Kt i
The back emf, e, is proportional to the angular velocity of the shaft by a
constant factor Ke.

Supervisor: Nguyen Minh Y Page 7


Senior Design 2


.
e  Ke

In SI units, the motor torque and back emf constants are equal, that is, Kt
= Ke; therefore, we will use K to represent both the motor torque constant
and the back emf constant.
We can derive the following governing equations based on Newton's 2nd
law and Kirchhoff's voltage law.

.. .
J   b  Ki
di .
L  Ri  V  K
dt

 Transfer Function
Applying the Laplace transform, the above modeling equations
can be expressed in terms of the Laplace variables.

s(Js + b)  (s) = KI (s)


(Ls + R)I (s) = V (s) - Ks  (s)
We arrive at the following open-loop transfer function by eliminating
I(s) between the two above equations, where the rotational speed is
considered the output and the armature voltage is considered the input.

(s)
. 

P(s)   
K  rad / sec
 

V (s) (Js  b)(Ls  R)  K 


2
V 

 State-Space
In state-space form, the governing equations above can be expressed
by choosing the rotational speed and electric current as the state variables.
Again the armature voltage is treated as the input and the rotational speed
is chosen as the output.

Supervisor: Nguyen Minh Y Page 8


Senior Design 2

K . 
 .    b  
J    1 V
0 
d    J
dt  i   K R   i   
       L 
L 
 L

 .
y  1 0 
i 



2.1.3 Construction of DC Motor


Every DC motor consist of 6 parts:
1. Stator,
2. field magnet
3. Rotor
4. Commutator
5. Field windings
6. Brushes

2.2 H-bridge circuit


2.2.1 General
An H bridge is an electronic circuit that enables a voltage to be applied
across a load in either direction, containing four switching element, with the load at
the center, in an H-like configuration.
These circuits are often used in robotics and other applications to allow DC
motors to run forwards and backwards. The switching elements (Q1, Q2, Q3, Q4)
can be relay, BJT or MOSFET. The diodes (D1..D4) are called catch diodes and
are usually of a Schottky type.

Supervisor: Nguyen Minh Y Page 9


Senior Design 2

Fig.1 H-bridge
The top-end of the bridge is connected to a power supply (battery for
example) and the bottom-end is grounded. In general all four switching elements
can be turned on and off independently, though there are some obvious restrictions.
Most DC-to-AC converters (power inverters), most AC/AC converters, the
DC-to-DC push–pull converter, most motor controllers, and many other kinds of
power electronics use H bridges. In particular, a bipolar stepper motor is almost
invariably driven by a motor controller containing two H bridges.

2.2.2 Operation
The basic operating mode of an H-bridge is fairly simple: if Q1 and
Q4 are turned on, the left lead of the motor will be connected to the power
supply, while the right lead is connected to ground.
Current starts flowing through the motor which energizes the motor
in the forward direction and the motor shaft starts spinning as illustrated in
Fig 1 .

If Q2 and Q3 are turned on, the reverse will happen, the motor gets
energized in the reverse direction, and the shaft will start spinning
backwards as illustrated in Figure 2.

Supervisor: Nguyen Minh Y Page 10


Senior Design 2

Fig2: The current of H-Bridge Q1 and Q4 or Q2 and Q3 are turned on.

In a bridge, you should never ever close both Q1 and Q2 (or Q3 and Q4) at
the same time. If you did that, you just have created a really low-resistance path
between power and GND, effectively short-circuiting your power supply. This
condition is called „shoot-through‟ and is an almost guaranteed way to quickly
destroy your bridge, or something else in your circuit.

The current of H-Bridge Q1 and Q2 or Q4 and Q3 are turned on.

Supervisor: Nguyen Minh Y Page 11


Senior Design 2

2.3 Proportinal Integral (PID) Controller


A typical structure of a PID system is shown, where it can be seen that in a PID
controller, the error signal e(t) is used to generate the proportional, integral, and
derivative actions, with the resulting signals weighted and summed to form the
control signal u(t) applied to the plant model. A mathematical description of the
PID controller is:

A typical PID control structure



d
u(t)  MV (t)  K pe(t)  Ki e( )d  Kd e(t)
0
dt

 Kp is the proportional gain, a tuning parameter


 Ki is the integral gain, a tuning parameter
 Kd is the derivative gain, a tuning parameter,
 e(t) = SP- PV(t) is the error (SP is the setpoint, and PV(t) is the process
variable),
 t is the time or instantaneous time (the present),
 ґ is the variable of integration (takes on values from time 0 to the present t).
• Proportional term.
The proportional term produces an output value that is proportional to the
current error value. The proportional response can be adjusted by multiplying the
error by a constant Kp, called the proportional gain constant.

The proportional term is given by:


Pout  K pe(t)

Supervisor: Nguyen Minh Y Page 12


Senior Design 2

A high proportional gain results in a large change in the output for a given
change in the error. If the proportional gain is too high, the system can become
unstable (see the section on loop tuning). In contrast, a small gain results in a small
output response to a large input error, and a less responsive or less sensitive
controller. If the proportional gain is too low, the control action may be too small
when responding to system disturbances. Tuning theory and industrial practice
indicate that the proportional term should contribute the bulk of the output change.

• 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  Ki  e( )d
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

Supervisor: Nguyen Minh Y Page 13


Senior Design 2

controller. However, since the integral term responds to accumulated errors from
the past, it can cause the present value to overshoot the setpoint value (see the
section on loop tuning).
 Derivative term
The derivative of the process error is calculated by determining the slope of the
error over time and multiplying this rate of change by the derivative gain Kd. The
magnitude of the contribution of the derivative term to the overall control action is
termed the derivative gain, Kd.

The derivative term is give by:


de(t)
Dout  Kd
dt

Derivative action predicts system behavior and thus improves settling time and
stability of the system. An ideal derivative is not causal, so that implementations of
PID controllers include an additional low-pass filtering for the derivative term to
limit the high-frequency gain and noise. Derivative action is seldom used in
practice though – by one estimate in only 25% of deployed controllers–because of
its variable impact on system stability in real-world applications

Supervisor: Nguyen Minh Y Page 14


Senior Design 2

 Manual tunning
If the system must remain online, one tuning method is to first set Ki and Kd
values to zero. Increase the Kp until the output of the loop oscillates, then the Kp
should be set to approximately half of that value for a "quarter amplitude decay"
type response. Then increase Ki until any offset is corrected in sufficient time for
the process. However, too much Ki will cause instability. Finally, increase Kd, if
required, until the loop is acceptably quick to reach its reference after a load
disturbance. However, too much Kd will cause excessive response and overshoot.
A fast PID loop tuning usually overshoots slightly to reach the setpoint more
quickly; however, some systems cannot accept overshoot, in which case an
overdamped closed-loop system is required, which will require a Kp setting
significantly less than half that of the Kp setting that was causing oscillation.
Effects of increasing a parameter indepedently

Supervisor: Nguyen Minh Y Page 15


Senior Design 2

2.4 Pulse width modulation (PWM)


2.4.1 Duty cycle
A duty cycle is the fraction of one period in which a signal or system is
active.Duty cycle is commonly expressed as a percentage or a ratio. A period is the
time it takes for a signal to complete an on-and-off cycle. As a formula, a duty
cycle (%) may be expressed as:
PW
D 100%
T

where D is the duty cycle, PW is the pulse width (pulse active time), and T
is the total period of the signal. Thus, a 60% duty cycle means the signal is on
60% of the time but off 40% of the time. The "on time" for a 60% duty cycle could
be a fraction of a second, a day, or even a week, depending on the length of the
period.

Duty cycles can be used to describe the percent time of an active signal in an
electrical device such as the power switch in a switching power supply or the firing
of action potentials by a living system such as a neuron.The duty factor for
periodic signal expresses the same notion, but is usually scaled to a maximum of
one rather than 100%
The duty factor for periodic signal expresses the same notion, but is usually
scaled to a maximum of one rather than 100%.

Supervisor: Nguyen Minh Y Page 16


Senior Design 2

Various duty cycle waveforms

 Electrical & Electronic


In electronics, duty cycle is the percentage of the ratio of pulse duration, or
pulse width (PW) to the total period (T) of the waveform. It is generally used to
represent time duration of a pulse when it is high (1). In digital electronics, signals
are used in rectangular waveform which are represented by logic 1 and logic 0.
Logic 1 stands for presence of an electric pulse and 0 for absence of an electric
pulse. For example, a signal (10101010) has 50% duty cycle, because the pulse
remains high for 1/2 of the period or low for 1/2 of the period. Similarly, for pulse
(10001000) the duty cycle will be 25% because the pulse remains high only for 1/4
of the period and remains low for 3/4 of the period. Electrical motors typically use
less than a 100% duty cycle. For example, if a motor runs for one out of 100
seconds, or 1/100 of the time, then, its duty cycle is 1/100, or 1 percent.
Pulse-width modulation (PWM) is used in a variety of electronic situations,
such as power delivery and voltage regulation.

Supervisor: Nguyen Minh Y Page 17


Senior Design 2

In electronic music, music synthesizers vary the duty cycle of their audio-
frequency oscillators to obtain a subtle effect on the tone colors. This technique is
known as pulse-width modulation.
• Biological systems
The concept of duty cycles is also used to describe the activity of neurons
and muscle fibers. In a biological neural network for example, a duty cycle
specifically refers to the proportion of a cycle period in which a neuron remains
active.
• Generation
One way to generate fairly accurate square wave signals with 1/n duty factor,
where n is an integer, is to vary the duty cycle until the nth-harmonic is
significantly suppressed. For audio-band signals, this can even be done "by ear";
for example, a -40dB reduction in the 3rd harmonic corresponds to setting the duty
factor to 1/3 with a precision of 1% and -60 dB reduction corresponds to a
precision of 0.1%.
2.5 Partical swarm optimization (PSO)
2.5.1 Introduction
In computational science, particle swarm optimization (PSO) is a
computational method that optimizes a problem by iteratively trying to improve a
candidate solution with regard to a given measure of quality.
Particle Swarm Optimization might sound complicated, but it's really a very
simple algorithm. Over a number of iterations, a group of variables have their
values adjusted closer to the member whose value is closest to the target at any
given moment. Imagine a flock of birds circling over an area where they can smell
a hidden source of food. The one who is closest to the food chirps the loudest and
the other birds swing around in his direction. If any of the other circling birds
comes closer to the target than the first, it chirps louder and the others veer over
toward him. This tightening pattern continues until one of the birds happens upon
the food. It's an algorithm that's simple and easy to implement.
The algorithm keeps track of three global variables:
 Target value or condition
 Global best (gBest) value indicating which particle's data is currently closest
to the Target

Supervisor: Nguyen Minh Y Page 18


Senior Design 2

 Stopping value indicating when the algorithm should stop if the Target isn't
found
Each particle consists of:
 Data representing a possible solution
 A Velocity value indicating how much the Data can be changed
 A personal best (pBest) value indicating the closest the particle's Data has
ever come to the Target.

2.5.2 The Algorithm


 Algorithm parameters
A : Population of agents
pi : Position of agent ai in the solution space
f : Objective function
vi : Velocity of agent‟s ai
V(ai) : Neighborhood of agent ai (fixed)
 Algorithm
[x*] = PSO()
P = Particle_Initialization();
For i=1 to it_max
For each particle p in P do
fp = f(p);
If fp is better than f(pBest)
pBest = p;
end
end5
gBest = best p in P;
For each particle p in P do
v = v + c1*rand*(pBest – p) + c2*rand*(gBest – p);

Supervisor: Nguyen Minh Y Page 19


Senior Design 2

p = p + v;
end
end
where p: particle‟s position
v: path direction
c1: weight of local information
c2: weight of global information
pBest: best position of the particle
gBest: best position of the swarm
rand: random variable
1. Create a „population‟ of agents (particles) uniformly distributed over X.
2. Evaluate each particle‟s position according to the objective function.
3. If a particle‟s current position is better than its previous best position, update
it.
4. Determine the best particle (according to the particle‟s previous best
positions).
5. Update particles velocities:

vi (t 1)  vi (t)  c1r1[xi (t)  xi (t)]  c2 r2 [g(t)  xi (t)]
 i is the partical index
  is the inertial coefficient 0 ≤ c1, c2 ≤ 2
 r1, r2 are random values ( 0 ≤ r1, r2 ≤ 1)regenerated every
velocity update
 vi (t) is the particle‟s velocity at time t
 xi (t) is the particle‟s position at time t


 xi (t) is
the particle‟s individual best solution as of time t
 g(t) is the swarm‟s best solution as of time t
  Inertia coefficient usually between 0.8 and 1.2
 Cognitive coefficient c1
 Social coefficient c2
 Update position:
xi (t 1)  xi (t)  vi (t 1)

Supervisor: Nguyen Minh Y Page 20


Senior Design 2

6. Go to step 2 until stopping criteria are satisfied

2.5.3 Examples

Supervisor: Nguyen Minh Y Page 21


Senior Design 2

A particle swarm searching for the global minimum of a function

Supervisor: Nguyen Minh Y Page 22


Senior Design 2

2.5.4 Advantages and Disadvantages.


 Advantages
 Insensitive to scaling of design variables
 Simple implementation
 Easily parallelized for concurrent processing
 Derivative free
 Very few algorithm parameters
 Very efficient global search algorithm

 Disadvantages
 Tendency to a fast and premature convergence in mid optimum points
 Slow convergence in refined search stage (weak local search ability)

Supervisor: Nguyen Minh Y Page 23


Senior Design 2

CHAPTER 3: SYSTEM AND CONTROL DESIGN


3.1 Hardware
3.1.1 Hardware Block Diagram

PSO

PID

Power Motor DC
Supply Controller
Driver Motor

3.1.2 Block diagram Description


3.1.2.1 15V, 3 Amp Single Output Switching Power Supply

 Specifications:
 Case Size: 111 x 78 x 36mm
 Input Frequency: 50-60Hz
 15V Power Supply
 3A Single Output
 AC: 110/220V
 Power 45W
 Protection: Overload |
Overpressure Short circuit.
 Cooling: air convection
 Safety Compliance: CCC / FCC /
CE
 Working temperature: 0 ~ 40 ° C
 Storage temperature: -20 ~ 60 ° C
 Environmental humidity: 0 ~ 95%

Supervisor: Nguyen Minh Y Page 24


Senior Design 2

3.1.2.2 Controller (Arduino MEGA 2560)

 Technical specifications
Microcontroller ATmega 2560
Operating Voltage 5V
Input Voltage 7-12V
(recommended)
Input Voltage (limit) 6-20V
Digital I/O pins 54(of which 15 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 20mA
DC Current for 3,3V Pin 50mA
Flash Memory 256kB of which 8kB used by
bootloader
SRAM 8kB
EEPROM 4kB
Clock Speed 16MHz
LED_BUILTIN 13
Length 101,52mm
Width 53.3mm
Weight 37g

Supervisor: Nguyen Minh Y Page 25


Senior Design 2

3.1.2.3 Motor Driver (L298N)


L298N Motor Driver IC is used in this project to drive the motors of the
robot. It receives signals from Arduino.
 Specifications:
 Module name : dual H bridge motor
drive module
 Work mode : H bridge drive (double
road)
 Main control chip : L298N
 Packaging : electrostatic bag
 Logical voltage : 5V
 Drive voltage : 5v-35v
 Logical current : 0mA-36mA
 Driving current : 2A(MAX single
bridge)
 Maximum power : 25W
 Weight : 30 g
 Peripheral dimensions : 43*43*27mm

Supervisor: Nguyen Minh Y Page 26


Senior Design 2

3.1.2.4 334 Pulse Encoder Motor + RP463 RPM Reducer 1: 9

DC Motor Gear Encoder 334 pluse

Disk 334 pluse

Supervisor: Nguyen Minh Y Page 27


Senior Design 2

Motor has 6 wires corresponding to 6 colours. Each colour has a


function, described below a figure.

VCC 5V (blue)
GND (green)

Motor Channel A (white)


Channel B (yellow)
Motor + (red)
Motor – (black)

DC motor power and encoder supply physical completely isolated, the only
the encoder power, hand rotating motor, can output AB phase square wave, can not
only determine the speed, can also determine the rotation moment direction. With
the principle can the motor as the encorder to use, the motor shaft connecting other
devices and follow up rotation. And motor or motor voltage range is very wide and
divided into positive and negative, polarity, in turn, ontrolling the motor to rotate
reversely 12V can work (the higher the voltage, the faster the rotational speed, or
with the PWM duty ratio control, and motor connected with the PWM drive ). But
the requirements are high, the requirements of voltage regulators, positive and
negative polarity is absolutely not wrong.

Supervisor: Nguyen Minh Y Page 28


Senior Design 2

3.2 Flowchart
 Flowchart of PSO

Supervisor: Nguyen Minh Y Page 29


Senior Design 2

 Flowchart of my project

Supervisor: Nguyen Minh Y Page 30


Senior Design 2

CHAPTER 4 : SIMULATION AND EXPERIMENT


4.1 Simulation
 Simulation on PID theory

Supervisor: Nguyen Minh Y Page 31


Senior Design 2

 Case 1: We put both Kp = 2 ; Ki = 0.2 ; Kd = 0.2 and the result is


shown in the picture

 Case2 : We put Kp = 0.5 ; Ki = 2 ; Kd = 0.1 and the result is shown


in the picture. This picture shows how Kp , Ki coefficients affect to
the output signal without Kd

Supervisor: Nguyen Minh Y Page 32


Senior Design 2

 Case 3: We choose randomly Kp = 5 ; Ki = 1; Kd = 0 and the result


is shown in the picture

 PSO-PID tunning

Supervisor: Nguyen Minh Y Page 33


Senior Design 2

4.2 Speed control of DC motor


4.2.1 Speed control of DC motor using PWM

This is an effective method to control the o/p voltage with constant


frequency This is a modulation of pulses by varying the duty cycle

Duty cycle (α) is a ratio of Ton /(Ton +Toff )

The width of pulses (T) determines the amount of avg. voltage applied to
motor terminals.

Height of pulse gives Average voltage.

Pulse Width Modulation (PWM) is a method for binary signals generation.It


has 2 signal periods (high and low). The width (W) of each pulse varies between 0
and the period (T). The main principle is control of power by varying the duty
cycle. The average voltage at output is given by

Va = α Vmax Where, α= Ton /(Ton +TOff )

TON =Time period for Pulse ON, TOFF =Time period for Pulse OFF

4.2.2 Using an Arduino with L298

Allowing us to control both the direction and speed of each motor. You
know how DC motors work, how you can reverse their direction by changing

Supervisor: Nguyen Minh Y Page 34


Senior Design 2

polarity and how you can change their speed using pulse width modulation, let‟s
examine an easy way to do this using a very common circuit configuration called
an “H-Bridge”.

4.2.3 Using particle swarm optimization (PSO)

To search the optimal PID controller, the PSO algorithm is applied. Here the
potential solutions called particles, where it is metaphor of fish in fish schools or
bird in bird flocks. These particles are randomly initialized and fly through multi-
dimensional space. During the flying, these particles update its velocity and
position based on the experience of its own and the whole population.

The updating procedure will drive the particle swarm to move toward region
with better fitness function and every particle is gathered around the point with the
best fitness functions. In the proposed PSO method each particle contains three
members Kp, Ki and Kd. It means that the search space has three dimensions and
particles must fly in a three dimensional space. But to making the basic problem,
we use two dimensional space, changing Kp and Ki.

Supervisor: Nguyen Minh Y Page 35


Senior Design 2

4.3 Results
 5 iters - 5 members
ki_best = 0.010996, kp_best = 0.010658

 10 iters – 10 members
ki_best = 0.016003, kp_best = 0.026379

Supervisor: Nguyen Minh Y Page 36


Senior Design 2

 25 iters – 40 members

ki_best = 0. 0203, kp_best = 0. 0385

 The greater numbers of


members anditerations, the greater
result
ki_best = 0.0203
kp_best = 0.0385

Supervisor: Nguyen Minh Y Page 37


Senior Design 2

CHAPTER 5 : CONCLUSION AND FUTURE WORK


5.1 Conclusion

In this project we have studied and implemented a speed control of DC


motor using a Arduino Mega 2560 and partical swarm optimization.
The speed control of DC motor using partical swarm optimization works
successfully to find the suitable coefficient values of Kp and Ki that minimize or
maximize the objective function while satisfying the constraints, making the
system runs better.
This paper presents a novel design method for determiningthe PID controller
parameters using the PSO method. The proposed method integrates the PSO
algorithm with the new time-domain performance criterion into a PSO-PID
controller.
From the results, the designed PID controller using PSO algorithm shows
superior performance over the traditional method of Ziegler-Nichols, in terms of
the system overshoot, settling time and rise time. However, the traditional method
provides us with the initial PID gain values for optimal tuning. Therefore the
benefit of using a modern artificial intelligence optimization approach is observed
as a complement solution to improve the performance of the PID controller design
conventional method. Of course there are many techniques can be used as the
optimization tools and PSO is one of the recent and efficient optimization tools.
5.2 Future work

A brief review of applications that may be of interest to data scientists


include:
 Hyperparameter optimization for deep learning models.
 Training different neural networks.
 Learning to play video games .
 Natural language processing tasks .
 Data clustering .
 Feature selection in classification .

Supervisor: Nguyen Minh Y Page 38


Senior Design 2

REFERENCE
[1] Kennedy, J., Eberhart, R.C.: Particle Swarm Optimisation. In:
Proceedings of IEEE International Conference on Neural Networks, Perth,
Australia, pp. 1942–1948 (1995)
[2] Hu, X., Shi, Y., Eberhart, R.: Recent Advances in Particle Swarm. In:
Congress on Evolutionary Computation, pp. 90–97. IEEE Service Center,
Piscataway (2004)
[3] Huang, C.M., Huang, C.J., Wang, M.L.: A Particle Swarm Optimisation
to Identifying the ARMAX Model for Short term Load Forecasting. IEEE
Transactions on Power Systems 20, 1126–1133 (2005)
[4] Clerc, M.: Particle Swarm Optimisation. ISTE Publishing Company
(2006)
[5] Nedjah, N., Mourelle, L.D.M.: Systems Engineering Using Particle
Swarm Optimisation. Nova Science Publishers (2007)
[6] Shi, Y., Eberhart, R.: A Modified Particle Swarm Optimiser. In: IEEE
International Conference on Evolutionary Computation, pp. 69–73. IEEE Press,
Piscataway (1998)
[7] Zhang, W.J., Xie, X.F.: DEPSO: Hybrid Particle Swarm with
Differential Evolution Operator. In: Proceedings of IEEE International Conference
on Systems, Man and Cybernetics, Washington DC, USA, pp. 3816–3821 (2003)
[8] Mohagheghi, S., Del Valle, Y., Venayagamoorthy, G., Harley, R.: A
Comparison of PSO and Back Propagation for Training RBF Neural Networks for
Identification of a Power System with STATCO. In: Proceedings of IEEE Swarm
Intelligence Symposium, pp. 381–384 (June 2005)
[9] del Valle, Y., Venayagamoorthy, G.K., Mohagheghi, S., Hernandez, J.,
Harley, R.G.: Particle Swarm Optimisation: Basic Concepts, Variants and
Applications in Power Systems. IEEE Transactions On Evolutionary Computation
12(2), 171–195 (2008)

Supervisor: Nguyen Minh Y Page 39


Senior Design 2

APPENDIX

Вам также может понравиться