19
Andrew Kavanagh EE451 Assignment ME4 DCU 1 School of Electronic Engineering Andrew Kavanagh ME4 12449652 EE451 Mechatronic System Simulation & Control Title: Investigation into a Speed Control Scheme for a Linear Brushless DC Motor Date: Mon. 14 th March 2016 Declaration I declare that this material, which I now submit for assessment, is entirely own work and has not been taken from the work of others, save and to the extent that such work has been cited and acknowledged within the text of my work. We understand that plagiarism, collusion, and copying are grave and serious offences in the university and accept the penalties that would be imposed should I engage in plagiarism, collusion, or copying. I have read and understood the Assignment Regulations set out in the module documentation. I have identified and included the source of all facts, ideas, opinions, viewpoints of others in the assignment references. Direct quotations from books, journal articles, internet sources, module text, or any other source whatsoever are acknowledged and the source cited are identified in the assignment references. This assignment, or any part of it, has not been previously submitted by me or any other person for assessment on this or any other course of study. I have read and understood the referencing guidelines found at http://www.library.dcu.ie/ and/or recommended in the assignment guidelines.

EE451 Mechatronic Simulation & Control Assignment

Embed Size (px)

DESCRIPTION

This assignment report uses a single selected source as the basis for an investigation into a speed control scheme for a DC motor and includes a details analysis, simulation and evaluation of the motor model used in the controller design.

Citation preview

Page 1: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

1

School of Electronic Engineering

Andrew Kavanagh

ME4 12449652

EE451 Mechatronic System Simulation & Control

Title: Investigation into a Speed Control Scheme for a Linear Brushless DC Motor

Date: Mon. 14

th March 2016

Declaration

I declare that this material, which I now submit for assessment, is entirely own work and has not been taken from

the work of others, save and to the extent that such work has been cited and acknowledged within the text of my

work. We understand that plagiarism, collusion, and copying are grave and serious offences in the university and

accept the penalties that would be imposed should I engage in plagiarism, collusion, or copying. I have read and

understood the Assignment Regulations set out in the module documentation. I have identified and included the

source of all facts, ideas, opinions, viewpoints of others in the assignment references. Direct quotations from books,

journal articles, internet sources, module text, or any other source whatsoever are acknowledged and the source

cited are identified in the assignment references. This assignment, or any part of it, has not been previously

submitted by me or any other person for assessment on this or any other course of study. I have read and

understood the referencing guidelines found at http://www.library.dcu.ie/ and/or recommended in the assignment

guidelines.

Page 2: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

2

Table of Contents Abstract ......................................................................................................................................................................................................................................... 3

Introduction ................................................................................................................................................................................................................................... 3

Source Selection ............................................................................................................................................................................................................................ 3

Control Scheme ............................................................................................................................................................................................................................. 3

PWM ........................................................................................................................................................................................................................................ 4

PID ........................................................................................................................................................................................................................................... 4

PSO ........................................................................................................................................................................................................................................... 5

Research Trail ................................................................................................................................................................................................................................ 6

Source used for Motor Modelling ............................................................................................................................................................................................. 6

Source used for Optimization Technique .................................................................................................................................................................................. 6

Source(s) used for Comparisons ............................................................................................................................................................................................... 6

Motor Model .................................................................................................................................................................................................................................. 6

System Analysis ............................................................................................................................................................................................................................ 7

Order ......................................................................................................................................................................................................................................... 7

System Model ........................................................................................................................................................................................................................... 7

Stability .................................................................................................................................................................................................................................... 8

Damping ................................................................................................................................................................................................................................... 8

Controllability/Observability .................................................................................................................................................................................................... 8

Frequency Response ................................................................................................................................................................................................................. 8

Partial Fraction Expansion ........................................................................................................................................................................................................ 9

Transient Performance Predictions ........................................................................................................................................................................................... 9

Simulation & Evaluation ............................................................................................................................................................................................................... 9

Conclusions ................................................................................................................................................................................................................................. 10

Reflection .................................................................................................................................................................................................................................... 10

References ................................................................................................................................................................................................................................... 10

Appendix ..................................................................................................................................................................................................................................... 10

List of Tables & Figures Table 1 - PSO/GA/LQR Comparison ............................................................................................................................................................................................ 6 Table 2- Motor Model Parameters ................................................................................................................................................................................................. 7 Table 3 - Performance Predictions ................................................................................................................................................................................................. 9 Table 4 - Performance Measurements ............................................................................................................................................................................................ 9 Table 5 - Varying input .................................................................................................................................................................................................................. 9

Figure 1 - Control Scheme ............................................................................................................................................................................................................. 4 Figure 2 - PWM Duty Cycle 100% ................................................................................................................................................................................................ 4 Figure 3 - PWM Duty Cycle 50% .................................................................................................................................................................................................. 4 Figure 4 - PWM Duty Cycle 25% .................................................................................................................................................................................................. 4 Figure 5 - PID Controller ............................................................................................................................................................................................................... 5 Figure 6 - PSO tuning algorithm .................................................................................................................................................................................................... 5 Figure 7 - PSO/GA/LQR Comparison ........................................................................................................................................................................................... 6 Figure 8 - Simplified BLDC .......................................................................................................................................................................................................... 7 Figure 9 - Motor Model Block Diagram ........................................................................................................................................................................................ 7 Figure 10 - pz map ......................................................................................................................................................................................................................... 8 Figure 11 - Nyquist Diagram ......................................................................................................................................................................................................... 8 Figure 12 - Step Response ............................................................................................................................................................................................................. 8 Figure 13 - Bode plot ..................................................................................................................................................................................................................... 9 Figure 14- Simulation Output ........................................................................................................................................................................................................ 9 Figure 15 - input vs output ........................................................................................................................................................................................................... 10

Page 3: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

3

Investigation into a Speed Control Scheme for a Linear Brushless DC Motor

-Andrew Kavanagh-

Abstract This assignment report uses a single selected source as the

basis for an investigation into a speed control scheme for a

DC motor and includes a details analysis, simulation and

evaluation of the motor model used in the controller design.

Keywords: speed control, brushless dc motor, PSO, PID,

motor model, MatLab, Simulink, system analysis

Introduction The journal paper “A PSO-Based Optimum Design of PID

Controller for a Linear Brushless DC Motor” by Mehdi

Nasri, Hossein Nezamabadi-pour, and Malihe Maghfoori

introduces a novel PSO (particle swarm optimization) based

control scheme for linear brushless DC motors (BLDC) and

provides the basis for the investigation carried out in this

assignment report.

PSO is a heuristic algorithmic approach to optimization

developed by James Kennedy and Russell Eberhart in 1995

by observing the behaviours of large groups of animals in

nature (fish schools, bird flocks, etc.) and how they

demonstrating “swarm intelligence” in tasks such as finding

food.

Nasri et al. use PSO methodologies to optimize the

parameters of a proportional-integral-derivative (PID)

controller to regulate the speed of a BLDC. This controller

design uses a BLDC motor model which is analysed using

the MatLab and Simulink software environments in this

report.

