pid算法C语言学习知识.doc
《pid算法C语言学习知识.doc》由会员分享,可在线阅读,更多相关《pid算法C语言学习知识.doc(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-!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 _pid warm,*pid;int process_point, set_point,dead_
2、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 *warm, int process_point, int set_point) struct
3、_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_tune(struct _pid *pid, float p_gain, float i_
4、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. This is useful for setting the initial output
5、 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 PID equation after an extended pause, the deri
6、vative 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 = (pid-sp)-(pid-pv); /*- pid_calc DESCRIPTION Perfo
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- pid 算法 语言 学习 知识
限制150内