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

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

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

199.810867 199.817154 199.823257 199.829147 199.834839 199.840347 199.845673 199.850815 199.855789 199.957428 199.958847 199.960205 199.961548 199.962830 199.964066 199.965271 199.966431 199.967545 199.990417 199.990753 199.991058 199.991348 199.991653 199.991913 199.992203 199.992447 199.992706 199.997849 199.997910 199.997986 199.998047 199.998108 199.998169 199.998245 199.998306 199.998352 199.999466 199.999496 199.999512 199.999527 199.999542 199.999557 199.999573 199.999588 199.999603 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 199.999771 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.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.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.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.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

PID控制算法的C语言实现六 抗积分饱和的PID控制算法C语言实现

所谓的积分饱和现象是指如果系统存在一个方向的偏差,PID控制器的输出由于积分作用的不断累加而加大,从而导致执行机构达到极限位置,若控制器输出U(k)继续增大,执行器开度不可能再增大,此时计算机输出控制量超出了正常运行范围而进入饱和区。一旦系统出现反向偏差,u(k)逐渐从饱和区退出。进入饱和区越深则退出饱和区时间越长。在这段时间里,执行机构仍然停留在极限位置而不随偏差反向而立即做出相应的改变,这时系统就像失控一样,造成控制性能恶化,这种现象称为积分饱和现象或积分失控现象。

防止积分饱和的方法之一就是抗积分饱和法,该方法的思路是在计算u(k)时,首先判断上一时刻的控制量u(k-1)是否已经超出了极限范围: 如果

u(k-1)>umax,则只累加负偏差; 如果u(k-1)

float SetSpeed; //定义设定值 float ActualSpeed; //定义实际值 float err; //定义偏差值

float err_last; //定义上一个偏差值

float Kp,Ki,Kd; //定义比例、积分、微分系数

float voltage; //定义电压值(控制执行器的变量) float integral; //定义积分值 float umax; float umin; }pid;

void PID_init(){

printf(\ pid.SetSpeed=0.0; pid.ActualSpeed=0.0; pid.err=0.0;

pid.err_last=0.0; pid.voltage=0.0; pid.integral=0.0; pid.Kp=0.2;

pid.Ki=0.1; //注意,和上几次相比,这里加大了积分环节的值 pid.Kd=0.2; pid.umax=400; pid.umin=-200;

printf(\}

float PID_realize(float speed){ int index;

pid.SetSpeed=speed;

pid.err=pid.SetSpeed-pid.ActualSpeed;

if(pid.ActualSpeed>pid.umax) //灰色底色表示抗积分饱和的实现 {

if(abs(pid.err)>200) //蓝色标注为积分分离过程 {

index=0; }else{

index=1;

if(pid.err<0) {

pid.integral+=pid.err; } }

}else if(pid.ActualSpeed

if(abs(pid.err)>200) //积分分离过程 {

index=0; }else{

index=1;

if(pid.err>0) {

pid.integral+=pid.err; } } }else{

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.err_last=pid.err;

pid.ActualSpeed=pid.voltage*1.0;

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

199.810867199.817154199.823257199.829147199.834839199.840347199.845673199.850815199.855789199.957428199.958847199.960205199.961548199.962830199.964066199.965271199.966431199.967545
推荐度:
点击下载文档文档为doc格式
53adw1dpq51j03u4hzb9
领取福利

微信扫码领取福利

微信扫码分享