Hello everyone, im afraid ive hit another roadblock and have to ask for help from the experts again.
Using a custom driver board with an stm32f401, as5600 and one of two motors. The smaller of the two, a cheap 5010 with 7 pole pairs, 750kv and 0.24ohms reaches a speed of 60rad/s, but a bigger one, the dji e2000 only gets to 10rad/s, both in closed and open loop modes, and doesnt seem to react to changes either in voltage or current limits, at least until they’re so low it cant maintain that 10rad/s.
Current never gets far above 3.5amps, despite everything being capable and hol;ding 20amps with the smaller motor, and voltage q seems to sit at the voltage limit, without impacting the motor.
Ive excluded the possibility of the motor being faulty by running it with a open loop drone esc, with which it easily spins far faster.
Im aware more poles means lower speed if its the loop speed thats limiting it, but i cant imagine jumping from 7 to 10 poles would mean 6 times more load on the mcu.
I have no idea what could be causing this issue. The math, at least with my shoddy skills, says it should get far above that.
Attached is the code and schematics of the driver(on which i know the mcu pins assigned to the low side phases wont work, this is fixed with some bodge wires on the real board.)
#include <AS5600.h>
#include <Wire.h>
#include <SimpleFOC.h>
unsigned long timeSinceLastPrint = 0;
BLDCMotor motor = BLDCMotor(10);
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8,PA7, PA9,PB0, PA10,PB1, PA15);
LowsideCurrentSense current_sense = LowsideCurrentSense(0.0025, 10, PA5, PA4, PA3);
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
AS5600 as5600(&Wire);
Commander command = Commander(Serial);
void onMotor(char* cmd){ command.motor(&motor,cmd); }
void setup() {
// put your setup code here, to run once:
SimpleFOCDebug::enable(&Serial);
command.add('M',onMotor,"my motor motion");
pinMode(PA8, OUTPUT);
pinMode(PA9, OUTPUT);
pinMode(PA10, OUTPUT);
pinMode(PA15, OUTPUT);
digitalWrite(PA15, HIGH);
Serial.begin(115200);
motor.useMonitoring(Serial);
motor.monitor_start_char = 'M';
motor.monitor_end_char = 'M';
SimpleFOCDebug::enable(&Serial);
command.verbose = VerboseMode::machine_readable;
driver.voltage_power_supply = 12;
driver.voltage_limit = 1;
driver.pwm_frequency = 20000;
driver.init();
motor.linkDriver(&driver);
current_sense.linkDriver(&driver);
motor.linkCurrentSense(¤t_sense);
if (current_sense.init()) Serial.println("Current sense init success!");
else{
Serial.println("Current sense init failed!");
return;
}
command.add('M',onMotor,"my motor motion");
motor.current_limit =3;
motor.controller = MotionControlType::angle;
motor.phase_resistance = 0.23;
motor.phase_inductance = 0.224;
motor.torque_controller = TorqueControlType::foc_current;
motor.KV_rating = 130;
motor.velocity_limit = 2000;
motor.linkSensor(&sensor);
motor.P_angle.P = 10;
motor.PID_velocity.P = 0.39;
motor.PID_velocity.I = 10,5;
motor.PID_velocity.D = 0;
motor.PID_current_q.P = 0.6;
motor.PID_current_q.I = 300;
motor.PID_current_q.D = 0;
motor.PID_current_q.limit = 10;
motor.PID_current_d.P = 1;
motor.PID_current_d.I = 300;
motor.PID_current_d.D = 0;
motor.PID_current_d.limit = 2;
motor.monitor_variables = NULL; // default _MON_TARGET | _MON_VOLT_Q | _MON_VEL | _MON_ANGLE
motor.monitor_downsample = 100; // default 10
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
Wire.begin();
uint8_t as5600_addr = 0;
int control_reg_0, control_reg_1;
as5600.begin();
int b = as5600.isConnected();
control_reg_0 = as5600.getConfigure();
as5600.setConfigure(0x1f00); // fast filter
control_reg_1 = as5600.getConfigure();
as5600_addr = as5600.getAddress();
motor.init();
sensor.init();
motor.initFOC();
Wire.setClock(1000000);
//current_sense.gain_a *=-1;
//current_sense.gain_b *=-1;
//current_sense.gain_c *=-1;
}
void loop() {
// put your main code here, to run repeatedly:
uint32_t start = _micros();
motor.loopFOC();
motor.move();
command.run();
motor.monitor();
uint32_t end = _micros();
static uint32_t lastPrintTime = 0;
if(millis() - timeSinceLastPrint > 500) {
timeSinceLastPrint = millis();
Serial.println(1000000 / (end - start));
}
}




