PID算法(c语言)(来自老外).doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《PID算法(c语言)(来自老外).doc》由会员分享,可在线阅读,更多相关《PID算法(c语言)(来自老外).doc(14页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、PID算法(c语言)(来自老外)(2010-02-17 00:18:24)转载#include #include/定义PID的结构体struct _pidint 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 pr
2、ocess_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 *warm, int process_point, int
3、 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. 设定PID参数 P,I,D,死区/void pid_tune(struct _pid *pid,
4、 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.This is useful for setting the in
5、itial 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 PID equation after an extended pause,t
6、he 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.pid_bumpless 实现无扰切换当突然改变设定值时,或重新启动后,将引起扰动输出。这个函数将能实现平顺扰动,在调用该函数之前需要先更新PV值/void pid_bumpless(struct _p
7、id *pid)pid-last_error = (pid-sp)-(pid-pv); /设定值与反馈值偏差/pid_calc DESCRIPTION Performs PID calculations for the _pid structure *a.This function uses the positional form of the pid equation, and incorporates an integral windup prevention algorithim.Rectangular integration is used, so this function must
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- PID 算法 语言 来自 老外
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内