PID控制算法的C语言实现五 积分分离的PID控制算法C语言实现

 

    通过三、四两篇文章,基本上已经弄清楚了PID控制算法的最常规的表达方法。在普通PID控制中,引入积分环节的目的,主要是为了消除静差,提高控制精度。但是在启动、结束或大幅度增减设定时,短时间内系统输出有很大的偏差,会造成PID运算的积分积累,导致控制量超过执行机构可能允许的最大动作范围对应极限控制量,从而引起较大的超调,甚至是震荡,这是绝对不允许的。

   为了克服这一问题,引入了积分分离的概念,其基本思路是 当被控量与设定值偏差较大时,取消积分作用; 当被控量接近给定值时,引入积分控制,以消除静差,提高精度。其具体实现代码如下:

    pid.Kp=0.2;
    pid.Ki=0.04;
    pid.Kd=0.2;  //初始化过程

 

if(abs(pid.err)>200)
    {
    index=0;
    }else{
    index=1;
    pid.integral+=pid.err;
    }
    pid.voltage=pid.Kp*pid.err+index*pid.Ki*pid.integral+pid.Kd*(pid.err-pid.err_last);    //算法具体实现过程

 

其它部分的代码参见《PID控制算法的C语言实现三》中的讲解,不再赘述。同样采集1000个量,会发现,系统到199所有的时间是原来时间的1/2,系统的快速性得到了提高。


199.003571
199.036804
199.068924
199.099960
199.129974
199.158981
199.187012
199.214111
199.240311
199.265640
199.290115
199.313797
199.336655
199.358795
199.380157
199.400818
199.420792
199.440109
199.458771
199.476807
199.494263
199.511124
199.527420
199.543182
199.558426
199.573135
199.587372
199.601120
199.614426
199.627289
199.639694
199.651718
199.663315
199.674561
199.685410
199.695908
199.706039
199.715851
199.725311
199.734482
199.743332
199.751907
199.760162
199.768173
199.775894
199.783371
199.790588
199.797577
199.804337
199.810867
199.817154
199.823257
199.829147
199.834839
199.840347
199.845673
199.850815
199.855789
199.860596
199.865234
199.869736
199.874069
199.878281
199.882324
199.886261
199.890045
199.893707
199.897263
199.900665
199.903992
199.907181
199.910278
199.913284
199.916168
199.918976
199.921677
199.924286
199.926804
199.929245
199.931610
199.933884
199.936081
199.938217
199.940277
199.942276
199.944183
199.946045
199.947830
199.949585
199.951248
199.952896
199.954437
199.955963
199.957428
199.958847
199.960205
199.961548
199.962830
199.964066
199.965271
199.966431
199.967545
199.968628
199.969666
199.970673
199.971649
199.972595
199.973511
199.974380
199.975235
199.976074
199.976852
199.977631
199.978378
199.979095
199.979797
199.980453
199.981125
199.981735
199.982361
199.982925
199.983505
199.984055
199.984604
199.985107
199.985611
199.986069
199.986557
199.987000
199.987442
199.987869
199.988281
199.988663
199.989044
199.989395
199.989761
199.990097
199.990417
199.990753
199.991058
199.991348
199.991653
199.991913
199.992203
199.992447
199.992706
199.992950
199.993179
199.993408
199.993607
199.993835
199.994034
199.994232
199.994431
199.994598
199.994797
199.994965
199.995132
199.995285
199.995453
199.995605
199.995743
199.995895
199.996017
199.996155
199.996277
199.996414
199.996521
199.996643
199.996750
199.996872
199.996964
199.997070
199.997162
199.997269
199.997360
199.997437
199.997528
199.997604
199.997681
199.997772
199.997849
199.997910
199.997986
199.998047
199.998108
199.998169
199.998245
199.998306
199.998352
199.998398
199.998459
199.998489
199.998550
199.998596
199.998642
199.998703
199.998734
199.998795
199.998825
199.998856
199.998886
199.998917
199.998962
199.998978
199.999023
199.999054
199.999084
199.999115
199.999146
199.999191
199.999207
199.999252
199.999283
199.999298
199.999313
199.999329
199.999344
199.999359
199.999374
199.999390
199.999405
199.999435
199.999435
199.999466
199.999466
199.999496
199.999512
199.999527
199.999542
199.999557
199.999573
199.999588
199.999603
199.999619
199.999634
199.999649
199.999680
199.999680
199.999710
199.999710
199.999741
199.999756
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771
199.999771

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值