DSP28335 sw软件触发

DSP28335 sw软件触发,第1张

对于28335的话,可以在EPWM配置模块添加下绝纯面的语句

//adc

EPwm1Regs.ETSEL.bit.SOCAEN = 1// Enable SOC on A group

EPwm1Regs.ETSEL.bit.SOCASEL = 2// TBPRD

EPwm1Regs.ETPS.bit.SOCAPRD = 1

这是默认EPWM1来触桥野发AD转换(目前我程序里用的就是这个)。要想保证AD好用,你AD的初始化并消咐及相关标志位的配置也得配套设定好,光有启动语句的话照样没用

采用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)

}

void svpwm(float *ptr)

{

int A,B,C,N

double X,Y,Z,Tx,Ty,T0,T1,Tm,Th

if(usbeta>0)A=1

else 耐仿A=0

if((1.732051*usalfa-usbeta)>0)B=1

else B=0

if((1.732051*usalfa-usbeta)>0)C=1

else C=0

N=A+2*B+4*C//计算扇区

X=1.732051*usbeta*Ts/udc

Y=(0.8660*usbeta+1.5*usalfa)*Ts/udc

Z=(-0.8660*usbeta+1.5*usalfa)*Ts/udc

swith(N)//各扇区昌运纤工作时间悄虚

{

case 1:Tx=YTy=-Zbreak

case 2:Tx=-XTy=Ybreak

case 3:Tx=ZTy=Xbreak

case 4:Tx=-ZTy=-Xbreak

case 5:Tx=XTy=-Ybreak

default:Tx=-YTy=Z

}

if((Tx+Ty)>Ts)

{

Tx=Tx*Ts/(Tx+Ty)

Ty=Ty*Ts/(Tx+Ty)

}

T0=(Ts-(Tx+Ty))/4

T1=(Ts+Tx-Ty)/4

Tm=(Ts-Tx+Ty)/4

Th=(Ts+Tx+Ty)/4

swith(N)//比较寄存器赋值

{

case 1:*ptr=Tm*(ptr+1)=T0*(ptr+2)=Thbreak

case 2:*ptr=T0*(ptr+1)=Th*(ptr+2)=Tmbreak

case 3:*ptr=T0*(ptr+1)=T1*(ptr+2)=Thbreak

case 4:*ptr=Th*(ptr+1)=Tm*(ptr+2)=T0break

case 5:*ptr=Th*(ptr+1)=T0*(ptr+2)=T1break

default:*ptr=T1*(ptr+1)=Th*(ptr+2)=T0break

}

}


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

原文地址: https://outofmemory.cn/yw/12420978.html

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

发表评论

登录后才能评论

评论列表(0条)

保存