|
ADI的DSP推广较差,BF506芯片是新出的,个人感觉比较好用。这个SVPWM程序是我们自己写的。确实能够驱动电机。没有什么控制策略,只能产生波形而已。输出滤波之后电压不是正弦波,不知道什么原因。小弟新手,请各位高手指导。
void Tx_calc(float u_alfa,float u_beta)
{
int N,A,B,C,BUF1,BUF2,BUF3;
float X,Y,Z,T1,T2,T_temp,T_zero;
A = (u_beta>0)*4;
B = ( u_beta - 1.73205*u_alfa >0)*2;
C = (1.73205*u_alfa+u_beta>0);
N = A+B+C;
X = 1.73205*Ts*(u_beta-1.73205*u_alfa)/Udc/2;
Y = 1.73205*Ts*u_beta/Udc;
Z = 1.73205*Ts*(1.73205*u_alfa+u_beta)/Udc/2;
switch(N)
{
case 5: T1 = Y; T2 = -X; break;//Sector I
case 7: T1 = Z; T2 = X; break;//Sector II
case 6: T1 = -Z; T2 = Y; break;//Sector III
case 2: T1 = X; T2 = -Y; break;//Sector IV
case 0: T1 = -X; T2 = -Z; break;//Sector V
case 1: T1 = -Y; T2 = Z; break;//Sector VI
default:asm("nop;");
}
if(T1+T2>Ts)
{
T_temp = T1+T2;
T1 = T1*Ts/T_temp;
T2 = T2*Ts/T_temp;
}
T_zero = Ts-T1-T2;
BUF1 = (int)(T_zero*f_sclk/4)-PWM_TM_BUF/2;
BUF2 = (int)((2*T2+T_zero)*f_sclk/4)-PWM_TM_BUF/2;
BUF3 = (int)((2*T1+2*T2+T_zero)*f_sclk/4)-PWM_TM_BUF/2;
switch(N)
{
case 5:PWM_CHA_BUF=BUF3;PWM_CHB_BUF=BUF2;PWM_CHC_BUF=BUF1; break;
case 7:PWM_CHA_BUF=BUF2;PWM_CHB_BUF=BUF3;PWM_CHC_BUF=BUF1; break;
case 6:PWM_CHA_BUF=BUF1;PWM_CHB_BUF=BUF3;PWM_CHC_BUF=BUF2; break;
case 2:PWM_CHA_BUF=BUF1;PWM_CHB_BUF=BUF2;PWM_CHC_BUF=BUF3; break;
case 0:PWM_CHA_BUF=BUF2;PWM_CHB_BUF=BUF1;PWM_CHC_BUF=BUF3; break;
case 1:PWM_CHA_BUF=BUF3;PWM_CHB_BUF=BUF1;PWM_CHC_BUF=BUF2; break;
default:asm("nop;");
}
}
下面是整个工程
点击此处下载 ourdev_687082QDH8OW.rar(文件大小:42K) (原文件名:SVPWM.rar) |
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|