Dlloydev / QuickPID

A fast PID controller with multiple options. Various Integral anti-windup, Proportional, Derivative and timer control modes.
MIT License
195 stars 50 forks source link

Derivative smoothing #49

Closed TomPcz closed 2 years ago

TomPcz commented 2 years ago

Could you please add an optional derivative smoothing? Noisy input causes jitter in the input. A simple low-pass filter (with user-defined cutoff frequency) would solve it.

Dlloydev commented 2 years ago

I'll look further into this, however, being quite busy, it might take a while to get started. A document that keeps catching my interest is Practical PID Controls, where any enhancement(s) could be done in stages:

  1. Removing Command Glitches from Derivative Response
  2. Averaging filter
  3. Single pole filter (as your suggestion)

I'm not sure if item 1 is an issue ... it'll take some testing (and so will 2 and 3).

gmarquart commented 2 years ago

@tpikalek -- why not try an existing filtering library? e.g., https://www.megunolink.com/articles/coding/3-methods-filter-noisy-arduino-measurements/

Dlloydev commented 2 years ago

Removed the "enhancement" label as there will be no time in the near term to work on this. Also having second thoughts as to how it may affect PID performance and as @tpikalek points out, an external filtering library could be an alternative. I'll leave this open for now as there could be more discussion.

gmarquart commented 2 years ago

e.g., using ExponentialFilter from aforementioned library to smooth the temp prior to feeding into QuickPID 24to37-24_to_4C_20min-P-25-I-0 055