Using MATLAB and Simulink for Control System Simulation ... - RPI

393 downloads 557 Views 63KB Size Report
Jan 29, 2003 ... Overview (and review) of MATLAB and Simulink. • Using MATLAB and Simulink for dynamical system analysis and simulation, and control ...
Using MATLAB and Simulink for Control System Simulation and Design

1/29/03

Outline • Overview (and review) of MATLAB and Simulink • Using MATLAB and Simulink for dynamical system analysis and simulation, and control design • Nonlinear vs. linear simulation and analysis • Application to Pan-Tilt platform

Last Time Equation of motion for dynamical systems: 1-link: ( I ! + N 2 I m )θ""! + ( B! + NBm )θ"! = Nτ m + mg ! c sin θ ! General: M (θ )θ"" + B(θ") + C (θ ,θ")θ" + G (θ ) = τ As a control system, we may regard τ is the input, θl is the output. Today, we will see how to use MATLAB and Simulink to simulate the response of the system for a given input trajectory.

MATLAB A powerful package with built-in math functions, array and matrix manipulation capabilities, plotting and lots of add-on toolboxes (e.g., control, image processing, symbolic manipulation, block diagram programming, i.e., Simulink, etc.)

MATLAB • • • • •

Vectors: theta=[theta_1;theta_2]; Matrices: M=[M11 M12; M21 M22]; Polynomials: p=[a3 a2 a1 a0]; Transfer functions: G=tf(num,den); Linear simulation: • step response: step(G); • impulse response: impulse(G); • general response: y=lsim(G,u,t);

MATLAB (Cont.) • Solving ODE x" = f (t , x) [t,x]=ode23(‘func’,[0 tf],xinit); f=func(t,x) • Plotting: plot(t,x1,t,x2);xlabel(‘time (sec)’);ylabel(‘theta (deg)’); title(‘theta(t)’); legend(‘\theta_1’,’\theta_2’); • Printing (to printer or file) print -f -d • Using m-files in MATLAB use any editor (or MATLAB built-in editor, just type in edit) function f=func(t,x) ... • Getting help in MATLAB: help or just help on-line tutorial: http://www.engin.umich.edu/group/ctm/

Application to Pan-Tilt Platform pantilt.m gives the symbolic expression for M (2x2 mass matrix) C (2x1 coriolis/centrifugal torque) G (2x1 gravity vector) For numerical computation, take a look of pantiltmodel.m: set up I, p, m for the two bodies

M (θ ) coriolis.m calculates C (θ ,θ")θ" massmatrix.m calculates gravity.m G (θ )

Simulation Consider input as the motor torques τ (2x1) and output as the joint angles (link) θ (2x1). Simulation involves find the output response for a given input trajectory. You will use a high fidelity simulation to validate your design (including nonlinearity, friction, saturation, etc.). For your control design, you will need to use a linearized model.

τ

pan-tilt dynamics

θ

Linearization Equation of motion is nonlinear (M, C, G are nonlinear functions of θ). To facilitate control system design, we first linearize about an operating point (θ ,θ") = (θ d , 0)

Linearization: 1-D example Taylor series expansion about (θ ,θ") = (θ d , 0) and keep the linear term. Consider the 1-D example from last class:

Iθ"" + Fc sgn θ" + Fvθ" − mglg sin θ = τ sin θ = sin θ d + cosθ d (θ − θ d ) − 0.5 sin θ d (θ − θ d ) 2 + #

Linearized system: I ∆θ"" + Fv ∆θ" − mglg cos θ d ∆θ = τ + mglg sin θ d $%&%' may be cancelled or treated as a disturbance

∆θ = (θ − θ d )

Linearization: General Mechanical Systems ∂G "" " (θ d )(θ − θ d ) = τ − G (θ d ) M (θ d )θ + Dθ + ( ∂θ cancelled or  ∂G1  ∂G  ∂θ1 = ∂θ  ∂G2  ∂θ  1

treated as disturbance

∂G1  ∂θ 2   ∂G2  ∂θ 2 

For pan-tilt platform, input is motor torque τ (2x1), output is θ (2x1).

τ

linearized pan-tilt dynamics

θ

Description of LTI Systems Input/Output (differential equation)

Frequency Domain

What does LTI mean?

State Space state

Input

output

Description of LTI Systems M (θ d )θ"" + Dθ" + ∇θ G (θ d )(θ − θ d ) = τ Input/Output (differential equation)  x  θ − θ  x =  1 =  " d   x2   θ 

Frequency Domain

State Space

I  0   0  "x =  x +  −1  τ −1 −1  − M ∇G − M D  $%%%&%%%' M 2 −1 $ &' ∆θ ( s ) = ( s M (θ d ) + Ds + ∇θ G (θ d )) τ ( s ) A B $%%%% %&%%%%% ' G(s) y = [ I 0] x + 0( τ $&' C

D

MATLAB Description of LTI Each LTI is treated as an object with a variety of possible description: transfer function: tf(num,den) (numerator and denominator polynomials) pole/zero/gain: zpk(z,p,k) (zeros, poles, gain) state space: ss(A,B,C,D) (state space parameters)

Take a look of pantilt_init.m on the webpage

Open Loop Linear System Response Impulse response: y=impulse(G) step response: y=step(G) general response: y=lsim(G,u,t)

Bode plot: y=bode(G) poles/zeros/dampings pole(G),zero(G), damp(G) pole/zero plot: pzmap(G) gain/phase margin (robustness): margin(G)

Incorporation of Control Interconnection of LTI systems:

r

F

+

K

τ

G

H

Gcl = feedback(G*K,H)*F

θ

Simulink Instead of command line entries, it may be easier to use a block diagram programming tool: LTI block Take a look of pantiltlinear.mdl for linearized pan-tilt under PID control

Effect of Sampling Most control systems these days are digital in nature so sampling is inherent (through A/D for sensor, which contains a sampler, and D/A for actuators, which contains a zero-order-hold). To analyze the effect of sampling, we can find the equivalent discrete time system: Gd = c2d(G,ts);%ts=sampling period (sec) Gd is also an LTI object and the commands for LTI may be applied.

Adding Sampling to Simulink Diagram To add sampling to your continuous time simulation, just add a zero-order-hold block (in the discrete time system library) to the input, then set the sampling time.

Nonlinear System Simulation G(s) may be replaced by a nonlinear block

What You Need to Do ! Turn your qualitative spec into more quantitative spec in terms of speed and precision, ability to reject disturbance, etc. ! Develop a Simulink diagram for your design iteration. • Use the Simulink diagram on-line as a starting template. • Add motor and gear parameters to the pan-tilt skeleton (generate composite m, I, p for each body). • Use your design parameters for simulation. • Desired input should be based on your spec. • You need to tweak the controllers also (e.g., gravity compensation, removing the mass matrix coupling, tune gains for each axis, avoid saturation, etc.)

Today at 5pm, Next Tuesday, 2/4 (5pm), Next Wednesday 2/5 (5pm) • Work on your project proposal (include preliminary design using MATLAB/Simulink)

Next Wednesday, 2/5 (9am) • Components of control systems: amplifier, encoder, motor

Suggest Documents