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();
}