//==============================================================
//PID.c文件
//==============================================================
#include "DSP28x_Project.h"
#include "C28x_FPU_FastRTS.h"
#include <math.h>
#include "PID.h"
//========函数定义 ===========================
//**********************************
/*
@ Description:
@ Param
@ Return
*/
//**********************************
void PIDfunc_calc(PID_FUNC *p)
{
//使用条件编译指令进行切换
#if PID_DEBUG //在校正PID参数时,使用宏定义将PID_DEBUG设为1,从而执行以下程序
float a0,a1,a2;
//这里每次都要计算 a0、a1、a2的值
a0 = p->Kp*(1 + p->T/p->Ti + p->Td/p->T);
a1 = p->Kp*(1 + 2*p->Td/p->T);
a2 = p->Kp*p->Td/p->T;
//计算PID调节器的输出
p->Output = p->LastOutput + a0*p->Ek - a1*p->Ek_1 + a2*p->Ek_2;
#else //当参数校正完成后,那么得到固定的a0、a1、a2的值,使用宏定义将PID_DEBUG设为0,从而执行以下过程
//当参数校正完成后,初始化时直接为p->a0、p->a1、p->a2赋值,省去计算过程
p->Output = p->LastOutput + p->a0*p->Ek - p->a1*p->Ek_1 + p->a2*p->Ek_2;
#endif
//输出限幅
if(p->Output > p->OutMax) p->Output = p->OutMax;
if(p->Output < p->OutMin) p->Output = p->OutMin;
//保存上一周期的值
p->LastOutput = p->Output;
p->Ek_1 = p->Ek;
p->Ek_2 = p->Ek_1;
}
//==============================================================
//End of file.
//==============================================================
undefined first referenced
symbol in file
--------- ----------------
_main D:\Texas Instruments\ccsv4\tools\compiler\c2000\lib\rts2800_fpu32.lib<args_main.obj>
error: unresolved symbols remain
error: errors encountered during linking; "PID.out" not built
>> Compilation failure
D:\Texas Instruments\ccsv4\utils\gmake\gmake: *** [PID.out] Error 1
D:\Texas Instruments\ccsv4\utils\gmake\gmake: Target `all' not remade because of errors.
出现以上错误,换了库文件还是不行。 |