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.