Using MATLAB and Simulink For
Using MATLAB and Simulink For
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:
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.)
" = f (t , x) Solving ODE 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<device type> <file name> 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 <function name> or just help
on-line tutorial: http://www.engin.umich.edu/group/ctm/
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, ") = ( , 0) we first linearize about an operating point ( , d
Linearized system: "" + F " mgl cos = + mgl sin I v g d g d $% &% '
may be cancelled or treated as a disturbance
= ( d )
Frequency Domain
state
State Space
Input
output
I 0 0 "= x x + 1 1 1 M M G M D 2 1 $%%%&%%%' $ & ' ( s ) = ( s M ( d ) + Ds + G ( d )) ( s ) A B $%%%% % &%%%%% ' G(s) y = [ I 0] x + 0 ( $ & '
C D
Frequency Domain
State Space
Incorporation of Control
Interconnection of LTI systems:
+ -
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.
Today at 5pm, Next Tuesday, 2/4 (5pm), Next Wednesday 2/5 (5pm)
Work on your project proposal (include preliminary design using MATLAB/Simulink)