⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbbeam.m

📁 离散控制系统设计的MATLAB 代码
💻 M
字号:
%%%%%%%%% Comprehensive Problem dbbeam.m %%%%%%%%
%   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              
% Model file dbbeam.m
% The model of the ball & beam system described in 
% Appendix A. The parameters of the system are from 
% an experiment made by Quanser Consulting, Inc.
% The system has 4 states, 1 input, and 2 outputs. 
% The states of the model are:
%     x1 - ball position
%     x2 - ball velocity
%     x3 - beam angle
%     x4 - beam angular velocity 
% This model includes friction on the beam. 
%----------------------------------------------------

% servo model
% parameters
K   = 0.54;    % V/(rad/s) - back emf constant  
Jeq = 0.00291; % kg-m^2 - inertia
R   = 2.6;     % ohms - resistance
Am = [      0              1 ; ...
            0   -K^2/(Jeq*R)];
Bm = [         0 ; ...
       K/(Jeq*R)];     
Cm = [      1              0];
Dm = 0;
Gm = ss(Am,Bm,Cm,Dm);

% ball position model
% parameters
g = 9.8;       % m/s^2 - gravity constant
rL = 0.0306;   % linkage ratio
D = 0.15;      % friction costant measured from real experiment
Ab = [      0              1 ; ...
            0             -D];
Bb = [      0    ; ...
        5*rL*g/7];
Cb = [      1              0];
Db = 0;
Gb = ss(Ab,Bb,Cb,Db);

% overall model with 2 outputs and 1 input
Gs = [Gb; 1]*Gm;  
[A,B,C,D] = ssdata(Gs);
Gstf = tf(Gs)
[numb,denb] = tfdata(Gs(1,1),'v');
numb = small20(numb,1e-10);
[numm,denm] = tfdata(Gs(2,1),'v');
numm = small20(numm,1e-10);

disp('Ball & beam system continuous-time state-space model')
disp('  in arrays A B C D')
disp('Ball & beam system continuous-time state-space model')
disp('  in LTI object Gs')
disp('Ball & beam system continuous-time tf model')
disp('  in LTI object Gstf')
disp('  outputs are ball position and beam angle')
disp('Ball & beam system transfer function')
disp('  denm is denominator and numm is numerator')
disp('    from Vin to beam angle')
disp('  denb is denominator and numb is numerator')
disp('    from Vin to ball position')
disp(' ')
disp('******>'), pause

Ts = 0.02;   % sampling at 50 Hz
Gz = c2d(Gs,Ts,'zoh');
[Ad,Bd,Cd,Dd] = ssdata(Gz);
Gztf = tf(Gz);
[dnumb,ddenb] = tfdata(Gz(1,1),'v');
[dnumm,ddenm] = tfdata(Gz(2,1),'v');

disp('Ball & beam system discretized model obtained using a sampling')
disp('  time of 0.02 sec and a zero-order hold')
disp('Discrete-time state-space model in arrays Ad Bd Cd Dd')
disp('Discrete-time state-space model in LTI object Gz')
disp('Discrete-time tf model in LTI object Gztf')
disp('  outputs are ball position and beam angle')
disp('Ball & beam system transfer function')
disp('  ddenm is denominator and dnumm is numerator')
disp('    from Vin to beam angle')
disp('  ddenb is denominator and dnumb is numerator')
disp('    from Vin to ball position')

disp('The system data is saved in bbeam.mat')

save bbeam.mat A B C D Gs Gstf denb numb denm numm ...
               Ad Bd Cd Dd Gz Gztf ddenb dnumb ddenm dnumm 
%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -