I’ve just started experimenting with SimpleFOCShield 2.0.4 with an Arduino Uno R4. I downloaded the dev branch of SimpleFOC and installed it in the Arduino IDE.
I am using this motor: BLWS231S-24V-2000
BLWS23 - Brushless DC Motors (anaheimautomation.com)
The motor is 4 poles, with Hall Sensors.
I am trying to run in closed loop velocity mode at 25 rad/sec (aka 250RPM) with no / minimal load. Current required is well within 5A, and should be around 0.2A per phase I think. (at least that is what I see with another controller). Voltage per phase should be pretty low as well, maybe 2-3 Volts. Pretty sure this is all within the capabilities of the SimpleFOCShield.
The code compiles and I get output from the Hall Sensors when I manually move the motor, but the motor does not rotate on its own. Am I missing something in the setup/configuration?
I am using the following code to test:
#include <Arduino.h>
#include <SimpleFOC.h>
// BLDC motor instance BLDCMotor(polepairs, (R), (KV))
BLDCMotor motor = BLDCMotor(2, 6.2);
// BLDC driver instance BLDCDriver3PWM(phA, phB, phC, (en))
BLDCDriver3PWM driver = BLDCDriver3PWM(5, 9, 6);
// position / angle sensor instance HallSensor(hallA, hallB , hallC , pole pairs)
HallSensor sensor = HallSensor(3, 2, 4, 2);
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
void setup() {
Serial.println("Setup Started.");
// USE_EXTERN is default (1k - 5k recommended), change to USE_INTERN if needed
sensor.pullup = Pullup::USE_EXTERN;
// initialize sensor
sensor.init();
// enable Hall effect interrupts
sensor.enableInterrupts(doA, doB, doC);
// link sensor to motor
motor.linkSensor(&sensor);
// pwm frequency to be used [Hz]
//driver.pwm_frequency = 20000;
// set power supply voltage
driver.voltage_power_supply = 19.5;
// set driver voltage limit, this phase voltage
driver.voltage_limit = 20;
// initialize driver
driver.init();
// link driver to motor
motor.linkDriver(&driver);
// set motion control type to velocity
motor.controller = MotionControlType::velocity;
// set torque control type to voltage (default)
motor.torque_controller = TorqueControlType::voltage;
// set FOC modulation type to sinusoidal
motor.foc_modulation = FOCModulationType::SinePWM;
// velocity PID controller
motor.PID_velocity.P = 0.2;
motor.PID_velocity.I = 10;
motor.PID_velocity.D = 0;
// angle / position P controller
//motor.P_angle.P = ;
// set motor voltage limit, this limits Vq
motor.voltage_limit = 12;
// set motor velocity limit
motor.velocity_limit = 100;
// initialize motor
motor.init();
// align sensor and start FOC
motor.initFOC();
Serial.println("Motor ready.");
_delay(1000);
}
void loop() {
// main FOC algorithm function
// the faster you run this function the better
sensor.update();
// display the angle and the angular velocity to the terminal
Serial.print(sensor.getAngle());
Serial.print("\t");
Serial.println(sensor.getVelocity());
motor.loopFOC();
// this function can be run at much lower frequency than loopFOC()
motor.move(25);
}