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:
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.