Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as...
Transcript of Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as...
Lab 5 Magnetic Levitation
By: Deepak Talwar, Aldrich Ong, Mandy Huo
ME 134
Lab #4
Lab conducted 10/22/13 and 10/29/13
Report due date 11/5/13
Lab 5: Magnetic Levitation
Objectives
The objective of this lab is to design and implement an analog controller for the magnetic
levitation (MagLev) system provided to us in the lab. It consists of an electromagnetic
system as the plant with a photoresistor as the sensor. The system is shown in Figure 1.
Pre-lab: 5a
In part a of this lab we will perform system identification arrive at the transfer function of the
linearized plant G(s). In part b we implement an analog circuit to control the plant. The high
level block diagram of the system is given below in Figure 2.
The circuit level details of this block diagram are given in Figure 3.
Figure 2: High level block diagram for the MagLev system shown in Figure 1
Figure 1: Magnetic Levitation system provided in the labs
The equations of motion of the ball can be modeled as follows:
๐ = ๐(๐ผ, ๐ฅ) โ ๐๐ (1)
๐ฆ = โ(๐ฅ) (2)
where x is the vertical position of the ball (in m), I is the current through the coil (in A) and
g = 9.81 m/s2 is the gravitational constant. The function f (I, x) is a non-linear function that
relates x and I with the magnetic force (in N) on the ball. The function h (x) is also a non-
linear function that relates the voltage of the photo-resistor to vertical position of the ball, x.
Derivation of the System Transfer Function
Desired position / output offset circuitry
This derivation involves the magenta box shown in Figure 3. We set ๐ฆ๐๐๐ โ ๐0 and perform
Kirchhoffโs current law at the inverting terminal of the op-amp to find the relation between
๐ฆ, the voltage across the photoresistor, ๐ฆ๐๐๐, the reference voltage which will be adjusted
using the potentiometer, and ๐ฆ1 the output voltage of the output offset circuit:
Figure 3: Circuit level schematic of the magnetic levitation setup
๐ฆ1 = 2๐ฆ๐๐๐ โ ๐ฆ (3)
Detailed calculations were given in the handwritten pre-lab.
Transfer function of the analog controller
We derive the transfer function of the analog controller (the red box in Figure 3). This is in
the usual inverting amplifier configuration with an equivalent input impedance. The gain is
given by:
๐บ๐ถ(๐ ) =๐๐๐๐๐๐๐๐ ๐๐๐๐๐๐๐๐๐
๐๐๐๐ข๐ก ๐๐๐๐๐๐๐๐๐
We find the equivalent input impedance. Let ๐1 be the impedance of ๐ 2 and ๐ถ and ๐2 be the
equivalent input impedance of the op-amp. Then:
๐1 = ๐ 2 +1
๐ถ๐
๐2 = (1
๐ 1+
1
๐1)
โ1
With 10k ohms as the feedback impedance, the transfer function of the analog controller
becomes:
๐บ๐(๐ ) =๐2(๐ )
๐1(๐ )= โ
10๐พ
๐ 1 โ
(๐ 1 + ๐ 2)๐ถ๐ + 1
๐ 2๐ถ๐ + 1
(4)
We see that the transfer function (gain) is actually negative. It inverts the input signal.
Current offset circuitry
his derivation involves the blue box in Figure 3. We define yi to be the voltage drop across
the potentiometer and Vout to be the output voltage of the Op-Amp. Applying Kirchhoffโs
current law on the inverting terminal of the Op-Amp, we find that yi, y2 and Vout are related
as:
๐๐๐ข๐ก = โ(๐ฆ2 + ๐ฆ๐) (5)
We observe that yi is negative as the potentiometer sweeps from 0V to -7V.
Linearization of the system
Linearizing the equation of motion of the plant (1), we get:
๐ โ ๐(๐ผ0, ๐ฅ0) + ๐พ๐๐ฟ๐ผ + ๐พ๐ฅ๐ฟ๐ฅ โ ๐๐ (6)
Where ฮดI = I โ I0 and ฮดx = x โ x0. We will tune the potentiometer of the current circuit
circuitry in order to obtain the correct yref at which f (I0, x0) = mg so that
๐ = ๐พ๐๐ฟ๐ผ + ๐พ๐ฅ๐ฟ๐ฅ (7)
We also linearize the output function y by approximating h (x) as aฮดx:
๐ฆ = ๐๐ฟ๐ฅ (8)
We take the Laplace transform of these equations, assuming the equilibrium position ๐ฅ0 = 0
m, and offset current ๐ผ0 = 0 A. Rearranging yields the transfer function of the linearized
system:
๐บ(๐ ) =๐(๐ )
๐ผ(๐ )=
๐๐พ๐
๐ (๐ 2 โ๐พ๐ฅ๐
)
(9)
Lab 5a - System Identification
Linearizing ๐(๐)
To find a linear relationship between ๐ฅ, the position of the ball, and ๐ฆ, the output voltage of the
photo resistor, we vary ๐ฅ near the equilibrium point (๐ฅ = 0) and determine the corresponding
voltage, ๐ฆ. Then we find a linear regression using Matlab to approximate the linear relationship
between ๐ฅ and ๐ฆ. The slope of the linear regression, ๐, will be the coefficient of the linear
function โ(๐ฅ) such that
๐ฆ = โ(๐ฅ) = ๐ โ ๐ฟ๐ฅ [10]
Table 1 shows the values used to find the linear relationship about the equilibrium position. The
data and the linear fit is plotted in Figure 4. We conclude that the linearization of the โ(๐ฅ) is
valid based on an observation of how well the data points fit the linear curve in Figure 4. The
value of the slope, ๐, was determined using MATLAB and present in Table 1.
๐, ๐ท๐๐๐๐๐๐๐ (๐๐) ๐, ๐ฝ๐๐๐๐๐๐ (๐ฝ)
2 4.27
1.5 3.69
1.0 3.14
0.5 2.42
0 (eq) 2.19
-0.5 2.00
๐ = 947 ๐/๐
Table 1 โ Data values of the output voltage
across the photoresistor for varying ball
position. The value of ๐ is also shown.
Figure 4 โ Plot of data values from Table 1. Linear
relationship is shown as the blue line.
Determining ๐ฒ๐
The relationship between the current change through the coils, ๐ฟ๐ผ, and the magnetic force, ๐น, on
the ball, can be determined by implementing a similar procedure as above when we found ๐. By
changing the voltage across the coils, the magnetic force changes and as a result changes the
weight calculated by the scale changes. During this process, we kept position of the ball at
equilibrium. The data values of voltage and apparent mass of the ball are presented in Table 2.
To determine ๐ฟ๐ผ, we used the following relationship
๐ฟ๐ผ = ๐ผ โ ๐ผ0 =20
3(๐ โ ๐0) [11]
Where ๐0 is the voltage at ๐ = 0.5๐. A plot of ball weight vs. ๐ฟ๐ผ is shown in Figure 5. Next the
value of ๐พ๐ was determined by finding the linear fit between the two.
Voltage (V) Mass (g)
-1.315 0.5
-1.283 0.7
-1.262 0.9
-1.234 1.1
-1.195 1.3
๐พ๐ = 0.0101 ๐/๐ด
Table 2 โ Data values of the apparent mass
as the voltage across the coils were varied.
๐พ๐ was determine and shown in the table.
Figure 5 โ Plot of data values from Table 2. Linear
relationship is shown as the blue line.
Finding ๐ฒ๐
Similar to the procedure for finding ๐พ๐ผ, we can find ๐พ๐ฅ by determining the linear relationship
between the position of the ball and its apparent weight. We maintain the current in the coils at
๐ผ0. The values of position and the corresponding mass are shown in Table 3. The plot of the
weight vs. position is shown in Figure 6. The ๐พ๐ฅ values is presented in Table 3.
Table 4 summarizes the values obtained from the system identification.
The DC gain from ๐ฆ to the current out is
๐ท๐ถ ๐๐๐๐ = ๐๐พ๐ถ๐พ๐ [12]
Where ๐พ๐ is the amplifier gain and is equal to 2A/V. If the DC gain of the circuit is 1000A/m,
and the values of ๐ is 947๐
๐ then the controller gain, ๐พ๐ถ, can be determined.
๐พ๐ถ = 0.53
Position (mm) Mass (g)
0 0.5
-0.5 1.4
-1.0 2.4
-1.5 2.3
-2.0 4
๐พ๐ฅ = 15.5 ๐/๐
Table 3 โ Data values of the apparent mass
as the position of the ball was varied. ๐พ๐ฅ
was calculated and is shown in the table.
Figure 6โ Plot of data values from Table 3. Linear
relationship is shown as the blue line.
๐ 947 ๐/๐
๐ฒ๐ฐ 0.0101 ๐/๐ด
๐ฒ๐ 15.5 ๐/๐ Table 4 โ Summary of values obtain through system
identification
Pre-lab 5b
After performing system identification in Lab 5a, we
obtained the following values for the system
parameters. We will use these values to design our
controller parameters that will be used in the analog
controller of the system.
Using the values given in Table 5, and plugging them
in the systemโs transfer function given in Equation 9,
we get our systemโs linearized transfer function. We
will now observe the systems performance and
design the controllerโs parameters in order to control
the system properly.
This is done by first observing the root locus and frequency response of the linearized plant
and determining what kind of controller will be required. Then, according to a few design
parameters, we will select the values of required poles and zeros in order to stabilize the
system. From those values of poles and zeros, we will find our controller parameters R1, R2
and C.
1. Root locus and Frequency response
Using MATLAB, and the values of system parameters given in Table 5, we plot the root
locus plot and the bode plot of the transfer function. These are shown in Figure 7 and
Figure 8 respectively.
Observations: The root locus plot is symmetric over the imaginary axis, which means that
for very high gains, all the poles and zeros will lie on the imaginary axis and the system
will only be marginally stable. We also observe that there is one pole on the right hand
plane, which makes the open loop system unstable. From the bode phase plot, we can see
that the phase is always -1800, which means that the system will be unstable for unity
gain, at 0 dB magnitude.
Linearized System Parameters
Parameters Value, units
Ki 0.0101 N/A
Kx 15.484 N/m
Ka 2 A/V
m (mass of
ball)
0.0161 kg
a 946.8571 V/m
Table 5 โ Parameters obtained from
system identification.
Figure 7: Root locus plot of the linearized version of the transfer function
Figure 8: Bode plot for the linearized version of the transfer function
2. Compensator
Based on the root locus plot and the bode plot, it is clear that we would need a Lead
compensator to stabilize this system. The lead compensator will add phase to the system
because of the extra zero near the origin, and also decrease the steady state error. Since
the system is never stable, we would need to reduce the steady state error to stabilize it.
3. Finding zero and pole location to stabilize the system
The parameters we need to match with our added poles and zeros are:
DC gain of 2
Phase margin of 60 degrees
From Equation 9, we can see that our transfer function is between the amplifier current I
and the voltage y at the photo resistor. We multiply this with Ka and get the transfer
function between amplifier voltage y2 and the photo resistor voltage y. The controller will
be of the form Gc(s) = Kc 1+๐ /๐ง
1+๐ /๐ . Using MATLAB function sisotool, we find the
location of the pole and zero. These are given in Figure 9.
Figure 9: sisotool session with phase margin of 59.60 and gain margin of 6 dB which
corresponds to a DC gain of 2
As we can see from the sisotool session plot, the DC gain is set to 2 and the phase
margin is set to 600. The controller gain Kc is determined by setting ๐ = 0 in the transfer
function ๐บ๐(๐ )๐บ(๐ ) = ๐ท๐ถ ๐๐๐๐. The value of ๐พ๐ came out to be 1.6. Using this
controller gain value and sisotool the value of the pole is -267 and the zero is -14.5.
4. Calculation of R1, R2 and C
Using the relations derived in the first pre-lab and given in Equations 4-9, we can find
relations to find the values for R1, R2 and C. The resulting relations and values are:
R1 = 10000
๐พc = 6176 ฮฉ
C = 1
๐ 1[
1
๐งโ
1
๐] = 0.1 ยตF
R2 = 1
๐๐ถ = 355 ฮฉ
Lab 5b - Controller Implementation
Staying close to the values of ๐ 1, ๐ 2, and ๐ถ calculated in Pre-lab 5b, we implemented our
controller using ๐ 1 โ 6170 ฮฉ, ๐ 2 โ 350 ฮฉ, and ๐ถ โ ๐. 1 ฮผF.
Calibration
To calibrate the controller we disconnected the controller circuit from the current offset circuit
and turned on the electromagnet. With the ball placed on the scale and the stage set to the
equilibrium position defined when we performed system identification, we adjusted the
potentiometer of the current offset circuit until the ball was almost weightless (< 0.5 g).
With the ball now virtually balanced by the magnet and held in the equilibrium position, we
adjusted the potentiometer of the position offset circuit until ๐ฆ1 โ 0 V so that at equilibrium
there no input goes into the controller circuit. Finally we reconnected the controller to test the
system, readjusting the potentiometers as necessary.
Implementation
With this controller we were unable to make the ball levitate. When we checked the output of the
op amp of the controller circuit with the DMM, we found that the op amp was railing. To fix this
we decreased the controller gain by decreasing ๐พ๐ถ. The value used in our first trial is ๐พ๐ถ =
1.6191 so we experimented with values below this. The location of the poles and zeros also
affect the magnitude of the controller gain ๐บ๐ถ, so we chose larger zeros and smaller poles to keep
the controller gain from being too large. However, with condition that phase margin = 60ยฐ, the
location of the pole and zero is uniquely determined once ๐พ๐ถ is set. To solve this we ran sisotool
on the plant transfer function ๐บ(๐ ) and added a pole and a zero. We dragged the cursor to change
the loop gain (corresponding to ๐พ๐ถ) then adjusted the pole and zero to meet the phase margin
specification at this value of ๐พ๐ถ, while making sure the closed-loop poles did not move to the
right-hand plane. Using this method we ran a few trials with our circuit before arriving at a
successful combination of ๐พ๐ถ, ๐ง, and ๐.
Our final design parameters were: ๐พ๐ถ = 0.828, ๐ง = 14.8, and ๐ = 247. These numbers correspond
to phase margin = 61.9ยฐ, but do not meet the original DC gain design specification. The
necessary circuit components are: ๐ 1 = 12 kฮฉ, ๐ 2 = 780 ฮฉ, and ๐ถ = 5.2 ฮผF. When picking
resistors we used the DMM to match the desired values more closely. The values used in our
final circuit are: ๐ 1 = 11992 ฮฉ, ๐ 2 = 776.55 ฮฉ, and ๐ถ โ 5.2 ฮผF.
With this controller the electromagnet was able to levitate the ball. See video at:
http://www.youtube.com/watch?v=sjAISWe4Q_4.
We also experimented with the controller by levitating a washer and a heavy screw. See videos
at: http://www.youtube.com/watch?v=8gSQ5VISk2E and
http://www.youtube.com/watch?v=pR2FDRh5kU4.