TI中文支持网
TI专业的中文技术问题搜集分享网站

svpwm算法

程序1代码如下

Sector = 0; \
temp_sv1=_IQdiv2(v.Ubeta); /*divide by 2*/ \
temp_sv2=_IQmpy(_IQ(0.8660254),v.Ualpha); /* 0.8660254 = sqrt(3)/2*/ \
\
/* Inverse clarke transformation */ \
Va = v.Ubeta; \
Vb = -temp_sv1 + temp_sv2; \
Vc = -temp_sv1 – temp_sv2; \
/* 60 degree Sector determination */ \
if (Va>_IQ(0)) Sector = 1; \
if (Vb>_IQ(0)) Sector = Sector+2; \
if (Vc>_IQ(0)) Sector = Sector+4; \
/* X,Y,Z (Va,Vb,Vc) calculations X = Va, Y = Vb, Z = Vc */ \
Va = v.Ubeta; \
Vb = temp_sv1 + temp_sv2; \
Vc = temp_sv1 – temp_sv2; \
/* Sector 0: this is special case for (Ualpha,Ubeta) = (0,0)*/ \
\
switch(Sector) \
{ \
case 0: \
v.Ta = _IQ(0.5); \
v.Tb = _IQ(0.5); \
v.Tc = _IQ(0.5); \
break; \
case 1: /*Sector 1: t1=Z and t2=Y (abc —> Tb,Ta,Tc)*/ \
t1 = Vc; \
t2 = Vb; \
v.Tb=_IQdiv2((_IQ(1)-t1-t2)); \
v.Ta = v.Tb+t1; /* taon = tbon+t1 */ \
v.Tc = v.Ta+t2; /* tcon = taon+t2 */ \
break; \
case 2: /* Sector 2: t1=Y and t2=-X (abc —> Ta,Tc,Tb)*/ \
t1 = Vb; \
t2 = -Va; \
v.Ta=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tc = v.Ta+t1; /* tcon = taon+t1 */ \
v.Tb = v.Tc+t2; /* tbon = tcon+t2 */ \
break; \
case 3: /* Sector 3: t1=-Z and t2=X (abc —> Ta,Tb,Tc)*/ \
t1 = -Vc; \
t2 = Va; \
v.Ta=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tb = v.Ta+t1; /* tbon = taon+t1 */ \
v.Tc = v.Tb+t2; /* tcon = tbon+t2 */ \
break; \
case 4: /* Sector 4: t1=-X and t2=Z (abc —> Tc,Tb,Ta)*/ \
t1 = -Va; \
t2 = Vc; \
v.Tc=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tb = v.Tc+t1; /* tbon = tcon+t1 */ \
v.Ta = v.Tb+t2; /* taon = tbon+t2 */ \
break; \
case 5: /* Sector 5: t1=X and t2=-Y (abc —> Tb,Tc,Ta)*/ \
t1 = Va; \
t2 = -Vb; /* tbon = (1-t1-t2)/2 */ \
v.Tb=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tc = v.Tb+t1; /* taon = tcon+t2 */ \
v.Ta = v.Tc+t2; \
break; \
case 6: /* Sector 6: t1=-Y and t2=-Z (abc —> Tc,Ta,Tb)*/ \
t1 = -Vb; \
t2 = -Vc; \
v.Tc=_IQdiv2((_IQ(1)-t1-t2)); \
v.Ta = v.Tc+t1; /* taon = tcon+t1 */ \
v.Tb = v.Ta+t2; /* tbon = taon+t2 */ \
break; \
}

程序2代码如下

