📄 cp8_1.m
字号:
%%%%%%%%%%% Comprehensive Problem 8.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('CP8.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) Closed_Loop - Response to% 0.1(rad) Step Input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Response to step input of magnitude 0.1 raddisp('Design of servo control loop using root-locus technique')disp('and closed-loop system response to unit step input of ')disp('wheel angle command.')disp('Select a gain for 0.9 damping ratio using the root-locus plot.')disp(' ')figure, ucircle, hold onrlocus(Gz(2,1)), hold offzgridaxis([-1 1 -1 1])[Kp1,ppm] = rlocfind(Gz(2,1));disp(['Kp1 = ', num2str(Kp1)])xy2p(ppm);disp('For a damping ratio of 0.9, Kp1 is found to be about 5.')disp('*******>'), pause%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part C : Inner (motor) Closed_Loop - Response to% 0.1(m) Step Input - Kpm = 5 with outer loop closed%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Response to step input of magnitude 0.1 mdisp('Design of ball position control loop using gain sweep')disp('and closed-loop response to step position command 0.1m.')disp('Select Kp using root-locus plots for 0.5 damping ratio')disp('for values of Kd from 0.8 to 2.')disp(' ')Kp1 = 5;Gm_OL = Gz*Kp1; % Open Loop (servo motor)Gm_CL = feedback(Gm_OL,1,1,2);Kd = [0.8:0.2:2]';lenKd = length(Kd);trb_vec = []; Mob_vec = []; ang_vec = []; Kp2 = [];figurefor i = 1:lenKd Kb = tf([(1+Kd(i)/Ts) -Kd(i)/Ts],[1 0],Ts); Gb_OL = Gm_CL*Kb; % Open Outer Loop rlocus(Gb_OL(1,1)) zgrid axis([0.951 1.01 -0.025 0.025]) disp('Select Kp using root-locus plots for 0.5 damping ratio') [Kp,ppb] = rlocfind(Gb_OL(1,1)); disp(['Kp = ', num2str(Kp)]) xy2p(ppb); Kp2(i) = Kp; Gb_CL = feedback(Gb_OL*Kp,1,1,1); % CLoop [yb,dtime] = step(Gb_CL); [Mob,tpb,trb,tsb,essb] = kstats(dtime,0.1*yb(:,1),0.1); trb_vec(i) = trb; % Rise Time of outer (b&b) CL Mob_vec(i) = Mob; % Max % Overshoot of outer CL ang_vec(i) = max(0.1*yb(:,2)); plot(dtime,0.1*yb(:,1),'o'); grid xlabel('Time (sec)') ylabel('Response (m)') title(['Kp2=',num2str(Kp2(i)),' Kd=',num2str(Kd(i))]) drawnow disp('Step response for selected poles') disp('******>'), pause end disp(' Kd Kp rise time (s) wheel angle (rad)')disp([Kd Kp2' trb_vec' ang_vec'])% Donedisp('End of Comprehensive Problem CP8.1')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -