Issue with SimpleFOC loop cutting out when reaching the voltage limit

Hi everyone!

I am new to the forums but have been experimenting with SimpleFOC for a few months now. Thanks for an amazing library! To give a bit of background, I am trying to make a camera gimbal for a drone. I have designed a custom PCB that uses an STM32G4 to control an iPower BLDC gimbal motor with a DRV8313 motor driver. I have added an AS5048A encoder for closed loop control and I am using a BMI323 IMU for the stabilisation. I have one PCB per axis for a 2 axis gimbal that work independently.

I have managed to implement closed loop velocity control and am now working on closed loop angle control as it is more intuitive to me but in my flight testing I have encountered an issue. When the gimbal meets a lot of resistance eg. wind, the FOC loop requests higher and higher voltages until it reaches the supply voltage limit. I have found that the FOC loop is exiting (I can tell as I lose all Serial Printing) resulting in the motor just holding position and no longer stabilising even when the external resistance is removed. Has anyone ever encountered this before and know a fix for it? I don’t mind if the gimbal lags slightly due to being under powered, I just need the FOC loop to continue pulling the max voltage if required until the disturbance is removed. ie. once the wind dies down I want the gimbal to still be stabilising and not have quit the main loop resulting in the motor just holding position.

I have already tried the following:

  • increasing the motor.voltage_limit and driver.voltage_limit equal to driver.voltage_power_supply
  • the voltage power supply cannot be increase any further due to restrictions on the platform (it is currently 13.6V)
  • I am in the process of upgrading to a size bigger motors but expect to still have this issue from time to time

My one suspicion is that I have swapped the 100uF electrolytic capacitor for the DRV8313 for the same size but tantalum capacitor (20TQC100MD2) due to height restrictions on my board. Could this be causing these issues or is it more likely to be a software issue?

Thank you in advance for any help that anyone can offer!