2048|0

2015

帖子

0

TA的资源

纯净的硅(中级)

楼主
 

SVPWM源代码及注释 [复制链接]

#include "IQmathLib.h" // Includeheader for IQmath library

// Don't forget to set a proper GLOBAL_Q in"IQmathLib.h" file

#include "dmctype.h"

#include "svgen_dq.h"

void svgendq_calc(SVGENDQ *v)

{

_iq Va,Vb,Vc,t1,t2;

Uint32 Sector = 0; // Sector is treated asQ0 - independently with global Q

// Inverse clarke transformation   //赋值

 

Va = v->Ubeta;

Vb = _IQmpy(_IQ(-0.5),v->Ubeta) +_IQmpy(_IQ(0.8660254),v->Ualpha); // sqrt(3)/2

Vc = _IQmpy(_IQ(-0.5),v->Ubeta) -_IQmpy(_IQ(0.8660254),v->Ualpha); // sqrt(3)/2

// 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

Va = v->Ubeta; // X = Va

Vb = _IQmpy(_IQ(0.5),v->Ubeta) +_IQmpy(_IQ(0.8660254),v->Ualpha); // Y = Vb

Vc = _IQmpy(_IQ(0.5),v->Ubeta) -_IQmpy(_IQ(0.8660254),v->Ualpha); // Z = Vc

7

if (Sector==0) // Sector 0: this is specialcase for (Ualpha,Ubeta) = (0,0)

{

v->Ta = _IQ(0.5);//把浮点数转化成IQ格式

v->Tb = _IQ(0.5);

v->Tc = _IQ(0.5);

}

if (Sector==1) // Sector 1: t1=Z and t2=Y (abc---> Tb,Ta,Tc),60-120

{

t1 = Vc;

t2 = Vb;

// tbon = (1-t1-t2)/2//赋值(2-41)

v->Tb = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));

v->Ta = v->Tb+t1; // taon = tbon+t1

v->Tc = v->Ta+t2; // tcon = taon+t2

}

else if (Sector==2) // Sector 2: t1=Y andt2=-X (abc ---> Ta,Tc,Tb),300-360

{

t1 = Vb;

t2 = -Va;

v->Ta = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));// taon = (1-t1-t2)/2

v->Tc = v->Ta+t1; // tcon = taon+t1

v->Tb = v->Tc+t2; // tbon = tcon+t2

}

else if (Sector==3) // Sector 3: t1=-Z andt2=X (abc ---> Ta,Tb,Tc),0-60

{

t1 = -Vc;

t2 = Va;

v->Ta = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));// taon = (1-t1-t2)/2

v->Tb = v->Ta+t1; // tbon = taon+t1

v->Tc = v->Tb+t2; // tcon = tbon+t2

}

else if (Sector==4) // Sector 4: t1=-X andt2=Z (abc ---> Tc,Tb,Ta),180-240

{

t1 = -Va;

t2 = Vc;

v->Tc = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));// tcon = (1-t1-t2)/2

v->Tb = v->Tc+t1; // tbon = tcon+t1

v->Ta = v->Tb+t2; // taon = tbon+t2

}

else if (Sector==5) // Sector 5: t1=X andt2=-Y (abc ---> Tb,Tc,Ta),120-180

{

t1 = Va;

t2 = -Vb;

v->Tb = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));// tbon = (1-t1-t2)/2

8

v->Tc = v->Tb+t1; // tcon = tbon+t1

v->Ta = v->Tc+t2; // taon = tcon+t2

}

else if (Sector==6) // Sector 6: t1=-Y andt2=-Z (abc ---> Tc,Ta,Tb),240-300

{

t1 = -Vb;

t2 = -Vc;

v->Tc = _IQmpy(_IQ(0.5),(_IQ(1)-t1-t2));// tcon = (1-t1-t2)/2

v->Ta = v->Tc+t1; // taon = tcon+t1

v->Tb = v->Ta+t2; // tbon = taon+t2

}

// Convert the unsigned GLOBAL_Q format(ranged (0,1)) -> signed GLOBAL_Q format (ranged

(-1,1))

v->Ta =_IQmpy(_IQ(2.0),(v->Ta-_IQ(0.5)));

v->Tb =_IQmpy(_IQ(2.0),(v->Tb-_IQ(0.5)));

v->Tc =_IQmpy(_IQ(2.0),(v->Tc-_IQ(0.5)));

}

点赞 关注
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/7 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表