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

SVPWM算法

 请问 SVPWM算法  频率按理来说是50HZ,为什么实际是20HZ? 
具体代码如下

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

#define EPWM_CLK 60000000
volatile Uint32 fz=15000;//载波
volatile Uint16 fs=50; //电压频率
volatile Uint16 N;
volatile Uint16 PRD=0;
volatile float UBETA,UALFA,t1,t2,X,Y,Z;
volatile float B0,B1,B2;
volatile float Ta,Tb,Tc;
volatile Uint16 Sector;
volatile float M=1;
volatile Uint16 i=0;
volatile float ta;

#pragma CODE_SECTION(epwm1_timer_isr,"ramfuncs");

// Prototype statements for functions found within this file.
__interrupt void epwm1_timer_isr(void);

void InitEPwmTimer(void);

// These are defined by the linker
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadSize;
extern Uint16 RamfuncsRunStart;

void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &epwm1_timer_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
InitEPwmTimer();
// CPU_TimerInit();
// For this example, only initialize the ePWM Timers
memcpy((uint16_t *)&RamfuncsRunStart,(uint16_t *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash();
// Enable CPU INT3 which is connected to EPWM1-6 INT:
IER |= 0x0005;
// Enable EPWM INTn in the PIE: Group 3 interrupt 1-6
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
// PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
PRD=EPWM_CLK/(2*fz);
N=fz/fs;
ta=2*3.1415926/N;
while(1)
{
}
}

// Interrupt routines uses in this example:
__interrupt void epwm1_timer_isr(void)
{
UALFA=M*cos(i*ta);
UBETA=M*sin(i*ta);
B0=UBETA;
B1=0.8660254*UALFA-0.5*UBETA;
B2=-0.8660254*UALFA-0.5*UBETA;
Sector=0;
if(B0>0) Sector =1;
if(B1>0) Sector =Sector +2;
if(B2>0) Sector =Sector +4;
X=UBETA;
Y=0.8660254*UALFA+0.5*UBETA;
Z=-0.8660254*UALFA+0.5*UBETA;
if(Sector==0)
{
Ta=0.5;
Tb=0.5;
Tc=0.5;
}
else if(Sector==1)
{
t1=Z;
t2=Y;
Tb=(1-t1-t2)/2;
Ta=Tb+t1;
Tc=Ta+t2;
}
else if(Sector==2)
{
t1=Y;
t2=-X;
Ta=(1-t1-t2)/2;
Tc=Ta+t1;
Tb=Tc+t2;

}
else if(Sector==3)
{
t1=-Z;
t2=X;
Ta=(1-t1-t2)/2;
Tb=Ta+t1;
Tc=Tb+t2;

}
else if(Sector==4)
{
t1=-X;
t2=Z;
Tc=(1-t1-t2)/2;
Tb=Tc+t1;
Ta=Tb+t2;

}
else if(Sector==5)
{
t1=X;
t2=-Y;
Tb=(1-t1-t2)/2;
Tc=Tb+t1;
Ta=Tc+t2;
}
else if(Sector==6)
{
t1=-Y;
t2=-Z;
Tc=(1-t1-t2)/2;
Ta=Tc+t1;
Tb=Ta+t2;
}
EPwm1Regs.CMPA.half.CMPA =(int)(PRD*Ta);
EPwm2Regs.CMPA.half.CMPA =(int)(PRD*Tb);
EPwm3Regs.CMPA.half.CMPA =(int)(PRD*Tc);
i++;
if(i>=N) i=0;
EPwm1Regs.ETCLR.bit.INT = 1;
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}

mangui zhang:

先用示波器看PWM波的频率是不是正确啊    

然后在计算PWM波频率和SVPWM波的频率关系

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