Overcurrent/Short at sudden changes in target velocity (velocity control & current_foc)

I’m testing a low resistance (220 mOhm) motor rated for 6 rad/s. I kept the target velocity limit as -2.5 rad/s to 2.5 rad/s. But instances where there is a sudden direction change (let’s say from 2.5 to -2.5 (while it’s carrying a load of 5 lbs), it’s triggering over current/short-circuit on my bench power supply. I’m very scared to put this on a battery.
I have tried playing with PID velocity, PID current (both d and q), but cannot fix this issue. I even tried putting constrains in the current_sp, but it didn’t work.
What could be causing it.
It’s a STM32 based motor controller, with 80V MOSFETs (power supply set to 54V).

I am going to assume you are using FOC because you mentioned D and Q currents.

When you suddenly change the speed command from -2.5 to 2.5 rad/s, the motor goes into regenerative braking mode. Regenerative braking is automatically activated when the torque (Q current) is in the opposite direction to the velocity. What are you using to deal with the regeneration energy? In my setup I use a TVS diode (with breakdown voltage around 10% higher than supply voltage) to absorb the regeneration energy. If you don’t have anything to absorb the regeneration energy, then you will get a big voltage spike on the input, and this could trip one of the protections in your power supply.

Connecting your motor driver to a battery (with a fuse or other protection circuit) will actually help, as the battery can absorb the regeneration energy.

It could also be an issue with the control algorithm or PID tuning, but if your motor is spinning fine otherwise then this is unlikely.

1 Like

Have you tried also setting the PID output_limit, ramp_speed, and maybe also motor voltage_limit? It could be a problem unrelated to the motor itself and instead the PID overreacting to the error.

Yes, sorry for not pointing it out.

I do have a TVS diode, but the reverse clamp V is 78V and breakdown voltage of 86V. Now, thinking about it, it looks too high :frowning: 13S batteries could go till 54V only. Battery with a fuse is a must.

I have tried playing with PID tuning. It didn’t do much help.

I’m trying to find a way to put a constraint limit in the firmware, which does not allow the motor to draw excess current even if the user input requires it to. I may not need to follow the user commands, but keep the motor and the boards safe.

Yes, I tried PID limit and output ramp, both didn’t do much. But the motor voltage_limit seems to have toned it down. However, it does come with a cost of lower speed/torque.
I’m trying to find a way to put a limit on the current applied to the coils. So, it never goes into such an over-current/short condition.

Have you tried setting motor.PID_current_q.limit? Documentation Options Reference | Arduino-FOC

Are you able to check the supply voltage with an oscilloscope when you send the command to reverse the motor direction? Also probe the supply current using either using a current clamp or shunt resistor. Then take a measurement of the motor phase currents as well. This info should be helpful narrowing down the root cause.

You were right my friend. This solved all the problems :smiley: