esp-cpp / espp

C++ components for ESP
https://esp-cpp.github.io/espp/
MIT License
30 stars 9 forks source link

Filters (Lowpass and Butterworth) may have bugs #6

Closed finger563 closed 1 year ago

finger563 commented 1 year ago

Describe the bug

As noticed when working on #5 - when enabling velocity filtering (either using Lowpass or Butterworth filters, the PID became unstable, however if I removed all filtering (just returning the raw input from the filter function in main()), then it stabilized and worked well.

This might not actually be a bug in the filters and may have more to do with the control system itself, but definitely warrants more investigation.

To Reproduce

Expected behavior

Filtering should not destroy the stability of the control system?

Screenshots / Images

Hardware / Software Configuration (please complete the following information):

Additional context

Could be related to the delay that the filters add (esp. since it seems to also occur when using a simple moving average filter with an alpha less than 0.5.

finger563 commented 1 year ago

Looking through some testing - it seems the instability results from the decent amount of time delay the filters add to the input signal; Looking through some other options right now to decrease the time delay.

CleanShot 2022-12-26 at 13 02 10@2x

Look through This DSP article to see if an alternate

finger563 commented 1 year ago

The filters were configured for a very low cutoff frequency - the lower the cutoff frequency the longer the time delay added to the input signal.