⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svm.c

📁 xc164的空间矢量调制的恒压频比控制
💻 C
字号:
#include "MAIN.H"#include "DEF.H"#include "TableQ15.h"unsigned int tk,tk1,to;					const int PulseMin_Div2 = 15;//****************************************************************************// @Function      void SVM (TComplex  *m, char *Sector) ////----------------------------------------------------------------------------// @Description   This Function calculate the compare values t0, tk and tk+1  //                for the SVM. Then this values are written in the Shadow-//                Registers of CC6-Unit//					//                Execution time 4.2us @ 40MHz ////----------------------------------------------------------------------------// @Returnvalue   None////----------------------------------------------------------------------------// @Parameters    None////----------------------------------------------------------------------------// @Date          15.10.2003////****************************************************************************unsigned int tk_temp,tk1_temp;
#ifdef _V_F_CONTROL_
extern unsigned int V_F_Ratio;
#endif
int Ta,Tb,Tc;
extern unsigned int TPWM;void CalcTimes(void)	{		int t_temp;		t_temp = tk+tk1;		if(t_temp > TPWM)		{			tk = tk*TPWM/(t_temp);			tk1 = tk1*TPWM/(t_temp);		}		Tc = (TPWM - tk -tk1) >>1;		Tb = Tc + tk;		Ta = Tb + tk1;	}void SVM(TComplex  *m, char *Sector){		int x;	// determiination of the sector	x=((long)m->imag*(long)SQRT3INV) >> 15;		if (m->imag>0)	{	// m.imag>0		if (m->real>0)		{	// Quadrant 1			if (x<m->real)	{*Sector=0;} else	{*Sector=1;}		}		else		{	// Quadrant 2			if (x< (-(m->real)))	{*Sector=2;} else	{*Sector=1;}		}	}	else	{	// m.imag<0		if (m->real<0)		{	// Quadrant 3			if (x<m->real)	{*Sector=4;} else	{*Sector=3;}		}		else		{	// Quadrant 4			if (x< (-(m->real)))	{*Sector=4;} else	{*Sector=5;}		}	}	//calculate the time of the adjacent vectors	tk1	=	((long)CosVectorQ1_15[*Sector]*(long)m->imag - (long)SinVectorQ1_15[*Sector]*(long)m->real) >> 15;	tk1	=	((long)tk1 * (long)TPWM) >> 15;	tk	=	((long)SinVectorQ1_15[*Sector+1]*(long)m->real-(long)CosVectorQ1_15[*Sector+1]*(long)m->imag) >> 15;	tk	=	((long)tk * (long)TPWM) >> 15;
	#ifdef _V_F_CONTROL_
	tk1	=	((long)tk1 * (long)V_F_Ratio) >> 16;
	tk	=	((long)tk * (long)V_F_Ratio) >> 16;
	#endif 
	tk_temp = tk;	tk1_temp = tk1;	switch (*Sector)	{  	case 0:		CCU6_TCTR2     =  0x006A;		CalcTimes();			CCU6_CC60SR=Tc;		CCU6_CC61SR=Tb;		CCU6_CC62SR=Ta;		break;		case 1:	    CCU6_TCTR2     =  0x0066;		tk = tk1_temp;		tk1= tk_temp;		CalcTimes();		CCU6_CC60SR=Tb;		CCU6_CC61SR=Tc;		CCU6_CC62SR=Ta;		break;		case 2:		CCU6_TCTR2     =  0x006E;		CalcTimes();		CCU6_CC60SR=Ta;		CCU6_CC61SR=Tc;		CCU6_CC62SR=Tb;		break;	case 3:		CCU6_TCTR2     =  0x006A;		tk = tk1_temp;		tk1= tk_temp;		CalcTimes();		CCU6_CC60SR=Ta;						  		CCU6_CC61SR=Tb;		  		CCU6_CC62SR=Tc;	        	  		break;		case 4:		CCU6_TCTR2     =  0x0066;	  	CalcTimes();											  		CCU6_CC60SR=Tb;			 		CCU6_CC61SR=Ta;		CCU6_CC62SR=Tc;		break;		case 5:		CCU6_TCTR2     =  0x006E;		tk = tk1_temp;		tk1= tk_temp;		CalcTimes();											   		CCU6_CC60SR=Tc;		CCU6_CC61SR=Ta;		CCU6_CC62SR=Tb;		break;		  		}	CCU6_vEnableShadowTransfer_CCU6_TIMER_12();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -