View Single Post
  #12   Spotlight this post!  
Unread 25-01-2005, 13:10
Rich Petras's Avatar
Rich Petras Rich Petras is offline
Registered User
#0691 (Hart Burn)
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Santa Clarita, CA
Posts: 4
Rich Petras is on a distinguished road
Re: PID code questions

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.