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

📄 sfoc_ti.c

📁 本程序来自TI公司网站原程序,其功能是通过传统的矢量控制算法来实现对永磁同步电机的控制,矢量控制采用双闭环结构
💻 C
📖 第 1 页 / 共 4 页
字号:
/* ==============================================================================
System Name:  PMSM3_2   (QEP version)

File Name:	SFOC_TI.C

Description:  Peripheral independent object for the implementation 
              of Sensorless Field Orientation Control for a Three Phase 
              Permanent-Magnet Synchronous Motor using Sliding mode 
              rotor angle observer.

Originator:		Digital control systems Group - Texas Instruments


Target dependency:	x240/1/2/3/07 
To Select the target device see target.h file.

Note that the PWM/sampling frequency in C system is running at 15 kHz, which 
is different from the PWM/samping frequency in ASM system (i.e., 20 kHz) as 
indicated in the PMSM3-2 system documentation. Also, this PWM/samping frequency
in both ASM and C systems are based on x2407 with 40 MHz clock. If the x243 with
20 MHz clock is used, then the PWM/samping frequency may be decreased accordingly.   
			
=====================================================================================
 History:
-------------------------------------------------------------------------------------
 03-01-2001	Release	Rev 1.0
=================================================================================  */

#include <sfoc_ti.h>
#include <build.h>

#if (BUILDLEVEL==LEVEL1)
void SFOC_TI_Init(SFOC_TI_handle v)
{  
/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Setup Ramp generator parameters.
-----------------------------------------------------------------------------*/
    v->rg.step_angle_max = 874;   /* This is based on 15kHz sampling frequency */     
 
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
    v->rmpc.rmp_dly_max = 50;        
    v->rmpc.rmp_lo_limit = 0x8000;        
    v->rmpc.rmp_hi_limit = 0x7FFF;   

} /* End: SFOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL1) */


#if (BUILDLEVEL==LEVEL2)
void SFOC_TI_Init(SFOC_TI_handle v)
{  
/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Setup Ramp generator parameters.
-----------------------------------------------------------------------------*/
    v->rg.step_angle_max = 874;   /* This is based on 15kHz sampling frequency */     
 
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
    v->rmpc.rmp_dly_max = 50;        
    v->rmpc.rmp_lo_limit = 0x8000;        
    v->rmpc.rmp_hi_limit = 0x7FFF;   

}      /* End: SFOC_TI_Init() */ 
#endif /* (BUILDLEVEL==LEVEL2) */

#if (BUILDLEVEL==LEVEL3)
void SFOC_TI_Init(SFOC_TI_handle v)
{  

/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Setup Ramp generator parameters.
-----------------------------------------------------------------------------*/
    v->rg.step_angle_max = 874;   /* This is based on 15kHz sampling frequency */     
 
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
    v->rmpc.rmp_dly_max = 50;        
    v->rmpc.rmp_lo_limit = 0x8000;        
    v->rmpc.rmp_hi_limit = 0x7FFF;   

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_id.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_id.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_id.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_id.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_id.pid_out_max = 0x4000;     /* Q15 */
    v->pid_id.pid_out_min = 0xC000;     /* Q15 */

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_iq.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_iq.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_iq.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_iq.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_iq.pid_out_max = 0x6500;     /* Q15 */
    v->pid_iq.pid_out_min = 0x9B00;     /* Q15 */
                      
}      /* End: SFOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL3) */


#if (BUILDLEVEL==LEVEL4)
void SFOC_TI_Init(SFOC_TI_handle v)
{  

/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Setup Ramp generator parameters.
-----------------------------------------------------------------------------*/
    v->rg.step_angle_max = 874;   /* This is based on 15kHz sampling frequency */     
 
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
    v->rmpc.rmp_dly_max = 50;        
    v->rmpc.rmp_lo_limit = 0x8000;        
    v->rmpc.rmp_hi_limit = 0x7FFF;   

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_id.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_id.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_id.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_id.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_id.pid_out_max = 0x4000;     /* Q15 */
    v->pid_id.pid_out_min = 0xC000;     /* Q15 */

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_iq.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_iq.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_iq.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_iq.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_iq.pid_out_max = 0x6500;     /* Q15 */
    v->pid_iq.pid_out_min = 0x9B00;     /* Q15 */
                      
}      /* End: SFOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL4) */


#if (BUILDLEVEL==LEVEL5)
void SFOC_TI_Init(SFOC_TI_handle v)
{  
/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Setup Ramp generator parameters.
-----------------------------------------------------------------------------*/
    v->rg.step_angle_max = 874;   /* This is based on 15kHz sampling frequency */     
 
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
    v->rmpc.rmp_dly_max = 50;        
    v->rmpc.rmp_lo_limit = 0x8000;        
    v->rmpc.rmp_hi_limit = 0x7FFF;   

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_id.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_id.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_id.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_id.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_id.pid_out_max = 0x4000;     /* Q15 */
    v->pid_id.pid_out_min = 0xC000;     /* Q15 */

/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
    v->pid_iq.Kp_reg3 = 21178;  		/* Q15 */                                                    
    v->pid_iq.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_iq.Kd_reg3 = 0;		   		/* Q14 */
    v->pid_iq.Kc_reg3 = 20281;  		/* Q15 */
    v->pid_iq.pid_out_max = 0x6500;     /* Q15 */
    v->pid_iq.pid_out_min = 0x9B00;     /* Q15 */

/*-----------------------------------------------------------------------------
Setup SMOPOS sliding mode rotor angle observer parameters.   
(based on 15kHz sampling freq)
-----------------------------------------------------------------------------*/
/* PMSM motor (Pacific Scientific) */
/* fb = 200 Hz */
   	v->smo.fsmopos = 32319; 	/* Q15 */
   	v->smo.gsmopos = 15434; 	/* Q15 */
   	v->smo.kslide = 4236; 	    /* Q15 */  
   	v->smo.kslf = 3431;         /* Q15 */

/*-----------------------------------------------------------------------------
Initialize parameters of the speed calculation based on estimated angle
(based on 15kHz sampling freq)
-----------------------------------------------------------------------------*/
/* fb = 200 Hz */
    v->speed.K1_fr = 4800;  
    v->speed.K2_fr = 32361;
    v->speed.K3_fr = 407;
    v->speed.rpm_max = 6000;

}      /* End: SFOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL5) */


#if (BUILDLEVEL==LEVEL6)
void SFOC_TI_Init(SFOC_TI_handle v)
{  

/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice, 
            (a) in the 'C' boot-up, and then 
            (b) in the execution of this code. Setting up the needed
                constants the declaration of SVGEN svgen = VALUES, 
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
    2.  There is also a code-size associated with these changes. 
-----------------------------------------------------------------------------*/

⌨️ 快捷键说明

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