Académique Documents
Professionnel Documents
Culture Documents
A PROJECT REPORT
DEGREE
32
Submitted By
MAMOONA BIRKHEZ SHAMI
MUHAMMAD SARMAD
SALMAN AHMED
TAHA HAMID
BACHELORS
IN
ELECTRICAL ENGINEERING
Year
2014
PROJECT SUPERVISOR
DR. FAHAD MUMTAZ MALIK
NUST COLLEGE OF
ELECTRICAL AND MECHANICAL ENGINEERING
Submitted by:
NS MAMOONA BIRKHEZ SHAMI
2010-NUST-CEME-BE-EE
EE-052
NS MUHAMMAD SARMAD
2010-NUST-CEME-BE-EE
EE-033
NS SALMAN AHMED
2010-NUST-CEME-BE-EE
EE-040
NS TAHA HAMID
2010-NUST-CEME-BE-EE
EE-044
Project Supervisor:
Date:
Dr. Fahad Mumtaz Malik
Head of Department:
Date:
Brig. Basharat
COLLEGE OF
ELECTRICAL AND MECHANICAL ENGINEERING
PESHAWAR ROAD, RAWALPINDI
1|Page
DECLARATION
We hereby declare that no portion of the work referred to in this Project Thesis has been
submitted in support of an application for another degree or qualification of this or of any other
university or other institute of learning. If any act of plagiarism found, we are fully responsible
for every disciplinary action taken against us depending upon the seriousness of the proven
offense.
COPYRIGHT STATEMENT
Copyright in text of this thesis rests with the student authors, copies (by any process)
either in full, or of extracts, may be made only in accordance with the instructions given
by the authors and lodged in the Library of NUST College of E&ME. Details may be
obtained by the Librarian, this page must form part of any such copies made. Further
copies (by any process) of copies made in accordance with such instructions may not be
made without the permission (in writing) of the authors.
The ownership of any intellectual property rights which may be described in this thesis is
vested in NUST College of E&ME, subject to any prior agreement to the contrary, and
may not be made available for use by third parties without the written permission of the
College of E&ME, which will prescribe the terms and conditions of any such agreement.
Further information on the conditions under which disclosures and exploitation may take
place is available from the Library of NUST College of E&ME, Rawalpindi.
2|Page
3|Page
ACKNOWLEDGEMENTS
First of all, we would like to thank ALLAH (Subhanahuwataala) Who enlightened us with the
knowledge that we needed for our project and gave us strength to accomplish our task.
We acknowledge, with deep gratitude and appreciation, the inspiration, encouragement, valuable
and continuous guidance given to us by Dr. Fahad Mumtaz Malik, we also acknowledge the
immense support of Dr. Shakeel Ahmed (Nescom) and Sir Mukhtar (Nescom) regarding control
design and system identification respectively.
Special thanks to our family members for bearing with us through the tough routine and for
continuously encouraging us.
4|Page
Table of Contents
Abstract ........................................................................................................................................... 8
1
Introduction ........................................................................................................................... 11
1.1
1.2
Objectives ....................................................................................................................... 13
1.3
2.2
2.2.1
2.3
2.3.1
3
Procedure ................................................................................................................ 17
Motivation ...................................................................................................................... 20
3.2
Modeling Approach........................................................................................................ 20
3.3
3.3.1
3.3.2
S function ................................................................................................................ 21
3.4
4
Procedure ................................................................................................................ 16
Linearization ......................................................................................................................... 24
4.1
4.2
Introduction .................................................................................................................... 27
5.2
5.2.1
5.2.2
5.2.3
5.3
Procedure........................................................................................................................ 28
5.4
5.5
5|Page
5.6
5.7
5.7.1
5.7.2
5.7.3
5.8
5.9
6.1.1
Introduction ............................................................................................................. 44
6.1.2
Design Steps............................................................................................................ 45
6.1.3
Results ..................................................................................................................... 50
6.1.4
6.2
H-Infinity........................................................................................................................ 54
6.2.1
Introduction ............................................................................................................. 54
6.2.2
Design Steps............................................................................................................ 55
6.2.3
Simulations ............................................................................................................. 56
6.2.4
Controller Identification........................................................................................................ 60
7.1
Introduction .................................................................................................................... 60
7.2
7.3
7.3.1
7.3.2
7.3.3
7.4
7.5
7.5.1
7.6
8
Controller Identification Vs. Lag Lead Controller and H infinity controller ......... 66
Limitations ..................................................................................................................... 66
Appendix ............................................................................................................................... 67
A.
S-Function ...................................................................................................................... 67
6|Page
B.
Sensor1.m File................................................................................................................ 68
C.
7|Page
Table of Figures:
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
FIG.
1-1 ...................................................................................................................................................................... 14
2-1 HARDWARE ASSEMBLY ........................................................................................................................ 15
3-1FREE BODY DIAGRAM ............................................................................................................................ 20
3-2 SIMULINK BLOCK DIAGRAM OF PLANT ........................................................................................... 21
3-3 VALIDATION SETUP ............................................................................................................................... 22
3-4 VALIDATION GRAPHS ........................................................................................................................... 23
4-1 STEP RESPONSE AT DIFFERENT EQUILIBRIUM POINTS ................................................................ 26
5-1: DIFFERENT MODELING STRUCTURES. ............................................................................................. 29
5-2: SYSTEM ID TOOL BOX MAIN WINDOW. ........................................................................................... 30
5-3: STEP INPUT TO THE OPEN LOOP SYSTEM. ....................................................................................... 34
5-4: STEP RESPONSE OF THE OPEN LOOP SYSTEM. ............................................................................... 34
5-5: RAMP INPUT TO THE OPEN LOOP SYSTEM. ..................................................................................... 34
5-6: RAMP RESPONSE OF THE OPEN LOOP SYSTEM. ............................................................................. 34
5-7: SINE INPUT TO THE OPEN LOOP SYSTEM. ....................................................................................... 35
5-8: SINE RESPONSE OF THE OPEN LOOP SYSTEM. ............................................................................... 35
5-9: SINE SWEEP INPUT TO THE SYSTEM. ................................................................................................ 35
5-10: SINE SWEEP RESPONSE OF THE OPEN LOOP SYSTEM. ............................................................... 35
5-11: SELECTED MODEL OUTPUT GRAPHS FOR THE STEP INPUT...................................................... 36
5-12: SELECTED MODEL OUTPUT GRAPHS FOR THE RAMP INPUT.................................................... 37
5-13: SELECTED MODEL OUTPUT GRAPHS FOR THE SINE INPUT. ..................................................... 38
5-14: SELECTED MODEL OUTPUT GRAPHS FOR THE SINE SWEEP INPUT. ....................................... 39
5-15: IDENTIFIED MODEL RESPONSES TO STEP INPUT AND CORRESPONDING ERROR. .............. 40
5-16 : IDENTIFIED MODEL RESPONSES TO RAMP INPUT AND CORRESPONDING ERRORS.......... 41
5-17: IDENTIFIED MODEL RESPONSES TO SINE INPUT AND CORRESPONDING ERRORS. ............ 41
5-18: IDENTIFIED MODEL RESPONSES TO SINE SWEEP INPUT AND CORRESPONDING ERRORS.
........................................................................................................................................................................... 42
5-19: RESPONSE OF THE MODELS TO A STEP INPUT. ............................................................................ 43
5-20: ERROR PLOTS FOR LINEARIZED AND IDENTIFIED MODELS. .................................................... 43
6-1 : NEGATIVE FEEDBACK CONFIGURATION USED IN LEAD LAD COMPENSATOR DESIGN .... 44
6-2: OPEN LOOP FREQUENCY RESPONSE OF THE PLANT .................................................................... 45
6-3 : BODE PLOTS FOR OPEN LOOP PLANT AND LEAD COMPENSATOR .......................................... 47
6-4: OPEN LOOP FREQUENCY RESPONSE WITH LEAD COMPENSATOR ........................................... 48
6-5: BODE PLOTS FOR GCLAG AND LEAD COMPENSATED SYSTEM ................................................. 49
6-6 : OPEN LOOP FREQUENCY RESPONSE OF LAG LEAD COMPENSATED SYSTEM ...................... 50
6-7: COMPARISON OF BODE PLOTS THREE DIFFERENT COMPENSATED SYSTEM ........................ 50
6-8: STEP RESPONSE OF LAG LEAD COMPENSATED SYSTEM ............................................................ 51
6-9: COMPARISON OF STEP RESPONSE OF SIMULATION AND HARDWARE .................................... 52
6-10: DISPLAYING NONLINEAR BEHAVIOR AT LARGE DISPLACEMENTS ....................................... 53
6-11: INSTABILITY OCCURRING AT DISPLACEMENT OF -10 CM ........................................................ 54
6-12: POSITIVE CONFIGURATION USED IN H INFINITY LOOP SHAPING DESIGN ........................... 55
6-13: COMPARISON OF STEP RESPONSE OF LAG LEAD AND H INFINITY LS CONTROLLED
SYSTEM ............................................................................................................................................................ 56
6-14 :COMPARISON OF STEP RESPONSE OF H INFINITY LS CONTROLLED SYSTEM ..................... 58
6-15( DISPLAYING H INFINITY LS ROBUSTNESS OVER LAG LEAD COMPENSATOR ) ................... 59
7-1: A CLOSED LOOP SYSTEM ..................................................................................................................... 60
8|Page
9|Page
Abstract
A linear model of a magnetic levitation module (ECP model 730) has been identified using
system identification techniques. The accuracy of the identified model has been affirmed by its
comparison with the mathematically derived linear model. Furthermore, three different linear
control schemes which include conventional lag lead compensator, H infinity loop shaping
controller and a relatively newer one which we name controller identification have been
implemented on the ECP model 730.
10 | P a g e
1. INTRODUCTION
Introduction
Maglev (derived from magnetic levitation) is a method of propulsion that uses magnetic
levitation to propel vehicles with magnets rather than with wheels, axles and bearings. With
maglev, a vehicle is levitated a short distance away from a guide way using magnets to create
both lift and thrust.
Maglev vehicles move more smoothly and somewhat more quietly than wheeled mass
transit systems. Their non-reliance on traction and friction means that acceleration and
deceleration can surpass that of wheeled transports, and they are unaffected by weather. The
power needed for levitation is typically not a large percentage of the overall energy
consumption; most of the power is used to overcome air resistance (drag), as with any other
high-speed form of transport. Although conventional wheeled transportation can travel very
quickly, a maglev system allows routine use of higher top speeds than conventional rail, and it is
this type which holds the speed record for rail transportation.
Earnshaw's theorem proves that using only paramagnetic materials (such as ferromagnetic iron)
it is impossible for a static system to stably levitate against gravity.For example, the simplest
example of lift with two simple dipole magnets repelling is highly unstable, since the top magnet
can slide sideways, or flip over, and it turns out that no configuration produced adding more
magnets can produce stability.However, controllers can be designed to control the magnetic
force which can allow stability to be achieved.
Bullet Trains
High speed trains in Europe and Japan are perhaps the best example of magnetic levitation
technology. According to the Los Alamos National Laboratory, Germany, France and Japan have
developed bullet trains with speeds ranging between 150-180 mph. This exceeds the speed of
conventional trains which are capable of up to 110 mph. Though the magnetic suspension system
of bullet trains allows for greater speeds, the technology is currently expensive to implement and
maintain.
Magnetic Bearings
1. INTRODUCTION
kind of physical contact. The benefits of this include reduced friction, reduced wear on
machinery and the highest speeds of any kind of bearing. Disadvantages of magnetic bearings
include attraction difficulties when increasing or decreasing bearing distances from levitating
objects.
Two additional scientific applications for magnetic levitation include flywheels and levitation
melting. Flywheels are rotating mechanisms used to store energy. Magnetic levitation can be
used to rotate flywheels thereby assisting with energy storage. With levitation melting, it is
possible to levitate small amounts of metal and eventually melt the metal through use of
magnetic forces and electricity. Levitation melting has been commercially tested and is a viable
application of the technology.
Maglev usages from view point of engineering science can be categorized and summarized as
follows:
Environmental engineering (small and huge wind turbines: at home, office, industry,
etc.),
Civil engineering including building facilities and air conditioning systems (magnetic
bearing, elevator, lift, fan, compressor, chiller, pump, gas pump, geothermal heat pumps,
etc.),
12 | P a g e
1. INTRODUCTION
1.2 Objectives
The second objective is to design such a linear control technique that stabilizes the
system over the range of operation and shows a linear response.
The third objective is to identify the transfer function of an ideal controller using system
identification techniques.
Various system identification models are present e.g. ARMAX, ARX etc. Based on the input and
output data, a system model can be obtained of the desired order. The response of this identified
model is then compared with the actual hardware to validate the identified model.
A lot of research has been done on control design techniques for maglev systems. Various linear
and non-linear control schemes, robust stabilization techniques and intelligent adaptive control
techniques have been implemented on maglev systems. For the purpose of this project, the
discussion has been limited to Lead-Lag compensator and H-infinity Loop Shaping controller.
H-infinity Loop Shaping controller shapes the frequency response of the plant using Lead-Lag
compensator as weights in its standard notation and robustly stabilizes the plant .
Controller identification is a relatively new field. This domain of study entails acquiring input
data and required output data (based on the performance and robustness criteria) and obtaining a
transfer function using identification techniques. This technique removes the restrictions on the
designer to use a set of equations to implement a particular kind of controller. This also waives
the tedious work involved in solving equations and designing a particular kind of controller.
13 | P a g e
1. INTRODUCTION
Acquire input and output data and get models of different orders using Ident Tool of
MATLAB and use the best fit model
Implement the model using Simulink and S-Function
S
Develop Lead-Lag
Lag Compensator and implement in Simulink and on hardware and
compare the results
Develop H-infinity
infinity loop shaping
shapi
controller and implement it in Simulink and on
hardware and compare the results
Using the input and required output data, identify the controller using Ident Tool
Hardware
Implementation &
Validation
Implementing LeadLag & H-Infinity
Data Acquisition
and system
Identification
Mathematical
Modelling &
Linearization
Fig. 1-1
14 | P a g e
Controller
Identification
The Model 730 Magnetic Levitation (Maglev) apparatus may be quickly transformed into
a variety of single input single output (SISO) and multi-input multi-output (MIMO)
configurations. By using repulsive force from the lower coil to levitate a single magnet,
an open loop stable SISO system is created. Attractive levitation via the upper coil affects an
open loop unstable system. Two magnets may be raised by a single coil to produce a SIMO
plant. If two coils are used a MIMO one is produced. These may be locally stable or unstable
depending on the selection of the magnet polarities and the nominal magnet positions. The plant
has inherently strong nonlinearities due to the natural properties of magnetic fields. These may
be compensated for in feed forward using derived or provided algorithms so that the
control problem may be approached as that of a linear or nonlinear system depending on
the desired course of study. Thus this dynamically rich system provides a test bed for
experiments ranging from demonstration of fundamental principles to advanced research. For
the purpose of this project, we will focus on the SISO system of the lower coil.
The experimental system is comprised of the three subsystems shown in Fig. 2-1. The first of
these is the electromechanical plant, which consists of the Maglev apparatus including its
actuators and sensors. The design features two high field density rare earth magnets and high
flux drive coils to provide more than 4 cm. of controlled levitation range. Laser sensors provide
15 | P a g e
Using sensor1.m file for curve fitting, the equation constants come out to be:
= 17632000
= 2166915
= 5739
= 1.9731
The values when plugged in the ECP software results in a sensor gain of 1000000 counts / meter.
17 | P a g e
11000
12000
14000
18000
22000
Table 2.2 Actuator Calibration
Using actuat1.m file for curve fitting: However the values of a1 and b1 were later changed by
hit and trial using the experiment mentioned in the manual.
= 1.04
= 6.2
19 | P a g e
3. MATHEMATICAL MODELING
Mathematical Modeling
3.1 Motivation
In control systems, any control technique for implementation requires a system model on
simulation. This is required because we cannot simply move on to the hardware in first go. We
need to be sure about how our control
con
technique is going to change the system. For that, it is
important to have a mathematical model of our system through which we can anal
analyze the system
responses beforehand.
( + 100 )
Fig. 3-1free
free body diagram
Where
=
=
= 1.04
= 6.2
.
1.1
3. MATHEMATICAL MODELING
2. S - function
Two approaches are used to verify the results of each other. This is done to boost our confidence
that the differential equation is implemented correctly.
3.3.1
Block model
double
double
double
Control effort
(counts)
1/0.121
1
s
double
Product
double
double
1
s
Integrator
Limited
Integrator1
1/m
1
air gap
(m)
Product4
0.121*9.8
double
double
double
double
mg
1.1
Converting m to cm
Friction Coefficient
Product1
double
Add
1
double
Constant2
double
1.04
double
double
double
Math
Function
double
100
6.2
Constant4
3.3.2 S function
In this tool, the entire differential equation is implemented in a code. The code is imported in the
S-function block of Simulink. The code is present in the appendix.
21 | P a g e
3. MATHEMATICAL MODELING
22 | P a g e
3. MATHEMATICAL MODELING
4
Impulse Response
x 10
4.5
x 10
Actual Hardware
Simulated Model
Sensor Position(counts)
3.5
2.5
0.2
0.4
0.6
0.8
1
1.2
Time (s)
1.4
1.6
1.8
0.2
0.4
0.6
(a)
1
1.2
time(sec)
1.4
1.6
1.8
(b)
4.5
0.8
x 10
Actual Plant
Simulated Nonlinear Model
3.5
3
2.5
2
1.5
1
0.5
0
8
Time (s)
(c)
Fig. 3-4 Validation Graphs
23 | P a g e
10
12
14
4. LINEARIZATION
Linearization
Plugging it in first equation and with some manipulations, thee linear model obtained is:
Where m = 0.121 kg
c = 1.1
a = 1.04
b = 6.2
u0 = 5575 counts
y0 = 0.02 m
24 | P a g e
4. LINEARIZATION
height (cm)
Control
Effort
(Counts)
3314.16
( )=
0.002957
+ 9.091 + 544.4
1.5
4335.1855
( )=
0.002261
+ 9.091 + 509.1
5575
( )=
0.001757
+ 9.091 + 477.98
2.5
7065.15
( )=
0.001387
+ 9.091 + 450.6
8834.78
( )=
0.001109
+ 9.091 + 426.1
3.5
10917.7
( )=
0.0008976
+ 9.091 + 404.1
13348.89
( )=
0.0007341
+ 9.091 + 384.3
Transfer Function
Table 4-1
Different step inputs were given to each model to compare the output displacement. It is evident
from the graphs that there is a significant difference in displacement in (m) between all models.
25 | P a g e
4. LINEARIZATION
The model at 1cm has the maximum displacement whereas the model linearized at 4cm has the
least displacement for equal control effort (counts). This suggests that controllers designed for
one linear model will not give us the same performance at other operating points.
-3
4.5
-3
x 10
1cm
1,5 cm
2 cm
2.5 cm
3 cm
3.5 cm
4 cm
4
3.5
2.5
2
5
4
1.5
0.5
0.2
0.4
0.6
0.8
1
time(sec)
1.2
1.4
1.6
1.8
1cm
1.5cm
2cm
2.5cm
3cm
3.5cm
4cm
Height ( m )
Height ( m )
x 10
0.2
0.4
0.6
0.8
(a)
1
time(sec)
(b)
0.016
0.014
Height ( m )
0.012
0.01
0.008
0.006
0.004
0.002
0.2
0.4
0.6
0.8
1
time(sec)
1.2
1.4
1.6
(c)
26 | P a g e
1.8
1.2
1.4
1.6
1.8
5.1 Introduction
In many practical scenarios in daily life in order to apply control on a specific plant the transfer
function is not easily determinable or is not known at all. In such situation a hit and trial
approach is used to apply a control scheme on the particular plant. But system identification not
only helps in finding a transfer function but also helps in applying a control scheme on the plant
by using that transfer function.
Therefore system identification is very important especially in case of plants where a hit and trial
approach is not feasible.
In this section the procedure to identify the model of the ECP 730 Maglev system and then
compare the identified transfer function with the actual model and linearized model to determine
the level of accuracy of the identified data is presented.
This identified model is also used as the basis to design different controllers for the plant.
27 | P a g e
5.3 Procedure
1. The data record. The input-output data are sometimes recorded during a specifically designed
identification experiment, where the user may determine which signals to measure and when to
measure them and may also choose the input signals. The object with experiment design is thus
to make these choices so that the data become maximally informative, subject to constraints that
may be at hand. In other cases the user may not have the possibility to affect the experiment, but
must use data from the normal operation of the system.
2. The set of models. A set of candidate models is obtained by specifying within which collection
of models we are going to look for a suitable one. This is no doubt the most important and, at the
same time, the most difficult choice of the system identification procedure. It is here that a priori
knowledge and engineering intuition and insight have to be combined with formal properties of
models. Sometimes the model set is obtained after careful modeling. Then a model with some
unknown physical parameters is constructed from basic physical laws and other well-established
relationships. In other cases standardlinear models may be employed, without reference to the
physical background. Such a model set, whose parameters are basically viewed as vehicles for
adjusting the fit to the data and do not reflect physical considerations in the system, is called a
black box. Model sets with adjustable parameters with physical interpretation may, accordingly,
be called gray boxes.
3. Determining the "best" model in the set, guided by the data. This is the identification method.
The assessment of model quality is typically based on how the models perform when they
attempt to reproduce the measured data.
28 | P a g e
For this model there is a need to find the parameters that are associated with that particular
model. For the purpose of this project least squares algorithm has been used. [1]
29 | P a g e
[ 1]
[ 2] +
[ 1] + [ ]
The above equation is the equation for the ARX model under consideration. Noise has been
treated as direct input. Using MATLAB tool box the parameters estimates yield the following
numerical values for the parameters
a1= -1.8894
a2= 0.9289
b= 0.1068
Plugging these parameters in the above equation will define the complete ARX model. Up till
now MATLABs system identification tool has done all the work.
30 | P a g e
+ [ ]
e[n] is the white noise which will obviously not be a part of the linear predictor ,thus linear
[ ]=
predictor is
Then error between predictor and linear model at any given k is
[ ]= [ ] [ ]
The residual for all values of k can be expressed in vector form as follows
[1]
[ ]
[1]
[1]
[ ]
[ ]
=
The optimal estimate
= (
) (
[ ]
) (
)..equation # 1
For simplest ARX model which is used above the optimal estimate is equal to
1
= 2
So putting values in the equation #1 and after solving the following particular equation for the
ARX model parameters can be obtained. In this case:
31 | P a g e
[0]
[1]
[0]
[ 1]
[ 2]
[ 1]
[ 1]
[ 1] [ 2]
[ 2] [ 1]
[ 2]
[ 1] [ 1]
[ 1] [ 2]
[0]
[ 1]
[1]
[ 2]
[ 1] [ 1]
[ 2] [ 1]
[ 1]
[0]
[ 1]
[ 1] [ ]
[ 2] [ ]
[ 1] [ ]
After finding the above equation the same input output data was used that was given to the
system identification tool box for finding the ARX model. And a code in MATLAB can be
written to solve the above given matrix equation for that particular input output data and thus
can be found out which comes out to be:
1.8894
= 0.8915
0.1005
Hence the parameters become
a1=-1.8894,
a2=0.8915,
b=0.1005
These values are very near to the values which were found by the system identification tool.
ARX model parameters can be derived while being independent of the system identification tool.
And after finding out those parameters, they can be compared with the parameters of the system
identification tool. The comparison for the values obtained from manual derivation and those
from System Id tool is given below:
Identification Tool
Manual Derivation
a1
-1.8894
-1.8894
a2
0.9289
0.8915
b
0.1068
0.1005
Table 5-1 Comparison of computer calculated values with manually calculated values.
32 | P a g e
The first step towards system identification is to apply suitable input to the actual system
and collect the output and input data. A rich input should be selected which excites all the states
of the system. The ECP module attached with the system provides a range of inputs that can be
applied to it. To achieve a better identified model and to maintain generality, four different
inputs were considered.
Input 1 was a step input with an amplitude of 4000 counts, dwell time of 1 s and 2
repetitions. Input 2 was a ramp input with distance of 4000 counts, velocity of 4000 counts,
dwell time of 2 s and 2 repetitions. Input 3 was a sine input with amplitude of 4000 counts,
frequency of 1 Hz and 2 repetitions. Input 4 was a sine sweep input with an amplitude of 2000
counts, frequency range from 1 to 30 Hz and sweep time of 20 s.
Note: The given specifications of the inputs are in accordance with the ECP software. To get
more information regarding the terminology please refer to the manual of the ECP system.[3]
Since the equilibrium point of 2 cm was chosen, first the disc had to be levitated to this
height before application of the input. Therefore this identification procedure returns a linear
identified system with an equilibrium point of 2 cm. The plots of the input output data collected
are provided below. The y-axis represents y in counts and x-axis represents time in seconds.
33 | P a g e
Hardware Input
2.5
4000
3500
Hardware Output
x 10
Height (counts)
Input (counts)
3000
2500
2000
1500
1.5
0.5
1000
500
0
-0.5
Time (s)
Time (s)
Hardware Input
Hardware Output
4000
12000
3500
10000
8000
2500
Height (counts)
Input (counts)
3000
2000
1500
6000
4000
1000
2000
500
0
6
Time (s)
34 | P a g e
10
Time (s)
10
Hardware Input
4000
1.5
3000
1
0.5
1000
Height (counts)
Input (counts)
2000
0
-1000
-2000
0
-0.5
-1
-1.5
-3000
-4000
-2
0.5
1.5
2
2.5
Time (s)
3.5
-2.5
1500
1000
500
Height (counts)
0
-500
-1500
-2
10
15
Time (s)
35 | P a g e
1.5
20
2
2.5
Time (s)
3.5
25
30
Hardware Output
x 10
0
-1
-1000
0.5
2000
-2000
Hardware Input
Input (counts)
Hardware Output
x 10
-3
10
15
Time (s)
20
25
30
The input output data was exported to the System Identification toolbox in MATLAB. The data
was preprocessed before applying the estimation procedure. Preprocessing removes any trends in
the data and divides the data into two parts: one for identification and the other for validation of
the identified model. For the purpose of this experiment ARX and ARMAX models were
considered. It was decided to minimize the complexity of the system by choosing a lower order
model such as a 2nd order model. The estimation focus was on Prediction and minimum least
squares method was used to estimate the parameters.
For each input a number of models were estimated and their output performance compared using
the Model Output plots of the System Identification toolbox. It was observed that for a second
order model best fit percentage varied from 40 to 75 % and to achieve a best fit percentage of
around 80% a much higher order was required. ARMAX models showed better estimation than
ARX models in most cases.
The model output graphs for selected step data are provided below:
4
1.5
x 10
arx221 (42.83)
arx931 (81.77)
amx2111 (79.06)
Validation Data
0.5
-0.5
-1
-1.5
2.5
3.5
4.5
Time
Fig. 5-11: Selected Model output graphs for the step input.
36 | P a g e
4000
2000
-2000
-4000
-6000
5.5
6.5
7.5
Time
8.5
9.5
10
Fig. 5-12: Selected Model output graphs for the ramp input.
It can be seen all these models give approximately same best fit percentage so the ARX model
with order [2 1 1] and best fit percentage of 81.86% is selected.
37 | P a g e
x 10
amx2221 (73.23)
arx331 (66.49)
amx2111 (73.23)
arx221 (66.76)
Validation Data
1.5
0.5
-0.5
-1
-1.5
-2
-2.5
-3
0.5
1.5
2
Time
2.5
3.5
Fig. 5-13: Selected Model Output graphs for the sine input.
Again the performance of all the estimated models is similar so the model with the highest best
fit percentage is selected. In this case ARMAX model with order [2 1 1 1] gives the maximum
best fit percentage of 73.23% and has the lowest order. Therefore it is selected.
38 | P a g e
x 10
arx311 (-1.073)
amx2111 (43.19)
arx211 (-3.932)
Validation Data
-1
-2
-3
10
11
Time
12
13
14
15
16
Fig. 5-14: Selected Model output graphs for the sine sweep input.
It can be seen that all models show poor performance especially the ARX models. This can be
attributed to the fact that the input is changing very quickly and so it becomes difficult for basic
techniques such as ARX or ARMAX to estimate a proper model. Either more advanced
modeling techniques such as Box Jenkins techniques can be applied or input improved to give
less variations. Considering that fact that such high variations do not occur normally ARMAX
model with order [2 1 1 1] is selected because it gives the highest best fit percentage (43.19%)
and has an acceptable order.
5.7.3
Having estimated four different models they were now compared to arrive at a general model
which gave minimum error for all considered inputs. This was done by applying the same
hardware inputs to all models and comparing their responses to each input. Then the percentage
error of each model was calculated for every input. The model which gave minimum error for all
inputs was selected as the identified model. This was achieved by making a model file in
Simulink with the appropriate blocks.
39 | P a g e
2.5
x 10
Hardware
Step Model
Ramp Model
Sine Model
Sinesweep Model
Height (counts)
1.5
0.5
-0.5
-1
0.5
1.5
2.5
3.5
Time (s)
Fig. 5-15: Identified Model responses to step input and corresponding error.
40 | P a g e
4.5
Height (counts)
15000
10000
5000
-5000
Time (s)
Fig. 5-16 : Identified model responses to ramp input and corresponding errors.
Sine response of the models together with the error percentages are provided below.
4
x 10
Hardware
Step Model
Ramp Model
Sine Model
Sinesweep Model
1.5
Height (counts)
0.5
-0.5
-1
-1.5
-2
-2.5
0.5
1.5
2
Time (s)
2.5
3.5
Fig. 5-17: Identified model responses to sine input and corresponding errors.
41 | P a g e
x 10
Hardware
Step Model
Ramp Model
Sine Model
Sinesweep Model
Height (counts)
-1
-2
-3
10
15
Time (s)
20
25
30
Fig. 5-18: Identified model responses to sine sweep input and corresponding errors.
It can be observed that in all cases the model estimated using the sine sweep data gives the least
error and in all cases except for the sine sweep input case the error is not more than 30% which is
quite acceptable. Therefore this model can serve as the general identified model at the
equilibrium point of 2 cm.
The discrete time and continuous time transfer function of the estimated model are as follows:
( )=
0.004231
1.986 + 0.9873
( )=
1.202 + 1362
+ 7.253 + 402.2
The conversion was done using MATLAB with zero order hold and sample time of 0.001768 s.
42 | P a g e
x 10
2.5
5000
4000
Error (counts)
Height (counts)
2
1.5
1
3000
2000
0.5
1000
-0.5
-1000
Time (s)
Time (s)
The graphs show that both linear models are quite close to each other with the identified model
being a little more accurate than the linearized model. Therefore it is preferable to use input
output data of the system to derive a model through MATLAB easily instead of taking on the
laborious task of linearizing the system equations manually.
43 | P a g e
6.1 Lead-Lag
Lag Compensator
6.1.1 Introduction
Control design begins by using a simple unity-feedback
unity feedback system (the uncompensated system) in
which the gain is adjusted in an effort to provide good steady performance and good stability. If
the uncompensated system is unable to meet the design goals, a compensator must be added.
Compensators improve the frequency response according to the performance requirements in a
feedback and control system. They are fundamental building blocks in classical control theory.
Many different types of compensators are available e.g. PID, lag-lead
lag lead etc. PID is an ideal
controller. Ideal integral compensation requires an active integrator
integrator with its pole on the origin. If
we use passive networks such as lag compensation instead of ideal integrator, the pole and zero
are moved to the left close to the origin. Even though this placement of the pole does not
increase the type number of the system, it yields an improvement in the static error constant over
an uncompensated system. Just as an ideal integrator can be realized by a lag compensator, ideal
derivative compensator can be approximated by lead compensator.
The advantages of passive networks over active networks are:
1. No additional power supplies are required
2. Noise due to differentiation is reduced
The disadvantage is that where an integrator increases the system type number, lag does not.
Also, the additional pole of lead does not reduce
reduce the number of branches of the root locus that
cross the imaginary axis into the right-half
right half plane while ideal derivative reduces the branches.
A negative feedback configuration is used in this section as shown below. The saturation block
limits the control
rol effort output in between -30000 to 30000. The dotted lines have digital data on
them and continuous lines have continuous data.
Fig. 6-1 : Negative feedback configuration used in Lead Lad Compensator Design
44 | P a g e
( )=
0.001757
+ 9.091 + 477.98
The sensor acts as a constant gain of 1000000 counts per meter. So the overall plant is
( )=
1757
+ 9.091 + 477.98
Bode Diagram
Gm = Inf dB (at Inf rad/s) , Pm = 14 deg (at 46.7 rad/s)
Magnitude (dB)
20
0
-20
-40
Phase (deg)
-60
0
-45
-90
-135
-180
0
10
10
10
10
Frequency (rad/s)
This Bode plot shows the frequency response of the uncompensated system. The phase margin is
very less at 14.
Lead compensator is used to shift the phase margin of the open loop system to the required phase
margin while not affecting low frequencies in any way.
45 | P a g e
= 28.69
Next we design the lead compensator to increase the phase margin of the open loop compensated
plant. The Phase margin (P.M) is calculated using equation as follows.
P. M
= tan
where = 0.5
2 + 1 + 4
P. M
= 51.83
As can be seen from the above diagram P.Mcurrent=14 . So the compensator has to add a phase of
P.Mcomp.
.
= 51.83 14 + 10 = 47.84
3. For this additional phase, the lead compensators poles and zeros are found using
( )=
Where,
( .
( .
+1
+1
=
The frequency on the uncompensated system's magnitude plot where the magnitude is -2.5943
dB is selected as the new phase margin frequency. By doing this, the magnitude bode plot of the
compensated system becomes 0db at this new frequency.
46 | P a g e
= 0.0367
Lastly, poles of compensator are calculated using the above equations and we get
( ) = 6.729
+ 27.23
+ 183.3
Bode Diagram
20
Magnitude (dB)
0
-20
-40
-60
gcLead
-80
gp
-100
45
Phase (deg)
0
-45
-90
-135
-180
0
10
10
10
10
10
Frequency (rad/s)
Fig. 6-3 : bode plots for open loop plant and lead compensator
This figure compares the frequency responses of the uncompensated system and the Lead
compensator. The magnitude curve of the compensator shows that it has no effect on the lower
frequencies. The cross over frequency is increased, the phase margin is increased.
47 | P a g e
Magnitude (dB)
40
20
0
-20
-40
-60
Phase (deg)
-80
45
0
-45
-90
-135
-180
0
10
10
10
10
10
Frequency (rad/s)
This bode plot shows that the required phase margin has been achieved but the dc gain is very
less. So we design Lag compensator such that its magnitude is 0 at higher frequencies but high at
lower frequencies to achieve the required gain.
To design Lag compensator:
We draw two asymptotes between 0 dB and the required gain i.e. 28.7 dB + 11.3 dB = 40dB.
Using equation of line:
= 20
( )+
The slope of line is -20 dB/decade. The upper frequency for lag compensator is chosen as 0.1
times less than the crossover frequency of lead compensator. This is done so that the pole and
zero of lag compensator do not interfere with the effect of lead compensator.
= 70.6448
48 | P a g e
+ 7.064
+ 0.2597
Bode Diagram
40
Magnitude (dB)
20
0
-20
-40
Lead Compensated
-60
gcLag
-80
45
Phase (deg)
0
-45
-90
-135
-180
-2
10
-1
10
10
10
10
10
10
Frequency (rad/s)
Fig. 6-5: Bode plots for GcLag and Lead Compensated system
This figure compares the frequency response of the Lead compensated system and the Lag
compensator. The magnitude curve of the Lag compensator shows that it adds the desired dc gain
in the system but does not affect the already achieved phase margin and crossover frequency of
the system.
Combining Lead and Lag gives the desired response.
( ) = 6.7303
( + 7.064)( + 27.23)
( + 183.3)( + 0.2597)
49 | P a g e
Results
Bode Diagram
Gm = Inf dB (at Inf rad/s) , Pm = 50.4 deg (at 70.9 rad/s)
40
Magnitude (dB)
20
0
-20
-40
-60
-80
0
Phase (deg)
-45
-90
-135
-180
-2
-1
10
10
10
10
10
10
10
Frequency (rad/s)
Fig. 6-6 : Open loop frequency response of Lag Lead compensated system
The phase margin of open loop compensated system has increased from 11.3 to the 50.4 which
is the design requirement.
Bode Diagram
Magnitude (dB)
50
-50
-100
45
Phase (deg)
0
-45
-90
-135
-180
-2
10
-1
10
10
10
10
10
Frequency (rad/s)
50 | P a g e
10
1.2
System: TfCL
Time (seconds): 0.464
Amplitude: 0.973
Amplitude
0.8
0.6
0.4
0.2
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
Time (seconds)
The time restrictions have been well met. Overshoot is less than 20%. Settling time is around 0.4
sec. Steady state error is also within the required bounds.
6.1.4 Discretization and Hardware implementation
To implement the compensator on hardware, we discretized the compensator block using
Simulink Model Discretizer with zero order hold [5].
The discretized model is as follows:
( )=
(
(
)(
)(
= 0.001768
In order to code this compensator in the ECP software, we made use of the following
methodology.
51 | P a g e
( )=
( )
( )
=
( )
(1
1(
( )+
+
=
+
+
( ( )
+
+(
)
)
( )
( )+
( )
[ 1] (
[ 1]
[ 2])
= 0.9868
Putting
) [ 2] + ( [ ]
=1
= 0.9611
= 0.7232
Input Ref
Hardware
Simulation
Delta y (counts)
2500
2000
1500
1000
500
0
0.5
1
time (sec)
1.5
52 | P a g e
6000
Delta y (counts)
4000
2000
0
-2000
-4000
-6000
-8000
3
time (sec)
If we increase the input step to 0.5cm, the response of hardware is still somewhat similar to the
simulated response but some deviations can be observed when the reference goes below 0. This
is because the gain of the linearized plant at lower positions is high. Compensator gain combined
with the gain of plant results in our system to move towards instability. This is observed once the
step input is large as shown below.
53 | P a g e
1.5
x 10
Input Ref
Hardware
Simulation
Delta y (counts)
0.5
0
-0.5
-1
-1.5
-2
3
time (sec)
For large input, such as 1cm (10000 counts), the hardware response does not match the simulated
response. The hardware response is faster and becomes unstable at lower positions.
6.2 H-Infinity
6.2.1 Introduction
In order to overcome the instability caused by the unknown model of the plant, as seen in the lag
lead compensator design section, an H-infinity loop shaping controller is designed. This
controller involves robust stabilization of combined with classical loop-shaping procedure as
mentioned in[6]. Its a two stage process in which first appropriate weights are chosen to shape
bode plot of the open loop plant as desired and then the shaped plant is robustly stabilized using
optimization . In our case, we have selected the weights to be that of lag-lead compensator
designed in the previous section.
A positive feedback configuration is used
54 | P a g e
and
are pre and post compensators respectively .
and
are used to shape the open loop
plant to the desired shape . Once that is done, is synthesized using robust stabilization
technique mentioned in [6].. The complete controller implemented is =
.
( + 183.3)( + 0.002597)
=1
2 thus
55 | P a g e
using
= 0.556
obtained is
. = [15.67 20.18
.
= 9.785
6.2.3 Simulations
The step response of lag lead and
controllers is shown in Fig 7-13. The rise time and settling
time of both controllers is also equal. This shows that the performance specifications by using
weights as conventional controller approximately remain same and we can use the
robust
stabilization to cater for uncertainties.
Amplitude
2000
1500
1000
500
Scale :
1000 counts = 1mm
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Time (seconds)
.
Fig. 6-13: Comparison of step response of lag lead and H infinity LS controlled system
56 | P a g e
0.9995 0
0
0
0
0 0.7232 0
0
0
0
0 0.5499 0
0
0
0
0 0.9629 0
0
0
0
0 0.9865
. = [0.004662
0.684 1.078
0.0002286 0.00003098]
1.7
0.1143
= 3.38
3.538
2.81
= 8.961
57 | P a g e
3000
input
hardware
simulation
2500
simulation
hardware
2500
2000
height(counts)
height(counts)
2000
1500
1500
1000
1000
500
500
Scale:
1000 counts = 1mm
0
0
0
0.5
1.5
0.5
(b) Ts = 0.003536
(a) Ts = 0.001768
3000
simulation
hardware
2500
height(counts)
2000
1500
1000
500
0.5
1.5
time(seconds)
(c) Ts = 0.005304
58 | P a g e
1
time(seconds)
Time (sec)
1.5
1000
1000
hinf
Lag lead
hinf
Lag lead
-1000
-1000
-2000
height(counts)
height(counts)
-2000
-3000
-4000
-5000
-3000
-4000
-5000
-6000
-7000
-6000
-8000
-7000
-9000
0.5
1.5
-8000
0.5
time(seconds)
(a) Ts = 0.001768
(b) Ts = 0.003536
2000
hinf
Lag lead
0
height(counts)
-2000
-4000
-6000
-8000
-10000
0.5
1.5
time(seconds)
(c) Ts = 0.005304
59 | P a g e
1
time(seconds)
1.5
7. CONTROLLER IDENTIFICATION
Controller Identification
7.1 Introduction
In chapter 5 it was stated that the transfer function of a system could be determined by collecting
the input-output data of the system and then applying the system identification procedure on it.
This method was illustrated by applying it on the maglev system. Similar procedure can be
applied to identify the transfer function of a controller. Essentially a controller is also a system
with a certain transfer function. Therefore provided that we can collect the input-output data for
the controller, we can identify it by applying the same system identification procedure.
The question that now arises is how to find the input and output data of the controller. The input
to a controller is the error signal, e(t), which is the difference between the required output and the
actual output. By setting the required parameters we can determine the system closed loop
response that we desire. For example, in the case of a second order system by setting the values
of wn and and by using the generalized second order system equation:
T.F =
,we can approximate closed loop system response which includes the
controller together with the plant. Now apply a test input to this system and observe the output.
The difference between the input provided and the output observed will be the error signal.
The output of the controller is a control effort or the plant input, u(t). Having knowledge of the
plant transfer function and the output response that we require, we can construct the input signal
to the plant. Since Y(s) = G(s) R(s) R(s) =
Y(s)
G(s)
to replacing the zeroes of the G(s) with its poles and vice versa.
=>
60 | P a g e
G-1(s)
7. CONTROLLER IDENTIFICATION
For a proper transfer function it creates a problem since now number of zeroes is greater than
number of poles and the inverse transfer function becomes unrealizable. Therefore extra zeroes
have to be added far from the original zeros so that they do not have a considerable effect on the
transfer function. Like this the input of the plant or the output of the controller can be
determined.
Having both input and output data it is now a simple problem of system identification. This
method is considerably easier to apply than designing of controllers and ideally gives an
optimized controller for the system.
Input to the controller is the error signal, e(t), which is the difference between the required output
and the actual output.In order to find this signal we need to first specify the performance
parameters and develop an ideal closed loop response desired. For a second order system the
general equation T.F =
Apply a step to this ideal transfer function and record the output. The error signal is the
difference between the input and the output. Like this the input to the controller is found.
61 | P a g e
7. CONTROLLER IDENTIFICATION
7.3.2
The output of the controller is the control effort which is fed to the plant. This means that
controllers output is the input of the plant. Therefore using the fact that Y(z) = G(z) U(z) which
means that U(z) = G-1(z) Y(z), the input of the plant can be calculated. In order to find it
information about the plants transfer function, G(z) is required. For this experiment the model of
the plant identified in chapter 5 will be used as plants transfer function. Inverse of this transfer
function is found simply by replacing zeroes with poles and vice versa.
For proper transfer functions calculating the inverse in this way can cause a problem because
now number of zeroes exceeds the number of poles which makes the transfer function
unrealizable. In order to make it realizable extra zeroes need to be added until the transfer
function becomes proper. Theses zeroes are added at such far locations that they have negligible
effect on the transfer function. In this experiment the extra zeroes were added at a frequency 50
times the natural frequency in the original transfer function before calculating its inverse. The
resulting bode plots and step responses of the original system (G) and modified system (G_mod)
show that there is negligible effect due to the extra zeroes.
Note that using this technique to find the inverse presents the limitation that the original system
must be minimum phase otherwise it will give rise to an unstable inverse.
Bode Diagram
20
G
Magnitude (dB)
G_mod
-20
-40
-60
-80
0
Phase (deg)
G
-45
G_mod
-90
-135
-180
-2
10
10
10
10
Frequency (rad/s)
Fig. 7-3: Open loop bode plot of original transfer function (G) and transfer function with added zeroes (G_mod).
62 | P a g e
7. CONTROLLER IDENTIFICATION
Step Response
6
G
G_mod
Amplitude
0.5
1.5
2.5
Time (seconds)
Fig. 7-4: Step response of original transfer function (G) and transfer function with added zeroes (G_mod).
Now the step response produced in section 7.3.1, which is the ideal step response required, is fed
to the calculated inverse and the output is recorded. This gives the input of the plant required to
generate the ideal response. This corresponds to the control effort that needs to be generated by
the controller which means that this is the output of the controller.
7.3.3
Now that the input-output data set of the controller is complete, system identification techniques
can be used to find the transfer function of the controller. For this experiment a third order ARX
model was found out using the system identification procedure similar to the one described in the
chapter 5. The resulting discrete time transfer function identified is:
.
.
.
.
.
The open loop bode plots for the plant alone and with the controller are shown below.
63 | P a g e
7. CONTROLLER IDENTIFICATION
Bode Diagram
100
Magnitude (dB)
G
50
GK
0
-50
-100
0
G
Phase (deg)
-45
GK
-90
-135
-180
-225
-3
-2
10
-1
10
10
10
10
10
10
Frequency (rad/s)
The step response obtained by using the controller is now compared with the ideal response
required to evaluate the identified controller model.
Step Response w ith K
1.4
Ideal
Using Controller
1.2
Height (counts)
0.8
0.6
0.4
0.2
0.5
1.5
2.5
3.5
4.5
time (seconds)
Fig. 7-6:Ideal step response and the response achieved by using the identified controller.
64 | P a g e
7. CONTROLLER IDENTIFICATION
The graphs show that the performance of the system using the identified controller is quite
similar to the ideal response desired. The only difference is the oscillatory behavior shown by the
system with identified controller for the first 0.5 s which is not a serious issue.
The closed loop system with the identified controller has a gain margin = 21.1 dB at 323 rad/s
and a phase margin of 41.1o at 43.4 rad/s. Therefore the system meets acceptable stability
requirements and the identified controller is accepted as a suitable controller for this system.
Height (counts)
3000
2000
1000
-1000
-2000
0.5
1.5
Time (s)
2.5
The graphs for actual hardware output and simulated output are quite similar and also in line
with applied input. Therefore this shows that using identification procedure a very suitable
controller was developed for the maglev system.
65 | P a g e
7. CONTROLLER IDENTIFICATION
7.5.1
This section gives the comparison plots of conventional lag-lead and H infinity controllers with
the controller designed using identification technique. A step input of 5000 counts is applied and
the performance of all three controllers is measured. The result is shown below:
Comparison of H infinity controller, Laglead Controller and Controller using Identification
2000
hinf
laglead
controller ID
height(counts)
-2000
-4000
-6000
-8000
-10000
0.5
1.5
time(seconds)
Fig. 7-8: Comparison plots for different controllers.
The graph shows that the controller obtained through identification technique gives enhanced
stability performance similar to the h infinity controller. Therefore this controller is better than
lag lead controller. On the other hand this controller gives a high initial overshoot which quickly
reduces to zero. In this regard H infinity controller shows better performance because it does not
give an overshoot. Furthermore it gives a zero steady state error. This means that the controller
obtained through identification technique is an acceptable controller which can be used in
practical situations.
7.6 Limitations
Though the controller obtained through identification process gives acceptable performance it
has certain limitations. The major among them are:
1. This process uses an ideal closed loop response which for the purpose of this experiment
is the ideal second order model. For controllers higher than second order generalized
models are scarcely available which makes this method difficult to apply for higher
models.
2. This method is applicable only to minimum phase systems. For non-minimum phase
systems pole zero cancellation is required which is not feasible in practical systems.
3. The accuracy of this method relies on the accuracy of the identified plant model.
66 | P a g e
8. APPENDIX
Appendix
A. S-Function
% Derivatives %
case 1,
sys=mdlDerivatives(t,x,u);
% Outputs %
case 3,
sys=mdlOutputs(t,x,u);
% Unhandled flags %
case { 2, 4, 9 },
sys = [];
% Unexpected flags %
otherwise
DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));
end
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
function [sys,x0,str,ts]=mdlInitializeSizes()
sizes = simsizes;
sizes.NumContStates = 2;
sizes.NumDiscStates = 0;
67 | P a g e
8. APPENDIX
sizes.NumOutputs
sizes.NumInputs
= 1;
= 1;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [2/100 0]; %zeros(2,1);
str = [];
ts = [0 0];
end mdlInitializeSizes
% mdlDerivatives
% Return the derivatives for the continuous states.
function sys=mdlDerivatives(t,x,u)
a=1.04;
b=6.2;
m=.121;
c=1.1;
g=9.81;
sys(1) = x(2);
sys(2) = (u./(a*m*(100*x(1)+b).^4)-g-((c/m)*x(2)));
end mdlDerivatives
% mdlOutputs
% Return the block outputs.
function sys=mdlOutputs(t,x,u)
sys = x(1);
end mdlOutputs
B. Sensor1.m File
% This script finds the coefficients for the sensor linearization / calibration
% using the assumed form of the correction which is linear in the parameters{e,f,g,h}
%INPUTS
68 | P a g e
8. APPENDIX
% Sensor Location (1=lower, 2=upper)
sensloc=2
% Actual magnet distance from mechanical stop (cm),
Yactual=[ 1 2 3 4 5 6 7]';
% Raw data from laser sensor at each height
Y1raw=[7540 4480 2590 1560 793 309 ]';
Y2raw=[ 20 210 493 870 1470 2190 3150]';
% Construct the correction function array
% Solve for the coefficient vector efgh via regression using the backslash operator
if sensloc==1
% Construct the correction function array
X=[1./Y1raw sqrt(1./Y1raw) ones(size(Y1raw)) Y1raw];
efgh=X\Yactual
% Create vector of evaluation points for correction function
Yraw_eval=(2000:100:30000)';
% Evaluate function at points
Ycal=[1./Yraw_eval sqrt(1./Yraw_eval) ones(size(Yraw_eval)) Yraw_eval]*efgh;
e1=efgh(1),f1=efgh(2),g1=efgh(3),h1=efgh(4)
% Plot
plot(Y1raw,Yactual,'o',Yraw_eval,Ycal,'-'),grid,%axis([0 30000 -7 0])
xlabel('Raw Sensor Output (counts)')
ylabel('Magnet Position (cm)')
title('y1 Sensor Calibration / Linearization')
end
if sensloc==2
% Construct the correction function array
X=[1./Y2raw sqrt(1./Y2raw) ones(size(Y2raw)) Y2raw];
efgh=X\(-Yactual);
e2=efgh(1),f2=efgh(2),g2=efgh(3),h2=efgh(4)
% Create vector of evaluation points for correction function
69 | P a g e
8. APPENDIX
Yraw_eval=(2000:100:30000)';
% Evaluate function at points
Ycal=[1./Yraw_eval sqrt(1./Yraw_eval) ones(size(Yraw_eval)) Yraw_eval]*efgh;
% Plot
plot(Y2raw,-Yactual,'o',Yraw_eval,Ycal,'-'),grid,axis([0 30000 -7 0])
xlabel('Raw Sensor Output (counts)')
ylabel('Magnet Position (cm)')
title('y2 Sensor Calibration / Linearization')
end
C. Actuat1.m File
% This script finds the coefficients for the magnetic actuator linearization / calibration
% using the assumed form of the correction which is linear in the parameter a
% For Model 730 Apparatus, The upper magnetic field characteristic may be considered to
% the mirror image of the lower ==> The UPPER field coefficent a is the same as for the
% LOWER, and b is the negative of that of the lower
n=4;
% Measured magnet height, CHANGE TO NEGATIVE VALUES FOR ACTUATOR #2
Ymeasured=[3.99 3.95 3.7 3.69 3.3 3.18 3.12 2.8 2.4 2.16 1.9 1.6 1.3 1 0.88 0.83 0.6 0.3 0.1 0]';
% Uncompensated Control Effort input
Utest=[22000 18000 14000 12000 11000 10000 9000 8000 7000 6000 5000 4500 4000 3500 3000 2800 2500 2300
2100 2000]';
% Specify offset parameter, b
b=6.2;
% Input Magnet mass in Kg
m=0.121
W=m*9.81 % magnet weight
% Construct the correction function array
X=[(Ymeasured+b).^n];
% Solve for the coefficient vector abcd via regression using the backslash operator
% Divide by W to normalize force to N
a=X\(Utest/W);
70 | P a g e
8. APPENDIX
% Create vector of evaluation points for correction function
Y_eval=(0:0.1:4.5)';
% Evaluate function at points. Multiply by W to show as-tested case
Ueval=[(Y_eval+b).^n]*a*W;
% Plot
plot(Ymeasured,Utest,'o',Y_eval,Ueval,'-'),grid,%axis([0 4.5 0 25000])
ylabel('Conrol Effort Required to Produce Force Equal to Magnet Weight (counts)')
xlabel('Magnet Position (cm)')
title('u1 Actuator Characteristic / Pre-correction')
a1=a
b1=b
a2=a
b2=-b
71 | P a g e
9. BIBLIOGRAPHY
Bibliography
72 | P a g e