BOOSTXL-DRV8301 interface with ESP32

Hi guys, I’m relatively new to this forum and this world of motors. I need some help with configuring the BOOSTXL DRV8301 with my esp32.
I have previously configured the TMC6300 with my esp32 and used a set of pins for driving the half bridges and on experimenting found that the motor wouldn’t respond too well with other sets of pins, now in the current scenario some of those pins happen to be the default SPI configuration of the ESP32 so I’m not able to use communicate with the boostXL.
So I tried to use a custom SPI pin configuration method that I found online.
I’m trying to spin the motor in open loop control, and I could observe no response in the least, which makes me wonder if at all the driver is engaged.
Kindly help me identify what I’m doing wrong in the current process or even if I happened to have missed something in the bigger picture entirely.
I’ll attach the wiring and the code along with the things I’m using for reference.

BOOSTXL_DRV 8301:
image

WIRING:

ESP32 BOOSTXL_ DRV8301
16 AH
17 AL
18 BH
19 BL
23 CH
33 CL
25 SDI
26 SDO
27 SCLK
5 CS
35 EN_GATE
34 FAULT
GND GND
POWER SUPPLY BOOSTXL_DRV 8301
12v VDD
GND GND
POWER SUPPLY ESP32
GND GND
BOOSTXL_DRV 8301 MOTOR
A U
B V
C W

CODE:

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

//driver
#define uh16 16
#define ul17 17
#define vh18 18
#define wh19 19
#define vl23 23
#define wl33 33


//motor driver
BLDCMotor motor = BLDCMotor(7);
BLDCDriver6PWM driver = BLDCDriver6PWM(uh16, ul17, vh18, vl23, wh19, wl33);
// DRV8301 gate_driver = DRV8301(MOSI, MISO, SCLK, CS, EN_GATE, FAULT);
DRV8301 gate_driver = DRV8301(25, 26, 27, 5, 35, 34);

void setup()
{
    // driver config
    // power supply voltage [V]
    SPI.begin(25, 26, 27, 5);
    driver.voltage_power_supply = 12;
    driver.dead_zone = 0.005;
    driver.init();
    gate_driver.begin(PWM_INPUT_MODE_6PWM);
    // link the motor and the driver
    motor.linkDriver(&driver);

    // limiting motor movements
    motor.voltage_limit = 3;   // [V]
    motor.velocity_limit = 4; // [rad/s]

    // open loop control config
    motor.controller = MotionControlType::velocity_openloop;

    // init motor hardware
    motor.init();

    Serial.begin(115200);
    Serial.println("Motor ready!");
    _delay(1000);
}

float target_velocity = 0; // [rad/s]

void loop()
{
    // open loop velocity movement
    // using motor.voltage_limit and motor.velocity_limit
    motor.move(target_velocity);

    // receive the used commands from serial
    serialReceiveUserCommand();
}

// utility function enabling serial communication with the user to set the target values
// this function can be implemented in serialEvent function as well
void serialReceiveUserCommand()
{
    // a string to hold incoming data
    static String received_chars;

    while (Serial.available())
    {
        // get the new byte:
        char inChar = (char)Serial.read();
        // add it to the string buffer:
        received_chars += inChar;
        // end of user input
        if (inChar == '\n')
        {
            // change the motor target
            target_velocity = received_chars.toFloat();
            Serial.print("Target velocity ");
            Serial.println(target_velocity);

            // reset the command buffer
            received_chars = "";
        }
    }
}

REFERENCES:

boostxl-drv8301 quick start guide:

custom spi configuration:

drv8301 + simple foc library

Thanks in advance.

Hi @msm , welcome to SimpleFOC forum!

Normally, ESP32 is a very nice chip because you can use any normal GPIO pins you want for SPI or PWM output.
But it can be tricky because there are a large number of pins that are not “normal” - either they are input only, or they’re already used for the flash, or there is some reason you should not use them - see the documentation of the ESP32 chip you’re using, it will list the pins and which can be used without restriction.
If you’re using a ready-made ESP32 board, then the pins available on the headers are usually good to use.

What do you mean by “would not respond too well”? Normally, if it’s a general IO pin, then it can be used for PWM or SPI (but not both at the same time!).

Which ESP32 board are you using?

By “would not respond too well” I mean that the movement is not completely graceful if i could describe it but rather a staggered rotation. I’m using the ESP32 38Pin Development Board WiFi whose pin out I’ll attach. And for context I obtained that particular combination of pins from SparkFun IoT Brushless Motor Driver (ESP32 WROOM, TMC6300) firmware file.

could that behavior be something specific to the tmc6300?

pins 34 and 35 of the esp32 were input only pins, I changed them to pins 13 and 32 and now everything works good. Thanks for the insight and here is the pinout reference for someone else who might need it.

1 Like

Hey, I’m glad you found it.

This thing with the input only pins is a common problem - and who can blame the users if even the pinout diagram doesn’t give this information?

Great that its working now!