#define SVGENDQ_MACRO(v) \
v.tmp1= v.Ubeta; \
v.tmp2= _IQdiv2(v.Ubeta) + (_IQmpy(_IQ(0.866),v.Ualpha)); \
v.tmp3= v.tmp2 – v.tmp1; \
\
v.VecSector=3; \
v.VecSector=(v.tmp2> 0)?( v.VecSector-1):v.VecSector; \
v.VecSector=(v.tmp3> 0)?( v.VecSector-1):v.VecSector; \
v.VecSector=(v.tmp1< 0)?(7-v.VecSector) :v.VecSector; \
\
if (v.VecSector==1 || v.VecSector==4) \
{ v.Ta= v.tmp2; \
v.Tb= v.tmp1-v.tmp3; \
v.Tc=-v.tmp2; \
} \
\
else if(v.VecSector==2 || v.VecSector==5) \
{ v.Ta= v.tmp3+v.tmp2; \
v.Tb= v.tmp1; \
v.Tc=-v.tmp1; \
} \
\
else \
{ v.Ta= v.tmp3; \
v.Tb=-v.tmp3; \
v.Tc=-(v.tmp1+v.tmp2); \

以上两个程序都是TI库里的函数只是版本不一样,但是经过我计算程序二和程序一的最终结果Ta、Tb、Tc基本完全不一样,请问是什么原因?

user5283999:您好,程序2的代码你读懂了吗?感觉不是很好理解

程序1代码如下

Sector = 0; \
temp_sv1=_IQdiv2(v.Ubeta); /*divide by 2*/ \
temp_sv2=_IQmpy(_IQ(0.8660254),v.Ualpha); /* 0.8660254 = sqrt(3)/2*/ \
\
/* Inverse clarke transformation */ \
Va = v.Ubeta; \
Vb = -temp_sv1 + temp_sv2; \
Vc = -temp_sv1 – temp_sv2; \
/* 60 degree Sector determination */ \
if (Va>_IQ(0)) Sector = 1; \
if (Vb>_IQ(0)) Sector = Sector+2; \
if (Vc>_IQ(0)) Sector = Sector+4; \
/* X,Y,Z (Va,Vb,Vc) calculations X = Va, Y = Vb, Z = Vc */ \
Va = v.Ubeta; \
Vb = temp_sv1 + temp_sv2; \
Vc = temp_sv1 – temp_sv2; \
/* Sector 0: this is special case for (Ualpha,Ubeta) = (0,0)*/ \
\
switch(Sector) \
{ \
case 0: \
v.Ta = _IQ(0.5); \
v.Tb = _IQ(0.5); \
v.Tc = _IQ(0.5); \
break; \
case 1: /*Sector 1: t1=Z and t2=Y (abc —> Tb,Ta,Tc)*/ \
t1 = Vc; \
t2 = Vb; \
v.Tb=_IQdiv2((_IQ(1)-t1-t2)); \
v.Ta = v.Tb+t1; /* taon = tbon+t1 */ \
v.Tc = v.Ta+t2; /* tcon = taon+t2 */ \
break; \
case 2: /* Sector 2: t1=Y and t2=-X (abc —> Ta,Tc,Tb)*/ \
t1 = Vb; \
t2 = -Va; \
v.Ta=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tc = v.Ta+t1; /* tcon = taon+t1 */ \
v.Tb = v.Tc+t2; /* tbon = tcon+t2 */ \
break; \
case 3: /* Sector 3: t1=-Z and t2=X (abc —> Ta,Tb,Tc)*/ \
t1 = -Vc; \
t2 = Va; \
v.Ta=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tb = v.Ta+t1; /* tbon = taon+t1 */ \
v.Tc = v.Tb+t2; /* tcon = tbon+t2 */ \
break; \
case 4: /* Sector 4: t1=-X and t2=Z (abc —> Tc,Tb,Ta)*/ \
t1 = -Va; \
t2 = Vc; \
v.Tc=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tb = v.Tc+t1; /* tbon = tcon+t1 */ \
v.Ta = v.Tb+t2; /* taon = tbon+t2 */ \
break; \
case 5: /* Sector 5: t1=X and t2=-Y (abc —> Tb,Tc,Ta)*/ \
t1 = Va; \
t2 = -Vb; /* tbon = (1-t1-t2)/2 */ \
v.Tb=_IQdiv2((_IQ(1)-t1-t2)); \
v.Tc = v.Tb+t1; /* taon = tcon+t2 */ \
v.Ta = v.Tc+t2; \
break; \
case 6: /* Sector 6: t1=-Y and t2=-Z (abc —> Tc,Ta,Tb)*/ \
t1 = -Vb; \
t2 = -Vc; \
v.Tc=_IQdiv2((_IQ(1)-t1-t2)); \
v.Ta = v.Tc+t1; /* taon = tcon+t1 */ \
v.Tb = v.Ta+t2; /* tbon = taon+t2 */ \
break; \
}

程序2代码如下

#define SVGENDQ_MACRO(v) \
v.tmp1= v.Ubeta; \
v.tmp2= _IQdiv2(v.Ubeta) + (_IQmpy(_IQ(0.866),v.Ualpha)); \
v.tmp3= v.tmp2 – v.tmp1; \
\
v.VecSector=3; \
v.VecSector=(v.tmp2> 0)?( v.VecSector-1):v.VecSector; \
v.VecSector=(v.tmp3> 0)?( v.VecSector-1):v.VecSector; \
v.VecSector=(v.tmp1< 0)?(7-v.VecSector) :v.VecSector; \
\
if (v.VecSector==1 || v.VecSector==4) \
{ v.Ta= v.tmp2; \
v.Tb= v.tmp1-v.tmp3; \
v.Tc=-v.tmp2; \
} \
\
else if(v.VecSector==2 || v.VecSector==5) \
{ v.Ta= v.tmp3+v.tmp2; \
v.Tb= v.tmp1; \
v.Tc=-v.tmp1; \
} \
\
else \
{ v.Ta= v.tmp3; \
v.Tb=-v.tmp3; \
v.Tc=-(v.tmp1+v.tmp2); \

以上两个程序都是TI库里的函数只是版本不一样,但是经过我计算程序二和程序一的最终结果Ta、Tb、Tc基本完全不一样,请问是什么原因?

Igor An:Sv的实现方式有很多种,究其本质是0和7向量的放置分布不同,其最终影响的是开关次数(也可以说影响效率),以及谐波,还有有些应用种的采样点配置。
TI库里面的实现方式,可以直接拿来使用。如果想充分弄明白其中原理,可以根据源码,把一周360度的向量编码列出来,对照看一下就会比较清楚了。

赞(0)
未经允许不得转载:TI中文支持网 » svpwm算法
分享到: 更多 (0)