esp32-wroom-32D + TMC6300 + EM3215

The problem: My motor toggles back and forth
what I have done:

I’ve tried a wild amount of different things but the farthest I’ve gotten is:
I have the three wires from the motor connected to pins U V and W on the driver.
I have the 6 pins for the H bridges connected through a logic level shifter. These are the connections to the gpio pins of the esp32:

  • UL → 26
  • UH → 27
  • VL → 25
  • VH → 33
  • WL → 32
  • WH → 23

I am unsure why the motor is bouncing back and forth. I’ve tried a ridiculous amount of things and I do not know how to troubleshoot this further.
If my question is lacking information that would help debug, please let me know!

the code I am running:

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

BLDCMotor motor = BLDCMotor(7);//, 7.8, 270);
BLDCDriver6PWM driver = BLDCDriver6PWM(32,23, 25,33, 26,27);

/*
 * ESP32
 * UL -> 26
 * UH -> 27
 * VL -> 25
 * VH -> 33
 * WL -> 32
 * WH -> 23
 */

//target variable
float target_velocity = 6;

Commander command = Commander(Serial);

void setup() {
  driver.voltage_power_supply = 5;
  driver.voltage_limit = 5;
  driver.pwm_frequency = 32000;

  driver.init();  
  motor.linkDriver(&driver);
  motor.voltage_limit = 3;   // [V]
  motor.controller = MotionControlType::velocity_openloop;
  motor.init();

  Serial.begin(115200);
  Serial.println("Motor ready!");
  Serial.println("Set target velocity [rad/s]");
  _delay(1000);
}

void loop() {
  motor.move(target_velocity);
  command.run();
}

What microcontroller? What driver board?
Are you using Arduino or PlatformIO?

The microcontroller I am using is an esp32-wroom-32D
The driver is a TMC6300
and I am using the arduino IDE

Hi @Ziayakens,

This pin configuration looks good, so does your code.
Could you tell us a bit more about your setup, how did you do the wiring?
Do you have a common ground between the microcontroller and the board?
How are you powering the board?

I am powering the board with an external variable power supply
I forgot to add but the microcontroller is powered through the usb connection
This is my setup:
These are the logic level shifters

oh no what am I doing! I got something mixed up and now have it clarified, this is a 3v logic, let me try changing that and see if it makes a difference.

Update: It spins but it seems to snap between positions slightly, like its not quite a 100% smooth spin, is that normal?

Yes, this is “cogging”. Every motor will exhibit this a bit, but some are worse than others. With proper PID tuning, higher current, and higher speed, it is reduced.

thank you for the heads up