View Single Post
  #12   Spotlight this post!  
Unread 12-03-2004, 10:07
kevinw kevinw is offline
Registered User
#0065
 
Join Date: May 2001
Location: Farmington Hills
Posts: 132
kevinw is a name known to allkevinw is a name known to allkevinw is a name known to allkevinw is a name known to allkevinw is a name known to allkevinw is a name known to all
Re: PID control loops - feedback is our friend!!!

Quote:
Originally Posted by mightywombat

pid = request;

error = request - actual; //find the difference of the two values

pid = pid + (error/PID_PROP); //add the proportional part of the error

pid = pid + ((actual - lastactual)/PID_DER); // add the derivative part of the error

pid = pid + (sumerror/PID_INT); //integral part of the pid

pid = pid + 127;

return(pid);
}
What is the reason for adding the requested position to the PID control output? Is there a need for a feed-forward term in the control loop? Are you scaling the output after pid is returned?

Also, you might want to add overflow checking, just in case.