This assignment report has been organized as follows:

choice of source used is outline and justified,

control scheme is introduced and discussed in

further detail under its main components (PWM,

PID and PSO),

a research trail is developed by discussing how 3

significant references contribute to the selected

source

Motor model is outlined, analysed, simulated and

evaluated.

Assignment concluded and reflected upon.

Source Selection The source used for this assignment report is a paper entitled

“A PSO-Based Optimum Design of PID Controller for a

Linear Brushless DC Motor” [1]by Mehdi Nasri, Hossein

Nezamabadi-pour, and Malihe Maghfoori based in Shahid

Bahonar University (Nasri) and Kerman University

(Nezamabadi-pour & Maghfoori) in Kerman, Iran.

It was originally published in the International Journal of

Electrical, Computer, Energetic, Electronic and

Communication Engineering (Vol :1, No: 2) in 2007. This is

a monthly international journal that commenced in January

1999 and is released for open access by the World Academy

of Science, Engineering and Technology (WASET).

It can be located online at: http://tiny.cc/ee451source . It is

also cited in the References section of this report and

included as an appendix.

According to the Abstract, this paper presents a novel

“particle swarm optimization (PSO) method for determining

the optimal proportional-integral-derivative (PID)

controller parameters, for speed control of a linear

brushless DC motor” [1].

This source is suitable to use for this assignment report for

the following reasons:

It is from a reputable journal

Outlines an appropriate speed control scheme

Includes a linear brushless DC motor model that

can be simulated & analysed in MatLab/Simulink

environment(s).

Lists quantitative parameters for the motor model

used during simulation & evaluation.

Contains references that can be used in a research

trail.

Control Scheme In terms of a speed control scheme for a linear brushless DC

motor (BLDC), Nasri et al. outline a PID controller for

which the parameters are identified using a PSO based

algorithm. They prove this to be a simple and efficient

method of control, when compared with LQR (Linear

Quadratic Regulator) and GA (Genetic Algorithm)

optimization methods for choosing PID parameters.

Page 4: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

4

In this case, the speed control scheme is made up of three

main components: PWM (Pulse Width Modulator), PID and

PSO. Figure 1 below [1] shows this in a block diagram,

including the BLDC motor model – discussed later in this

report.

Figure 1 - Control Scheme

PWM The speed of the BLDC motor is directly controlled by a

PWM inverter (three-phase and half-bridge). The duty cycle

of the PWM determines the average voltage that is supplied

to the motor, varying its speed.

For example, Figure 2, 3 and 4 below show a simple PWM

motor speed control relationship. In this example a duty

cycle of 100% would supply the motor with the full

available voltage (e.g. 60V) resulting in a motor speed of

100RPM, a duty cycle of 50% would therefore supply an

average voltage of 30V (50RPM) and a duty cycle of 25%

supplies 15V (25RPM) - assuming relationships between

duty cycle, average voltage and motor speed are linear.

The duty cycle of the PWM is determined by a PID

controller.

Figure 2 - PWM Duty Cycle 100%

Figure 3 - PWM Duty Cycle 50%

Figure 4 - PWM Duty Cycle 25%

PID A PID controller is a feedback/closed loop control system

that works by comparing the actual output of a process with

a desired setpoint and changing the input to the process

appropriately if they do not match. It achieves this by

analysing the error signal, i.e. how far from the setpoint the

actual output signal is.

The error signal is multiplied by a constant (P), integrated (I)

and/or differentiated (D). The weighted summation of these

results is used to adjust the process so that the error signal is

ideally zero and other transient performance characteristics

(rise time and overshoot) are varied as desired. This is

outlined by the equation (1) and block diagram (Figure 5) in

below, where KP, KI, and KD are the weighted gains of the

PID controller.

𝑢(𝑡) = 𝐾𝑝𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 + 𝐾𝑑

𝑑𝑒(𝑡)

𝑑𝑡

(1)

Page 5: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

5

Figure 5 - PID Controller

The “P” parameter accounts for present errors and its

addition will improve the rise time. The “I” parameter

represents the accumulation of past errors and is used to

improve the overshoot. The “D” attempts to predict future

error and is included to eliminate the steady-state error.

However there is a trade off when determining the weighted

gain values of these parameters, for example KP contributes

to a decrease in rise time but will increase the overshoot.

The optimal setting of these parameters is called “tuning”. In

this case, the PID controller is tuned using PSO-based

techniques.

PSO PSO (Particle Swarm Optimization) is an optimization

technique for nonlinear functions originally developed by

James Kennedy and Russell Eberhart in 1995 by observing

the natural behaviour of fish schools and bird flocks. They

determined that these social-psychological groups were

demonstrating “swarm intelligence” in tasks such as finding

food.

When simplified, the techniques used by groups of animals

in nature to solve problems such as food sourcing were seen

to be a quick, effective and computationally inexpensive

optimisation procedure that could be developed into a

computational algorithm to optimise nonlinear functions,

using only simple mathematical operators.

It is an example of biomimicry (inspiration from nature) and

is similar to the Artificial Bee Colony Algorithm in

simulating social behaviour or Genetic Algorithm – an

example of evolutionary computation developed with

Darwinian principles for a global optimization and problem

solving technique based on trial and error.

Nasri et al. applied PSO theory to a speed control scheme of

a BLDC motor by using the algorithmic flowchart in Figure

6 [1] to select the optimal tunings gains of the PID

controller. This was achieved by developing a fitness

function to determine how each set of tested parameters

affected the behaviour of the motor control design and

selecting the best set.

Figure 6 - PSO tuning algorithm

When compared with LQR and GA optimization techniques

for selecting the tuning gains of the PID controller, the novel

PSO based approach developed by Nasri et al. was more

effective in improving the dynamic performance of the

motor output. This can be seen in Figure 7 and Table 1

below.

Page 6: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

6

Figure 7 - PSO/GA/LQR Comparison

LQR GA PSO

Rise Time (ms) 0.46786 0.46127 0.3038

Percentage Overshoot (%) 1.4186 0 0

Steady State Error 2.2513 1.5785 0.77186

Settling Time (ms) 0.79368 0.87404 0.60116

Table 1 - PSO/GA/LQR Comparison

Research Trail The source used in this assignment contained 21 references,

3 of which are summarized and discussed below in terms of

their contributions to the selected source.

Source used for Motor Modelling The source used to describe the linear brushless DC motor

model was “Dynamic Simulations of Electric Machinery:

Using MATLAB/SIMULINK” by Chee-Mun Ong [2].

In this book Ong outlines not only how many electrical

systems can be modelled, simulated, analysed and evaluated

using the software packages MatLab & Simulink but also

covers the underlying background theory & operating

principles behind systems such as transformers, inductors,

synchronous machines and DC motors. The project files can

be downloaded from an accompanying website.

Nasri et al. used this book as a basis for the linear brushless

DC motor model used in their PSO/PID control system

design, from which the characteristics equations (2) - (5),

transfer function (6) and block diagram (Figure 9) of the

BLDC motor were developed.

