stm32f446re+DRV8302 control torque BLDC motor


I require some assistance, please. I am attempting to control a BLDC motor using an STM32F446RE and a DRV8302 driver. I am using the SimpleFOC library to achieve this. Specifically, I am attempting to control the torque using the TorqueControlType::FOC_CURRENT method. Additionally, I am utilizing a low-side current sensor within the DRV8302.

I am encountering issues when attempting to control the motor’s current components (Iq = desired torque) and (Id = 0). When I make adjustments to the PI controller for Iq and Id, the motor starts rotating rapidly in both the clockwise (CW) and counterclockwise (CCW) directions. I would greatly appreciate any suggestions you may have to address this issue.

“I also have the following data from the serial port. When trying to align the sensor, why does it give me ‘success 2’? According to what I’ve read, I should reconfigure the pins, but I don’t know which ones.”

MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: Index search…
MOT: Success!
MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 4.06
MOT: Align current sense.
MOT: Success: 2
MOT: Ready.

Hi @Allafi , welcome to SimpleFOC!

Have you tried the torque-voltage and velocity modes first? If your setup permits (ie the phase resistance of the motor is not too low) it is better to test these modes first, and make sure things are set up correctly, your sensor is working, etc

The success 2 implies the pins were switched, which means the current sense pins do not correspond to the PWM pins - you can switch them around in the current sense constructor until you get success 0.

1 Like