Quote:
|
Originally Posted by Don Reid
In the pid code from First's "Navigation" sample, there is something I don't understand.
The integral error is combined with "pid_time", which is unfamiliar to me, I thought the integrated error (sum) should just used as is.
motor_info[motor].pwm = (KP_P * motor_info[motor].pos_error) +
((KI_P * motor_info[motor].pos_error_i)/pid_time) +
(KD_P * motor_info[motor].pos_error_d);
This pid_time variable is reset when the target position (or velocity) is changed,
but the integral value is not also cleared. Won't that cause problems?
|
As someone else pointed out, dividing by a time term helps (but does not
completely eliminate) windup.
You are right, set_pos() and set_vel() really should clear the integral term.
However, if you look at the way we used the code in robot.c, we always
call set_pid_stop() which does clear all the terms.