• 大小: 13KB
    文件类型: .c
    金币: 2
    下载: 2 次
    发布日期: 2021-06-06
  • 语言: 其他
  • 标签: SVPWM  

资源简介

三相三电平NPC型逆变器的SVPWM控制算法的C代码。

资源截图

代码片段和文件信息

 //三电平SVPWM波的生成程序

#include “math.h“
#include “DSP281x_Device.h“     // DSP281x Headerfile Include File
#include “DSP281x_Examples.h“
#include 
//全局变量
int16 Ts=2048;   //Tz=5e-4乘以1000,Q12,f=2kHz
int16 T_SAMPLE=2048;   //采样周期和载波周期相等
int16 Vdc=45;    //Q0
int16 uaphaubeta;
int16 theta=0;      
int16 theta1;
int16 p3=12868;     // piQ12
int16 p1=4289;    // pi/3
int16 p2=8579;    //2*pi/3
int16 p4=17157;   //4*pi/3
int16 p5=21447;  //5*pi/3
int16 p6=25736;   //2pi
int16 p7=2145;   //pi/6
Uint16 N=0n=0;
Uint16 i=0;
int16 Vref;
int16 TaTbTc;
int16 T1T2T3;
int16 TmTnThTxTy;
int16 cmpr[6]={000000};   //cmpr[6]={CMPR1CMPR2CMPR3CMPR4CMPR5CMPR6};
int16 *ptr=cmpr;
int16 F_OMEGA=314;   //2pi*50Hz Q0格式
int16 SET_F=128;   //f/50Q7
int16 MAX_V=2365;//Q12   1.732Udc/3
int16 thetatheta_1=0;
int16 THETA_1=0;
int16 OMEGATEMPTEMP1TEMP_1=0;    //Q0
int16 ATOD=917; //Q4
int16 SET_V;
int16 SIN_thetaCOS_thetaSIN_theta1COS_theta1;
int16 sin_table[91]={0
71
143
214
286
357
428
499
570
641
711
782
852
921
991
1060
1129
1198
1266
1334
1401
1468
1534
1600
1666
1731
1796
1860
1923
1986
2048
2110
2171
2231
2290
2349
2408
2465
2522
2578
2633
2687
2741
2793
2845
2896
2946
2996
3044
3091
3138
3183
3228
3271
3314
3355
3396
3435
3474
3511
3547
3582
3617
3650
3681
3712
3742
3770
3798
3824
3849
3873
3896
3917
3937
3956
3974
3991
4006
4021
4034
4046
4056
4065
4074
4080
4086
4090
4094
4095
4096};  //Q12
int16 *p=sin_table;
int16 *q=&sin_table[90];
int16 m_1m_2m_3M_1M_2M_3m1m2m3;
int16 rs;
int16 ab;
Uint16 t=0;
Uint16 x[39];

// Prototype statements for functions found in this file.
interrupt void MY_T1UFINT_ISR(void);
interrupt void MY_T3UFINT_ISR(void);
void init_eva(void);
void init_evb(void);
void main(void)
{
 
// Step 1. Initialize System Control:
// PLL--30MHz*10/2 disable WatchDog enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO: 
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it‘s default state.
InitGpio(); 

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
    DINT;       //asm(“ setc INTM“)

// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared. 
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();


// Initialize the PIE vector table with pointers to the shell Interrupt 
// Service Routines (ISR). 
// This will populate the entire table even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
/

评论

共有 条评论