View Single Post
  #2   Spotlight this post!  
Unread 12-02-2005, 12:03
Don Reid Don Reid is offline
Registered User
#0997
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Corvallis, Oregon
Posts: 45
Don Reid will become famous soon enough
Re: PID cmd_drive can't drive straight?

Yes, we saw something similar. Our solution was to set the velocity for the startup, is several steps to ramp up the speed, then when the distance is close, switch to position.

It is common for PID implementations to inhibit accumulating an integral of the error when the output is clamped to a limit (high or low). You can put in code like:

Code:
         // Only integrate if not driving at a limit
         if ((motor_info[motor].pwm < (MAX_PWM-PWM_ZERO)) &&
             (motor_info[motor].pwm > (MIN_PWM-PWM_ZERO))){
             motor_info[motor].vel_error_i += motor_info[motor].vel_error;
             }
__________________
Don Reid

Last edited by Don Reid : 12-02-2005 at 12:05. Reason: Quote code