📄 cp9_1.m
字号:
%%%%%%%%%%% Comprehensive Problem 9.1 %%%%%%%%%%%% Discrete-Time Control Problems using %% MATLAB and the Control System Toolbox %% by J.H. Chow, D.K. Frederick, & N.W. Chbat %% Brooks/Cole Publishing Company %% September 2002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ball and Beam System % System has 4 states, 1 input, and 2 outputs% 4 states : ball's position and velocity, and% wheel's angular position and velocity% 1 input : motor voltage (u)% 2 output : ball's position (xi), and % wheel's angular position (theta)disp('CP9.1:Ball and Beam')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part A : Load model%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear; close all% Load continuous and discrete-time systemsif ~exist('bbeam.mat'), dbbeamelseif exist('bbeam.mat') == 2, load bbeam endTs = 0.02; % (50Hz) in dbbeam alreadydisp('Loaded dbbeam')disp('*******>'); pause; disp(' ')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part B : Inner (motor) loop - Close Loop using % proportional gain controller%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Response to step input of magnitude 0.1 raddisp('Design of servo control loop using lag controller')disp('and closed-loop system response to unit step input of ')disp('wheel angle command.')disp(' ')Kp1 = 5;Gm_OL = Gz*Kp1; % Open Loop (servo motor)Gm_CL = feedback(Gm_OL,1,1,2);Gbw = d2c(Gm_CL,'tustin') % bilinear transformdisp('*****>'), pausefigure, bode(Gbw(1,1)),grid % phase goes below -180 deg because of the bilinear transformtitle('Bode plot of Ball position with servo control loop closed')disp('Plotting frequency response of ball position')disp('*****>'), pausefigure, margin(Gbw(1,1))title('Margin plot of Ball position with servo control loop closed')disp('Plotting margins of ball position loop')disp('*****>'), pause% unity gain feedback systemGbw_CL = feedback(Gbw(1,1),1,1,1);figure, step(Gbw_CL,'o'),gridtitle('Step response of ball position with unity feedback')disp('Plotting step response of ball position with unity feedback')disp('*****>'), pause% find gain and phase of Gbw_CL at 1 rad/s[mag1,ph1] = bode(Gbw(1,1),1)des_pm = 55;del_pm = des_pm - (180 + ph1);Alead = (1+sin(del_pm*pi/180))/(1-sin(del_pm*pi/180)) % Eq (9.21)wwc = 1; % desired gain crossover frequencyZlead = -wwc/sqrt(Alead) % compute zeroKbw1 = tf(Alead*[1 -Zlead],[1 -Alead*Zlead]) % 1 section of lead[magKbw1,phKbw1] = bode(Kbw1,1)Kbw = (1/mag1)/magKbw1*Kbw1;figure, bode(Gbw_CL*Kbw),gridtitle('bode plot of ball position with lead controller')disp('Plotting frequency response of ball position with lead controller')disp('*****>'), pausefigure, margin(Gbw_CL*Kbw),gridtitle('Margin plot of ball position with lead controller')disp('Plotting margins of ball position with lead controller')disp('*****>'), pauseGbw_CL_final = feedback(Gbw*Kbw,1,1,1)figure, step(Gbw_CL_final,'o'),gridtitle('Step response of ball position with lead controller')disp('Plotting step response of ball position with lead controller')% Donedisp('End of Comprehensive Problem CP9.1')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -