数字PID 的经典C 语言实现方法

时间:2012-10-08 13:47:10
【文件属性】:

文件名称:数字PID 的经典C 语言实现方法

文件大小:2KB

文件格式:NONE

更新时间:2012-10-08 13:47:10

PID C语言

详细介绍了PID 用C语言的源代码 /*===================================================================================== File name: PID_REG3.C (IQ version) Originator: Digital Control Systems Group Texas Instruments Description: The PID controller with anti-windup ===================================================================================== History: ------------------------------------------------------------------------------------- 04-15-2005 Version 3.20 -------------------------------------------------------------------------------------*/ #include "IQmathLib.h" // Include header for IQmath library // Don't forget to set a proper GLOBAL_Q in "IQmathLib.h" file #include "dmctype.h" #include "pid_reg3.h" void pid_reg3_calc(PIDREG3 *v) { // Compute the error v->Err = v->Ref - v->Fdb; // Compute the proportional output v->Up = _IQmpy(v->Kp,v->Err); // Compute the integral output v->Ui = v->Ui + _IQmpy(v->Ki,v->Up) + _IQmpy(v->Kc,v->SatErr); // Compute the derivative output v->Ud = _IQmpy(v->Kd,(v->Up - v->Up1)); // Compute the pre-saturated output v->OutPreSat = v->Up + v->Ui + v->Ud; // Saturate the output if (v->OutPreSat > v->OutMax) v->Out = v->OutMax; else if (v->OutPreSat < v->OutMin) v->Out = v->OutMin; else v->Out = v->OutPreSat; // Compute the saturate difference v->SatErr = v->Out - v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up; }


网友评论

  • 有点儿参考价值
  • 缺少头文件啊怎么用
  • 很好地代码,谢谢分享
  • 非常不错的学习资料哦,值得收藏
  • 缺少点东西,但非常感谢分享
  • 挺好,可惜没有pidreg3.h文件
  • 是缺东西,但还是谢谢分享
  • 还少文件吧?