Iq spike above the target current_q when the motor hits an obstacle

Hardware Setup

  • MCU: ESP32-S3

  • Motor Driver: DRV8305 (6-PWM mode enabled)

  • Motor: BLDC / PMSM

  • Encoder: AS5048B (I2Cclock speed: 100kHz)

  • Current Sensing: LowSideCurrentSense

Control Configuration

  • Control Mode: Torque control with current_foc type

  • Loop Frequency: motor.loopFOC() running at ~1.6kHz

  • Electrical Angle Alignment: Completed correctly with negligible load

  • motor.PID_current_q.P = 0.1; motor.PID_current_q.I = 80.5; motor.PID_current_q.D = 0.0; motor.LPF_current_q.Tf = 0.001; motor.PID_current_q.limit = 5.0;

  • motor.PID_current_d.P = 0.1; motor.PID_current_d.I = 80.5; motor.PID_current_d.D = 0.0; motor.LPF_current_d.Tf = 0.001; motor.PID_current_d.limit = 5.0;

Problem Description

I’m experiencing significant current_q overshooting when the motor encounters obstacles.

Expected Behavior: When setting target_current_q = 1.0f as shown in the diagram as red dotted line, the measured iq_value as shown in the diagram as red solid line should remain close to the target, even under load variations.

Actual Behavior: When the motor hits an obstacle, the measured iq_value spikes well beyond the target value (see attached diagram - red line shows measured current, dotted line shows target).

Recovery Time: It takes approximately 200ms for the current to recover from the spike and return back to the target region.

Questions

  1. Why is the current controller allowing such significant overshoot beyond the target current_q value?

  2. Is the 200ms recovery time normal, or does it indicate a tuning issue?

  3. What parameters should I focus on tuning to minimize this overshoot when hitting obstacles?

  4. Could the 1.6kHz loopFOC frequency be insufficient for my application?

Additional Context

The spiking only occurs when the motor encounters sudden mechanical resistance (obstacles). Any guidance on tuning the current control loop or adjusting relevant SimpleFOC parameters would be greatly appreciated!

What behavior do you get with the default current PID values (P=3, I=300, Tf=0.005)? I tried tuning it once, just out of curiosity, but the defaults seemed to be very good.

1.6KHz is very slow for the main loop, but I still wouldn’t expect more than a few ms to suppress the spike. Is there a reason you’re running it so slow, despite having plenty of processing power on the S3? 5-10KHz would probably be better.

Hi, deku. Thanks for the reply. I have tested with both the suggestions you have provided:

  • Right now the frequency of the motor.loopFOC() is around 5kHz as I have increased the clock speed of the AS5048B (I2C) to 1MHz.
    Just the idea of doubting whether is the angle updating fast enough so that it won’t bottleneck the loop. The test I have done is just increasing the I2C clock speed and the time used to run the motor.loopFOC() has reduced, so I have decided to stick with just 1MHz of the I2C clock. And I am not sure is there any other way to increase the current loop frequency (motor.loopFOC()) more.
    But still, the problem of the spiking Iq is not resolved.
  • I have tried with the current PI controller with values of Kp=3, Ki=300, and Tf=0.005, the PCB board restart immediately when the torque is exerted by the motor. The restart reason is as follow:
    BOD: Brownout detector was trig
    rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)