I ran this modified version of âopen_loop_velocity_exampleâ and experimented with various pole counts. The motor will run with values of 1 through 17 with the speed increasing with greater pole counts. Above 17 and the motor shakes. Hence, I should be able to use a value of 11 from the earlier tests.
[quote="program"]
// Open loop motor control example
#include <SimpleFOC.h>
// BLDC motor & driver instance
BLDCMotor motor = BLDCMotor(11);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
void setup() {
driver.voltage_power_supply = 12;
driver.init();
motor.linkDriver(&driver);
motor.voltage_limit = 3; // rad/s
motor.velocity_limit = 20; // rad/s
motor.controller = ControlType::velocity_openloop;
motor.init();
Serial.begin(57600);
Serial.println(âMotor ready!â);
_delay(1000);
}
float target_velocity = 13; // rad/s should be about 2 rotations per second
int pole_pair = 11; // start value
void loop() {
motor.move(target_velocity);
serialReceiveUserCommand();
}
void serialReceiveUserCommand() {
static String received_chars;
while (Serial.available()) {
char inChar = (char)Serial.read();
received_chars += inChar;
if (inChar == â\nâ) {
// change the motor poles
pole_pair = received_chars.toInt();
Serial.print("pole pair ");
Serial.println(pole_pair);
// reset the command buffer
received_chars = "";
motor.move(0);
motor.pole_pairs = pole_pair;
motor.init();
}
}
}
[/quote]