ee 4237- state space control laboratory university of...

19
EE 4237- State Space Control Laboratory University of Minnesota

Upload: vankiet

Post on 12-Mar-2018

217 views

Category:

Documents


2 download

TRANSCRIPT

EE 4237- State Space Control Laboratory

University of Minnesota

DEPARTMENT OF ELECTRICAL ENGINEERING

UNIVERSITY OF MINNESOTA

EE4237 State Space Control Laboratory

The first experiment is to introduce the use of Matlab and simulink in control

system design. Students will learn the basics of Matlab software which is convenient and rapid solution of problems in numerical linear algebra.

The second set of experiments will introduce DC motor control concepts using

Quanser's QET DC Motor Control Trainer(DCMCT). The DC Motor Control Trainer consists of a motor instrumented with an encoder, and the motor is driven my a low-noise linear power amplifier. QET DCMCT provides a way to demonstrate the fundamentals of motor control, tuning and haptics using several integrated experiments.

The third set of experiments will be based on a magnetic levitation apparatus

manufactured by ECP. This consists of two electro-magnets used to levitate two magnets in the vertical space between them. The levitated magnets are constrained by a guiding rod which provides lateral stability while feedback via use of laser distance sensors and actuation through control of the electromagnets is used to stabilize and control their vertical motion.

The fourth set of experiments will be based on torsional and inertial apparatus.

This consists of a set of disks rigidly connected to a vertical flexible rod. The position and motion of the disks is controlled by feedback via optical encoders and torque applied by an electric motor.

The fifth set has an introduction to another apparatus by ECP systems and that is

the Gyroscope. Important concepts like nutation, precession will be studied. And the remaining set of experiments are related with inverted pendulum.

Inverted pendulum accessory by ECP systems is attached to the torsion control system and control software will be required to invert the pendulum. Students will also try to balance the two-wheel robot made from LEGO mindstorms NXT.

TABLE OF CONTENTS

EXPERIMENT 0 Introduction to Matlab, Simulink, state feedback control

and nonlinear state simulation (1 week) EXPERIMENT 1 DC motor control using DCMCT (2 weeks) EXPERIMENT 2 Magnetic Levitation System: Control of nonlinear

compensated SISO system EXPERIMENT 3 Magnetic Levitation System: Multi input multi output

control EXPERIMENT 4 Torsion Control System: Dynamic parameter

identification EXPERIMENT 5 Torsion Control System: PD/PID control of rigid body

dynamics EXPERIMENT 6 Torsion Control System: LQR control (1 week) EXPERIMENT 7 Control Moment Gyroscope: Nutation and Precession (1

week) EXPERIMENT 8 Control Moment Gyroscope: Full state LQR (1 week) EXPERIMENT 9 Inverted Pendulum using Torsion Control System (1

week) EXPERIMENT 10 Balancing robot using LEGO Mindstorms NXT (1 week) Notes: (3 weeks for experiments 2 and 3 and 3 weeks for experiments 4 and 5)

DEPARTMENT OF ELECTRICAL ENGINEERING UNIVERSITY OF MINNESOTA

EE 4237 EXPERIMENT 0: Introduction to Matlab, Simulink, state feedback control and nonlinear state simulation. Purpose: To introduce the use of Matlab in control system design. References: 1. PC-MATLAB User’s guide 2. Control System Toolbox User’s guide Equipment: IBM PC/AT with Printer Introduction: Matlab is a software system for doing numerical mathematics. The basic Matlab software is structured for convenient and rapid solution of problems in numerical linear algebra. In addition there are a number of toolboxes, which adapt Matlab to special tasks. We will study the basic Matlab package and the Control System Toolbox. The easiest way to get started on Matlab is to run demos 1 and 2 of the Matlab DEMO program, run the Matlab HELP programs and then start playing around with simple examples. Prelab: Look at the attached “help step” and “help simulink” printouts from Matlab. Procedure: 1. The basic Matlab system

a. Throughout this and the other experiments the symbol <cr> means the ENTER or RETURN key on the keyboard.

b. At the DOS prompt type matlab<cr> and then wait for the Matlab prompt, which is >>. At the Matlab prompt type demo<cr>. Follow the instructions to observe Demos 1) and 2). (Observe others if you want)

