- 2
- 0
- 约6.18千字
- 约 7页
- 2017-01-06 发布于贵州
- 举报
C语言实现PID算法C语言实现PID算法
C语言实现PID算法
#include stdio.h struct _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_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 _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_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 of the pid controller at start up. ------------------------------------------------------------------------*/ void pid_setinteg(struct _pid *pid,float new_integ) { pid-integral = new_integ; pid-last_error = 0; } /*---------------------------
您可能关注的文档
- CTAB法原理总结.doc
- CT成像技术模拟试题.doc
- CT正常值 总结.docx
- CT医师培训复习题1.doc
- CT操作技术规范.doc
- CT诊断报告书写规范.doc
- CT诊断常用数据汇总.doc
- cumcmlichy.doc
- cutoff值-参考区间.docx
- CT诊断学基础知识.docx
- 人教版九年级英语Unit 4曾害怕课件3a-4c.pdf
- 雅思口语考题回顾:朗阁海外考试研究中心2019年10月10日Part 1考题总结.pdf
- 2026届高三地理一轮复习课件小专题河流袭夺.pptx
- 【名师原创】复习专题5 三角函数 作者:合肥市第八中学 蒲荣飞名师工作室.docx
- 高中数学一轮复习 微专题2 抽象函数.docx
- 高中数学——复习专题4 空间向量与立体几何.docx
- 高中数学一轮复习 微专题3 空间几何体中的截面、轨迹问题.docx
- 高中数学一轮复习 微专题4 空间几何体的最值、范围问题.docx
- 导流洞施工质量通病防治手册.docx
- 江苏省徐州市第一中学、徐市第三中学等五校2026届高三上学期12月月考历史试题含答案.docx
原创力文档

文档评论(0)