📄 foc_ti.c
字号:
/* ==============================================================================
System Name: PMSM3_1 (QEP version)
File Name: FOC_TI.C
Description: Peripheral independent object for the implementation
of Sensored Field Orientation Control for a Three Phase
Permanent-Magnet Synchronous Motor using measured rotor angle.
Originator: Digital control systems Group - Texas Instruments
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 30 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 <foc_ti.h>
#include <build.h>
#if (BUILDLEVEL==LEVEL1)
void FOC_TI_Init(FOC_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: FOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL1) */
#if (BUILDLEVEL==LEVEL2)
void FOC_TI_Init(FOC_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: FOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL2) */
#if (BUILDLEVEL==LEVEL3)
void FOC_TI_Init(FOC_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: FOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL3) */
#if (BUILDLEVEL==LEVEL4)
void FOC_TI_Init(FOC_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: FOC_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL4) */
#if (BUILDLEVEL==LEVEL5)
void FOC_TI_Init(FOC_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.
-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
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 */
/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -