Magnetic Levitation System Electromagnet Infrared LED Phototransistor Levitated Ball Magnetic Levitation System K. Craig 1
Magnetic Levitation System Electromagnet Emitter Infrared LED i Detector Phototransistor V sensor 2.5 V At Equilibrium gap Levitated Ball m = 0.008 kg r = 0.0062 m Equilibrium Conditions gap 0 = 0.0053 m i 0 = 0.31 A Magnetic Levitation System K. Craig 2
Emitter Circuit Power MOSFET with Diode To Electromagnet Buffer Op-Amp Power Supply Capacitors to Ground Buffer Op-Amp Analog Sensor Detector PWM Gnd Circuit Magnetic Levitation System K. Craig 3
Microcontroller Board Gnd PWM Analog Sensor Magnetic Levitation System K. Craig 4
Electromagnet Actuator Current flowing through the coil windings of the electromagnet generates a magnetic field. The ferromagnetic core of the electromagnet provides a low-reluctance path in the which the magnetic field is concentrated. The magnetic field induces an attractive force on the ferromagnetic ball. Electromagnetic Force Proportional to the square of the current and inversely proportional to the square of the gap distance Magnetic Levitation System K. Craig 5
The electromagnet uses a ¼ - inch steel bolt as the core with approximately 3000 turns of 26-gauge magnet wire wound around it. The electromagnet at room temperature has a resistance R = 34 Ω and an inductance L = 154 mh. Magnetic Levitation System K. Craig 6
Ball-Position Sensor The sensor consists of an infrared diode (emitter) and a phototransistor (detector) which are placed facing each other across the gap where the ball is levitated. Infrared light is emitted from the diode and sensed at the base of the phototransistor which then allows a proportional amount of current to flow from the transistor collector to the transistor emitter. When the path between the emitter and detector is completely blocked, no current flows. When no object is placed between the emitter and detector, a maximum amount of current flows. The current flowing through the transistor is converted to a voltage potential across a resistor. Magnetic Levitation System K. Craig 7
The voltage across the resistor, V sensor, is sent through a unity-gain, follower op-amp to buffer the signal and avoid any circuit loading effects. V sensor is proportional to the vertical position of the ball with respect to its operating point; this is compared to the voltage corresponding to the desired ball position. The emitter potentiometer allows for changes in the current flowing through the infrared LED which affects the light intensity, beam width, and sensor gain. The transistor potentiometer adjusts the phototransistor current-to-voltage conversion sensitivity and allows adjustment of the sensor s voltage range; a 0-5 volt range is required as an analog input to the microcontroller. Magnetic Levitation System K. Craig 8
Emitter Current = 10 ma Detector Voltage = 0-5 V Ball-Position Sensor LED Blocked: e sensor = 0 V LED Unblocked: e sensor = 5 V Equilibrium Position: e sensor 2.5 V K sensor 1.6 V/mm Range ± 1mm Magnetic Levitation System K. Craig 9
Magnetic Levitation System Block Diagram Feedback Control System to Levitate Steel Ball about an Equilibrium Position Corresponding to Equilibrium Gap gap 0 and Equilibrium Current i 0 From Equilibrium: As i, gap, & V sensor As i, gap, & V sensor Magnetic Levitation System K. Craig 10
Magnetic Levitation System Derivation m Neglect m m field Magnetic Levitation System K. Craig 11 f gap,i i C gap 2 2 2 Ni m m m core gap object return path m N N L i Define: core object return path 2 2 2 gap N N 0 gap Lm 0A x gap m gap 0Agap xgap 0 gap Ni constant x A N gap A W 1 2 1 Lxi 2 2 A A N 2 x 0 gap gap i 2 0 gap 2 2 1 2 dl(x) 1 2 2 1 i fe i 0AgapN i K1 2 dx 2 0Agap x gap K2 x gap
Equation of Motion: 2 i mx mg C x 2 At Static Equilibrium: mg i C x 2 2 Magnetic Levitation System Control System Design Measure the gap from the electromagnet with x positive Linearization: C C C x C i x x x x 2 2 2 i i 2i 2i ˆ ˆ 2 2 3 2 mxˆ mg C C x C i x x x i 2 2i 2 ˆ 2i ˆ 2 3 2 mxˆ C x C i x x 2 i 2 ˆ 2 i ˆ 3 2 Magnetic Levitation System K. Craig 12
Use of Experimental Testing in Multivariable Linearization f f (i, y) m f f f f i, y y y i i m 0 0 0 0 y i i,y i,y 0 0 0 0 Magnetic Levitation System K. Craig 13
SI Units m 0.008 g 9.81 mg x 0.0053 i 0.31 2 2 i 2 i mxˆ C ˆ 3 xˆ C i 2 x x xˆ 3695xˆ 63i ˆ i C x 2 2 xˆ 63 i ˆ 2 s 3695 C 2.29E 5 Magnetic Levitation System K. Craig 14
Electromagnet Model L = 154 mh R = 34 Ω e in KVL KCL L i L i R dil ein L eout 0 dt i i i i 0 L R out R d e dt R I out = 0 R e out out ein L eout 0 Basic Component Equations (Constitutive Equations) L deout eout ein R dt L De e e R L D 1 e out e in R out out in L ein eout L dt Magnetic Levitation System K. Craig 15 e out eout 1 i R e in L R L R D 1 in D 1 e 1 R di i R
Magnetic Levitation System Control Design Design a Feedback Controller to Stabilize the Magnetic Levitation Plant with Adequate Stability Margins voltage 0.029 63 2 0.0045s 1 s 3695 position Note: Controller gain will need to be negative Magnetic Levitation System K. Craig 16
Phase (deg) Imag Axis Magnitude (db) Uncompensated Electromagnet + Ball System 600 Root Locus Editor for Open Loop 1 (OL1) -60 Open-Loop Bode Editor for Open Loop 1 (OL1) -80 400-100 -120 200-140 -160 0-180 -200-180 G.M.: 66.1 db Freq: 0 rad/s Unstable loop -200-225 -400-600 -800-600 -400-200 0 200 400 Real Axis Note: Negative Controller Gain Is Required 10 1 10 2 10 3 10 4 Magnetic Levitation System K. Craig 17-270 P.M.: Inf Freq: NaN Frequency (rad/s) xˆ 0.029 63 2 êin 0.0045s 1 s 3695
Sample Control Design z = -50 p = -800 K = 52664 s 50 G c(s) 52664 s 800 Magnetic Levitation System K. Craig 18
Nyquist Stability Criterion Key Fact: The Bode magnitude response corresponding to neutral stability passes through 1 (0 db) at the same frequency at which the phase passes through180. The Nyquist Stability Criterion uses the open-loop transfer function, i.e., (B/E)(s), to determine the number, not the numerical values, of the unstable roots of the closed-loop system characteristic equation. If some components are modeled experimentally using frequency response measurements, these measurements can be used directly in the Nyquist criterion. The Nyquist Stability Criterion handles dead times without approximation. In addition to answering the question of absolute stability, Nyquist also gives useful results on relative stability, i.e., gain margin and phase margin. The Nyquist Stability Criterion handles stability analysis of complex systems with one or more resonances, with multiple magnitudecurve crossings of 1.0, and with multiple phase-curve crossings of 180. Magnetic Levitation System K. Craig 19
Procedure for Plotting the Nyquist Plot 1. Make a polar plot of (B/E)(i) for - <. The magnitude will be small at high frequencies for any physical system. The Nyquist plot will always be symmetrical with respect to the real axis. 2. If (B/E)(i) has no terms (i) k, i.e., integrators, as multiplying factors in its denominator, the plot of (B/E)(i) for - < < results in a closed curve. If (B/E)(i) has (i) k as a multiplying factor in its denominator, the plots for + and - will go off the paper as 0 and we will not get a single closed curve. The rule for closing such plots says to connect the "tail" of the curve at 0 - to the tail at 0 + by drawing k clockwise semicircles of "infinite" radius. Application of this rule will always result in a single closed curve so that one can start at the = - point and trace completely around the curve toward = 0 - and = 0 + and finally to = +, which will always be the same point (the origin) at which we started with = -. Magnetic Levitation System K. Craig 20
3. We must next find the number N p of poles of B/E(s) that are in the right half of the complex plane. This will almost always be zero since these poles are the roots of the characteristic equation of the open-loop system and openloop systems are rarely unstable. 4. We now return to our plot (B/E)(i), which has already been reflected and closed in earlier steps. Draw a vector whose tail is bound to the -1 point and whose head lies at the origin, where = -. Now let the head of this vector trace completely around the closed curve in the direction from = - to 0- to 0+ to +, returning to the starting point. Keep careful track of the total number of net rotations of this test vector about the -1 point, calling this N p-z and making it positive for counter-clockwise rotations and negative for clockwise rotations. 5. In this final step we subtract N p-z from N p. This number will always be zero or a positive integer and will be equal to the number of unstable roots for the closed-loop. Magnetic Levitation System K. Craig 21
A system must have adequate stability margins. Both a good gain margin and a good phase margin are needed. Useful lower bounds: GM > 2.5, PM > 30 Vector Margin is the distance to the -1 point from the closest approach of the Nyquist plot. This is a single-margin parameter and it removes all ambiguities in assessing stability that come from using GM and PM in combination. Magnetic Levitation System K. Craig 22
ω = ± N p =1 N p-z = 1 N p N p-z = 0 Magnetic Levitation System K. Craig 23
ω = 0 rad/s GM = -4.23 db = 0.615 ω = 356 rad/s GM = 15.9 db = 6.237 ω = 86 rad/s PM = 32.5 Magnetic Levitation System K. Craig 24
closed-loop Bode plot Magnetic Levitation System K. Craig 25
z = -50 p = -800 K = 3.2792E5 Magnetic Levitation System K. Craig 26
Neutral Stability Magnetic Levitation System K. Craig 27
z = -50 p = -800 K = 1.0443E6 Magnetic Levitation System K. Craig 28
ω = ± N p =1 N p-z = -1 N p N p-z = 2 Magnetic Levitation System K. Craig 29
z = -50 p = -800 K = 32323 Magnetic Levitation System K. Craig 30
Neutral Stability Magnetic Levitation System K. Craig 31
z = -50 p = -800 K = 20095 Magnetic Levitation System K. Craig 32
ω = ± N p =1 N p-z = 0 N p N p-z = 1 Magnetic Levitation System K. Craig 33
Phase (deg) Imag Axis Magnitude (db) Uncompensated Electromagnet + Ball System 600 Root Locus Editor for Open Loop 1 (OL1) -60 Open-Loop Bode Editor for Open Loop 1 (OL1) -80 400-100 -120 200-140 -160 0-180 -200-180 G.M.: 66.1 db Freq: 0 rad/s Unstable loop -200-225 -400-600 -800-600 -400-200 0 200 400 Real Axis Note: Negative Controller Gain Is Required 10 1 10 2 10 3 10 4 Magnetic Levitation System K. Craig 34-270 P.M.: Inf Freq: NaN Frequency (rad/s) xˆ 0.029 63 2 êin 0.0045s 1 s 3695
Phase (deg) Imag Axis Magnitude (db) s 30 N G c(s) 132020 KP KDs s 800 s N K P = 4951 K D = 159 N = 800 500 Root Locus Editor for Open Loop 1 (OL1) 20 0 Open-Loop Bode Editor for Open Loop 1 (OL1) 400-20 300-40 -60 Control Design PD 200 100 0-100 -200-80 -100-120 -140-135 -180 G.M.: -7.78 db Freq: 0 rad/s Stable loop -300-400 -500-300 -250-200 -150-100 -50 0 50 100 Real Axis -225-270 P.M.: 25.3 deg Freq: 201 rad/s 10 0 10 1 10 2 10 3 10 4 10 5 Frequency (rad/s) Closed-Loop Poles: -888, -20.4, -56.9 ± 222i Magnetic Levitation System K. Craig 35
s 38.28s 370.42 K N I G c(s) 113200 KP KDs s s 896 s s N 2 K P = 4784 K I = 46798 K D = 121 N = 896 Root Locus Editor for Open Loop 1 (OL1) 50 Open-Loop Bode Editor for Open Loop 1 (OL1) 200 Control Design PID Imag Axis 150 100 50 0-50 Magnitude (db) 0-50 -100-150 -135 G.M.: -6.55 db Freq: 21.7 rad/s Stable loop P.M.: 30.1 deg Freq: 163 rad/s -100-150 Phase (deg) -180-225 -200-270 -250-200 -150-100 -50 0 50 10 0 10 1 10 2 10 3 10 4 10 5 Real Axis Frequency (rad/s) Closed-Loop Poles: -959, -67 ± 185i, -12.8 ± 17.2i Magnetic Levitation System K. Craig 36
Linear System M_hat Perturbation Control Effort i_hat Perturbation Current Step -113200 Controller Gain s 2+38.28s+370.42 s 2+896s Control Saturation -10.57 to 4.43 volts 0.029 0.0045s+1 LR Circuit -63 s 2+-3695 Magnet + Ball x_hat Perturbation Position Comparison: Linear Plant vs. Nonlinear Plant Step -113200 Controller Gain e0 V Bias s 2+38.28s+370.42 s 2+896s Control Saturation 0 to 15 volts M Control Effort Nonlinear System C = 2.29E-5 m = 0.008 g = 9.81 R = 34.1 L = 154.2E-3 x0 = 0.0053 i0 = 0.31 e0 = 10.57 i R/L Gain1 1/s Integrator2 1/R Gain2 u 2 Math Function Current Product g Constant C/m Gain 1/s Integrator 1 u Math Function1 1/s Integrator1 u 2 Math Function2 x Ball Position Magnetic Levitation System K. Craig 37
Position x (m) 7.2 x 10-3 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command 7 6.8 6.6 Nonlinear Pant Linear Plant 6.4 6.2 6 PD Control 5.8 5.6 5.4 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 38
Current i (A) 0.5 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command 0.45 0.4 0.35 0.3 Nonlinear Plant Linear Plant 0.25 0.2 PD Control 0.15 0.1 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 39
Control Effort M (volts) 15 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command 10 Nonlinear Plant Linear Plant 5 PD Control 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 40
Position x (m) 7.2 x 10-3 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command Nonlinear Plant 7 Linear Plant 6.8 6.6 6.4 6.2 6 5.8 PID Control 5.6 5.4 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 41
Current i (A) 0.5 0.45 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command Nonlinear Plant Linear Plant 0.4 0.35 0.3 0.25 PID Control 0.2 0.15 0.1 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 42
Control Effort M (volts) 15 Nonlinear & Linear Plant Response Comparison: 1 mm Step Command Nonlinear Plant Linear Plant 10 PID Control 5 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 43
Complete System: Electromagnet + Ball + PWM Voltage Control Step 1 mm step command e0 V Bias Identical Controller - PID Format -1-113200 Controller Gain Controller Gain2 PID(s) PID Controller s 2 +38.3s+370.4 s 2 +896s Controller 1/3 Reference Signal 4000Hz Saturation 0 to 15 volts > Relational Operator 1 M Control Effort Convert Boolean into Double 5 Set amplitude to 5V C = 2.29E-5 m = 0.008 g = 9.81 R = 34.1 L = 154.2E-3 x0 = 0.0053 i0 = 0.31 e0 = 10.57 Supply Voltage Switch ON 15 0 Supply Voltage Switch Off >= PWM Switch Transistor MOSFET R/L Gain1 1/s Integrator2 1/R Gain2 Saturation 0 to 1 amp u 2 Math Function i Current Product g Constant C/m Gain 1/s Integrator 1 u Math Function1 1/s Integrator1 u 2 Math Function2 x Ball Position Magnetic Levitation System K. Craig 44
Position x (m) 7.2 x 10-3 Nonlinear Plant & PWM Voltage Control: 1 mm Step Command 7 6.8 6.6 6.4 6.2 6 PD Control 5.8 5.6 5.4 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 45
Current i (A) 0.5 Nonlinear Plant & PWM Voltage Control: 1 mm Step Command 0.45 0.4 0.35 0.3 0.25 PD Control 0.2 0.15 0.1 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 46
Control Effort M (volts) 15 Nonlinear Plant & PWM Voltage Control: 1 mm Step Command 10 5 PD Control 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 47
Position x (m) 7.2 x 10-3 7 Nonlinear Plant & PWM Voltage Control 1 mm Step Command 6.8 6.6 6.4 6.2 6 5.8 PID Control 5.6 5.4 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 48
Current i (A) 0.5 Nonlinear Plant & PWM Voltage Control 1 mm Step Command 0.45 0.4 0.35 0.3 0.25 PID Control 0.2 0.15 0.1 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 49
Control Effort M (volts) 15 Nonlinear Plant & PWM Voltage Control 1 mm Step Command 10 5 PID Control 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 time (sec) Magnetic Levitation System K. Craig 50
Emitter Circuit Power MOSFET with Diode To Electromagnet Buffer Op-Amp Power Supply Capacitors to Ground Buffer Op-Amp Analog Sensor Detector PWM Gnd Circuit Magnetic Levitation System K. Craig 51
Microcontroller Board Gnd PWM Analog Sensor Magnetic Levitation System K. Craig 52
Arduino Microcontroller Implementation With Simulink Autocode Generator 2.5 Commanded Position Volts 5.98 Constant 1/1600 Gain 0.0053 m gap -1 Controller Gain2 PID(s) PID Controller 10.57 Bias Voltage Saturation 0 to 15 volts 1/3 255/5 8-Bit D/A Arduino Discrete PiD Control Magnetic Levitation System PWM Ts = sample period = 0.001 Pin 10 Digital Output Pin 0 Analog Input 5/1023 10-Bit A/D 1/1600 Gain1 Operating point is 0.0053 m gap and corresponds to sensor reading of 2.5 V Sensor gain is 1.6V/mm around operating point + or - 1 mm volts = 1600*m - 5.98 m = (volts + 5.98)/1600 Magnetic Levitation System K. Craig 53
Closed-Loop System Block Diagram LM 258 Low-Power Dual Op-Amp Unity-Gain Buffer Op-Amp e in = e out and in phase Magnetic Levitation System K. Craig 54
Power MOSFET TO-220 N-Channel, 60 V, 0.07 Ω, 16 A Magnetic Levitation System K. Craig 55
Alternative: Analog Power Stage Voltage-to-Current Converter e in R 2 R 1 +V + - -V OPA544 High-Voltage, High Current Op Amp e out Assume Ideal Op-Amp Behavior e R S R M Magnetic Levitation System K. Craig 56 L M Electromagnet R 2 1 im ein R1 R 2 RS e R 1 = 49KΩ, R 2 = 1KΩ, R S = 0.1Ω
e in e in R 1 +V R 2 e 1 R 2 R R 1 2 + - Σ e 1 + - R S A s1 -V L M e out R M Electromagnet Saturation Non-Ideal Op-Amp Behavior A eo e e s1 Magnetic Levitation System K. Craig 57 e e L s R i e out 1 M M R i 1 S 1 eout e1 LMs R M R S e L s R R M M S out 1 RS e out e 1 RS L s R R M M S 1 R S e e i