求F28335 spwm 三相相差120° 的dsp程序代码 亲测好用的

求F28335 spwm 三相相差120° 的dsp程序代码 亲测好用的,第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)

}

工作原理你可以看一下STC单片机的PCA相关章节,占空比由CCAP0L,CCAP0H,

CCAP1L,CCAP1H的值确定比如其值为255,那么占空比就为0%,其值为128,占空比就为50%,其值为0,占空比就为100%。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11332241.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存