> 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 > > ... > and the derivative term helps > react to a rapidly changing error. The derivative term is often not needed > - > I would certainly start without it. The derivative term is often used with negative gain to dampen the system and prevent it from ringing. Unfortunately it is also the most susceptible to input noise. High integral term gain can lead to instability, which can be partially offset by the damping effect of a negative derivative term. Personally, I would start out with just the P and D terms. Start experimenting with the system with just the P term and get a feeling for how it reacts, then slowly crank up the -D term and see how the damping works. I would leave the I term to last and only use it if you need low long term error or the steady state error without it is too large. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body