B-G431B-ESC1 not able to move the motor

Hi,

I am trying to use the disco-B-G431B-ESC1 board to move my gimbal motor. I am using the simpleFOC library example. The problem I am facing is that the motor is not moving. Also, I am not getting any output on the serial terminal. The motor is vibrating at a pole. If I move the motor by force then it vibrates at the next pole but does not start to rotate. I have checked with different motors but the issue persists. I have tried this same code with other gimbal controllers (storm BGC and basecam BGC) and it works fine. The motors are not faulty as I have tested them. Could anyone please advise me what to do?

Below is the code I am using to run the motor at constant velocity in open loop mode -

// Open loop motor control example
#include <SimpleFOC.h>


// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(7);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
BLDCDriver3PWM driver = BLDCDriver3PWM(PA8, PA9, PA10);

// Stepper motor & driver instance
//StepperMotor motor = StepperMotor(50);
//StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6,  8);


//target variable
float target_velocity = 10;

void setup() {

  // use monitoring with serial 
  Serial.begin(115200);

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 12;
  // limit the maximal dc voltage the driver can set
  // as a protection measure for the low-resistance motors
  // this value is fixed on startup
  driver.voltage_limit = 6;
  if(!driver.init()){
    Serial.println("Driver init failed!");
    return;
  }
  // link the motor and the driver
  motor.linkDriver(&driver);

  // limiting motor movements
  // limit the voltage to be set to the motor
  // start very low for high resistance motors
  // current = voltage / resistance, so try to be well under 1Amp
  motor.voltage_limit = 3;   // [V]
 
  // open loop control config
  motor.controller = MotionControlType::velocity_openloop;

  // init motor hardware
  if(!motor.init()){
    Serial.println("Motor init failed!");
    return;
  }

  Serial.println("Motor ready!");
  Serial.println("Set target velocity [rad/s]");
  _delay(1000);
}

void loop() {

  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit
  // to turn the motor "backwards", just set a negative target_velocity
  motor.move(target_velocity);
}

Below is the platform.ini file for my project -

[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
framework = arduino
monitor_speed = 115200
monitor_port = /dev/ttyACM0

build_flags = 
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
    -D PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMOODE

lib_deps =
    https://github.com/simplefoc/Arduino-FOC.git

You need to use BLDCDriver6PWM.

Hi,

My BLDC motor is a 3 phase motor. Do I still have to use BLDCDriver6PWM?

Yep. There are always 6 mosfets, two per phase wire to connect it to either positive or ground (called high side and low side). 6PWM gives the CPU independent control of each one, whereas with 3PWM the CPU tells the driver which of the two mosfets for each phase should be turned on, and the other is automatically turned off. Each scheme has its advantages (hence why neither has become the universal standard), but the result is largely the same either way.

This didn’t work. The motor is still vibrating and not rotating. The 3 phases of my motor are connected to UH, VH and WH. Is there anything else I have to change?

I think I remember reading before that PIO_FRAMEWORK_ARDUINO_ENABLE_CDC shouldn’t be used. Otherwise I’m not sure what could be wrong.