📄 vhz_ti.c
字号:
/* ==============================================================================
System Name: ACI3_1
File Name: VHZ_TI.C
Description: Peripheral independent object for implementation of Sensored Volt/Hertz
control of a Three Phase AC Induction Motor.
Originator: Digital control systems Group - Texas Instruments
Target dependency: x240/1/2/3/07
To Select the target device see target.h file.
=====================================================================================
History:
-------------------------------------------------------------------------------------
9-15-2000 Release Rev 1.0
================================================================================= */
#include <vhz_ti.h>
#include <build.h>
#if (BUILDLEVEL==LEVEL1)
void VHZ_TI_Init(VHZ_TI_handle v)
{
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3fff;
v->svgen.freq_max = 2400;
v->speed_setpt = 0x4000;
/*------------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------*/
#define MY_VHZ_PROFILE { 0x0000, \
0x0000, \
0x7fff, \
0x0000, \
0x0000, \
0x0000, \
0x0000, \
(int (*)(int))Vhz_Profile_Calculate }
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 0x1000;
v->vhzprof.vmax = 0x7000;
v->vhzprof.fl = 0x1000;
v->vhzprof.fh = 0x7000;
v->vhzprof.slope= 0x1000;
} /* End: VHZ_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL1) */
#if (BUILDLEVEL==LEVEL2)
void VHZ_TI_Init(VHZ_TI_handle v)
{
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3fff;
v->svgen.freq_max = 2400;
v->speed_setpt = 0x4000;
/*-----------------------------------------------------------------------------
Setup Volt-Hertz profile parameters.
-----------------------------------------------------------------------------*/
v->vhzprof.vmin = 0x1000;
v->vhzprof.vmax = 0x7000;
v->vhzprof.fl = 0x1000;
v->vhzprof.fh = 0x7000;
v->vhzprof.slope= 0x1000;
} /* End: VHZ_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL2) */
#if (BUILDLEVEL==LEVEL3)
void VHZ_TI_Init(VHZ_TI_handle v)
{
/*------------------------------------------------------------------------------
Configure Attributes for the Space Vector Function Generator
------------------------------------------------------------------------------*/
v->svgen.freq = 0x3fff;
v->svgen.freq_max = 2400;
v->speed_setpt = 0x4000;
/*------------------------------------------------------------------------------
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 = 0x1000;
v->vhzprof.vmax = 0x7000;
v->vhzprof.fl = 0x1000;
v->vhzprof.fh = 0x7000;
v->vhzprof.slope= 0x1000;
/*-----------------------------------------------------------------------------
Set up PID Controller parameters.
-----------------------------------------------------------------------------*/
v->pid.K0=0x4000;
v->pid.K1=0xc010;
v->pid.K2=0x0000;
v->pid.Kf=0x0000;
} /* End: VHZ_TI_Init() */
#endif /* (BUILDLEVEL==LEVEL3) */
#if (BUILDLEVEL==LEVEL1)
void VHZ_TI_Run(VHZ_TI_handle v)
{
/*-----------------------------------------------------------------------------
Connect system variables to the SVGENMF
-----------------------------------------------------------------------------*/
v->vhzprof.freq = v->svgen.freq; /* Input freq to VHZPROFILE vhz */
/*-----------------------------------------------------------------------------
Call the compute function for the VHZPROF
-----------------------------------------------------------------------------*/
v->vhzprof.calc((void *)&v->vhzprof); /* Call VHZPROFILE compute func */
v->svgen.gain=v->vhzprof.vout; /* Use the computed gain */
/*-----------------------------------------------------------------------------
Call the compute function for the SVGEN
-----------------------------------------------------------------------------*/
v->svgen.calc((void *)&v->svgen); /* Call SVGEN compute function */
/*---------------------------------------------------------------------------*/
} /* End: VHZ_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL1) */
#if (BUILDLEVEL==LEVEL2)
void VHZ_TI_Run(VHZ_TI_handle v)
{
int temp;
/*-----------------------------------------------------------------------------
Connect system variables to the SVGENMF
-----------------------------------------------------------------------------*/
v->vhzprof.freq = v->svgen.freq; /* Input freq to VHZPROFILE vhz */
/*-----------------------------------------------------------------------------
Call the compute function for the VHZPROF
-----------------------------------------------------------------------------*/
v->vhzprof.calc((void *)&v->vhzprof); /* Call VHZPROFILE compute func */
v->svgen.gain=v->vhzprof.vout; /* Use the computed gain */
/*-----------------------------------------------------------------------------
Call the compute function for the SVGEN
-----------------------------------------------------------------------------*/
v->svgen.calc((void *)&v->svgen); /* Call SVGEN compute function */
/*-----------------------------------------------------------------------------
Look at the direction flag and if non-zero, switch two outputs.
-----------------------------------------------------------------------------*/
if(v->direction==0)
{
temp=v->svgen.vb;
v->svgen.vb=v->svgen.vc;
v->svgen.vc=temp;
}
} /* End: VHZ_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL2) */
#if (BUILDLEVEL==LEVEL3)
void VHZ_TI_Run(VHZ_TI_handle v)
{
int temp;
/*-----------------------------------------------------------------------------
Check if the closed_loop_flag is TRUE (1),
and if so run the PID regulator.
-----------------------------------------------------------------------------*/
if(v->closed_loop_flag==TRUE)
{
/*-----------------------------------------------------------------------------
Connect system variables to the PID Controller..
-----------------------------------------------------------------------------*/
v->pid.en=v->speed_setpt-v->speed_value; /*Err fb */
v->pid.rn=v->speed_setpt; /*Speed reference */
/*-----------------------------------------------------------------------------
Call the compute function for the PID Controller object.
-----------------------------------------------------------------------------*/
v->pid.calc((void *)&v->pid);
/*-----------------------------------------------------------------------------
Connect the PID Controller output to the system.
-----------------------------------------------------------------------------*/
v->svgen.freq=v->pid.output;
}
/*-----------------------------------------------------------------------------
Connect system variables to the SVGENMF
-----------------------------------------------------------------------------*/
v->vhzprof.freq = v->svgen.freq; /* Input freq to VHZPROFILE vhz */
/*-----------------------------------------------------------------------------
Call the compute function for the VHZPROF
-----------------------------------------------------------------------------*/
v->vhzprof.calc((void *)&v->vhzprof); /* Call VHZPROFILE compute func */
v->svgen.gain=v->vhzprof.vout; /* Use the computed gain */
/*-----------------------------------------------------------------------------
Call the compute function for the SVGEN
-----------------------------------------------------------------------------*/
v->svgen.calc((void *)&v->svgen); /* Call SVGEN compute function */
/*-----------------------------------------------------------------------------
Look at the direction flag and if non-zero, switch two outputs.
-----------------------------------------------------------------------------*/
if(v->direction==0)
{
temp=v->svgen.vb;
v->svgen.vb=v->svgen.vc;
v->svgen.vc=temp;
}
} /* End: VHZ_TI_Run() */
#endif /* (BUILDLEVEL==LEVEL3) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -