原创 15工程之13_SVPWM

2014-4-13 23:44 1120 11 11 分类: 工程师职场 文集: 15工程
        SVPWM应该称为空间矢量脉宽调制吧。实用的是电压空间矢量,存在于两个地方:VC+SVPWM,或者DTC。我有些搞不清SVPWM与DTC的联系与区别。我认为SVPWM就是DTC的一部分,可能理解错了。SVPWM的重点在于确定电压矢量的维持时间,也就是选择三相桥6个开关管的开关时间;DTC却是通过转矩、磁链、磁链区域3个变量来选择开关管的开关状态,进而使磁链沿着圆形走。我不知道它们有没有关系。
        TI的代码是很神奇的。TI的电机驱动库文档svgen_dq非常棒地解释了SVPWM,神奇地是它最终输出的Ta,Tb,Tc不关角度的事,这与曾允文的《变频调速SVPWM技术的原理、算法与应用》讲得不一样,更简单。Ta,Tb,Tc是什么?它们是6个开关管的开关状态,这并不是PWM波形。TI的代码里面Phase_Voltage模块里面用不到,输出的Ta,Tb,Tc在后面与DSP的比较器作用后才出现PWM波形。svgen_dq里面的Figure7给出了一个PWM波形,很短的一个波形。我认为这个图有些细节错误,时间标注不对,T6和T4标得不对,这究竟是电压空间矢量6边形的哪一个区域啊?难道不是S1?这个文档有很多细节错误,细看的话你会发现。
       TI的SVPWM源代码太神奇了,我看不懂。我不得不用Matlab来仿真,协助理解,将CCS程序翻译成M文件,出来的波形很漂亮,短短的几行程序。可能就是因为太短,还是看不懂。感觉就像是经历过好几代的程序,已经看不出来它原来的意思。我试着按照文档自己编一个Matlab程序,努力了好一阵,结果出来了,跟源代码差不多,但是程序长了不少。TI就是神奇,让你不知道为什么!
svpwm.jpg
下面是程序:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name         : tam20131205_SVPWM
%% Author       : tam   (tangaiming_@126.com)
%% Date         : 20131205
%% Description  : SVPWM generator,
%%                way1: do as the TI's datasheet.
%%                way2: do as the TI's programm.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;clc;clf;

T = 1;

time=1:1:360;

for theta=1:1:360;
    theta_rad=theta/180*pi;

    sin_theta=sin(theta_rad);
    cos_theta=cos(theta_rad);

    Ualfa=0.1*cos_theta-0.3*sin_theta;
    Ubeta=0.1*sin_theta+0.3*cos_theta;
   
%%%%%%%%%%%%%%%%%%%%%%%%%%% way1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    Va=     Ubeta;
    Vb=-1/2*Ubeta+sqrt(3)/2*Ualfa;
    Vc=-1/2*Ubeta-sqrt(3)/2*Ualfa;
   
    sector1=0;
    if(Va>0)    sector1=sector1+1;
    end
    if(Vb>0)    sector1=sector1+2;
    end
    if(Vc>0)    sector1=sector1+4;
    end

    Va=    Ubeta;
    Vb=1/2*Ubeta+sqrt(3)/2*Ualfa;
    Vc=1/2*Ubeta-sqrt(3)/2*Ualfa;
   
    if    (sector1==1)
        t1 = Vc;
        t2 = Vb;
        Tb1=(1-t1-t2)/2;
        Ta1=Tb1+t1;
        Tc1=Ta1+t2;
    elseif(sector1==2)
        t1 = Vb;
        t2 =-Va;
        Ta1=(1-t1-t2)/2;
        Tc1=Ta1+t1;
        Tb1=Tc1+t2;
    elseif(sector1==3)
        t1 =-Vc;
        t2 = Va;
        Ta1=(1-t1-t2)/2;
        Tb1=Ta1+t1;
        Tc1=Tb1+t2;
    elseif(sector1==4)
        t1 =-Va;
        t2 = Vc;
        Tc1=(1-t1-t2)/2;
        Tb1=Tc1+t1;
        Ta1=Tb1+t2;
    elseif(sector1==5)
        t1 = Va;
        t2 =-Vb;
        Tb1=(1-t1-t2)/2;
        Tc1=Tb1+t1;
        Ta1=Tc1+t2;
    elseif(sector1==6)
        t1 =-Vb;
        t2 =-Vc;
        Tc1=(1-t1-t2)/2;
        Ta1=Tc1+t1;
        Tb1=Ta1+t2;
    end
   
    Ta1=2*(Ta1-0.5);
    Tb1=2*(Tb1-0.5);
    Tc1=2*(Tc1-0.5);
       
    y_Ualfa(theta,1)=Ualfa;
    y_Ubeta(theta,1)=Ubeta;
    y_Va(theta,1)=Va;
    y_Vb(theta,1)=Vb;
    y_Vc(theta,1)=Vc;
    y_sector1(theta,1)=sector1;
    y_Ta1(theta,1)=Ta1;
    y_Tb1(theta,1)=Tb1;
    y_Tc1(theta,1)=Tc1;
   
