




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、PID控制算法的C语言实现四 增量型PID的C语言实现 上一节中介绍了最简单的位置型PID的实现手段,这一节主要讲解增量式PID的实现方法,位置型和增量型PID的数学公式。实现过程仍然是分为定义变量、初始化变量、实现控制算法函数、算法测试四个部分,详细分类请参加PID控制算法的C语言实现三中的讲解,这里直接给出代码了。/* PID.c*/#include#includestruct _pid float SetSpeed; /定义设定值 float ActualSpeed; /定义实际值 float err; /定义偏差值 float err_next; /定义上一个偏差值 float err
2、_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 incrementSpee
3、d=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); printf(%fn,speed)
4、; 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.135.135.136.
5、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.174.175.175.
6、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.190.190.190.
7、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.196.196.196.
8、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.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.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.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.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.199.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 机电班组长试题及答案
- 激光参数调节技巧试题及答案
- 对比分析专利保护与其他知识产权的特点试题及答案
- 理论与实践结合的光电试题及答案
- 理论知识与光电工程师考试的相互影响试题及答案
- 药剂临床药学研究方向讨论题及答案
- 激光探测技术在航天的应用试题及答案
- 了解2024年专利代理人考试的完整知识体系试题及答案
- 创森栽树合同样本
- 2025-2030安检产品入市调查研究报告
- 模拟训练中的作战环境构建
- 自考《13180操作系统》考前强化练习试题库及答案
- 永久不能过户的房屋买卖合同
- 中央空调维护保养服务投标方案(技术方案)
- 华能广东汕头海上风电有限责任公司招聘真题
- 2024年中考数学《二次函数的图象与性质》真题含解析
- 2024 NCCN指南:造血生长因子指南更新要点及治疗方案解读
- 博士后研究报告(出站)
- 2025届高考语文复习:辨析并修改病句+课件
- 2023-2024学年贵州省黔南州八年级(下)期末数学试卷(含答案)
- 石家庄市桥西区第四十一中学2022-2023学年七年级下学期期中数学试题
评论
0/150
提交评论