Hi, I’m working on an actuator using BLDC motor(24V, 5000rpm bldc motor with hall sensor). Yesterday I found simpleFOC library and i have change some of the connection of controller board and tried to spin.
But when I increased the voltage_limit, motor does not rotate as expected. When voltage 1, motor run very slowly but if I increase voltage 2 or more motor was wrong spinning. Previously I wrote a firmware for this controller, and same motor (using the hall sensor sequence, I made PWM pulse) I achieved 5000 rpm. But I can’t able to make good PID controlled that way I am thinking to use simpleFOC library.
Motor i’m using link
Here’s my test code, and circuit
// BLDC motor & driver instance
BLDCMotor motor = BLDCMotor(2);//13
BLDCDriver6PWM driver = BLDCDriver6PWM(13, 4, 11, 12, 10, 9); //( UH,UL,VH,VL,WH,WL) (3, 8, 2, 7, 5, 6) 13, 4, 11, 12, 10, 9
HallSensor sensor = HallSensor(A10, A9, A8, 2);//13
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
// software interrupt
PciListenerImp listenA(sensor.pinA, doA);
PciListenerImp listenB(sensor.pinB, doB);
PciListenerImp listenC(sensor.pinC, doC);
float target=1.0;
void getCommand()
{
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') {
target = received_chars.toFloat();
Serial.print("Tar= "); Serial.println(target);
// reset the command buffer
received_chars = "";
}
}
}
void setup() {
Serial.begin(115200);
sensor.pullup = Pullup::EXTERN;
sensor.init();
// software interrupts
PciManager.registerListener(&listenA);
PciManager.registerListener(&listenB);
PciManager.registerListener(&listenC);
motor.linkSensor(&sensor);
// power supply voltage
// default 24V
//driver.pwm_frequency = 32000;
driver.voltage_power_supply = 24;
driver.voltage_limit = 24;
driver.dead_zone = 0.05;//0.2 // 5%
driver.init();
//link to the drive
motor.linkDriver(&driver);
// limiting motor movements
motor.voltage_limit = 3; // [V]
motor.velocity_limit = 300; // rad/s 1 RPM = 0.10472 rad/s
motor.voltage_sensor_align = 1;
// open loop control config
motor.controller = ControlType::voltage;
motor.useMonitoring(Serial);
// init motor hardware
motor.init();
motor.initFOC();
Serial.println(">setup");
_delay(1000);
}
void loop() {
getCommand();
motor.loopFOC();
motor.move(target);
motor.monitor();
}