Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as...

13
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

Transcript of Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as...

Page 1: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 2: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 3: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 4: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

๐‘ฆ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)

Page 5: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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)

Page 6: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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.

Page 7: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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.

Page 8: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 9: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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.

Page 10: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 11: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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

Page 12: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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 ฮฉ

Page 13: Lab 5 Magnetic Levitation - Deepak Talwarย ยท The equations of motion of the ball can be modeled as follows: ฬˆ= (๐ผ, )โˆ’ (1) =โ„Ž( ) (2) where x is the vertical position of the

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.