Source used for Optimization Technique The source used to describe the PSO optimization technique

was “Particle Swarm Optimization” by James Kennedy and

Russell Eberhart [3].

In this paper, Kennedy & Eberhart introduce a new “concept

for optimization of nonlinear functions” [3] based on the

observation of algorithmic problem solving behaviours of

large socially dependent groups of animals in the in the

natural world, such as schools of fish or flocks of birds.

They outline how these techniques may be applied to

computational optimization applications, carry out

benchmark testing and discuss other biologically inspired

optimization techniques such as the Genetic Algorithm

compare to their new PSO method.

Nasri et al. apply the PSO theory introduced in this paper to

a speed control scheme of a BLDC motor by using the

algorithmic flowchart in Figure 6 to select the optimal

tunings gains of the PID controller. This was achieved by

developing a fitness function to determine how each set of

tested parameters affected the behaviour of the motor control

design and selecting the best set.

Source(s) used for Comparisons The novel PSO optimization approach was compared with

another pre-existing method of optimization using the source

entitled “Optimal PID speed control of brush less DC

motors using LQR approach” by Gwo-Ruey Yu and Rey-

Chue Hwang [4].

In this paper, Yu & Hwang propose a novel method to find

the optimal values of the parameters for a PID controlled

BLDC, using Linear Quadratic Regulator methodologies.

Through computer simulation & experimental data, they

determine that the performance of a PID with LQR

optimized parameters is better than that of a traditional PID

controller.

Nasri et al. use the results in this paper to compare with their

PSO based optimization method, the results of which can be

seen in Figure 7 and Table 1 above.

Similarly, the source entitled “GA-based multiobjective PID

control for a linear brushless DC motor” by Chun-Liang

Lin, Horn-Yong Jan and Niahn-Chung Shieh [5] was used to

compare PSO against GA (Genetic Algorithm) based

optimization approach.

Motor Model The motor model used in this control scheme is a three-

phase two-pole linear brushless DC motor (BLDC), a

simplified version of which can be seen in Figure 8 [6]. This

type of motor differs from permanent magnet motors that

use carbon or graphite brushes to commutate the armature

current. In BLDC motors, Hall Effect sensors detect the state

of the poles and use enhanced control units to achieve

commutation instead. This is done by the sensors indicating

that rotor has been aligned with the stator field and the

controller switching power to the next stator. The speed can

be controlled by varying the amplitude and duration of the

pulses applied to stator windings by the controller [7].

Page 7: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

7

Figure 8 - Simplified BLDC

It is assumed that the dynamic characteristics of BLDC

motors are similar to permanent magnet DC motors and that

the the motor model can be characterised by the equations

(2) – (5) [2]:

𝑉𝑎𝑝𝑝(𝑡) = 𝐿𝑑𝑖(𝑡)

𝑑𝑡+ 𝑅. 𝑖(𝑡) + 𝑉𝑒𝑚𝑓 (𝑡)

(2)

𝑉𝑒𝑚𝑓(𝑡) = 𝐾𝑏 . 𝜔(𝑡)

(3)

𝑇(𝑡) = 𝐾𝑡 . 𝑖(𝑡)

(4)

𝑇(𝑡) = 𝐽𝑑𝜔(𝑡)

𝑑𝑡+ 𝐷. 𝜔(𝑡)

(5)

These equations can be used to develop the transfer function

(6) and block diagram below [1]:

𝜔(𝑠)

𝑉𝑎𝑝𝑝(𝑠)=

𝐾𝑡

𝐿𝐽. 𝑆2 + (𝐿𝐷 + 𝑅𝐽)𝑆 + 𝐾𝑡𝐾𝑏

(6)

Figure 9 - Motor Model Block Diagram

where: 𝑉𝑎𝑝𝑝(𝑡) = applied voltage [V]

𝜔(𝑡) = motor speed [rad/sec]

𝐿 = Inductance of stator [H]

𝑖(𝑡) = Current of the circuit [A]

𝑅 = Stator resistance [Ω]

𝑉𝑒𝑚𝑓(𝑡) = Back emf [V]

𝑇 = Torque of the motor [Nm]

𝐷 = Viscous coefficient [Kg-m s/rad]

𝐽 = Moment of inertia [Kgm s2/rad]

𝐾𝑡 = Motor torque constant [Vs rad-1]

𝐾𝑏 = Back emf constant [Kg-m/A]

The parameters used for this motor model can be seen below

in Table 2 [1].

Table 2- Motor Model Parameters

System Analysis Please note, the MatLab code used to complete the analysis

of the system is included as an appendix to this report.

Order From the transfer function in equation (6), it can be seen that

the motor model used is of 2nd

order.

System Model Using the parameters provided in Table 2, the motor was

expressed as a transfer function (7), which was converted to

its minimum representation (8) and converted to a state

space (9)

𝜔(𝑠)

𝑉𝑎𝑝𝑝(𝑠)=

(0.1433)

(5.2 𝑥 10−7)𝑠2 + (0.0002172)𝑠 + (0.0253)

(7)

𝜔(𝑠)

𝑉𝑎𝑝𝑝(𝑠)=

(2.756 𝑥 105)

𝑠2 + (417.7)𝑠 + (3.949 𝑥 104)

(8)

𝐴 = [−417.6923 −154.2585

256 0] 𝐵 = [

320

]

𝐶 = [0 33.6398] 𝐷 = [0]

(9)

Page 8: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

8

Stability The model was determined to be stable for the following

reasons:

The poles & eigenvalues were located at -273.0843 and

-144.6080 (Figure 10) i.e. negative real parts

“isstable” MatLab command returned a value of 1,

meaning system tested is stable

The Nyquist Criterion - which states that a feedback

control system is stable, if and only if, for the Nyquist

contour (Γ), the number of counterclockwise

encirclements (N) of the −1 + j0 point is equal to the

number of unstable poles of GH(s) (P), i.e. N = P). In

this case N = P = 0, therefore the system can be

considered stable Figure 11.

The step response Figure 12 settled to a steady value.

Figure 10 - pz map

Figure 11 - Nyquist Diagram

Figure 12 - Step Response

Damping The damping factor (ζ) of the system was equal to 1, which

implies a critically damped system.

This means that the performance measurements will be the

same as those of a 1st order system because a critically

damped 2nd order system has essentially the same behaviour

as a 1st order system.

The critical damping can also be seen in the step response in

Figure 12 above.

Controllability/Observability The state space representation of the system was used to

generate the controllability and observability matrices, the

determinants of which were equal to 262144 and 1000

respectively (i.e. not equal to zero) – meaning the system

was both controllable & observable.

This was confirmed by finding the rank of the controllability

and observability matrices from first principles.

The system was therefore able to be represented in controller

canonical format (10) where:

𝐴 = [0 (−3.949 𝑥 104)1 (−417.7)

] 𝐵 = [10

]

𝐶 = [0 (2.756 𝑥 105)] 𝐷 = [0]

(10)

Frequency Response The bode plot in Figure 13 below shows a frequency

response of the system with an infinite gain margin and a

