err = reference - new_measurement
I += kI * err
Derivative = err - old_err
output = I - kD * Derivative + kP * err
old_err = err
现在你就得到了它。当然省略限制。
一旦控制器达到参考值,误差将变为零,积分器将停止变化。噪声自然会使其稍微反弹,但它将保持在满足目标所需的稳态值,而 P 和 D 项则完成了减少瞬态的大部分工作。
请注意,在稳态条件下,I 项是唯一提供任何输出的项。如果控制已达到参考值并且需要非零输出,则该输出仅由积分器提供,因为误差为零。如果 I 项使用加权误差,它将开始衰减回零并且无法维持所需的输出。
The integral term is the sum of ALL the past errors. You simply add the error to the "integrator" at each time step. If this needs to be limited, clamp it to a min or max value if it goes out of range. Then copy this accumulated value to your output and add the proportional and derivative terms and clamp the output again if necessary.
The Derivative term is the difference in the present and previous error (the rate of change in the error). P of course is just proportional to the error.
err = reference - new_measurement
I += kI * err
Derivative = err - old_err
output = I - kD * Derivative + kP * err
old_err = err
And there you have it. Limits omitted of course.
Once the controller reaches the reference value, the error will become zero and the integrator will stop changing. Noise will naturally make it bounce around a bit, but it will stay at the steady state value required to meet your objective, while the P and D terms do most of the work to reduce transients.
Notice that in a steady state condition, the I term is the ONLY thing providing any output. If the control has reached the reference and this requires a non-zero output, it is provided solely by the integrator since the error will be zero. If the I term used weighted errors, it would start to decay back to zero and not sustain the output as needed.
发布评论
评论(1)
积分项是过去所有误差的总和。您只需在每个时间步将误差添加到“积分器”即可。如果需要限制此值,则在超出范围时将其限制为最小值或最大值。然后将此累积值复制到输出中,并添加比例项和导数项,并在必要时再次钳位输出。
导数项是当前误差和先前误差的差值(误差的变化率)。 P当然与误差成正比。
现在你就得到了它。当然省略限制。
一旦控制器达到参考值,误差将变为零,积分器将停止变化。噪声自然会使其稍微反弹,但它将保持在满足目标所需的稳态值,而 P 和 D 项则完成了减少瞬态的大部分工作。
请注意,在稳态条件下,I 项是唯一提供任何输出的项。如果控制已达到参考值并且需要非零输出,则该输出仅由积分器提供,因为误差为零。如果 I 项使用加权误差,它将开始衰减回零并且无法维持所需的输出。
The integral term is the sum of ALL the past errors. You simply add the error to the "integrator" at each time step. If this needs to be limited, clamp it to a min or max value if it goes out of range. Then copy this accumulated value to your output and add the proportional and derivative terms and clamp the output again if necessary.
The Derivative term is the difference in the present and previous error (the rate of change in the error). P of course is just proportional to the error.
And there you have it. Limits omitted of course.
Once the controller reaches the reference value, the error will become zero and the integrator will stop changing. Noise will naturally make it bounce around a bit, but it will stay at the steady state value required to meet your objective, while the P and D terms do most of the work to reduce transients.
Notice that in a steady state condition, the I term is the ONLY thing providing any output. If the control has reached the reference and this requires a non-zero output, it is provided solely by the integrator since the error will be zero. If the I term used weighted errors, it would start to decay back to zero and not sustain the output as needed.