# Help needed regarding custom DRV8302 based driver

**URL:** <https://community.simplefoc.com/t/help-needed-regarding-custom-drv8302-based-driver/5458>\
**Category:** hardware support\
**Tags:** bldc, arduino, as5600, drv8302\
**Created:** [September 14, 2024, 11:47am UTC](https://community.simplefoc.com/t/help-needed-regarding-custom-drv8302-based-driver/5458 "2024-09-14T11:47:30Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Papouc](https://community.simplefoc.com/user_avatar/community.simplefoc.com/papouc/32/7467_2.png) [@Papouc](https://community.simplefoc.com/u/Papouc)\
**Post date:** [September 14, 2024, 11:47am UTC](https://community.simplefoc.com/t/help-needed-regarding-custom-drv8302-based-driver/5458/1 "2024-09-14T11:47:30Z")

</div>

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](https://www.rhydolabz.com/documents/26/BLDC_A2212_13T.pdf)).

Could anyone please take a quick look if there are any obvious mistakes in my code / driver design?

Schematic:

 ![Schematic_MotorDriverPrototype_2024-09-14](https://community.simplefoc.com/uploads/default/original/2X/4/4aae0b14a36b0e66f0b9ebd047195ea847e3d437.png)

Code:

```auto
#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!!

---

_[View the full topic](https://community.simplefoc.com/t/help-needed-regarding-custom-drv8302-based-driver/5458)._