c. At the Matlab prompt type help<cr> and note the available operators and functions. Next type help sin<cr> to see the type of help available for individual functions. Next try others.

d. Enter a vector by typing x = [1 2 3]. Next type x’. Now create a matrix by typing A = [x’ x’ x’]. Find determinant of this matrix. Enter another matrix A that is not singular. Calculate A * x. Solve A * y = x for y.

e. Generate the vector t = 0:10. Repeat for t = 0:0.1:1. f. Generate the logspaced vector w = logspace(-1,2) and note the entries. Read help

logspace.

2. Matlab Graphics

a. Plot several cycles of a sinusoid. Put axis labels and a title on your plot. b. Define a random vector and plot it. c. Define two random vectors x and y and make a point plot of x vs y. d. Print out one of your plots on printer.

3. The control system toolbox

a. Type ctrldemo<cr> and observe the demo. b. Type help rlocus<cr>, help bode<cr> and help step<cr> c. Plot the locus of the roots of (s3 + 6s2 + 5s) + K (s2 + 6s + 18) = 0 for 0 ≤ K≤ 200.

On your plot indicate roots locations for K = 10. Re-scale your root locus plot showing only the second quadrant. (Hint: see help axis. Let (s2 + 6s + 18) as num and (s3 + 6s2 + 5s) as den. )

4. Control system Example: A unity feedback control system has loop gain function L(s)= 200 (s + 5) /[s (s+1) (s+20)(s + 30)].

a. Plot a bode plot for L (jw). b. Plot a Nyquist plot for L (jw). c. Plot the closed loop poles and zeros on the sgrid (Type help sgrid<cr>.) d. Plot the closed loop step response. Put on axis labels and a title and make a

hardcopy. Put your name and date on your plot using the Matlab function text (see help text <cr>.)

e. Generate a discrete time transfer function L (z) using the Toolbox function c2d (do help c2d <cr>). Use a sampling period Ts = 0.01 sec.

f. Plot the poles and zeros of the closed loop discrete time system on zgrid. 5. Simulink Example 1:

a. Wire simulation for two-integrator feedback system shown in fig 0.1. b. Run simulation. c. Plot unit step response. d. Replace first integrator by the transfer function 2 / (s + 3) as shown in fig 0.2 and

select the two feedback gains a and b to place closed loop poles at -1 + j2 and -1 - j2.

e. Plot unit step response of your design.

6. Simulink example 2: a. Wire the simulink diagram of the Lorentz attractor shown in the simulink help

write up b. Plot 3D response of the system.

Postlab Report: Turn in hardcopy of step response generated in part 4.d and 5.e. and calculations involved in 5.d. Also turn in the 3D plot requested in 6.b. above.

To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. » help simulink Simulink Version 3.0 (R11) 01-Sep-1998 Model analysis and construction functions. Simulation. sim - Simulate a Simulink model. sldebug - Debug a Simulink model. simset - Define options to SIM Options structure. simget - Get SIM Options structure Linearization and trimming. linmod - Extract linear model from continuous-time system. linmod2 - Extract linear model, advanced method. dlinmod - Extract linear model from discrete-time system. trim - Find steady-state operating point. Model Construction. close_system - Close open model or block. new_system - Create new empty model window. open_system - Open existing model or block. load_system - Load existing model without making model visible. save_system - Save an open model. add_block - Add new block. add_line - Add new line. delete_block - Remove block. delete_line - Remove line. find_system - Search a model. replace_block - Replace existing blocks with a new block. set_param - Set parameter values for model or block. get_param - Get simulation parameter values from model. bdclose - Close a Simulink window. bdroot - Root level model name. gcb - Get the name of the current block. gcbh - Get the handle of the current block. gcs - Get the name of the current system. getfullname - get the full path name of a block slupdate - Update older 1.x models to 3.x. addterms - Add terminators to unconnected ports. bool - Convert numeric array to boolean.

