pid算法C语言.doc
《pid算法C语言.doc》由会员分享,可在线阅读,更多相关《pid算法C语言.doc(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、如有侵权,请联系网站删除,仅供学习与交流pid算法C语言【精品文档】第 10 页pid算法C语言PID 算法(c语言)BC31 TC30 编译过,可运行。#include #includestruct _pid int pv; /*integer that contains the process value*/ int sp; /*integer that contains the set point*/ float integral; float pgain; float igain; float dgain; int deadband; int last_error;struct _pi
2、d warm,*pid;int process_point, set_point,dead_band; float p_gain, i_gain, d_gain, integral_val,new_integ; /*- pid_init DESCRIPTION This function initializes the pointers in the _pid structure to the process variable and the setpoint. *pv and *sp are integer pointers. -*/ void pid_init(struct _pid *w
3、arm, int process_point, int set_point) struct _pid *pid; pid = warm; pid-pv = process_point; pid-sp = set_point; /*- pid_tune DESCRIPTION Sets the proportional gain (p_gain), integral gain (i_gain), derivitive gain (d_gain), and the dead band (dead_band) of a pid control structure _pid. -*/ void pid
4、_tune(struct _pid *pid, float p_gain, float i_gain, float d_gain, int dead_band) pid-pgain = p_gain; pid-igain = i_gain; pid-dgain = d_gain; pid-deadband = dead_band; pid-integral= integral_val; pid-last_error=0; /*- pid_setinteg DESCRIPTION Set a new value for the integral term of the pid equation.
5、 This is useful for setting the initial output of the pid controller at start up. -*/ void pid_setinteg(struct _pid *pid,float new_integ) pid-integral = new_integ; pid-last_error = 0; /*- pid_bumpless DESCRIPTION Bumpless transfer algorithim. When suddenly changing setpoints, or when restarting the
6、PID equation after an extended pause, the derivative of the equation can cause a bump in the controller output. This function will help smooth out that bump. The process value in *pv should be the updated just before this function is used. -*/ void pid_bumpless(struct _pid *pid) pid-last_error = (pi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- pid 算法 语言
限制150内