piclist 2001\07\19\183638a >
Thread: Need help with PID for motor control on a F877
www.piclist.com/techref/microchip/ios.htm?key=motor
flavicon
face BY : Mike Mansheim email (remove spam text)



>> pid_calc:
>>   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 spamlistservEraseMEspam.....mitvma.mit.edu with SET PICList DIGEST in the body


<OF308B04B9.E425A531-ON86256A8E.007B1810@graco.com>

See also: www.piclist.com/techref/microchip/ios.htm?key=motor
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Need help with PID for motor control on a F877

month overview.

new search...