void svpwm(float *ptr)
{
int A,B,C,N
double X,Y,Z,Tx,Ty,T0,T1,Tm,Th
if(usbeta>0)A=1
else 耐仿A=0
if((1.732051*usalfa-usbeta)>0)B=1
else B=0
if((1.732051*usalfa-usbeta)>0)C=1
else C=0
N=A+2*B+4*C//计算扇区
X=1.732051*usbeta*Ts/udc
Y=(0.8660*usbeta+1.5*usalfa)*Ts/udc
Z=(-0.8660*usbeta+1.5*usalfa)*Ts/udc
swith(N)//各扇区昌运纤工作时间悄虚
{
case 1:Tx=YTy=-Zbreak
case 2:Tx=-XTy=Ybreak
case 3:Tx=ZTy=Xbreak
case 4:Tx=-ZTy=-Xbreak
case 5:Tx=XTy=-Ybreak
default:Tx=-YTy=Z
}
if((Tx+Ty)>Ts)
{
Tx=Tx*Ts/(Tx+Ty)
Ty=Ty*Ts/(Tx+Ty)
}
T0=(Ts-(Tx+Ty))/4
T1=(Ts+Tx-Ty)/4
Tm=(Ts-Tx+Ty)/4
Th=(Ts+Tx+Ty)/4
swith(N)//比较寄存器赋值
{
case 1:*ptr=Tm*(ptr+1)=T0*(ptr+2)=Thbreak
case 2:*ptr=T0*(ptr+1)=Th*(ptr+2)=Tmbreak
case 3:*ptr=T0*(ptr+1)=T1*(ptr+2)=Thbreak
case 4:*ptr=Th*(ptr+1)=Tm*(ptr+2)=T0break
case 5:*ptr=Th*(ptr+1)=T0*(ptr+2)=T1break
default:*ptr=T1*(ptr+1)=Th*(ptr+2)=T0break
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)