phase margin of 46.51° at 479 rad/sec.

Page 9: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

9

Figure 13 - Bode plot

Partial Fraction Expansion The system generated residuals of r1 = -2.1450 and r2 =

2.1450 at the poles p1 = -273.0843 and p2 = -144.6080,

meaning the transfer function and output could be

represented by (11) and (12) respectively.

𝜔(𝑠)

𝑉𝑎𝑝𝑝(𝑠)= (

𝑟1

𝑠 − 𝑝1

) + (𝑟2

𝑠 − 𝑝2

)

(11)

= (2.1450

𝑠 + 144.6080) − (

2.1450

𝑠 + 273.0843)

𝜔(𝑡) = 𝑟1𝑒𝑝1𝑡 + 𝑟2𝑒𝑝2𝑡

(12)

= (2.1450)𝑒( −144.6080)𝑡 − (2.1450 )𝑒(273.0843)𝑡

Transient Performance Predictions The transient performance predictions of the model &

parameters used are outlined in Table 1.

Characteristic Value Unit

Initial Value 0 [rad/sec]

Final Value 6.9784 [rad/sec]

Rise time 0.0152 [sec]

Settling Time 0.0277 [sec]

Time constant 0.0069 [sec]

Table 3 - Performance Predictions

Due to the system being critically damped the percentage

overshoot or peak time could not be predicted.

Simulation & Evaluation The system response was simulated for a step input in

Simulink, using an LTI block and transfer function

representation of the model Figure 14.

The transient performance predictions vs. measurements can

be seen below in Table 1Table 4. The measured percentage

overshoot can be considered negligible.

Characteristic Predicted Measured Unit

Initial Value 0 0 [rad/sec]

Final Value 6.9784 6.9784 [rad/sec]

Rise time 0.0152 0.0181 [sec]

Settling Time 0.0277 0.0322 [sec]

Time constant 0.0069 0.0112 [sec]

Peak time - 0.2331 [sec]

Percentage Overshoot - 3.6233 x 10-6 -

Table 4 - Performance Measurements

Figure 14- Simulation Output

The system was then simulated & analysed for a series of

input values. This was done by altering the size of the step

input. The results in Table 5 and Figure 15 show a linear

relationship between input and steady state output.

Input [V] Output [rad/sec]

0 0

1 6.9784

2 13.9567

3 20.9351

5 34.8918

10 69.7837

100 697.8367

Table 5 - Varying input

Page 10: EE451 Mechatronic Simulation & Control Assignment

Andrew Kavanagh

EE451 Assignment

ME4

DCU

10

Figure 15 - input vs output

Conclusions Nasri et al. proposed method for a PSO based PID controller

for a linear brushless DC motor was shown to be more

effective when compared with other optimization

techniques.

The transient performance predictions of BLDC model

match the simulated outputs within an acceptable margin of

error.

Reflection Through the research carried out as part of this assignment, I

learned about biologically-inspired optimization techniques

and how they can be applied to control systems.

This was very interesting as it shows how knowledge

outside of traditional engineering principles (i.e. biology,

nature, and socio-economics) can be developed to apply

those methodologies to other engineering & problem solving

applications. This interdisciplinary approach forms a basis

for efficient design & development in engineering.

I also learned how to perform analysis, simulation and

evaluations of systems, such as a BLDC motor model, in

MatLab/Simulink software environments. These techniques

can be applied to a range of other electrical & mechanical

systems.

References

[1] H. N.-p. a. M. M. Mehdi Nasri, “A PSO-Based Optimum

Design of PID Controller for,” International Journal of

Electrical, Computer, Energetic, Electronic and

Communication Engineering, vol. 1, no. 2, pp. 171-175,

2007.

[2] C.-M. Ong, Dynamic Simulations of Electric Machinery:

Using MATLAB/SIMULINK, Upper Saddle River, NJ

07458: Prentice Hall, 1998.

[3] R. E. James Kennedy, “Particle Swarm Optimization,” in

IEEE International Conference on Neural Networks,

University of Western Australia, Perth, Western

Australia, 1995.

[4] G.-R. Yu and R.-C. Hwang, “Optimal PID speed control

of brush less DC motors using LQR approach,” in IEEE

International Conference on Systems, Man and

Cybernetics, The Hague, 2004.

[5] C.-L. Lin, H.-Y. Jan and N.-C. Shieh, “GA-based

multiobjective PID control for a linear brushless DC

motor,” IEEE/ASME Transactions on Mechatronics ,

vol. 8, no. 1, pp. 56-65, 2003.

[6] J. Z. Yu, “Brushless DC Motor Fundamentals

Application Note,” Monolithic Power Systems, 2011.

[7] A. R. Hambley, Electrical Engineering: Principles and

Application, New Jersey: Prentice Hall, 1997.

Appendix The following appendix consists of:

the selected source as originally published

the MatLab code used

Page 11: EE451 Mechatronic Simulation & Control Assignment

Abstract—This Paper presents a particle swarm optimization

(PSO) method for determining the optimal proportional-integral-derivative (PID) controller parameters, for speed control of a linear brushless DC motor. The proposed approach has superior features, including easy implementation, stable convergence characteristic and good computational efficiency. The brushless DC motor is modelled in Simulink and the PSO algorithm is implemented in MATLAB. Comparing with Genetic Algorithm (GA) and Linear quadratic regulator (LQR) method, the proposed method was more efficient in improving the step response characteristics such as, reducing the steady-states error; rise time, settling time and maximum overshoot in speed control of a linear brushless DC motor.

Keywords—Brushless DC motor, Particle swarm optimization, PID Controller, Optimal control.

I. INTRODUCTION HERE are mainly two types of dc motors used in industry. The first one is the conventional dc motor where the flux

is produced by the current through the field coil of the stationary pole structure. The second type is the brushless dc motor (BLDC motor) where the permanent magnet provides the necessary air gap flux instead of the wire-wound field poles [1].

This kind of motor not only has the advantages of DC motor such as better velocity capability and no mechanical commutator but also has the advantage of AC motor such as simple structure, higher reliability and free maintenance. In addition, brushless DC motor has the following advantages: smaller volume, high force, and simple system structure. So it is widely applied in areas which needs high performance drive [2].

From the control point of view, dc motor exhibit excellent control characteristics because of the decoupled nature of the field and armature mmf’s [1]. Recently, many modern control methodologies such as nonlinear control [3], optimal control [4], variable structure control [5] and adaptive control [6] have been widely proposed for linear brushless permanent magnet DC motor. However, these approaches are either complex in theorical bases or difficult to implement [7]. PID control with its three term functionality covering treatment to both transient

M. Nasri is now with Shahid Bahonar University of Kerman, Kerman, Iran as MSc student (fax: +98341-3239500, e-mail: [email protected] ).

H. Nezamabadi-pour is with the Department of EE, Shahid Bahonar University of Kerman, Kerman, Iran (e-mail: [email protected]).

M. Maghfoori is with the Department of EE, Shahid Bahonar University of Kerman, Kerman, Iran (e-mail: [email protected]).

