好文档 - 专业文书写作范文服务资料分享网站

PID控制算法的C语言实现(完整版) 

天下 分享 时间: 加入收藏 我要投稿 点赞

return pid.ActualSpeed; }

最终的测试程序运算结果如下,可以明显的看出系统的稳定时间相对前几次来讲缩短了不少。

100.000000 30.000000 95.000000 194.870834 195.299072 195.691193 199.828537 199.842834 199.855972 199.994263 199.994751 199.995178 199.999817 199.999817 199.999847 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 65.500000 103.750000 92.175003 115.237503 112.173752 126.794380 127.653938 137.468842 139.967911 146.934479 149.954224 155.144211 158.157745 162.174561 164.953079 168.149734 170.611786 173.205124 175.339691 177.470551 179.298065 181.063431 182.616440 184.086655 185.400513 186.628952 187.737457 188.766006 189.699692 190.561951 191.347580 192.071030 192.731674 193.338928 193.894257 194.404160

196.050888 196.380341 196.682465 196.959244 197.213043 197.445572 197.658768 197.854111 198.033203 198.197311 198.347763 198.485626 198.612015 198.727829 198.834000 198.931290 199.020477 199.102219 199.177139 199.245804 199.308746 199.366425 199.419296 199.467758 199.512161 199.552872 199.590179 199.624390 199.655716 199.684464 199.710785 199.734924 199.757034 199.777298 199.795883 199.812912

199.867981 199.879013 199.889099 199.898361 199.906845 199.914612 199.921753 199.928268 199.934280 199.939743 199.944794 199.949371 199.953629 199.957474 199.961029 199.964279 199.967270 199.969986 199.972504 199.974792 199.976898 199.978821 199.980591 199.982208 199.983688 199.985062 199.986298 199.987442 199.988495 199.989441 199.990326 199.991135 199.991867 199.992554 199.993179 199.993744

199.995590 199.995941 199.996292 199.996582 199.996887 199.997116 199.997391 199.997574 199.997803 199.997971 199.998154 199.998291 199.998444 199.998581 199.998703 199.998810 199.998917 199.999008 199.999084 199.999176 199.999237 199.999298 199.999359 199.999405 199.999466 199.999496 199.999542 199.999588 199.999619 199.999649 199.999680 199.999710 199.999725 199.999756 199.999771 199.999786

199.999847 199.999863 199.999863 199.999878 199.999893 199.999893 199.999908 199.999924 199.999924 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

199.999939 199.999939 199.999939 199.999939 199.999939 199.999939

PID控制算法的C语言实现七 梯形积分的PID控制算法C语言实现

先看一下梯形算法的积分环节公式

作为PID控制律的积分项,其作用是消除余差,为了尽量减小余差,应提高积分项运算精度,为此可以将矩形积分改为梯形积分,具体实现的语句为: pid.voltage=pid.Kp*pid.err+index*pid.Ki*pid.integral/2+pid.Kd*(pid.err-pid.err_last); //梯形积分 其它函数请参见本系列教程六中的介绍

最后运算的稳定数据为:199.999878,较教程六中的199.9999390而言,精度进一步提高。

PID控制算法的C语言实现(完整版) 

returnpid.ActualSpeed;}最终的测试程序运算结果如下,可以明显的看出系统的稳定时间相对前几次来讲缩短了不少。100.00000030.00000095.000000194.870834195.299072195.691193199.828537199.842834199.855972199.994263199
推荐度:
点击下载文档文档为doc格式
53adw1dpq51j03u4hzb9
领取福利

微信扫码领取福利

微信扫码分享