www.pudn.com > PMSM111.zip > observor.m, change:2011-07-31,size:1040b


function Observor=test(x); 
 
global theta_ob theta_ob_old w_ob_old w_ob Td_ob Td_ob_old theta_dalta w_dalat Ts g1 g2 g3 nowsvm k1 k2 k3 J Bm Te Theta Theta_old 
global rotor_data Te_old 
Ts=50e-6;    % 控制周期 
Theta=x(1); 
J=x(2); 
Bm=x(3); 
Te=x(4); 
nowsvm=x(5);%外部时钟值采样 
 
% if nowsvm<1e-6 
    times=1e-6; 
    k1=-10000; 
    k2=-11000; 
    k3=-12000; 
    g1=-(k1+k2+k3)-Bm/J; 
    g2=(k1*k2+k1*k3+k2*k3)+(k1+k2+k3)*Bm/J+(Bm/J)*(Bm/J); 
    g3=k1*k2*k3*J; 
 
 
%     theta_ob=0; 
%     w_ob=0; 
%     Td_ob=0; 
%      
%     theta_ob_old=0; 
%     w_ob_old=0; 
%     Td_ob_old=0; 
%     Te_old=0; 
    %elseif nowsvm>=times 
   %times=nowsvm+Ts 
    
% else  
    rotor_data=Theta_old-theta_ob_old; 
    theta_ob=theta_ob_old+Ts*w_ob_old+Ts*g1*rotor_data; 
    w_ob=w_ob_old+Ts/J*(Te_old-Td_ob_old)-Bm/J*w_ob_old+Ts*g2*rotor_data; 
    Td_ob=Td_ob_old+Ts*g3*rotor_data; 
     
    Theta_old=Theta; 
    theta_ob_old=theta_ob; 
    w_ob_old=w_ob; 
    Td_ob_old=Td_ob; 
    Te_old=Te; 
% end; 
Observor=[theta_ob w_ob Td_ob]