:263.852KB : :1 :2022-09-16 23:30:56
void SVPWM_cal(float Ualpha,float Ubeta,float Udc)
{
vref1=Ubeta;
vref2=(-Ubeta Ualpha*1.732051)*0.5;
vref3=(-Ubeta-Ualpha*1.732051) *0.5;
if(vref1>0) a=1;
else a=0;
if(vref2>0) b=1;
else b=0;
if(vref3>0) c=1;
else c=0;
N=4*c 2*b a;
x=1.732051* Ubeta/Udc;
y=(1.5*Ualpha 0.8660254*Ubeta)/Udc;
z=(-1.5*Ualpha 0.8660254*Ubeta)/Udc;
switch(N){
case 1:sector=2;
T1=z;
T2=y;
break;
case 2:sector=6;
T1=y;
T2=-x;
break;
case 3:sector=1;
T1=-z;
T2=x;
break;
case 4:sector=4;
T1=-x;
T2=z;
break;
case 5:sector=3;
T1=x;
T2=-y;
break;
case 6:sector=5;
T1=-y;
T2=-z;
break;
default:break;
}
if((T1 T2)>1)
{
T1=T1/(T1 T2);
T2=T2/(T1 T2);
}
ta=(1-T1-T2)/4*Tpwm;
tb=ta T1/2*Tpwm;
tc=tb T2/2*Tpwm;
switch(sector) {
case 1 :cmp1=(ta);
cmp2=(tb);
cmp3=(tc);
break;
case 2 :cmp1=(tb);
cmp2= (ta);
cmp3= (tc);
break;
case 3 :cmp1= (tc);
cmp2= (ta);
cmp3= (tb);
break;
case 4 :cmp1= (tc);
cmp2= (tb);
cmp3= (ta);
break;
case 5 :cmp1= (tb);
cmp2= (tc);
cmp3= (ta);
break;
case 6 :cmp1= (ta);
cmp2= (tc);
cmp3= (tb);
break;
default : break;
}