Modeling and Control of a Magnetic Levitation...

25
Modeling and Control of a Magnetic Levitation System By: Marwan K. Abbadi Advisor: Dr. Winfred Anakwa Date: May 13, 2004 Department of Electrical and Computer Engineering-Bradley University

Transcript of Modeling and Control of a Magnetic Levitation...

Page 1: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

Modeling and Control of a Magnetic Levitation System

By: Marwan K. Abbadi

Advisor: Dr. Winfred Anakwa

Date: May 13, 2004

Department of Electrical and Computer Engineering-Bradley University

Page 2: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

2

A B S T R A C T

Magnetic levitation technology has been receiving increasing attention

because it helps eliminate frictional losses due to mechanical contact. Some

engineering applications include high-speed maglev trains, magnetic bearings and

high-precision platforms. The objectives of this project are to model and control a

laboratory-scale magnetic levitation system. The control algorithm is

implemented using assembly language on Intel 8051 microprocessor to levitate

and stabilize a spherical steel ball at a desired vertical position.

Page 3: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

3

T A B L E O F C O N T E N T S

1. Introduction............................................................................ 4

2. System Description................................................................ 5

3. System Identification............................................................. 6

4. Controller Implementation.....................................................8

5. Hardware...............................................................................10

6. Software................................................................................13

7. Results and Analysis.............................................................16

8. Parts and Equipment.............................................................22

9. Conclusions...........................................................................22

10. Acknowledgments.................................................................23

11. References.............................................................................23

12. Appendices:

Appendix A: Simulation and modeling plots........................24

Appendix B: Hardware circuits.............................................25

Appendix C: Software code..................................................26

Page 4: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

4

1 . I N T R O D U C T I O N

Overview

Magnetic levitation (or maglev) systems are electromechanical devices that

suspend ferromagnetic materials using electromagnetism. Maglev technology has

been receiving increasing attention since it eliminates energy losses due to

friction. Centered on friction reduction, maglev systems have wide engineering

applications such as magnetic bearings, high-precision positioning platforms,

aerospace shuttles, and fast maglev trains.

Problem Definition

Maglev systems, based on electromagnetism, are characterized by open-

loop instability and nonlinear dynamics that suggest the need of stabilizing

controllers.

The Electrical and Computer Engineering Department (ECE) has

purchased a laboratory-scale maglev system from Feedback Limited Inc, shown

in figure 1. The maglev system included an analog controller that levitated and

stabilized a set of hollow steel balls about an operating region. However, there is

little insight known about the model of the plant. After consulting with the project

advisor, we agreed upon the following project objectives:

Figure 1: Maglev system, model 33-210

Page 5: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

5

Intel microntroller+

+

-

Set point

Referenceinput

E*(s)

DigitalcontrollerE(s)

Tszoh

InterfaceCircuit

MagneticLevitationSystemU(s)

Actual Ball position Y(s)

Maglev Front Panel

InterfaceCircuit

1. To obtain a good model for the maglev system, model 33-210 manufactured by

Feedback Limited In.

2. To implement a microcontroller-based digital controller that stabilizes a 21-

gram steel ball and tracks reference input signals applied to the maglev.

2 . S Y S T E M D E S C R I P T I O N

The control system consists of three inputs and one output. The inputs are:

1. Set point − adjusts the vertical position of the ball.

2. Reference input signal

3. Disturbances − such as power supply fluctuations, coil temperature

variations and external forces applied to the ball. The final output of the

system is the actual ball position. Figure 2 shows a block diagram of the

digital controller interfaced to the maglev system.

Figure 2: Overall system block diagram

Page 6: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

6

3 . S Y S T E M I D E N T I F I C A T I O N

A fundamental concept in science and technology is that of mathematical

modeling. System identification is conducted to obtain the plant transfer function

needed for the control design. Once a good model is obtained and verified, a

suitable control law can be implemented to compensate the plant instability and