Masking. hasmask - Check for mask. hasmaskdlg - Check for mask dialog. hasmaskicon - Check for mask icon. iconedit - Design block icons using ginput function. Maskpopups - Return and change masked block's popup menu items. movemask - Restructure masked built-in blocks as masked subsystems. Library. libinfo - Get library information for a system. Hardcopy and printing. frameedit - Edit print frames for annotated model printouts. print - Print graph or Simulink system; or save graph to M-file. printopt - Printer defaults. orient - Set paper orientation. See also BLOCKS and SIMDEMOS. For more details on use of Simulink See Appendix A. » help step STEP Step response of LTI models. STEP(SYS) plots the step response of the LTI model SYS (created with either TF, ZPK, or SS). For multi-input models, independent step commands are applied to each input channel. The time range and number of points are chosen automatically. STEP(SYS,TFINAL) simulates the step response from t=0 to the final time t=TFINAL. For discrete-time models with unspecified sampling time, TFINAL is interpreted as the number of samples. STEP(SYS,T) uses the user-supplied time vector T for simulation. For discrete-time models, T should be of the form Ti:Ts:Tf where Ts is the sample time. For continuous-time models, T should be of the form Ti:dt:Tf where dt will become the sample time for the discrete approximation to the continuous system. The step input is always assumed to start at t=0 (regardless of Ti). STEP(SYS1,SYS2,...,T) plots the step response of multiple LTI models SYS1,SYS2,... on a single plot. The time vector T is optional. You can also specify a color, line style, and marker for each system, as in step(sys1,'r',sys2,'y--',sys3,'gx').

When invoked with left-hand arguments, [Y,T] = STEP(SYS) returns the output response Y and the time vector T used for simulation. No plot is drawn on the screen. If SYS has NY outputs and NU inputs, and LT=length(T), Y is an array of size [LT NY NU] where Y(:,:,j) gives the step response of the j-th input channel. For state-space models, [Y,T,X] = STEP(SYS) also returns the state trajectory X which is an LT-by-NX-by-NU array if SYS has NX states. See also IMPULSE, INITIAL, LSIM, LTIVIEW, LTIMODELS. Overloaded methods help lti/step.m help frd/step.m

Appendix A Solving non linear state equations in SIMULINK

Many nonlinear dynamic input/output systems can be described with the help of the state differential equations as

dx/dt = f(x(t), u(t)); x(0)=x0 y(t) =h(x(t))

where x(t) is an n-dimensional state vector, u(t) is the system input vector, assumed m- dimensional and y(t) is the p-dimensional system output vector. Here f is an n-vector function of x and u and h is a p-vector function of x and u. These equations describe a time invariant finite dimensional nonlinear system. The system could also be a function of time e.g.

dx1/dt = f1(x1,x2,x3,t) dx2/dt = f2(x1,x2,x3,t)

dx3/dt = f3(x1,x2,x3,t) (1.1)

with initial conditions known as x1(0), x2(0), x3(0). There exists a strong dependence of the solutions of nonlinear systems on their initial conditions. It is impossible to exactly predict the behavior of nonlinear systems, even though the underlying phenomenon is deterministic and represented by a simple set of ordinary differential equations as shown above. The behavior of nonlinear systems can be studied and analyzed easily using MATLAB. Another easy way to go about it is to use the SIMULINK from MATLAB. SIMULINK is an extension to MATLAB that adds a graphical environment for modeling, simulating, and analyzing the dynamic linear and nonlinear dynamic systems. By expressing the ordinary differential equations in state form the dynamic element can be expressed as a nonlinear interconnection of integrator outputs. We will take a well-studied example of a third order nonlinear system whose solutions are obtained using SIMULINK. The example in itself will explain how to solve the nonlinear state equations using SIMULINK with many possibilities for the inputs and outputs (sources and sinks). Figure 1.0 shows the basic building blocks in simulink. Fig. 1.1 is a SIMULINK block diagram of the example under the discussion i.e. Lorenz Attractor. It arose first in the study of convective processes in fluid dynamics aimed at modeling atmospheric phenomena important for understanding weather and climate.

The mathematical model of this system is governed by three equations same as equ 1.1 and those are

dx1(t)/dt = A( x2(t) - x1(t) ) dx2(t)/dt = ( 1 + B - x3(t) ) x1(t) - x2(t)

dx3(t)/dt = ( x2(t) x1(t)) - C x3(t) (1.2) As mentioned earlier, The figure 1.1 depicts the graphical realization of the Lorentz Attractor.

Explanation of the Block Diagram of Lorentz Attractor • The block diagram shows three integrators, four adders, two products and some gain

factors. The output will be the 3 state components x1(t), x2(t), x3(t). • We have chosen A = 10, B = 27, C = 2.67 and the initial conditions as x1(0) = 5,

