位置式PID与增量式PID


//位置式PID

float Kp;
float Ki;
float Kd;

float eSum,e0,e1;

float pid_control(float now,float target)
{
    float pe,ie,de;
    float out;
    
    e0 = target - now;
    eSum += e0;
    
    pe = e0;
    ie = eSum;
    de = e0 - e1;
        
    out = pe*Kp + ie*Ki + de*Kd;
    
    out = limit(out,-LIMIT,LIMIT);

    e1 = e0;
    
    return out;
}

//增量式PID

float Kp;
float Ki;
float Kd;

float eSum,e0,e1,e2;

float pid_control(float now,float target)
{
    float pe,ie,de;
    float out;

    e0 = target - now;
    
    pe = e0 - e1;
    ie = e0;
    de = e0 - 2*e1 + e2;
    
    out = pe*Kp + ie*Ki + de*Kd;
    out = limit(out,-LIMIT,LIMIT);
    
    e2 = e1;
    e1 = e0;
    
    return out;
    
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM