Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current PI Autotuning #426

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Current PI Autotuning #426

wants to merge 1 commit into from

Conversation

Candas1
Copy link
Collaborator

@Candas1 Candas1 commented Jul 21, 2024

Shared by @mcells from his fork https://github.com/mcells/Arduino-FOC/blob/d40c7d7fddff4c3e58b26ebd2e2cc846fddfc09e/src/HFIBLDCMotor.cpp#L71

if phase resistance and phase inductance are known:

Will initialize Kp and Ki for q and d current PI controllers automatically based on phase resistance, phase inductance and current bandwidth (default 300).
Needs to be adapted if Ld and Lq are available in the future.
⚠️ What if users have set phase resistance and phase inductance but were using default PI parameters ? Is there an impact ?

if phase resistance and phase inductance are not known:

Same SimpleFOC default values as before are used.

Users that have already tuned their PIs:

They will overwrite Kp and Ki from their code.

@mcells
Copy link
Contributor

mcells commented Jul 21, 2024

Great!
One thing though, that part of the code is not by me, all credit goes to @Copper280z. I just had my fork on hand quicker when sharing this earlier🙈
Thanks for the mention regardless!

@Copper280z
Copy link
Contributor

To be clear, this method is really more like pole placement, rather than autotuning.

I would recommend also setting the filter cutoff based on the controller bandwidth, otherwise the controller will have a higher bandwidth than the filter likely leading to some integral windup or something else undesirable happening. The default filter for faster chips has a cutoff frequency of ~30hz. Something like 1.5-5x the controller bandwidth (so 450-1500hz) is probably a good place to start. In the hfi fork we've been using a fixed ~2khz lowpass for both controllers.

@askuric
Copy link
Member

askuric commented Jul 22, 2024

Oohh, very very very nice!
Do you guys have some refereces/papers about this?

@Candas1
Copy link
Collaborator Author

Candas1 commented Jul 22, 2024

Some time ago I shared this:
https://community.simplefoc.com/t/measuring-the-resistance-of-the-motor/3647/11?u=candas1

The blog and video in the the next post are great.

@askuric
Copy link
Member

askuric commented Jul 22, 2024

Nice, I'll look into it.

@Copper280z
Copy link
Contributor

Copper280z commented Jul 23, 2024

Oohh, very very very nice! Do you guys have some refereces/papers about this?

I believe I used a combination of this Ben Katz blog post and Elwin's project when I wrote this. I did some algebra to convert the coefficients to the form used in SFOC.
https://build-its-inprogress.blogspot.com/2016/08/desktop-inverted-pendulum-part-2-control.html

Extra fun fact is that this same method applies to tuning the velocity PI controller too! The units just change. I'd need to work it out though as I don't remember off the top of my head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants