PID控制算法的C语言实现四-增量型PID的C语言实现(共28页).docx

上传人:飞****2 文档编号:14065957 上传时间:2022-05-02 格式:DOCX 页数:28 大小:16.68KB
返回 下载 相关 举报
PID控制算法的C语言实现四-增量型PID的C语言实现(共28页).docx_第1页
第1页 / 共28页
PID控制算法的C语言实现四-增量型PID的C语言实现(共28页).docx_第2页
第2页 / 共28页
点击查看更多>>
资源描述

《PID控制算法的C语言实现四-增量型PID的C语言实现(共28页).docx》由会员分享,可在线阅读,更多相关《PID控制算法的C语言实现四-增量型PID的C语言实现(共28页).docx(28页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上PID控制算法的C语言实现四 增量型PID的C语言实现 上一节中介绍了最简单的位置型PID的实现手段,这一节主要讲解增量式PID的实现方法,位置型和增量型PID的数学公式。实现过程仍然是分为定义变量、初始化变量、实现控制算法函数、算法测试四个部分,详细分类请参加PID控制算法的C语言实现三中的讲解,这里直接给出代码了。/* PID.c*/#include#includestruct _pid float SetSpeed; /定义设定值 float ActualSpeed; /定义实际值 float err; /定义偏差值 float err_next; /定义上一个

2、偏差值 float err_last; /定义最上前的偏差值 float Kp,Ki,Kd; /定义比例、积分、微分系数pid;void PID_init() pid.SetSpeed=0.0; pid.ActualSpeed=0.0; pid.err=0.0; pid.err_last=0.0; pid.err_next=0.0; pid.Kp=0.2; pid.Ki=0.015; pid.Kd=0.2;float PID_realize(float speed) pid.SetSpeed=speed; pid.err=pid.SetSpeed-pid.ActualSpeed; float

3、incrementSpeed=pid.Kp*(pid.err-pid.err_next)+pid.Ki*pid.err+pid.Kd*(pid.err-2*pid.err_next+pid.err_last); pid.ActualSpeed+=incrementSpeed; pid.err_last=pid.err_next; pid.err_next=pid.err; return pid.ActualSpeed;int main() PID_init(); int count=0; while(count1000) float speed=PID_realize(200.0); prin

4、tf(%fn,speed); count+; return 0;运行后的1000个数据为:83.11.59.28.52.38.51.46.53.51.55.55.58.59.62.63.65.67.68.70.72.73.75.76.78.79.81.82.84.85.87.88.89.91.92.94.95.96.97.99.100.101.102.104.105.106.107.108.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.130.131.132.133.134

5、.135.135.136.137.138.139.139.140.141.142.142.143.144.144.145.146.146.147.148.148.149.150.150.151.152.152.153.153.154.154.155.156.156.157.157.158.158.159.159.160.160.161.161.162.162.163.163.164.164.164.165.165.166.166.167.167.167.168.168.169.169.169.170.170.170.171.171.172.172.172.173.173.173.174.174

6、.174.175.175.175.175.176.176.176.177.177.177.178.178.178.178.179.179.179.179.180.180.180.180.181.181.181.181.182.182.182.182.182.183.183.183.183.183.184.184.184.184.184.185.185.185.185.185.186.186.186.186.186.186.187.187.187.187.187.187.187.188.188.188.188.188.188.188.189.189.189.189.189.189.189.190

7、.190.190.190.190.190.190.190.190.191.191.191.191.191.191.191.191.191.192.192.192.192.192.192.192.192.192.192.192.193.193.193.193.193.193.193.193.193.193.193.193.194.194.194.194.194.194.194.194.194.194.194.194.194.194.195.195.195.195.195.195.195.195.195.195.195.195.195.195.195.195.195.195.196.196.196

8、.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.196.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.197.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198

9、.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.198.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

10、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

11、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

12、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

13、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

14、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

15、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199

16、.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