Hello Everyone
Wondering if someone could give me some pointers on why I am unable to get my motor to spin in open-loop velocity control. The physical connection is correct, as I am able to profile the motor in the stm motor profiler.
-I am using Arduino IDE
-I am able to upload code to b_g431esc (blinky LED)
-I am able to read the hall sensors on my BLDC motor.
-Running my code is applying current to motor phases, locking it up in position.
- I have my PSU set to 24v, 0.1A (these were sufficient for getting the stm motor profiler to work)
- maxon motor, unknown actual datasheet, but I have general specs, 30W motor
The next thing I would do unless someone has a better suggestion is try to verify the PWM signal getting to the phases. I don’t have an oscilloscope tho.
Code :
#include <SimpleFOC.h>
// void setup() {
// pinMode(PC6, OUTPUT);
// Serial.begin(115200);
// // Serial.println(“Motor ready!”);
// // Serial.println(“Set target velocity [rad/s]”);
// delay(3000);
// }
// void loop() {
// digitalWrite(PC6, HIGH);
// delay(2000);
// digitalWrite(PC6, LOW);
// delay(3000);
// Serial.println(“Hello World”);
// }
BLDCMotor motor = BLDCMotor(8, 6.0); //6.28
BLDCDriver6PWM driver = BLDCDriver6PWM(A_PHASE_UH, A_PHASE_UL, A_PHASE_VH, A_PHASE_VL, A_PHASE_WH, A_PHASE_WL);
HallSensor sensor = HallSensor(A_HALL1, A_HALL2, A_HALL3, 8);
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
//float target = 10; //[rad/s]
// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&motor.target, cmd); }
void setup() {
// // put your setup code here, to run once:
Serial.begin(115200);
// Sensor Init:
sensor.init();
sensor.enableInterrupts(doA,doB,doC);
sensor.velocity_max = 1000; // 1000rad/s by default ~10,000 rpm
// // driver config
// // power supply voltage [V]
driver.voltage_power_supply = 24;
driver.voltage_limit = 2; // limit the source voltage because it heats up
driver.pwm_frequency = 20000;
driver.init();
//link the motor and the driver
motor.linkDriver(&driver);
// limiting motor current (provided resistance)
motor.current_limit = 0.5; // [Amps]
motor.voltage_limit=2;
motor.voltage_sensor_align=1;//not needed until closed loop
//motor.velocity_limit = 100; // [rad/s]
// open loop control config
motor.controller = MotionControlType::velocity_openloop;
//init motor hardware
motor.init();
//motor.initFOC();
//add target command T
command.add(‘T’, doTarget, “target velocity”);
//command.add(‘C’, doLimitCurrent, “current limit”);
Serial.println(“Motor ready!”);
Serial.println(“Set target velocity [rad/s]”);
//Serial.println(“Sensor ready”);
_delay(5000);
}
void loop() {
// put your main code here, to run repeatedly:
//motor.loopFOC();
// open loop velocity movement
// using motor.current_limit and motor.velocity_limit
motor.move();
// motor.move(analogRead(A_POTENTIOMETER));
// // user communication
command.run();
// // sensor test:
sensor.update();
// // display the angle and the angular velocity to the terminal
//Serial.print(sensor.getAngle());
//Serial.print(“\t”);
//Serial.println(sensor.getVelocity());
// delay(100);
}