Hi, I am using the ROB-20441 BLDC motor, TMC6300 driver, and ESP32-WROOM-32UE. There should be no compatability issues, and the motor is rated at 2000 rpm at 7.4 V. However when I run the basic example code my velocity peaks at about 50 radians per second. Anything higher and the motor freezes. Am I missing something here?
#include <Arduino.h>
// Open loop motor control example
#include <SimpleFOC.h>
// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(7); // Motor actually has 8 poles, documentation suggests running with 7 poles
BLDCDriver6PWM driver = BLDCDriver6PWM(33, 32, 26, 25, 14, 27); // uh, ul, vh, vl, wh, wl ((16,17,18,23,19,33 example code))
//target variable
float target_velocity = 100;
// // instantiate the commander
Commander command = Commander(Serial);
// void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
// void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
void setup() {
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 9;
// limit the maximal dc voltage the driver can set
// as a protection measure for the low-resistance motors
// this value is fixed on startup
driver.voltage_limit = 9;
// pwm frequency to be used [Hz]
// for atmega328 fixed to 32kHz
// esp32/stm32/teensy configurable
driver.pwm_frequency = 20000;
driver.init();
// link the motor and the driver
motor.linkDriver(&driver);
// limiting motor movements
// limit the voltage to be set to the motor
// start very low for high resistance motors
// current = voltage / resistance, so try to be well under 1Amp
motor.voltage_limit = 7.4; // [V]
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
// init motor hardware
motor.init();
// add target command T
// command.add('T', doTarget, "target velocity");
// command.add('L', doLimit, "voltage limit");
Serial.begin(115200);
Serial.println("Motor ready!");
Serial.println("Set target velocity [rad/s]");
_delay(1000);
}
void loop() {
// open loop velocity movement
// using motor.voltage_limit and motor.velocity_limit
motor.move(target_velocity);
// user communication
command.run();
}