Академический Документы
Профессиональный Документы
Культура Документы
REPORT OF PROJECT II
SETTING THE PID COEFICIENT FOR
SPEED CONTROL OF DC MOTOR USING
PARTICLE SWARM OPTIMIZATION
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
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
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.
CHAPTER 1: INTRODUCTION
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.
CHAPTER 2: BACKGROUND
2.1 DC motor
.
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)
.
P(s)
K rad / sec
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.
K .
. b
J 1 V
0
d J
dt i K R i
L
L
L
.
y 1 0
i
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.
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.
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
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.
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
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
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%.
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
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.
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)
2.5.3 Examples
Disadvantages
Tendency to a fast and premature convergence in mid optimum points
Slow convergence in refined search stage (weak local search ability)
PSO
PID
Power Motor DC
Supply Controller
Driver Motor
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%
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
VCC 5V (blue)
GND (green)
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.
3.2 Flowchart
Flowchart of PSO
Flowchart of my project
PSO-PID tunning
The width of pulses (T) determines the amount of avg. voltage applied to
motor terminals.
TON =Time period for Pulse ON, TOFF =Time period for Pulse OFF
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
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”.
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.
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
25 iters – 40 members
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)
APPENDIX