and steady-states response, offers the simplest and yet most efficient solution to many real world control problems [8]. In spite of the simple structure and robustness of this method, optimally tuning gains of PID controllers have been quite difficult.

Yu et al. [9] have presented a LQR method to optimally tune the PID gains. In this method, the response of the system is near optimal but it requires mathematical calculation and solving equations. Lin et al. [10] have introduced GA-based PID control for brushless DC motor. Genetic algorithm is a stochastic optimization algorithm that is originally motivated by the mechanism of natural selection and evolutionary genetics.

Though the GA methods have been employed successfully to solve complex optimization problems, recent search has identified some deficiencies in GA performance. This degradation in efficiency is apparent in applications with highly epistatic objective functions (i.e., where the parameters being optimized are highly correlated), the crossover and mutation operations cannot ensure better fitness of offspring because chromosomes in the population have similar structure and their average fitness are high toward the end of the evolutionary process [11], [12], [13]. PSO first introduced by Kennedy and Eberhart is one of the modern heuristic algorithms, it has been motivated by the behavior of organisms, such as fish schooling and bird flocking [14]. Generally, PSO is characterized as a simple concept, easy to implement, and computationally efficient. Unlike the other heuristic techniques, PSO has a flexible and well-balanced mechanism to enhance the global and local exploration abilities [15].

In this paper, a novel PSO-based approach to optimally design a PID controller for a brushless DC motor is proposed. This paper has been organized as follows: in section 2 the linear brushless DC motor is described and the speed model of it is shown. In section 3, the particle swarm optimization method is reviewed. Section 4, describes how PSO is used to design the PID controller optimally for a linear brushless DC motor. A comparison between the results obtained by the proposed method and GA method and LQR design [9] via simulation the DC motor is presented in section 5. The paper is concluded in section 6.

II. LINEAR BRUSHLESS DC MOTOR Permanent magnet DC motors use mechanical commutators

and brushes to achieve the commutation. However, BLDC motors adopt Hall Effect sensors in place of mechanical commutators and brushes [17]. The stators of BLDC motors are the coils, and the rotors are the permanent magnets. The

A PSO-Based Optimum Design of PID Controller for a Linear Brushless DC Motor

Mehdi Nasri, Hossein Nezamabadi-pour, and Malihe Maghfoori

T

World Academy of Science, Engineering and TechnologyInternational Journal of Electrical, Computer, Energetic, Electronic and Communication Engineering Vol:1, No:2, 2007

171International Scholarly and Scientific Research & Innovation 1(2) 2007 scholar.waset.org/1999.5/10876

Inte

rnat

iona

l Sci

ence

Ind

ex, E

lect

rica

l and

Com

pute

r E

ngin

eeri

ng V

ol:1

, No:

2, 2

007

was

et.o

rg/P

ublic

atio

n/10

876

Page 12: EE451 Mechatronic Simulation & Control Assignment

stators develop the magnetic fields to make the rotor rotating. Hall Effect sensors detect the rotor position as the commutating signals. Therefore, BLDC motors use permanent magnets instead of coils in the armature and so do not need brushes. In this paper, a three-phase and two-pole BLDC motor is studied. The speed of the BLDC motor is controlled by means of a three-phase and half-bridge pulse-width modulation (PWM) inverter. The dynamic characteristics of BLDC motors are similar to permanent magnet DC motors. The characteristic equations of BLDC motors can be represented as [18]:

(4) )(.)()(

(3) )(.)((2) )(.

(1) )()(.)()(

tDdt

tdJtT

tiKtTtK

ttiRdt

tdiLt

t

bemf

emfapp

ωω

ων

νν

+=

=

=

++=

where )(tappν is the applied voltage, ( )tω is the motor speed, L is the inductance of the stator, i(t) is the current of the circuit, R is the resistance of the stator, ( )temfν is the back electromotive force, T is the torque of motor, D is the viscous coefficient, J is the moment of inertia, Kt is the motor torque constant, and Kb is the back electromotive force constant.

Fig. 1 shows the block diagram of the BLDC motor. From the characteristic equations of the BLDC motor, the transfer function of speed model is obtained

(5) )(.)(

)(2

bt

t

app KKSRJLDSLJK

ss

+++=

νω

Fig. 1 The block diagram of BLDC motor

The parameters of the motor used for simulation are as follows:

TABLE I PARAMETERS OF THE MOTOR

III. OVERVIEW OF PARTICLE SWARM OPTIMIZATION PSO is one of the optimization techniques and a kind of

evolutionary computation technique. The method has been found to be robust in solving problems featuring nonlinearity and nondifferentiability, multiple optima, and high dimensionality through adaptation, which is derived from the social-psychological theory [13]. The technique is derived from research on swarm such as fish schooling and bird flocking. According to the research results for a flock of birds, birds find food by flocking (not by each individual). The observation leads the assumption that every information is shared inside flocking. Moreover, according to observation of behavior of human groups, behavior of each individual (agent) is also based on behavior patterns authorized by the groups such as customs and other behavior patterns according to the experiences by each individual. The assumption is a basic concept of PSO [16]. In the PSO algorithm, instead of using evolutionary operators such as mutation and crossover, to manipulate algorithms, for a d-variabled optimization problem, a flock of particles are put into the d-dimensional search space with randomly chosen velocities and positions knowing their best values so far (Pbest) and the position in the d-dimensional space. The velocity of each particle, adjusted according to its own flying experience and the other particle’s flying experience. For example, the i th particle is represented as ),...,,( ,2,1, diiii xxxx = in the d-dimensional space. The

best previous position of the i th particle is recorded and represented as:

)Pbest...,,Pbest,Pbest(Pbest ,2,1, diiii = .

The index of best particle among all of the particles in the group is dgbest . The velocity for particle i is represented as

),....,,( ,2,1, diiii vvvv = . The modified velocity and position of each particle can be calculated using the current velocity and the distance from ddi, gbest toPbest as shown in the following formulas [13]:

Parameters Values and units

R 21.2Ω

bK 0.1433 Vs rad-1

D 1*10-4 Kg-m s/rad

L 0.052 H

tK 0.1433 Kg-m/A

J 1*10-5 Kgm s2/rad

World Academy of Science, Engineering and TechnologyInternational Journal of Electrical, Computer, Energetic, Electronic and Communication Engineering Vol:1, No:2, 2007

172International Scholarly and Scientific Research & Innovation 1(2) 2007 scholar.waset.org/1999.5/10876

Inte

rnat

iona

l Sci

ence

Ind

ex, E

lect

rica

l and

Com

pute

r E

ngin

eeri

ng V

ol:1

, No:

2, 2

007

was

et.o

rg/P

ublic

atio

n/10

876

Page 13: EE451 Mechatronic Simulation & Control Assignment

dmnivxx

xRandc

xrandcvwv

tmi

tmi

tmi

tmi

tmimi

tmi

tmi

,...,2,1,...,2,1

(7)

(6) )gbest(*()*

)pbest(*()*.

)1(,

)(,

)1(,

)(,m2

)(,,1

)(,

)1(,

==

+=

−+

−+=

++

+

where

n Number of particles in the group d dimension t Pointer of iterations(generations)

)(,tmiv Velocity of particle I at iteration t

maxd

)(,

mind VV ≤≤ t

div w Inertia weight factor

, 21 cc Acceleration constant

()()

Randrand

Random number between 0 and 1

)(,tdix Current position of particle i at iterations

iPbest Best previous position of the ith particle

gbest Best particle among all the particles in the population

IV. IMPLEMENTATION OF PSO-PID CONTROLLER

A. Fitness Function In PID controller design methods, the most common

performance criteria are integrated absolute error (IAE), the integrated of time weight square error (ITSE) and integrated of squared error (ISE) that can be evaluated analytically in the frequency domain [19], [20]. These three integral performance criteria in the frequency domain have their own advantage and disadvantages. For example, disadvantage of the IAE and ISE criteria is that its minimization can result in a response with relatively small overshoot but a long settling time because the ISE performance criterion weights all errors equally independent of time. Although the ITSE performance criterion can overcome the disadvantage of the ISE criterion, the derivation processes of the analytical formula are complex and time-consuming [21]. The IAE, ISE, and ITSE performance criterion formulas are as follows:

(10) )(

(9) )(

(8) )()()(

0

2

0

2

00

∫∫

∞∞

=

=

=−=

dttteISTE

dtteISE

dttedttytrIAE

In this paper a time domain criterion is used for evaluating the PID controller [13]. A set of good control parameters

DIP and , can yield a good step response that will result in performance criteria minimization in the time domain. These performance criteria in the time domain include the overshoot, rise time, settling time, and steady-state error. Therefore, the performance criterion is defined as follows [13]:

)

