Motor keeps shaking and no longer rotates after the motor stalls

I use simplefoc to drive two Hoverboard motors, the motor has a Hall sensor, after the motor stalls then releases the motor, the motor keeps shaking and no longer rotates, how to solve it?

#include <SimpleFOC.h>

#define MOTOR PE8

HardwareSerial SerialMain(PB7, PB6);

BLDCMotor motor1 = BLDCMotor(15);
BLDCMotor motor2 = BLDCMotor(15);
BLDCDriver6PWM driver1 = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15);
BLDCDriver6PWM driver2 = BLDCDriver6PWM(PC6, PA7, PC7, PB0, PC8, PB1);

HallSensor sensor1 = HallSensor(PE2, PE3, PE4, 15);
HallSensor sensor2 = HallSensor(PE13, PE14, PE15, 15);

void doA1(){sensor1.handleA();}
void doB1(){sensor1.handleB();}
void doC1(){sensor1.handleC();}
void doA2(){sensor2.handleA();}
void doB2(){sensor2.handleB();}
void doC2(){sensor2.handleC();}

// velocity set point variable
float target_velocity = 0;
// instantiate the commander
Commander command = Commander(SerialMain);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }

void setup() {
  pinMode(MOTOR, OUTPUT);
  digitalWrite(MOTOR, LOW);

  sensor1.pullup = Pullup::USE_EXTERN;
  sensor2.pullup = Pullup::USE_EXTERN;
  sensor1.init();
  sensor2.init();
  sensor1.enableInterrupts(doA1, doB1, doC1); 
  sensor2.enableInterrupts(doA2, doB2, doC2); 
  motor1.linkSensor(&sensor1);
  motor2.linkSensor(&sensor2);

  driver1.voltage_power_supply = 36;
  driver2.voltage_power_supply = 36;
  driver1.init();
  driver2.init();
  motor1.linkDriver(&driver1);
  motor2.linkDriver(&driver2);

  motor1.voltage_sensor_align = 3;
  motor2.voltage_sensor_align = 3;

  motor1.controller = MotionControlType::velocity;
  motor2.controller = MotionControlType::velocity;

  motor1.PID_velocity.P = 0.2f;
  motor1.PID_velocity.I = 2;
  motor1.PID_velocity.D = 0;
  motor1.voltage_limit = 18;
  motor1.PID_velocity.output_ramp = 1000;
  motor1.LPF_velocity.Tf = 0.01f;

  motor2.PID_velocity.P = 0.2f;
  motor2.PID_velocity.I = 2;
  motor2.PID_velocity.D = 0;
  motor2.voltage_limit = 18;
  motor2.PID_velocity.output_ramp = 1000;
  motor2.LPF_velocity.Tf = 0.01f;

  // use monitoring with serial
  SerialMain.begin(115200);
  // comment out if not needed
  // motor.useMonitoring(SerialMain);

  // initialize motor
  motor1.init();
  motor2.init();
  // align sensor and start FOC
  motor1.initFOC();
  motor2.initFOC();

  // add target command T
  command.add('T', doTarget, "target voltage");

  SerialMain.println(F("Motor ready."));
  SerialMain.println(F("Set the target velocity using serial terminal:"));
  _delay(1000);
}


void loop() {
  // main FOC algorithm function
  // the faster you run this function the better
  // Arduino UNO loop  ~1kHz
  // Bluepill loop ~10kHz
  motor1.loopFOC();
  motor2.loopFOC();

  // Motion control function
  // velocity, position or voltage (defined in motor.controller)
  // this function can be run at much lower frequency than loopFOC() function
  // You can also use motor.move() and set the motor.target in the code
  motor1.move(target_velocity);
  motor2.move(target_velocity);

  // function intended to be used with serial plotter to monitor motor variables
  // significantly slowing the execution down!!!!
  // motor.monitor();

  // user communication
  command.run();
}

Hi,

Is it ok in torque mode?
You are not using the controller on the picture right? As you are controlling 2 motors.

There is no problem with torque mode, velocity and angle mode not work after stalls, however, I am working on a smart car application, and torque mode is not suitable for me

I use a controller of my own design

Is something going wrong with the position when this is happening?

It’s not related to your issue but you will have also better results with the smoothing sensor.

I’d recommend reducing the motor voltage limit until you have the voltage-based current limiting and PIDs tuned. Aside from being safer, it could be the source of your problem. If there’s any hardware overcurrent protection or temperature sensor, it could be getting tripped. Or you could even be getting power brownout if the power supply can’t keep up.