Hi community,
I recently started to experiment with driving BLDC motors. My main intention is to put together a motorized leg for robot dog.
So I designed my custom driver board supporting SimpleFOC. I based it around DRV8302 from TI and Infenion’s IRF1404Z mosfets (schematic and PCB layout attached).
It works when i test it using driver.setPwm(A, B, C)
. Meaning voltage on all phases is correctly set. It also makes a small BLDC motor move, but eventually ends up burning it in like 3 or 4 seconds. The motor used for testing was A2212/13T (specsheet).
Could anyone please take a quick look if there are any obvious mistakes in my code / driver design?
Schematic:
Code:
#include <SimpleFOC.h>
// MANUALLY GROUNDED -> M_OC, GAIN, DC_CAL
// MANUALLY PULLED HIGH -> OC_ADJ (needes to be remade in final design)
// --- ENCODER ---
MagneticSensorI2C sensor(AS5600_I2C);
// --- DRIVER ---
#define INH_A 6
#define INH_B 5
#define INH_C 3
#define ENABLE A3
#define M_PWM 4
BLDCDriver3PWM driver(INH_A, INH_B, INH_C, ENABLE);
// --- CURRENT SENSING ---
// skip for now
// --- BLDC MOTOR ---
#define POLE_PARIS 7
#define KV 1000
BLDCMotor motor(POLE_PARIS, NOT_SET, KV);
void setup()
{
Serial.begin(115200);
sensor.init();
motor.linkSensor(&sensor);
// external driver setup
pinMode(M_PWM, OUTPUT);
digitalWrite(M_PWM, HIGH); // set 3-pwm mode
// set driver voltage to 12V
driver.voltage_power_supply = 20;
driver.voltage_limit = 12;
driver.init();
motor.linkDriver(&driver);
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
motor.controller = MotionControlType::velocity;
motor.useMonitoring(Serial);
motor.init();
motor.initFOC();
// set desired speed
motor.target = 1;
}
void loop()
{
motor.loopFOC();
// move at the desired speed
motor.move();
}
Thanks!!