stablizing:K

.(

)).(1()(min

rs

ssp

tteEMeKW

++−= −− ββ

(11)

Where K is [P, I, D], and β is the weightening factor. The performance criterion W(K) can satisfy the designer requirement using the weightening factor β value. β can set to be larger than 0.7 to reduce the overshoot and steady states error, also can set smaller than 0.7 to reduce the rise time and settling time [13]. The optimum selection of β depends on the designer’s requirement and the characteristics of the plant under control. In BLDC motor speed control system the lower β would lead to more optimum responses. In this paper, due to trials, β is set to 0.5 to optimum the step response of speed control system.

The fitness function is reciprocal of the performance criterion, in the other words:

)(1KW

f = (12)

B. Proposed PSO-PID Controller In this paper a PSO-PID controller used to find the optimal

parameters of LBDC speed control system. Fig. 2 shows the block diagram of optimal PID control for

the BLDC motor.

Fig. 2 Optimal PID control

In the proposed PSO method each particle contains three

members DIP and , . It means that the search space has three dimension and particles must ‘fly’ in a three dimensional space.

The flow chart of PSO-PID controller is shown in Fig. 3.

World Academy of Science, Engineering and TechnologyInternational Journal of Electrical, Computer, Energetic, Electronic and Communication Engineering Vol:1, No:2, 2007

173International Scholarly and Scientific Research & Innovation 1(2) 2007 scholar.waset.org/1999.5/10876

Inte

rnat

iona

l Sci

ence

Ind

ex, E

lect

rica

l and

Com

pute

r E

ngin

eeri

ng V

ol:1

, No:

2, 2

007

was

et.o

rg/P

ublic

atio

n/10

876

Page 14: EE451 Mechatronic Simulation & Control Assignment

Fig. 3 Flowchart of the PSO-PID Control system

V. NUMERICAL EXAMPLES AND RESULTS

A. Optimal PSO-PID Response To control the speed of the LBDC motor at 1000 rmp,

according to the trials, the following PSO parameters are used to verify the performance of the PSO-PID controller parameters:

• Population size: 20; • ;1.0,6.0 minmax == ww • C1 =C2 =1.5; • Iteration :20;

The optimal PID controller is shown in Fig. 4.

Fig. 4 Step response of BLDC motor in PSO based PID speed control

Table II lists the performance of the PSO-PID controller.

TABLE II PERFORMANCE OF THE PSO-PID CONTROLLER

Fig. 5 shows the convergence graph in the PSO method.

Fig. 5 Convergence graph in the PSO method

B. Comparison of PSO-PID Method with LQR and GA

Methods To show the effectiveness of the proposed method, a

comparison is made with the designed PID controller with GA and LQR methods. At first method, the PID controller is designed using LQR method [9] and the values of designed PID Controller are 70.556, 10, and 0.0212 [9]. Also, GA method is used to tune the PID controller. The following GA parameters which are used to verify the performance of the GA-PID controller parameters:

• Population size: 30 • Crossover rate: 0.9 • Mutation rate: 0.005 • Number of iterations :30

The values of designed PID Controller are 93.1622, 38.6225, and 0.027836. Fig. 6 shows the convergence graph in the GA method, Fig. 7 shows the PSO response in comparison with

[P I D] [190.0176,50,0.039567]

Rise time(ms) 0.3038

Max overshoot (%) 0

Steady States error 0.77186

Settling time(ms) 0.60116

No

Yes

Start

Generate initial Population

Run the LBDC control system model for each set of Parameters

Calculate Mp, Ess, Tr, Ts of model's step response

Calculate the Pbest of each particle and gbest of population

Update the velocity, position, gbest and pbest of particles

Maximum iteration number reached?

Stop

Calculate the fitness function

World Academy of Science, Engineering and TechnologyInternational Journal of Electrical, Computer, Energetic, Electronic and Communication Engineering Vol:1, No:2, 2007

174International Scholarly and Scientific Research & Innovation 1(2) 2007 scholar.waset.org/1999.5/10876

Inte

rnat

iona

l Sci

ence

Ind

ex, E

lect

rica

l and

Com

pute

r E

ngin

eeri

ng V

ol:1

, No:

2, 2

007

was

et.o

rg/P

ublic

atio

n/10

876

Page 15: EE451 Mechatronic Simulation & Control Assignment

GA and LQR methods and Table III lists the performance of the two methods.

Fig. 6 Convergence graph in the GA method

Fig. 7 Comparison between GA, LQR and PSO based PID control in

speed control of LBDC motor

TABLE III LQR AND GA PERFORMANCE

LQR GA P 70.556 93.1622 I 10 38.6225 D 0.0212 0.027836 Tr (ms) 0.46786 0.46127 Mp% 1.4186 0 Ess 2.2513 1.5785 Ts (ms) 0.79368 0.87404

VI. CONCLUSION In this paper a new design method to determine PID

controller parameters using the PSO method is presented. Obtained through simulation of BLDC motor, the results show that the proposed controller can perform an efficient search for the optimal PID controller. By comparison with LQR and GA methods, it shows that this method can improve the dynamic performance of the system in a better way.

REFERENCES [1] V. Tipsuwanporn, W. Piyarat and C. Tarasantisuk, “Identification and

control of brushless DC motors using on-line trained artificial neural networks,” in Proc. Power Conversion Conf., pp. 1290-1294, Apr. 2002.

[2] X.Li Q.Zhang and H.Xiao, “The design of brushless DC motor servo system based on wavelet ANN, “in Proc. Int. Conf. Machine Learning and Cybernetics, pp. 929-933, 2004.

[3] N. Hemati, J. S. Thorp, and M. C. Leu, “Robust nonlinear control of Brushless dc motors for direct-drive robotic applications,” IEEE Trans. Ind. Electron., vol. 37, pp. 460–468, Dec 1990.

[4] P. M. Pelczewski and U. H. Kunz, “The optimal control of a constrained drive system with brushless dc motor,” IEEE Trans. Ind. Electron., vol. 37, pp. 342–348, Oct. 1990.

[5] F. J. Lin, K. K. Shyu, and Y. S. Lin, “Variable structure adaptive control for PM synchronous servo motor drive,” IEE Proc. IEE B: Elect. Power Applicat., vol. 146, pp. 173–185, Mar. 1999.

[6] E. Cerruto, A. Consoli, A. Raciti, and A. Testa, “A robust adaptive controller for PM motor drives in robotic applications,” IEEE Trans. Power Electron., vol. 10, pp. 62–71, Jan. 1995.

[7] C.-L. Lin, and H.-Y. Jan, “Evolutionarily multiobjective PID control for linear brushless DC motor, ”in Proc. IEEE Int. Conf .Industrial Elect. Society, Nov. 2002, pp.39-45.

[8] K. Ang, G. Chong, and Y. Li, “PID control system analysis, design, and technology,” IEEE Trans.Control System Technology, vol. 13, pp. 559-576, July 2005.

[9] G. Yu, and R. Hwang, “Optimal PID speed control of brush less DC motors using LQR approach,” in Proc. IEEE Int. Conf. Systems, Man and Cybernetics, 2004, pp. 473-478.

[10] C. L. Lin, and H. Y. Jan, and N. C. Shieh, “GA-based multiobjective PID control for a linear brushless DC motor,” IEEE/ASME Trans. Mechatronics , vol.8, No. 1, pp. 56-65, 2003.

[11] D. B. Fogel, Evolutionary Computation toward a New Philosophy of Machine Intelligence: New York: IEEE, 1995.

[12] R. C. Eberhart and Y. Shi, “Comparison between genetic algorithms and particle swarm optimization,” in Proc. IEEE Int. Conf. Evol. Comput., Anchorage, AK, May 1998, pp. 611–616.

[13] Z.-L. Gaing, “A particle swarm optimization approach for optimum design of PID controller in AVR system,” IEEE Trans. Energy Conversion, vol. 19, pp. 384-391, June 2004.

[14] J. Kennedy and R. Eberhart, “Particle swarm optimization,” in Proc. IEEE Int. Conf. Neural Networks, vol. IV, Perth, Australia, 1995, pp. 1942–1948.

[15] M. A. Abido, “Optimal design of power-system stabilizers using particle swarm optimization,” IEEE Trans. Energy Conversion, vol. 17, pp.406-413, Sep. 2002.

[16] H. Yoshida, K. Kawata, Y. Fukuyama, S. Takayama, and Y. Nakanishi, “A particle swarm optimization for reactive power and voltage control considering voltage security assessment,” IEEE Trans. on Power Systems, Vol. 15, No. 4, Nov. 2000, pp. 1232 – 1239.

[17] Allan R. Hambley, Electrical Engineering: Principles and Application, Prentice Hall, New Jersey 1997.

[18] Chee-Mun Ong, Dynamic Simulation of Electric Machinery, Prentice Hall, New Jersey, 1998.

[19] R. A. Krohling and J. P. Rey, “Design of optimal disturbance rejection PID controllers using genetic algorithm,” IEEE Trans. Evol. Comput., vol. 5, pp. 78–82, Feb. 2001.

[20] Y. Mitsukura, T. Yamamoto, and M. Kaneda, “A design of self-tuning PID controllers using a genetic algorithm,” in Proc. Amer. Contr. Conf., San Diego, CA, June 1999, pp. 1361–1365.

[21] R. A. Krohling, H. Jaschek, and J. P. Rey, “Designing PI/PID controller for a motion control system based on genetic algorithm,” in Proc. 12th IEEE Int. Symp. Intell. Contr., Istanbul, Turkey, July 1997, pp. 125–130.

Mehdi Nasri was born in Isfahan, Iran on May 13, 1982. He received his B.S degree in Biomedical Engineering from Isfahan University in 2004. He is now with Shahid Bahonar University of Kerman, Kerman, Iran as MSc student in Electrical Engineering. His research interests include Soft Computing, Biological Control Systems, Nonlinear Control and Image Processing.

Hossein Nezamabadi-pour, received his B.S. degree in Electrical Engineering from Kerman University in 1998, and his M.Sc. and Ph.D degree in Electrical Engineering from Tarbiat Modarres University in 2000 and 2004 respectively. Since 2004 he has been with Kerman University, Kerman, Iran, where he is currently an Assistant Professor of Electrical Engineering. His interests include Pattern Recognition, Soft Computing, evaluation computation and Image Processing. Malihe maghfoori is received her B.S. degree in Electrical Engineering from Ferdousi University in 1995, and her PhD degree in Electrical Engineering from Brunel Institute of Power Systems, Brunel University in 2003. Since 2003, she has been with Kerman University, Kerman, Iran where she is currently an Assistant Professor of Electrical Engineering. Her interests include Power System Control and stability.

World Academy of Science, Engineering and TechnologyInternational Journal of Electrical, Computer, Energetic, Electronic and Communication Engineering Vol:1, No:2, 2007

175International Scholarly and Scientific Research & Innovation 1(2) 2007 scholar.waset.org/1999.5/10876

Inte

rnat

iona

l Sci

ence

Ind

ex, E

lect

rica

l and

Com

pute

r E

ngin

eeri

ng V

ol:1

, No:

2, 2

007

was

et.o

rg/P

ublic

atio

n/10

876

Page 16: EE451 Mechatronic Simulation & Control Assignment

%% Andrew Kavanagh ME4 12449652 %% % DCU EE451 Assignment MatLab Code % % March 2016 %

%% START

%% m file code appears in command window and therefore diary file echo on

%% diary file set up diary Assignment.txt diary on

%% clear workspace and free up system memory. clear all; % Clear all variables and functions from memory close all; %close figures

%% Motor Model Set up

R = 21.2 Kb = 0.1433 D = 1*(10^-4) L = 0.052 Kt = 0.1433 J = 1*(10^-5)

sysGtf = tf([Kt],[(L*J) ((L*D)+(R*J)) (Kt*Kb)]) sysGmin = minreal(sysGtf) sysGss = ss(sysGmin) [A,B,C,D] = ssdata(sysGss) %transfer functions are unique % but state spaces are not % as different state spaces can give the same transfer function

sysG = sysGmin

%% Model Analysis

%stability (poles, eigenvalues, etc.) poleG = pole(sysG) eigG = eig(sysG) %=>stable if all eigenvalues have negative real parts; it is unstable if at least one

eigenvalue has positive real part. pzmap(sysG) stabilityG = isstable(sysG) % 0 => unstable & 1 => stable nyquist(sysG)

figure(1) subplot(1,2,1) pzmap(sysG) %graph edits xlabel('Real Axis', 'FontWeight', 'bold', 'FontSize', 16) % x-axis title, bold font, 16pt ylabel('Imaginary Axis', 'FontWeight', 'bold', 'FontSize', 16) % y-axis title, bold font, 16pt set(gca, 'box', 'off') %turns off the box border set(findobj('Type','axes'), 'LineWidth', 1.5) % Set axis line width to 1.5 set(findobj('Type','line'), 'LineWidth', 1.5) % Set plot line width to 1.5 set(gca, 'FontSize', 14) % set axis font size to 14pt set(gca, 'FontWeight', 'bold') % set axis font to bold subplot(1,2,2) nyquist(sysG) %graph edits xlabel('Real Axis', 'FontWeight', 'bold', 'FontSize', 16) % x-axis title, bold font, 16pt ylabel('Imaginary Axis', 'FontWeight', 'bold', 'FontSize', 16) % y-axis title, bold font, 16pt set(gca, 'box', 'off') %turns off the box border set(findobj('Type','axes'), 'LineWidth', 1.5) % Set axis line width to 1.5 set(findobj('Type','line'), 'LineWidth', 1.5) % Set plot line width to 1.5 set(gca, 'FontSize', 14) % set axis font size to 14pt set(gca, 'FontWeight', 'bold') % set axis font to bold

Page 17: EE451 Mechatronic Simulation & Control Assignment

t =0:0.0001:0.1 step(sysG,t) %graph edits xlabel('Time', 'FontWeight', 'bold', 'FontSize', 16) % x-axis title, bold font, 16pt ylabel('Amplitude', 'FontWeight', 'bold', 'FontSize', 16) % y-axis title, bold font, 16pt set(gca, 'box', 'off') %turns off the box border set(findobj('Type','axes'), 'LineWidth', 1.5) % Set axis line width to 1.5 set(findobj('Type','line'), 'LineWidth', 1.5) % Set plot line width to 1.5 set(gca, 'FontSize', 14) % set axis font size to 14pt set(gca, 'FontWeight', 'bold') % set axis font to bold

%damping [Wn,zeta] = damp(sysG) %=>zeta equal to one implies critically damped system

%controllable/observable etc Co = ctrb(sysGss) detCo = det(Co)

Ob = obsv(sysGss) detOb = det(Ob)

%system is controllable & observable if determinants not zero

%rank (confirmation of controllable & observable a from first principles) Co_first = [B;A*B] rankCo = rank(Co_first)

Ob_first = [C;C*A] rankOb = rank(Ob_first)

%controller canonical format sysGcanon = canon(sysGss,'companion')

%frequency response performance [gainMargin, phaseMargin, wcg, wcp] = margin(sysG); display(gainMargin) display(wcg) display(phaseMargin) display(wcp)

margin(sysG); %graph edits xlabel('Frequency', 'FontWeight', 'bold', 'FontSize', 16) % x-axis title, bold font, 16pt ylabel('Phase', 'FontWeight', 'bold', 'FontSize', 16) % y-axis title, bold font, 16pt set(gca, 'box', 'off') %turns off the box border set(findobj('Type','axes'), 'LineWidth', 1.5) % Set axis line width to 1.5 set(findobj('Type','line'), 'LineWidth', 1.5) % Set plot line width to 1.5 set(gca, 'FontSize', 14) % set axis font size to 14pt set(gca, 'FontWeight', 'bold') % set axis font to bold

%residue [numG,denG] = tfdata(sysG,'v') [resG,poleG,kG] = residue(numG,denG)

display(resG) display(poleG)

%performance predictions polesG = pole(sysG) realPart = abs(real(polesG(2))) imajPart = abs(imag(polesG(2))) %=>no imaginary part, can't use Real/Imag method to find transient

performance characteristics (b/c critically damped)

[Wn,zeta] = damp(sysG) %=>zeta equal to one implies critically damped system

a = (-1)*(max(polesG))

%initial value predInitial = evalfr(sysG,inf)

%final value (steady state output) predYss = dcgain(sysG)

Page 18: EE451 Mechatronic Simulation & Control Assignment

%rise time %predRT = (pi-(atan(imajPart/realPart)))/(imajPart) predRT = 2.2/a

%settling time %predST = (4/realPart) predST = 4/a

%time constant %predTC = 0.63*predRT predTC = 1/a

%percentage overshoot %predOS = 100*(exp(-pi*(realPart/imajPart)))

%peak time %predPT = (pi/imajPart)

%% Simulation & Evaluation

%simulink Tstart = 0 Tstop = 0.1

input = 1

sim 'assignement' plot(tout, yout) %graph edits xlabel('Output (rad/sec)', 'FontWeight', 'bold', 'FontSize', 16) % x-axis title, bold font, 16pt ylabel('Time (secs)', 'FontWeight', 'bold', 'FontSize', 16) % y-axis title, bold font, 16pt set(gca, 'box', 'off') %turns off the box border set(findobj('Type','axes'), 'LineWidth', 1.5) % Set axis line width to 1.5 set(findobj('Type','line'), 'LineWidth', 1.5) % Set plot line width to 1.5 set(gca, 'FontSize', 14) % set axis font size to 14pt set(gca, 'FontWeight', 'bold') % set axis font to bold

Tstart = 0 Tstop = 1 %simulate for longer to get more accurate steady state responses input = 1 sim 'assignement'

%performance measurements %measured inital value measInit = yout(1)

%measured final value measYss = mean(yout(901:end))

%measured percentage overshoot [maxVal, maxInd] = max(yout) measOS = 100*((maxVal-measYss)/(measYss))

%measured peak time measPT = tout(maxInd)

%measured time constant indTc = find(yout>=(measYss*0.63),1,'first') measTC = tout(indTc)

%measured rise time indT90 = find(yout>=(measYss*0.9),1,'first') indT10 = find(yout>=(measYss*0.1),1,'first') measRT = tout(indT90) - tout(indT10)

%measured settling time indHi = find(yout > (measYss*1.02),1,'last') indLo = find(yout < (measYss*0.98),1,'last') indTs = max([indHi indLo])

measST = tout(indTs)

Page 19: EE451 Mechatronic Simulation & Control Assignment

%values display(measInit) display(measYss) display(measOS) display(measPT) display(measTC) display(measRT) display(measST)

%varying input input = 0 sim 'assignement' measYss0 = mean(yout(901:end))

input = 1 sim 'assignement' measYss1 = mean(yout(901:end))

input = 2 sim 'assignement' measYss2 = mean(yout(901:end))

input = 3 sim 'assignement' measYss3 = mean(yout(901:end))

input = 5 sim 'assignement' measYss5 = mean(yout(901:end))

input = 10 sim 'assignement' measYss10 = mean(yout(901:end))

input = 100 sim 'assignement' measYss100 = mean(yout(901:end))

%% END diary off