br3ttb / Arduino-PID-Library

1.93k stars 1.11k forks source link

modified SetSampleTime() to allow PID::Compute() synch to external timing source #111

Open paynterf opened 3 years ago

paynterf commented 3 years ago

I modified SetSampleTime() to set the internal SampleTime variable to zero for an input argument of zero, without modifying ki or kd. This forces Compute() to generate a new output value each time it is called, and allows the PID engine to be synchronized with an external timing source.

This modification does not change the normal behavior in any way, but allows a knowledgeable user to synchronize the PID engine to an external timing source.

paynterf commented 3 years ago

For some additional details in support of this modification, see my blog post https://www.fpaynter.com/2021/05/turn-rate-pid-tuning-part-ii/