Need help with PID for motor control on a F877
Mike Mansheim email (remove spam text)
>> last_error = error
> This first step should go at the end, otherwise the DELTA_ERROR below
> will always be 0.
>> error = target_rpm - measured_rpm
>> sum_error = sum_error + error
>> delta_error = error - last_error
>> proportional_term = error * proportional_gain
>> integral_term = sum_error * integral_gain
>> derivative_term = delta_error * derivative_gain
>> control_signal = proportional_term + integral_term + derivative_term
I should have been clear on scope: either last_error or error will have
to be global or static; I assumed error would be global. In that case,
I think the way I wrote it would work. If that statement is at the end,
it requires that last_error survive until the next call.
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email mitvma.mit.edu with SET PICList DIGEST in the body listserv
See also: www.piclist.com/techref/microchip/ios.htm?key=motor
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the