Hall sensor bldc motor does not turn

engine pp=2
volts = 24
voltage control
pp check = 2 correct
but the motor does not turn, only the sound is heard, the interruptions are 12 in a full revolution


2 PP is a very low number of pole pairs :slight_smile:

With hall sensors, I think you only get 12 counts per revolution, this won’t give you much position accuracy.

If you share your code here, perhaps we can help to see if there are mistakes, but if you get no movement at all then it could also be an electrical problem… kindly share some more details of your setup (which driver, which MCU, maybe some pictures/diagrams of how you have connected things).

 * Velocity motion control example
 * Steps:
 * 1) Configure the motor and sensor
 * 2) Run the code
 * 3) Set the target velocity (in radians per second) from serial terminal
 * NOTE :
 * > Specifically for Arduino UNO example code for running velocity motion control using a hall sensor
 * > Since Arduino UNO doesn't have enough interrupt pins we have to use software interrupt library PciManager.
 * > If running this code with Nucleo or Bluepill or any other board which has more than 2 interrupt pins
 * > you can supply doC directly to the sensor.enableInterrupts(doA,doB,doC) and avoid using PciManger
#include <SimpleFOC.h>
// software interrupt library

// BLDC motor & driver instance
BLDCMotor motor = BLDCMotor(2);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
// Stepper motor & driver instance

// hall sensor instance
HallSensor sensor = HallSensor(2, 3, 4, 2);

// Interrupt routine intialisation
// channel A and B callbacks
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
// If no available hadware interrupt pins use the software interrupt

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

void setup() {

  // initialize sensor sensor hardware
  sensor.enableInterrupts(doA, doB, doC);
  // software interrupts
  sensor.pullup = Pullup::USE_EXTERN;
  // link the motor to the sensor

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 24;
  // link the motor and the driver

  // aligning voltage [V]
  motor.voltage_sensor_align = 1;

  // set motion control loop to be used
  motor.controller = MotionControlType::velocity;

  // contoller configuration
  // default parameters in defaults.h

  // velocity PI controller parameters
  motor.PID_velocity.P = 0.2f;
  motor.PID_velocity.I = 2;
  motor.PID_velocity.D = 0;
  // default voltage_power_supply
  motor.voltage_limit = 12;
  // jerk control using voltage voltage ramp
  // default value is 300 volts per sec  ~ 0.3V per millisecond
  motor.PID_velocity.output_ramp = 1000;

  // velocity low pass filtering time constant
  motor.LPF_velocity.Tf = 0.01f;

  // use monitoring with serial
  // comment out if not needed

  // initialize motor
  // align sensor and start FOC

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

  Serial.println(F("Motor ready."));
  Serial.println(F("Set the target velocity using serial terminal:"));

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

  // 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

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

  // user communication

this is the code

mcu card = stm32f411 re

driver card =

  • IR2103 drivers
  • 1 engine
  • 36V/20A
  • low-side current sensing

doing engine recognition
getting offset
but in speed mode the motor makes noise and does not turn.

Your code says

float target_velocity = 0;

Did you send the velocity command to the motor? If you just run the code it will stand still. You need to change the velocity.

Serial command
Target velocity=2

What’s the resistance of the motor?

You’re using 24V normally, but 1V during alignment. Maybe the currents are too high? You could try setting a lower voltage limit to see if things improve.

Are you working in ArduinoIDE or PlatformIO?

If you check the PWM outputs from the MCU to the IR2103 drivers, do they look correct? You can check them with an oscilloscope or logic analyzer…

Isn’t it supposed to be


Instead of

Target velocity=2

Also you say


But I don’t see you setting this variable anywhere. It’s initialized as 0 at the beginning, then you just pass it directly without modifying it.

float target_velocity = 0;

I suggest you initialize it with

float target_velocity = 1;

and see what happens.