求F28335 spwm 三相相差120° 的dsp程序代码 亲测好用的 55
1个回答
展开全部
采用SVPWM,空间矢量调制更简单。
.h 文件
/* =================================================================================
File name: SVGEN_DQ.H (IQ version)
Originator: Digital Control Systems Group
Texas Instruments
Description:
Header file containing constants, data type definitions, and
function prototypes for the SVGEN_DQ.
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
------------------------------------------------------------------------------*/
#ifndef __SVGEN_DQ_H__
#define __SVGEN_DQ_H__
typedef struct { float32 Ualpha; // Input: reference alpha-axis phase voltage
float32 Ubeta; // Input: reference beta-axis phase voltage
float32 Ta; // Output: reference phase-a switching function
float32 Tb; // Output: reference phase-b switching function
float32 Tc; // Output: reference phase-c switching function
void (*calc)(); // Pointer to calculation function
} SVGENDQ;
typedef SVGENDQ *SVGENDQ_handle;
/*-----------------------------------------------------------------------------
Default initalizer for the SVGENDQ object.
-----------------------------------------------------------------------------*/
#define SVGENDQ_DEFAULTS { 0,0,0,0,0, \
(void (*)(Uint32))svgendq_calc }
/*------------------------------------------------------------------------------
Prototypes for the functions in SVGEN_DQ.C
------------------------------------------------------------------------------*/
void svgendq_calc(SVGENDQ_handle);
#endif // __SVGEN_DQ_H__
.c文件
/*=====================================================================================
File name: SVGEN_DQ.C (IQ version)
Originator: Digital Control Systems Group
Texas Instruments
Description: Space-vector PWM generation based on d-q components
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
-------------------------------------------------------------------------------------*/
// Don't forget to set a proper GLOBAL_Q in "IQmathLib.h" file
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "SUB_CONTROL_SVGEN_DQ_FLOAT.h"
#ifdef FLASH_MODE
#pragma CODE_SECTION(svgendq_calc,"ramfuncs");
#endif
void svgendq_calc(SVGENDQ *v)
{
float32 Va,Vb,Vc,t1,t2;
Uint32 Sector = 0; // Sector is treated as Q0 - independently with global Q
// Inverse clarke transformation
Va = v->Ubeta;
Vb = -0.5*v->Ubeta + 0.8660254*v->Ualpha; // 0.8660254 = sqrt(3)/2
Vc = -0.5*v->Ubeta - 0.8660254*v->Ualpha; // 0.8660254 = sqrt(3)/2
// 60 degree Sector determination
if (Va>0)
Sector = 1;
if (Vb>0)
Sector = Sector + 2;
if (Vc>0)
Sector = Sector + 4;
// X,Y,Z (Va,Vb,Vc) calculations
Va = v->Ubeta; // X = Va
Vb = 0.5*v->Ubeta + 0.8660254*v->Ualpha; // Y = Vb
Vc = 0.5*v->Ubeta - 0.8660254*v->Ualpha; // Z = Vc
if (Sector==0) // Sector 0: this is special case for (Ualpha,Ubeta) = (0,0)
{
v->Ta = 0.5;
v->Tb = 0.5;
v->Tc = 0.5;
}
if (Sector==1) // Sector 1: t1=Z and t2=Y (abc ---> Tb,Ta,Tc)
{
t1 = Vc;
t2 = Vb;
v->Tb = 0.5*(1-t1-t2); // tbon = (1-t1-t2)/2
v->Ta = v->Tb+t1; // taon = tbon+t1
v->Tc = v->Ta+t2; // tcon = taon+t2
}
else if (Sector==2) // Sector 2: t1=Y and t2=-X (abc ---> Ta,Tc,Tb)
{
t1 = Vb;
t2 = -Va;
v->Ta = 0.5*(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 and t2=X (abc ---> Ta,Tb,Tc)
{
t1 = -Vc;
t2 = Va;
v->Ta = 0.5*(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 and t2=Z (abc ---> Tc,Tb,Ta)
{
t1 = -Va;
t2 = Vc;
v->Tc = 0.5*(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 and t2=-Y (abc ---> Tb,Tc,Ta)
{
t1 = Va;
t2 = -Vb;
v->Tb = 0.5*(1-t1-t2); // tbon = (1-t1-t2)/2
v->Tc = v->Tb+t1; // tcon = tbon+t1
v->Ta = v->Tc+t2; // taon = tcon+t2
}
else if (Sector==6) // Sector 6: t1=-Y and t2=-Z (abc ---> Tc,Ta,Tb)
{
t1 = -Vb;
t2 = -Vc;
v->Tc = 0.5*(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 = 2.0*(v->Ta-0.5);
// v->Tb = 2.0*(v->Tb-0.5);
// v->Tc = 2.0*(v->Tc-0.5);
}
.h 文件
/* =================================================================================
File name: SVGEN_DQ.H (IQ version)
Originator: Digital Control Systems Group
Texas Instruments
Description:
Header file containing constants, data type definitions, and
function prototypes for the SVGEN_DQ.
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
------------------------------------------------------------------------------*/
#ifndef __SVGEN_DQ_H__
#define __SVGEN_DQ_H__
typedef struct { float32 Ualpha; // Input: reference alpha-axis phase voltage
float32 Ubeta; // Input: reference beta-axis phase voltage
float32 Ta; // Output: reference phase-a switching function
float32 Tb; // Output: reference phase-b switching function
float32 Tc; // Output: reference phase-c switching function
void (*calc)(); // Pointer to calculation function
} SVGENDQ;
typedef SVGENDQ *SVGENDQ_handle;
/*-----------------------------------------------------------------------------
Default initalizer for the SVGENDQ object.
-----------------------------------------------------------------------------*/
#define SVGENDQ_DEFAULTS { 0,0,0,0,0, \
(void (*)(Uint32))svgendq_calc }
/*------------------------------------------------------------------------------
Prototypes for the functions in SVGEN_DQ.C
------------------------------------------------------------------------------*/
void svgendq_calc(SVGENDQ_handle);
#endif // __SVGEN_DQ_H__
.c文件
/*=====================================================================================
File name: SVGEN_DQ.C (IQ version)
Originator: Digital Control Systems Group
Texas Instruments
Description: Space-vector PWM generation based on d-q components
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
-------------------------------------------------------------------------------------*/
// Don't forget to set a proper GLOBAL_Q in "IQmathLib.h" file
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "SUB_CONTROL_SVGEN_DQ_FLOAT.h"
#ifdef FLASH_MODE
#pragma CODE_SECTION(svgendq_calc,"ramfuncs");
#endif
void svgendq_calc(SVGENDQ *v)
{
float32 Va,Vb,Vc,t1,t2;
Uint32 Sector = 0; // Sector is treated as Q0 - independently with global Q
// Inverse clarke transformation
Va = v->Ubeta;
Vb = -0.5*v->Ubeta + 0.8660254*v->Ualpha; // 0.8660254 = sqrt(3)/2
Vc = -0.5*v->Ubeta - 0.8660254*v->Ualpha; // 0.8660254 = sqrt(3)/2
// 60 degree Sector determination
if (Va>0)
Sector = 1;
if (Vb>0)
Sector = Sector + 2;
if (Vc>0)
Sector = Sector + 4;
// X,Y,Z (Va,Vb,Vc) calculations
Va = v->Ubeta; // X = Va
Vb = 0.5*v->Ubeta + 0.8660254*v->Ualpha; // Y = Vb
Vc = 0.5*v->Ubeta - 0.8660254*v->Ualpha; // Z = Vc
if (Sector==0) // Sector 0: this is special case for (Ualpha,Ubeta) = (0,0)
{
v->Ta = 0.5;
v->Tb = 0.5;
v->Tc = 0.5;
}
if (Sector==1) // Sector 1: t1=Z and t2=Y (abc ---> Tb,Ta,Tc)
{
t1 = Vc;
t2 = Vb;
v->Tb = 0.5*(1-t1-t2); // tbon = (1-t1-t2)/2
v->Ta = v->Tb+t1; // taon = tbon+t1
v->Tc = v->Ta+t2; // tcon = taon+t2
}
else if (Sector==2) // Sector 2: t1=Y and t2=-X (abc ---> Ta,Tc,Tb)
{
t1 = Vb;
t2 = -Va;
v->Ta = 0.5*(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 and t2=X (abc ---> Ta,Tb,Tc)
{
t1 = -Vc;
t2 = Va;
v->Ta = 0.5*(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 and t2=Z (abc ---> Tc,Tb,Ta)
{
t1 = -Va;
t2 = Vc;
v->Tc = 0.5*(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 and t2=-Y (abc ---> Tb,Tc,Ta)
{
t1 = Va;
t2 = -Vb;
v->Tb = 0.5*(1-t1-t2); // tbon = (1-t1-t2)/2
v->Tc = v->Tb+t1; // tcon = tbon+t1
v->Ta = v->Tc+t2; // taon = tcon+t2
}
else if (Sector==6) // Sector 6: t1=-Y and t2=-Z (abc ---> Tc,Ta,Tb)
{
t1 = -Vb;
t2 = -Vc;
v->Tc = 0.5*(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 = 2.0*(v->Ta-0.5);
// v->Tb = 2.0*(v->Tb-0.5);
// v->Tc = 2.0*(v->Tc-0.5);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
晓网科技
2024-10-17 广告
2024-10-17 广告
电源: 2V-3.6V 典型值:3.3V。模块总功耗:A无线模块不工作时平均功耗 22-25mW B无线模块工作时平均功耗 130-135mW C无线模块工作时峰值功耗 140-150mW。发射功率:100mW 天线功率:1dBm ...
点击进入详情页
本回答由晓网科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询