improve performance.

Analytical Model

Analytical and experimental plant models were obtained for comparison

and verification. According to T. H. Wong, laboratory-scale maglev systems are

represented with electrical and mechanical equations [1]. Figure 3 shows the RLC

coil circuit that displaces the steel ball using electromagnetism.

Using Kirchoff’s voltage rule around the loop, the electrical equation is:

(1) Where:

e= coil voltage i= coil current R= coil resistance L=coil inductance

x=ball position xo and Lo are nominal operating constants.

δtδx

xixL

δtδiLiRe 200 ⋅−+⋅=

Coil ResistanceR

Coil inductance= L+e-

Input Voltage

Current= i

Photo-detectorCells

Photo-emitterCells

Figure 3: Coil circuit

Page 7: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

7

(3)

On the other hand, the mechanical equation is obtained from the force

diagram based on Newton’s second law, as shown in figure 4:

(2)

Where C= Magnetic constant determined experimentally=1.477x10-4 N.m2/A2

m= mass of steel ball= 0.021 kg

g= gravitational acceleration= 9.82 m/s2

Using Taylor series expansion to linearize the non-linear differential

equations about the equilibrium point xo=22.5 mm, the plant analytical model is:

It was determined that the coil circuit was driven by an active circuit that

indictates that the current i is a non-linear function of the coil voltage e.

2

