Custom bldc running torque mode not spinning

Got a custom bldc motor with a custom drv8353 motor driver using hall sensors.

Motors spins good in open loop, but just vibrates after setup when running in torque mode.
I’ve attached torque mode code.

Hall sensor test code look good, when rotating a full circle reading is 6.28

MOT: Align sensor.
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 5.24
MOT: No current sense.
MOT: Ready.
Motor ready.
Set the target voltage using serial terminal:

/**
 * 
 * Torque control example using voltage control loop.
 * 
 * Most of the low-end BLDC driver boards doesn't have current measurement therefore SimpleFOC offers 
 * you a way to control motor torque by setting the voltage to the motor instead of the current. 
 * 
 * This makes the BLDC motor effectively a DC motor, and you can use it in a same way.
 */
#include <SimpleFOC.h>


HardwareSerial Serial1(USART1);

#define INH_A PB0
#define INH_B PA7
#define INH_C PA6

#define EN_GATE PA8
// BLDC motor & driver instance
BLDCMotor motor = BLDCMotor(14);
BLDCDriver3PWM driver = BLDCDriver3PWM(INH_A, INH_B, INH_C, EN_GATE);


// hall sensor instance
HallSensor sensor = HallSensor(PB14, PB13, PB12, 14);

// Interrupt routine intialisation
// channel A and B callbacks
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}


// voltage set point variable
float target_voltage = 1;
// instantiate the commander
Commander command = Commander(Serial1);
void doTarget(char* cmd) { command.scalar(&target_voltage, cmd); }

void setup() { 
  
  // initialize encoder sensor hardware
  sensor.init();
  sensor.enableInterrupts(doA, doB, doC); 
  // link the motor to the sensor
  motor.linkSensor(&sensor);

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  driver.voltage_limit = 4;
  driver.init();
  // link driver
  motor.linkDriver(&driver);

    motor.voltage_limit = 4;   // [V]

  // aligning voltage
  motor.voltage_sensor_align = 1;
  
  // choose FOC modulation (optional)
  motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

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

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

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

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

  Serial1.println(F("Motor ready."));
  Serial1.println(F("Set the target voltage 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 
  motor.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
  motor.move(target_voltage);
//motor.monitor();
  // user communication
  command.run();
}

Hi @nitram321 , welcome to SimpleFOC!

One question I have: is the motor really 14 pole-pairs, or is it 14 poles, meaning 7 pole-pairs? If so you should change the initialisation of BLDCMotor accordingly…
although it is saying PP check OK! so probably its correct.

Can you perhaps also change the modulation to FOCModulationType::SinePWM for now, and change the motor voltage limit to be half the driver voltage limit? These parameters should lead to more sine-like waveforms.

Hi @runger

thanks for your replay.
It was a mechanical error on our part. Hall sensors was placed incorrectly to create the normal “binary” output. its working now, but there is another issue with initializing current sensing. Will create another topic.

1 Like