I’ve received my custom motor driver PCBs today with the STM32G431CBU6 and DRV8316CT. The motor is a 1 pp 24V BLDC inrunner with a max amp of 0.6A. There are two test LEDs connected to PA11 and PA12 which blink fine when uploaded to the STM.
This is part of the schematic:
However, when uploading the 6PWM SimpleFOC code (e.g., openloop velocity), the STM seems to break and 3.3V is now shorted to GND (I measure 3 Ohms resistance between 3.3V and GND). When the STM is removed the short is gone. I upload the code using ArduinoIDE with the ‘generic STM32G4 series’ and board part ‘Generic G431CBUx’. This is the code:
// Open loop motor control example
#include <SimpleFOC.h>
// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(1);
// BLDCDriver6PWM( int phU_h, int phU_l, int phV_h, int phV_l, int phW_h, int phW_l, int en)
BLDCDriver6PWM driver = BLDCDriver6PWM(PA10,PB15,PA9,PB14,PA8,PB13, PB11);
//target variable
float target_velocity = 20;
// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
void setup() {
// use monitoring with serial
Serial.begin(115200);
// enable more verbose output for debugging
// comment out if not needed
SimpleFOCDebug::enable(&Serial);
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 24;
// 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 = 24;
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 = 12; // [V]
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
// init motor hardware
if(!motor.init()){
Serial.println("Motor init failed!");
return;
}
// add target command T
command.add('T', doTarget, "target velocity");
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);
// user communication
command.run();
}
The motor seems to work fine with a Nucleo STM32G431 and the evaluation board for the DRV8316. In the last iteration of this custom PCB with a DRV8317H and the same STM32 I had the exact same issue. However, I had to do some other soldering modifications to it which turned out messy so I assumed the shorting was due to faulty reflow of some components. Now it turns out this is not the case.
What could be going on here?