Hi all,
Here is my first test of this great library. Open loop mode with ESP32 and a quite big Gimbal BLDC 24 poles motor.
See the result here :

As you can see I feed the motor with 2A 12V
code is a merge of examples from the lib :
/**
* ESP32 open loop control example sensorless
*/
#include <SimpleFOC.h>
float target_velocity = 0; // rad/s
// Motor instance
// BLDCMotor( pin_pwmA, pin_pwmB, pin_pwmC, pole_pairs, enable (optional))
BLDCMotor motor = BLDCMotor(25, 26, 27, 12);
void setup() {
// power supply voltage
// default 12V
motor.voltage_power_supply = 12;
// choose FOC modulation (optional)
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
// set motion control loop to be used
motor.controller = ControlType::velocity_openloop;
// contoller configuration
// default parameters in defaults.h
// maximal voltage to be set to the motor
motor.voltage_limit = 7;
motor.velocity_limit = 50;
// use monitoring with serial
Serial.begin(115200);
// comment out if not needed
motor.useMonitoring(Serial);
// initialize motor
motor.init();
Serial.println("Motor ready.");
Serial.println("Set the target velocity using serial terminal:");
_delay(1000);
}
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 = "";
}
}
}
It works really well, but as it is in open loop the motor ends by loosing the sync and stalls.
I canāt bear waiting for my magnetic sensor to come from Chinaā¦
I would be really interested in helping if current sensing mode would be developped.
Thanks for all teh efforts done in this lib
JP