x2(0) = 5, x3(0) = 20.(Refer equ 1.2) These are the initial conditions of the integrators.

• The SIMULINK helps us finding the solution of the state equations in an easy manner. The different blocks in the diagram like integrator, adder, gain etc are included in the SIMULINK library browser.

• These blocks are to be dragged down on the worksheet and the block diagram has to be drawn.

• After setting up all the initial conditions and parameter values the system is ready for simulation.

• Simulation parameters are also to be set from the simulation menu on the menu bar. In this example the start time is set to 0 and stop time is set to 100 and a sampling time of 0.01 seconds is used.

Following is the detailed explanation of how to start using SIMULINK with this specific example of Lorentz Attractor. 1. To begin for MATLAB with SIMULINK, type simulink (while in MATLAB) after

the prompt >>. 2. The SIMULINK Library browser will pop up which contains the variety of blocks

(e.g. transfer-function block, gain factor block, integrator, step input, graph display), which are required to represent a system in graphical manner. These blocks are organized into groups (or sublibraries) according to their behavior (see fig 1.0). A block diagram is drawn by copying blocks from the library to a working window and drawing properly directed lines to connect the blocks. Any two blocks can be connected by drawing a line or several connected line segments from the output port of a block (with ">" pointing out of the block) to the input port of the other block (with ">" pointing toward the block). A branch line can be added by initiating the

branch near the output of a block or by pressing the control key when starting the branch.

3. Double clicking on a sublibrary name will open a new window that displays the

content of the group. 4. Create a working window by selecting New from the File menu of any library

window. Copy the desired block e.g. Sum block to the working window by dragging it from its library i.e. Linear Library in this case. Double click on the block to open a dialog box. To introduce the subtraction, enter + - in the text box labeled List of signs.

5. In the similar way specify the initial conditions and values in the windows, which will

pop up by double clicking on the blocks. e.g. specify initial condition of the integrator as mentioned above i.e. x1(0) = 5. Also specify the values of gain factors in the same manner.

6. To get the values of x1, x2, x3 first the values are to be stored in a file. Hence the sink

will be a block 'To File'. The 'To File' block gives values from which we can plot a 3-D realization of the solution. If 'To workspace' sink is chosen, it only gives us 2-D realizations. 'To file' option requires the name of the variable say out1 for x1 wherein it writes the values of simulation time and corresponding output.

7. To view the plot of the values of x1(t) for 0 < t <= 100, apply the scope as the sink. With the help of the scope, we can actually see the graph of the values varying as a function of simulation time.

8. When the Block diagram is ready with all the initial conditions, parameter values, connections and simulation parameters set, start the simulation from the simulation menu.

9. The simulation will show the graph proceeding on the scope when it is double clicked. After all the values are calculated, the simulation ends. Here we have three output variables out1, out2, out3 in the file names simudata1, simudata2, simudata3 (as specified by user).

10. Return to the MATLAB >> prompt and type in the code as shown on the attached code page.

11. The code ultimately plots in 3D plot the variables x1, x2, x3 for 0 < t <= 100

The important point to note here is that there exists the randomness in this example. Even with the same initial conditions, the 3D plots show noticeable changes in the solution when plotted every time. Observe fig.1.2 and fig 1.3. A discussion about the type of solutions for the Lorenz Attractor can be found in reference 1 page 199. The example above depicted how to use SIMULINK to obtain the solutions of nonlinear state equations. A general reference for properties of state differential equation is reference 2. See page 100 for results related to observability (outputs) in state systems.

Code used to obtain the 3D plot of x1(t), x2(t), x3(t) is >> load simudata1 >> load simudata2 >> load simudata3 >> p=[0 1]; >>x1=p * out1; >>x2=p * out2; >>x3=p * out3; >> plot3(x1,x2,x3) p matrix is required because the out1, out2, out3 variables written to the three files simudata1, simudata2, simudata3 contain the values of time in the first column elements and the actual values of the output of our interest in the second column. Hence to get rid of the values of time, out1 variable is multiplied by p to get the x1 values which are plotted using the standard plot3 function of the MATLAB. References:

1. B. W. Dickinson, SYSTEMS Analysis, Design, And Computation, Prentice Hall 1991 2. M. Vidyasagar, Nonlinear Systems Analysis, Prentice Hall, 1993