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

📄 foc_ti.c

📁 TI 的DSP2407A的无速度传感器永磁同步电机FOC控制程序
💻 C
📖 第 1 页 / 共 3 页
字号:
-----------------------------------------------------------------------------*/
    v->pid_spd.Kp_reg3 = 31457;  		/* Q15 */                                                    
    v->pid_spd.Ki_reg3 = 5592;   		/* Q31-16bit */
    v->pid_spd.Kd_reg3 = 0;   			/* Q14 */
    v->pid_spd.Kc_reg3 = 31858;  		/* Q15 */
    v->pid_spd.pid_out_max = 0x7FFF;    /* Q15 */
    v->pid_spd.pid_out_min = 0x8000;    /* Q15 */

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


/* ************************************************************************** */
/* ************************************************************************** */
 
#if (BUILDLEVEL==LEVEL1)
void FOC_TI_Run(FOC_TI_handle v)
{

/*-----------------------------------------------------------------------------
Connect freq_testing inputs to the RMPCNTL  
-----------------------------------------------------------------------------*/
    v->rmpc.target_value = v->speed_ref;  

/*-----------------------------------------------------------------------------
Call the compute function for the RMPCNTL
-----------------------------------------------------------------------------*/
    v->rmpc.calc((void *)&v->rmpc); 	/* Call RMPCNTL compute function */

/*-----------------------------------------------------------------------------
Connect RMPCNTL output to the RAMPGEN input  
-----------------------------------------------------------------------------*/
    v->rg.rmp_freq = v->rmpc.setpt_value;  

/*-----------------------------------------------------------------------------
Call the compute function for the RAMPGEN
-----------------------------------------------------------------------------*/
    v->rg.calc((void *)&v->rg); 	/* Call RAMPGEN compute function */

/*-----------------------------------------------------------------------------
Connect voltages in DQT structure  
-----------------------------------------------------------------------------*/
    v->voltage_DQt.D = v->Vd_testing;
    v->voltage_DQt.Q = v->Vq_testing;
    v->voltage_DQt.theta = v->rg.rmp_out;
      
/*-----------------------------------------------------------------------------
Call the compute function for the IPARK 
-----------------------------------------------------------------------------*/
	ipark((void *)&v->voltage_DQt,(void *)&v->voltage_dq);

/*-----------------------------------------------------------------------------
Connect IPARK voltage outputs to the SVGENDQ inputs 
-----------------------------------------------------------------------------*/
    v->svgen.d = v->voltage_dq.d;      
	v->svgen.q = v->voltage_dq.q;      
 		
/*-----------------------------------------------------------------------------
Call the compute function for the SVGENDQ
-----------------------------------------------------------------------------*/
    v->svgen.calc((void *)&v->svgen); 	/* Call SVGENDQ compute function */

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


#if (BUILDLEVEL==LEVEL2)         
void FOC_TI_Run(FOC_TI_handle v)
{  

/*-----------------------------------------------------------------------------
Connect freq_testing inputs to the RMPCNTL  
-----------------------------------------------------------------------------*/
    v->rmpc.target_value = v->speed_ref;  

/*-----------------------------------------------------------------------------
Call the compute function for the RMPCNTL
-----------------------------------------------------------------------------*/
    v->rmpc.calc((void *)&v->rmpc); 	/* Call RMPCNTL compute function */

/*-----------------------------------------------------------------------------
Connect RMPCNTL output to the RAMPGEN input  
-----------------------------------------------------------------------------*/
    v->rg.rmp_freq = v->rmpc.setpt_value;  

/*-----------------------------------------------------------------------------
Call the compute function for the RAMPGEN
-----------------------------------------------------------------------------*/
    v->rg.calc((void *)&v->rg); 	/* Call RAMPGEN compute function */

/*-----------------------------------------------------------------------------
Connect voltages in DQT structure  
-----------------------------------------------------------------------------*/
    v->voltage_DQt.D = v->Vd_testing;
    v->voltage_DQt.Q = v->Vq_testing;
    v->voltage_DQt.theta = v->rg.rmp_out;
      
/*-----------------------------------------------------------------------------
Call the compute function for the IPARK 
-----------------------------------------------------------------------------*/
	ipark((void *)&v->voltage_DQt,(void *)&v->voltage_dq);

/*-----------------------------------------------------------------------------
Connect IPARK voltage outputs to the SVGENDQ inputs 
-----------------------------------------------------------------------------*/
    v->svgen.d = v->voltage_dq.d;      
	v->svgen.q = v->voltage_dq.q;      
 		
/*-----------------------------------------------------------------------------
Call the compute function for the SVGENDQ
-----------------------------------------------------------------------------*/
    v->svgen.calc((void *)&v->svgen); 	/* Call SVGENDQ compute function */

/*-----------------------------------------------------------------------------
Call the compute function for the CLARKE 
-----------------------------------------------------------------------------*/
	clark((void *)&v->current_abc,(void *)&v->current_dq);

/*-----------------------------------------------------------------------------
Connect currents in DQT structure  
-----------------------------------------------------------------------------*/
    v->current_dqt.D = v->current_dq.d;
    v->current_dqt.Q = v->current_dq.q;
    v->current_dqt.theta = v->rg.rmp_out;

/*-----------------------------------------------------------------------------
Call the compute function for the PARK 
-----------------------------------------------------------------------------*/
	park((void *)&v->current_dqt,(void *)&v->current_DQ);

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


#if (BUILDLEVEL==LEVEL3)         
void FOC_TI_Run(FOC_TI_handle v)
{  
 
/*-----------------------------------------------------------------------------
Connect freq_testing inputs to the RMPCNTL  
-----------------------------------------------------------------------------*/
    v->rmpc.target_value = v->speed_ref;  

/*-----------------------------------------------------------------------------
Call the compute function for the RMPCNTL
-----------------------------------------------------------------------------*/
    v->rmpc.calc((void *)&v->rmpc); 	/* Call RMPCNTL compute function */

/*-----------------------------------------------------------------------------
Connect RMPCNTL output to the RAMPGEN input  
-----------------------------------------------------------------------------*/
    v->rg.rmp_freq = v->rmpc.setpt_value;  

/*-----------------------------------------------------------------------------
Call the compute function for the RAMPGEN
-----------------------------------------------------------------------------*/
    v->rg.calc((void *)&v->rg); 	/* Call RAMPGEN compute function */

/*-----------------------------------------------------------------------------
Connect PIDREG3 inputs for Id control  
-----------------------------------------------------------------------------*/
    v->pid_id.pid_ref_reg3 = v->Id_ref;  
    v->pid_id.pid_fdb_reg3 = v->current_DQ.d;

/*-----------------------------------------------------------------------------
Call the compute function for the PIDREG3 inputs for Id control
-----------------------------------------------------------------------------*/
    v->pid_id.calc((void *)&v->pid_id); 	/* Call PIDREG3 compute function */

/*-----------------------------------------------------------------------------
Connect PIDREG3 inputs for Iq control  
-----------------------------------------------------------------------------*/
    v->pid_iq.pid_ref_reg3 = v->Iq_ref;  
    v->pid_iq.pid_fdb_reg3 = v->current_DQ.q;

/*-----------------------------------------------------------------------------
Call the compute function for the PIDREG3 inputs for Iq control
-----------------------------------------------------------------------------*/
    v->pid_iq.calc((void *)&v->pid_iq); 	/* Call PIDREG3 compute function */

/*-----------------------------------------------------------------------------
Connect voltages in DQT structure  
-----------------------------------------------------------------------------*/
    v->voltage_DQt.D = v->pid_id.pid_out_reg3;
    v->voltage_DQt.Q = v->pid_iq.pid_out_reg3;
    v->voltage_DQt.theta = v->rg.rmp_out;
      
/*-----------------------------------------------------------------------------
Call the compute function for the IPARK 
-----------------------------------------------------------------------------*/
	ipark((void *)&v->voltage_DQt,(void *)&v->voltage_dq);

/*-----------------------------------------------------------------------------
Connect IPARK voltage outputs to the SVGENDQ inputs 
-----------------------------------------------------------------------------*/
    v->svgen.d = v->voltage_dq.d;      
	v->svgen.q = v->voltage_dq.q;      
 		
/*-----------------------------------------------------------------------------
Call the compute function for the SVGENDQ
-----------------------------------------------------------------------------*/
    v->svgen.calc((void *)&v->svgen); 	/* Call SVGENDQ compute function */

/*-----------------------------------------------------------------------------
Call the compute function for the CLARKE 
-----------------------------------------------------------------------------*/
	clark((void *)&v->current_abc,(void *)&v->current_dq);

/*-----------------------------------------------------------------------------
Connect currents in DQT structure  
-----------------------------------------------------------------------------*/
    v->current_dqt.D = v->current_dq.d;
    v->current_dqt.Q = v->current_dq.q;
    v->current_dqt.theta = v->rg.rmp_out;

/*-----------------------------------------------------------------------------
Call the compute function for the PARK 
-----------------------------------------------------------------------------*/
	park((void *)&v->current_dqt,(void *)&v->current_DQ);

}  /* End: FOC_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL3) */


⌨️ 快捷键说明

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