|
Re: Speed PID Function
Quote:
Originally Posted by John_1102
I understand the theoretical stuff with the PID now.
I just need some psuedo-code or something to help me implement it.
I'm currently clueless.
|
Code:
previous_error = setpoint - process_feedback
integral = 0
start:
wait(dt)
error = setpoint - process_feedback
integral = integral + (error*dt)
derivative = (error - previous_error)/dt
output = (Kp*error) + (Ki*integral) + (Kd*derivative)
previous_error = error
goto start
Straight from: http://en.wikipedia.org/wiki/PID_controller#Pseudocode
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
|