Subject: Custom FOC implementation - Motor runaway and Iq/Id coupling at high speed
Hello everyone,
I am developing my own FOC implementation (not using the SimpleFOC library itself) and I’m facing a persistent “runaway” issue that I haven’t been able to solve. I would appreciate some expert insight into what might be happening.
The Problem: The motor operates fine at lower speeds, but as it accelerates, it enters a runaway state. Specifically, in Current Control mode:
-
If I command
Iq = 5A, the motor spins as expected. -
If I then command
Iq = -5Ato reverse, the motor instead accelerates rapidly in the opposite direction. -
During this runaway, I observe that both Iq and Id go to approximately -5A.
What I’ve tried:
-
Manual Offset: I haven’t implemented an automated encoder calibration routine yet. I am using a manual offset and I’ve tried to align the
zero_electric_angleas accurately as possible. -
Angle Delay Compensation: I suspected phase lag, so I attempted to implement an angle delay compensation (predicting the angle based on velocity), but the runaway persists above certain RPMs.
Additionally, I would like to know if implementing a feed-forward Back-EMF compensation is strictly necessary to prevent this runaway. I have already attempted to implement it in my code, but it resulted in a very limited top speed, far below what the motor should be capable of. Given that my current manual offset might be slightly off, could the lack of proper Back-EMF compensation (or a poorly tuned one) be contributing to the loss of synchronization and the subsequent runaway, or should the standard PI current loops be able to handle this as long as the angle is correct?

