simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
1.95k stars 511 forks source link

Foc refactoring #340

Closed Candas1 closed 7 months ago

Candas1 commented 7 months ago

This is the refactoring I mentioned about here. It prevents the code duplication in getDCcurrents and getfoccurrents, this will make future changes in the Clarke transform easier (e.g. using the best 2 phases) getDQCurrents could be used when implementing FOC for stepper motors.

This shouldn't change how FOC works.

runger1101001 commented 7 months ago

Hey, you didn't include speed comparison, but I assume you compared it? Is there a performance impact?

Looks great to me!

Candas1 commented 7 months ago

It is very similar:

Before: RAM: [= ] 9.0% (used 4428 bytes from 49152 bytes) Flash: [=== ] 26.8% (used 70280 bytes from 262144 bytes) loopfoc=280us

After: RAM: [= ] 9.0% (used 4428 bytes from 49152 bytes) Flash: [=== ] 26.8% (used 70224 bytes from 262144 bytes) loopfoc=280us