开发者

Scaling PID (Proportional Integral Derivative) Output

开发者 https://www.devze.com 2023-01-18 23:36 出处:网络
I have implemented a PID function using the formula, correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors)

I have implemented a PID function using the formula,

correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors)

What should I do to keep my output between 开发者_如何学运维a certain range? say 0-255 If I disregard any value not between 0 to 255 it produces a jiggly behavior?


correction = ...

correction2 = correction;
if(correction < least) {correction2 = least;}
if(correction > most) {correction2 = most;}

Then use correction and correction2 as your output where appropriate.

Don't correct based on correction2 and then wonder why it behaves in an odd way when you reach the edge of least <-> most.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号