⋅−⋅=−=xiCgmEFGFF

)115.70)(114.29)(114.29(0013.0)(

+−+= ssssGp analytical

Gravitational force= mg

Magnetic force= C(i/x)2

Figure 4: Force diagram

Page 8: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

8

Figure 5: Frequency response data for the plant

Experimental approach

Obtaining and fitting frequency response data to estimate a plant model is

a common practice in control design. Closed-loop frequency response data for the

plant were obtained and plotted in the bode diagram shown in figure 5.

From the diagram, the experimental model of the maglev system was

approximated as:

(4)

The experimental model was used rather than the analytical one because it is more

accurate since it represents the practical model of the system.

4 . C O N T R O L L E R I M P L E M E N T A T I O N

The analog controller from the manufacturer was discretized and implemented on

a microcontroller to examine the performance of the same control law using

analog and digital realizations. This approach would reveal the effect of

discretization on the plant performance.

)15.30)(15.30(60.1)(exp_

−+= sssGp

Page 9: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

9

Figure 6: Frequency response data for controller from manufacture

From frequency response plot shown on figure 6, the analog controller

from the manufacturer was approximated as:

(5)

The double poles at -4000π rad/s are relatively higher than the plant bandwidth of

126 rad/s. Ignoring the high-frequency poles, the analog controller model was

simplified to a first-order model:

(6)

Sampling frequency

After conducting frequency response analysis, the cut-off frequency was

approximated to 126 rad/s. According to Franklin/Powell rule, the sampling

2_

)14000

)(1900

(

115)(

++

+=

ππ

πss

s

sG manc

)1900

(

115)(_

+

+=

π

πs

s

sG manc

Page 10: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

10

frequency must be at least six times the cut-off frequency [2]. To satisfy this

heuristic rule, the sampling period cannot be slower than 8.3 ms. Different

sampling periods were examined and a sampling frequency of 5 ms resulted in the

most stable and satisfactory tracking system response.

Discretization

The analog controller was transformed to a digital equivalent using

bilinear transformation with a sampling period of 5 ms. The transfer function of

the digital controller is:

(7)

To avoid software overflow, the transfer function was normalized to:

(8)

The gain of 8.3 was implemented in hardware, and the normalized digital filter

was implemented on the microcontroller.

5 . H A R D W A R E

In addition to the controller gain implementation, hardware circuitry was needed

to adjust the signals before and after the microcontroller as shown in figure 2. The

hardware circuitry must:

a. Adjust the error signal before being sent to the microcontroller.

b. Provide impedance matching between the hardware interface and

the plant.

1

1

7521.0156.63.8)( −

⋅+⋅−

=zzzGc

1

1

7521.017904.013.8)( −

⋅+⋅−

=zzzGc

Page 11: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

11

+-0.5

-2.5

e -1 e/2+2.5-5~5V 0~5V

maglev positionerror generator

Siemens 80515A/D

Figure 7: Error-to-A/D shifter

c. Adjust the control signal to the correct scale.

d. Amplify the control signal from the microcontroller to the maglev.

e. Filter high-frequency noise and provide anti-aliasing filtering.

Error-to-A/D

The error signal was level-shifted to a range of 0~5V that corresponds to

the 80515 microcontroller voltage rating. The interface circuitry scales down the

error signal by a factor of 1/2 and provides a 2.5 V offset as shown in figure 7.

The hardware components and layout for the circuit is shown in appendix B,

figure 17a.

Impedance Matching

A voltage follower was connected between the final control signal and the

maglev system. This solves possible impedance mismatch thereby ensuring

enough voltage and current drive the maglev system.

Page 12: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

12

+-2

+5

u/2+2.5-8.3

U0~5V

Siemens 80515D/A

Maglev controlsignal input

Gainpotentiometer

Figure 8: D/A-to-Control shifter

D/A-to-Control

The factored control signal sent from the microcontroller needed to be

readjusted to the correct scale and amplified by a controller gain of 8.3. Figure 8

shows a signal flow diagram between the microcontroller and the maglev system.

The hardware components and layout is shown in appendix B, figure 17b.

Anti-aliasing/noise-reduction filter

Anti-aliasing filters are important key elements in digital control. Apart

from reducing aliasing and distortion of the sampled signals, they are used to filter

out high-frequency noise that can burn the microcontroller chip. A first-order,

low-pass filter was connected to the final control signal to eliminate any amplified

noise. This ensures less noise at the final stage before the control signal reaches

the maglev system. The pole of the filter was placed at 188 rad/s. The RC circuit

is connected at the end terminal of the D/A-to-Control circuit as shown in figure

17b.

Page 13: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

13

6 . S O F T W A R E

The software code of the project was programmed using assembly language on an

80515 microcontroller manufactured by Siemens. The software code was

developed using Keil uvision 2 simulation package.

The primary tasks of the software:

a. sample and decode the error signal

b. compute the corresponding control signal

c. encode then produce the control signal through the D/A.

Decoding and encoding scheme

The decoding and encoding scheme controlled the polarity of the signals by

defining signed number representation. Signed number representation was needed

since positive and negative signals were sampled and produced via the analog and

digital converters. Table 1 displays specific error values and their mapped sample

value.

Initial error signal Adjust error signal to EMAC

5 5 =(255d)

0 2.5=(127d)

-5 0=(0)

Table 1: Error values mapping

The microcontroller samples the error signal through an 8-bit A/D channel. Then,

the error signal is checked if it is greater than 127 (2.5V) or not. If it is greater

than 127, then the error signal is positive and the sign bit is cleared and vice versa.

Page 14: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

14

When the control signal is computed, it is divided by 2 and added to 127

thereby generating u/2+2.5 which is sent to the D/A, as shown in figure 8. This

solves the polarity problem and ensures the resultant control signal is within the

0~5V range of the D/A.

Realizing the mathematical function on 8051microcontroller

The 80515 microcontroller does not handle floating-point arithmetic, which

suggests extra steps are needed to represent the coefficients shown in equation 8.

The coefficients were approximated using fixed-point rational integers.

From equation (8), the recursive equation of the factored control law is:

⟩−⋅+−⋅⟨−= )1(7904.0)1(7521.0)()( nUnEnEnU (9)

Approximating to fixed-point realization:

⟩−⋅+−⋅⟨−= )1(1411)1(

1410)()( nUnEnEnU (10)

The remainders of the division operation were truncated in the mathematical

computations because they only affect the first or second least significant bits.

This error can be simply ignored because the 80515 has +/- 1 to 2 least-significant

bits error during sampling and generation of signals using the 8-bit A/D and D/A

respectively.

Page 15: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

15

Software flowchart

Figure 9 shows the software flowchart for the project. Initially, the

program initializes different parameters such as timer interrupt, stack pointer,

80515 port initializations and initial conditions of the control signals. The main

program is a dummy loop that waits for the timer to overflow every 5 ms.

When the timer interrupt handler is serviced, the error signal is sampled

and stored in the accumulator. The program calls the controller subroutine to

compute the corresponding control signal based on the value of the accumulator.

Intializations80515, Stack, Timer 0 interrrupt,

and variables initializations

MAINTimer 0

- Sample A/D input Call Controller Produce via D/A

Update variablese(n), e(n-1), u(n-1)

Prepare E(n)- Set sign bit if -ve- Multiply by coefficient

Prepare U(n-1)- Set sign bit if -ve.- Multiply by coefficient

Prepare E(n-1)- Set sign bit if -ve- Multiply by coefficient

Multiplex operation 1

Multiplex operation 2

Figure 9: Software flow chart

Page 16: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

16

At the beginning of the controller subroutine, the current error e(n), past

error e(n-1), and past control u(n-1) signals are updated. Next, the polarity of a

signal is determined and accordingly a sign bit is set or cleared. Using the same

2’s complement convention for sign bits, if the number is negative then the sign

bit is set, otherwise cleared. The signals are then multiplied by their

corresponding coefficients through series of division and multiplications

instructions before they are sent to the arithmetic operations routine.

According to the combination of the different sign bits of the operands, the

appropriate arithmetic operation is selected. If both signals were positive, the

result is positive and addition operation is executed. Similarly, if both signals

were negative, the result is negative and addition operation is also performed. The

final control signal is computed and adjusted through the encoding/decoding

scheme and sent out via the D/A. The D/A generates the control signal and the

operation is repeated every 5 ms.

7 . R E S U L T S A N D A N A L Y S I S

Stability

The 21-gram steel ball was stabilized at the equilibrium point xo=22.5 mm

from the electromagnet. Figure 10 shows the ball response at steady-state with no

reference input applied.

Ball position

Figure 10: Ball response at steady state

Top= Final Control signal Bottom= Ball Position

Page 17: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

17

As shown in figure 10, there were small oscillations in the ball position

that were due to quantization, truncation and computation errors of the 8-bit

microcontroller. A/D and D/A quantization errors are the primary reason for these

oscillations rather than the computational errors. Figure 11 shows the ball position

along with the factored control signal from the microcontroller. As shown from

figure 11, the quantization errors occur every sampling period and peak to a value

of + 100 and -50 mV. These values correspond to +5 and – 2 least-significant bit

that are then amplified resulting in the position waveform shown.

Figure 11: Factored control signal from the microcontroller zoomed out to display

quantization errors.

Top= Ball Position Bottom= Control signal from the EMAC before amplified

Page 18: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

18

Tracking

The ball tracked sinusoidal, square and triangular reference inputs with a

magnitude less than 0.4 V. The tracking performance was not very good because

of the oscillations, however using higher-resolution converters will produce better

tracking results. Figure 12 shows the response of the ball position to a sinusoidal

reference input. Apart from the oscillations, the ball position tracks the reference

input signal with constant error because the controller equation produces a non-

zero steady-state position error. As shown in figure 12, the response peaks at the

same instance as the reference input.

Figure 12: Sinusoidal input response

Top= Ball Position Bottom= Reference input

Page 19: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

19

Figure 13 shows the response of the ball position to a square wave reference

input. As seen in the figure, the ball position attempts to track the reference signal

and gradually reduces the error.

Figure 13: Square wave response

Page 20: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

20

Step response

Simulation and experimental step responses of the analog and digital

controller are shown in figures 14. Figure 14a shows the closed-loop step

response using the analog controller from the manufacturer. The response is

inverted because the ball position in the maglev front panel is inverted; however

the actual response is positive.

Figure 14a: CL response for 0.6V step input with controller from manufacturer connected. Figure 14b shows the closed-loop step response from SIMULINK with the analog controller connected. There was 0.2V difference, however the overall responses are similar.

Figure 14b: CL response for 0.6V step input from SIMULINK for the analog controller

Page 21: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

21

Figure 14c and 14d show the simulations and experimental step response with the

digital controller connected. In figure 14d, the digital controller overshoots as

expected and tries to minimize the error. At steady state, the response continued

to oscillate due to the quantization errors discussed earlier.

Figure 14c: SIMULINK CL step response with digital controller

Figure 14d: CL step response for the digital controller

Page 22: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

22

8 . P A R T S A N D E Q U I P M E N T

Quantity Description

1 Maglev system from Feedback Inc, model 33-210

1 200 MHz PC with Keil software package to develop and run the software code

1 80515 Microcontroller from Siemens with built-in A/D and D/A

3 HP power supplies

1 Tube-caliber for measuring distance in millimeter range

7 LM741 operational amplifiers

9. CONCLUSIONS

This project investigated different control practices that are common in control

systems design. Modeling a non-linear, open-loop unstable plant, such as maglev

systems and inverted pendulums, is a challenging engineering problem. The

project examined the different approaches in obtaining a model for the maglev

system.

Another practice in control systems is investigating performance of

different controllers such as analog vs. digital. The analog controller from the

manufacturer was converted to digital equivalent using bilinear transformation

with a sampling frequency of 5ms.

Different phenomena associated with sampled data systems were observed

during the interface of the microcontroller. This includes effect of varying the

sampling period, quantization errors, aliasing and programming low resolution

microcontrollers. Assembly language was used rather than C language because C

compiler is needed for C language which can add more costs to the project.

Page 23: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

23

10. ACKNOWLEDGMENTS

I would like to thank Dr. W. Anakwa for his continuous support and advice

during the different stages of the project. Special thanks are due to Mr. David

Miller for supplying the tube-caliber needed during the modeling stage for

adjusting the ball position.

11. REFERENCES

[1] Wong, T. H. “Design of a magnetic levitation system-an undergraduate project,” IEEE Tran.

on Education, vol E-29, no. 4, November 1986.

[2] Franklin, Powell & R.D Harbor, Feedback Control of Dynamic Systems, 3rd Ed. Addison-

Wesley 1994.

Page 24: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

24

12. APPENDICES

APPENDIX A: Modeling plots

Figure 15 shows the sensor calibration data obtained during the modeling phase.

The sensor gain was determined to be 450.3 V/m.

Figure 16 shows the coil inductance at different ball positions. In the region of

operation, the coil inductance was approximated as a constant equal to 296.73mH.

Figure 15 Sensor Calibration (gain=450.3V/m)

Figure 16: Coil inductance vs. ball position, L=constant=296.73mH

Page 25: Modeling and Control of a Magnetic Levitation Systemcegt201.bradley.edu/projects/proj2003/maglev/docs/PDF/final.pdf · Modeling and Control of a Magnetic Levitation System By: Marwan

25

A P P E N D I X B : Hardware circuits

Error-to-A/D

Figure 17a: Error-to-A/D circuitry

Figure 17a shows the level-shifter circuitry needed to adjust the error signal. The two diodes at the end terminal provide protective circuitry that limits voltages above 5.5V and less than -0.5V to be sent to the microcontroller.

Figure 17b: D/A-to-Control

Figure 17b shows the interface circuitry needed to amplify and readjust control signal. A low-pass filter is connected at the end terminal to filter high-frequency noise and provide anti-aliasing filtering effect.