%%%%%%%%%%%%%%%%%%%%%%%%%%% way2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    tmp1=     Ubeta;
    tmp2= 1/2*Ubeta+sqrt(3)/2*Ualfa;
    tmp3=-1/2*Ubeta+sqrt(3)/2*Ualfa; % tmp2-tmp1;

    sector2=3;
    if(tmp2>0) sector2=sector2-1;
    end
    if(tmp3>0) sector2=sector2-1;
    end
    if(tmp1<0) sector2=7-sector2;
    end
   
    if    (sector2==1||sector2==4)
       Ta2= tmp2;               
       Tb2= tmp1-tmp3;             
       Tc2=-tmp2;                                  
    elseif(sector2==2||sector2==5)                                  
       Ta2= tmp3+tmp2;             
       Tb2= tmp1;               
       Tc2=-tmp1;                   
    elseif(sector2==3||sector2==6)                                                                       
       Ta2= tmp3;               
       Tb2=-tmp3;               
       Tc2=-(tmp1+tmp2);               
    end

    y_Ualfa(theta,1)=Ualfa;
    y_Ubeta(theta,1)=Ubeta;
    y_tmp1(theta,1)=tmp1;
    y_tmp2(theta,1)=tmp2;
    y_tmp3(theta,1)=tmp3;
    y_sector2(theta,1)=sector2;
    y_Ta2(theta,1)=Ta2;
    y_Tb2(theta,1)=Tb2;
    y_Tc2(theta,1)=Tc2;
   
end

% draw the picture
% way 1
figure(1);
subplot(221);
plot(time,y_Ualfa,'r',time,y_Ubeta,'g');
xlabel('Ualfa,Ubeta');
subplot(222);
plot(time,y_Va,'r',time,y_Vb,'g',time,y_Vc,'b');
xlabel('Va,Vb,Vc');
subplot(223);
plot(time,y_sector1);
xlabel('sector1');
subplot(224);
plot(time,y_Ta1,'r',time,y_Tb1,'g',time,y_Tc1,'b');
xlabel('Ta1,Tb1,Tc1');

% way 2
figure(2);
subplot(221);
plot(time,y_Ualfa,'r',time,y_Ubeta,'g');
xlabel('Ualfa,Ubeta');
subplot(222);
plot(time,y_tmp1,'r',time,y_tmp2,'g',time,y_tmp3,'b');
xlabel('tmp1,tmp2,tmp3');
subplot(223);
plot(time,y_sector2);
xlabel('sector2');
subplot(224);
plot(time,y_Ta2,'r',time,y_Tb2,'g',time,y_Tc2,'b');
xlabel('Ta2,Tb2,Tc2');

% PWM
figure(4);
set(gcf,'Color','w');
line([-0.25,1.25],[0,0],'Color','k');
line([0.5,0.5],[-1,-0.5],'Color','k');
line([0,0],[-1,0.5],'Color','k');
line([1,1],[-1,0.5],'Color','k');
line([-0.25,0],[0,0.5]);
line([0,0.5],[0.5,-0.5]);
line([0.5,1],[-0.5,0.5]);
line([1,1.25],[0.5,0]);

line([-0.25,1.25],[y_Ta2(1,1),y_Ta2(1,1)],'Color','r');
line([-0.25,1.25],[y_Tb2(1,1),y_Tb2(1,1)],'Color','r');
line([-0.25,1.25],[y_Tc2(1,1),y_Tc2(1,1)],'Color','r');

line([-0.25,1.25],[-1,-1],'Color','k');

line([0.1,0.1],[0.3017,-1],'Color','g');
line([0.17,0.17],[0.1641,-1],'Color','g');
line([0.4,0.4],[-0.3017,-1],'Color','g');
line([0.6,0.6],[-0.3017,-1],'Color','g');
line([0.83,0.83],[0.1641,-1],'Color','g');
line([0.9,0.9],[0.3017,-1],'Color','g');

% PWM1
line([0,0.17],[-0.7,-0.7],'Color','m');
line([0.17,0.83],[-0.65,-0.65],'Color','m');
line([0.83,1],[-0.7,-0.7],'Color','m');
line([0.17,0.17],[-0.7,-0.65],'Color','m');
line([0.83,0.83],[-0.7,-0.65],'Color','m');

% PWM2
line([0,0.1],[-0.8,-0.8],'Color','m');
line([0.1,0.9],[-0.75,-0.75],'Color','m');
line([0.9,1],[-0.8,-0.8],'Color','m');
line([0.1,0.1],[-0.8,-0.75],'Color','m');
line([0.9,0.9],[-0.8,-0.75],'Color','m');

% PWM3
line([0,0.4],[-0.9,-0.9],'Color','m');
line([0.4,0.6],[-0.85,-0.85],'Color','m');
line([0.6,1],[-0.9,-0.9],'Color','m');
line([0.4,0.4],[-0.9,-0.85],'Color','m');
line([0.6,0.6],[-0.9,-0.85],'Color','m');

text(-0.05,0.1841,'Ta');
text(-0.05,0.3217,'Tb');
text(-0.05,-0.2817,'Tc');

text(-0.1,-0.7,'PWM1');
text(-0.1,-0.8,'PWM2');
text(-0.1,-0.9,'PWM3');

line([0.17,0.19],[-0.7,-0.7],'Color','c');
line([0.19,0.19],[-0.7,-0.65],'Color','c');
line([0.83,0.85],[-0.65,-0.65],'Color','c');
line([0.85,0.85],[-0.7,-0.65],'Color','c');

line([0.1,0.12],[-0.8,-0.8],'Color','c');
line([0.12,0.12],[-0.8,-0.75],'Color','c');
line([0.9,0.92],[-0.75,-0.75],'Color','c');
line([0.92,0.92],[-0.8,-0.75],'Color','c');

line([0.4,0.42],[-0.9,-0.9],'Color','c');
line([0.42,0.42],[-0.9,-0.85],'Color','c');
line([0.6,0.62],[-0.85,-0.85],'Color','c');
line([0.62,0.62],[-0.9,-0.85],'Color','c');

%%%%%%%%%%%%%%%%%%%%%%%%%%% The end of the program %%%%%%%%%%%%%%%%%%%%%%%%

tam

文章评论0条评论)

登录后参与讨论
我要评论
0
11
关闭 站长推荐上一条 /2 下一条