📄 vfmrasti.c
字号:
/* ==============================================================================
System Name: ACI3_2
File Name: VFMRASTI.C
Description: Peripheral independent object for implementation of Sensorless Volt/Hertz
control of a Three Phase AC Induction Motor using reactive power
MRAS speed estimator.
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 ACI3-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:
-------------------------------------------------------------------------------------
9-15-2000 Release Rev 1.0
================================================================================= */
#include <vfmrasti.h>
#include <build.h>
#if (BUILDLEVEL==LEVEL1)
void VFMRAS_TI_Init(VFMRAS_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 Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 6553;
v->vhzprof.vmax = 31129;
v->vhzprof.fl = 6553;
v->vhzprof.fh = 16384;
v->vhzprof.slope= 10243;
} /* End: VFMRAS_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL1) */
#if (BUILDLEVEL==LEVEL2)
void VFMRAS_TI_Init(VFMRAS_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.
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3FFF;
v->svgen.freq_max = 3146; /* This is based on 15kHz PWM frequency */
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 6553;
v->vhzprof.vmax = 31129;
v->vhzprof.fl = 6553;
v->vhzprof.fh = 16384;
v->vhzprof.slope= 10243;
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
v->rmpc.rmp_dly_max = 40;
v->rmpc.rmp_lo_limit = 0x0000;
v->rmpc.rmp_hi_limit = 0x7FFF;
} /* End: VFMRAS_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL2) */
#if (BUILDLEVEL==LEVEL3)
void VFMRAS_TI_Init(VFMRAS_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.
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3FFF;
v->svgen.freq_max = 3146; /* This is based on 15kHz PWM frequency */
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 6553;
v->vhzprof.vmax = 31129;
v->vhzprof.fl = 6553;
v->vhzprof.fh = 16384;
v->vhzprof.slope= 10243;
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
v->rmpc.rmp_dly_max = 40;
v->rmpc.rmp_lo_limit = 0x0000;
v->rmpc.rmp_hi_limit = 0x7FFF;
} /* End: VFMRAS_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL3) */
#if (BUILDLEVEL==LEVEL4)
void VFMRAS_TI_Init(VFMRAS_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.
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3FFF;
v->svgen.freq_max = 3146; /* This is based on 15kHz PWM frequency */
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 6553;
v->vhzprof.vmax = 31129;
v->vhzprof.fl = 6553;
v->vhzprof.fh = 16384;
v->vhzprof.slope= 10243;
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
v->rmpc.rmp_dly_max = 40;
v->rmpc.rmp_lo_limit = 0x0000;
v->rmpc.rmp_hi_limit = 0x7FFF;
/*-----------------------------------------------------------------------------
Setup Box-car parameters.
-----------------------------------------------------------------------------*/
v->bc.bc_scaler = 0x7FFF;
/*-----------------------------------------------------------------------------
Setup ACI MRAS speed estimator parameters. (based on 15kHz sampling freq)
-----------------------------------------------------------------------------*/
/* 1-Hp WEG motor */
v->mras.K1 = 13113; /* Q10 */
v->mras.K2 = 1672; /* Q15 */
v->mras.K3 = 22811; /* Q8 */
v->mras.K4 = 41; /* Q15 */
v->mras.K5 = 32750; /* Q15 */
v->mras.K6 = 1646; /* Q15 */
v->mras.K7 = 18; /* Q15 */
v->mras.base_rpm = 28800; /* Q3 */
v->mras.Kp = 0x0050; /* Q15 */
v->mras.Ki_high = 0x001D; /* Q31 */
v->mras.Ki_low = 0xDEAD; /* Q31 */
} /* End: VFMRAS_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL4) */
#if (BUILDLEVEL==LEVEL5)
void VFMRAS_TI_Init(VFMRAS_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.
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3FFF;
v->svgen.freq_max = 3146; /* This is based on 15 kHz PWM frequency */
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 6553;
v->vhzprof.vmax = 31129;
v->vhzprof.fl = 6553;
v->vhzprof.fh = 16384;
v->vhzprof.slope= 10243;
/*-----------------------------------------------------------------------------
Setup Ramp control parameters.
-----------------------------------------------------------------------------*/
v->rmpc.rmp_dly_max = 40;
v->rmpc.rmp_lo_limit = 0x0000;
v->rmpc.rmp_hi_limit = 0x7FFF;
/*-----------------------------------------------------------------------------
Setup Box-car parameters.
-----------------------------------------------------------------------------*/
v->bc.bc_scaler = 0x7FFF;
/*-----------------------------------------------------------------------------
Setup ACI MRAS speed estimator parameters. (based on 15kHz sampling freq)
-----------------------------------------------------------------------------*/
/* 1-Hp WEG motor */
v->mras.K1 = 13113; /* Q10 */
v->mras.K2 = 1672; /* Q15 */
v->mras.K3 = 22811; /* Q8 */
v->mras.K4 = 41; /* Q15 */
v->mras.K5 = 32750; /* Q15 */
v->mras.K6 = 1646; /* Q15 */
v->mras.K7 = 18; /* Q15 */
v->mras.base_rpm = 28800; /* Q3 */
v->mras.Kp = 0x0050; /* Q15 */
v->mras.Ki_high = 0x001D; /* Q31 */
v->mras.Ki_low = 0xDEAD; /* Q31 */
/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
v->pid.Kp_reg1 = 0x2000;
v->pid.Ki_high_reg1 = 0x0010;
v->pid.Ki_low_reg1 = 0xBEEF;
v->pid.Kd_reg1 = 0x0000;
v->pid.pid_out_max = 0x0666;
v->pid.pid_out_min = 0x0000;
} /* End: VFMRAS_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL5) */
/* ************************************************************************** */
/* ************************************************************************** */
#if (BUILDLEVEL==LEVEL1)
void VFMRAS_TI_Run(VFMRAS_TI_handle v)
{
/*-----------------------------------------------------------------------------
Connect freq_testing inputs to the VHZPROFILE
-----------------------------------------------------------------------------*/
v->vhzprof.freq = v->freq_testing;
/*-----------------------------------------------------------------------------
Call the compute function for the VHZPROF
-----------------------------------------------------------------------------*/
v->vhzprof.calc((void *)&v->vhzprof); /* Call VHZPROFILE compute function */
} /* End: VFMRAS_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL1) */
#if (BUILDLEVEL==LEVEL2)
void VFMRAS_TI_Run(VFMRAS_TI_handle v)
{
/*-----------------------------------------------------------------------------
Connect freq_testing to the RAMPCNTL input
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -