📄 foc_ti.c
字号:
#if (BUILDLEVEL==LEVEL4)
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 */
/*-----------------------------------------------------------------------------
Checking lockrtr_flg=FALSE for spinning mode, lockrtr_flg=TRUE for locked rotor mode
-----------------------------------------------------------------------------*/
if(v->lockrtr_flg==TRUE)
{
/* locked rotor mode if lockrtr_flg = 1 */
/*-----------------------------------------------------------------------------
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 = 0x0000;
/*-----------------------------------------------------------------------------
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 = 0x0000;
} /* End: lockrtr_flg==TRUE */
else if(v->lockrtr_flg==FALSE)
{ /* spinning mode if lockrtr_flg = 0 */
/*-----------------------------------------------------------------------------
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;
} /* End: lockrtr_flg==FALSE */
/*-----------------------------------------------------------------------------
Call the compute function for the PARK
-----------------------------------------------------------------------------*/
park((void *)&v->current_dqt,(void *)&v->current_DQ);
} /* End: FOC_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL4) */
#if (BUILDLEVEL==LEVEL5)
void FOC_TI_Run(FOC_TI_handle v)
{
/*-----------------------------------------------------------------------------
Connect PIDREG3 inputs for speed control
-----------------------------------------------------------------------------*/
v->pid_spd.pid_ref_reg3 = v->speed_ref;
v->pid_spd.pid_fdb_reg3 = v->Mea_spd;
/*-----------------------------------------------------------------------------
Call the compute function for the PIDREG3 inputs for speed control
-----------------------------------------------------------------------------*/
v->pid_spd.calc((void *)&v->pid_spd); /* Call PIDREG3 compute function */
/*-----------------------------------------------------------------------------
Connect PIDREG3 inputs for Iq control
-----------------------------------------------------------------------------*/
v->pid_iq.pid_ref_reg3 = v->pid_spd.pid_out_reg3;
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 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 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->shaft_theta_elec;
/*-----------------------------------------------------------------------------
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->shaft_theta_elec;
/*-----------------------------------------------------------------------------
Call the compute function for the PARK
-----------------------------------------------------------------------------*/
park((void *)&v->current_dqt,(void *)&v->current_DQ);
}
#endif /* (BUILDLEVEL==LEVEL5) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -