vedderb / bldc

The VESC motor control firmware
2.09k stars 1.31k forks source link

PID speed control uses filtered speed #640

Open Zob314 opened 1 year ago

Zob314 commented 1 year ago

The comment here makes it sound like m_speed_est_fast should be used for speed control https://github.com/vedderb/bldc/blob/e3d7e8624cc45f8dcc677d53b76fb18e4b2768f7/motor/mcpwm_foc.c#L3256 But in the PID speed control uses the slower and more filtered m_pll_speed. https://github.com/vedderb/bldc/blob/e3d7e8624cc45f8dcc677d53b76fb18e4b2768f7/motor/foc_math.c#L464 I switched this out for m_speed_est_fast and was able to achieve much better PID speed control performance. The setup I had used a magnetic encoder, so it likely has a much cleaner speed input than hall or sensorless setups, but I would think that filtering / de-tuning should be done in the PID tuning and not the input to the PID algorithm.

vedderb commented 1 year ago

Good observation. I have added an option to choose the speed source in https://github.com/vedderb/bldc/commit/9eb978ef15cfffffc135710d3a5d63de1502fbd1 Should be in the next beta.