Hey there,
I’m very new to this. I have similar issues as to what I’ve found here https://community.simplefoc.com/t/as5600-gbm2804h-100t-not-working-in-closed-loop-vibrating-or-idling/3688
but dont see what I can do. I have tied the DIR-pin of my AS5600 board to GND, I get good readings when printing the angle using serial. I’m using the SimpleFOC configuration tool.
The moment I enable the motor, the current draw is ~600mA, independent of any setpoint.
I can then use open loop angle and velocity control modes, and the work. At some point the motor gets really hot and I stop things, it seems I’m getting some overload shutdown as I can’t control it afterwards unless I let it cool down and reset the ESP32.
When trying velocity control nothing happens until I spin the motor by hand, it then goes rather stuttering about, and I don’t have the impression a set point change has any real effect.
Angle isn’t working at all.
My code is pretty straightforward:
// mode: c++-mode
#include <SimpleFOC.h>
#define ENABLE 15
#define IN3 2
#define IN2 4
#define IN1 25
#define SDA 22
#define SCL 23
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
BLDCMotor motor = BLDCMotor(14);
BLDCDriver3PWM driver = BLDCDriver3PWM(IN1, IN2, IN3, ENABLE);
Commander commander = Commander(Serial, '\n');
void onTarget(char* cmd){ commander.motion(&motor, cmd); }
void onMotor(char* cmd){ commander.motor(&motor, cmd); }
void setup() {
Serial.begin(115200);
Serial.print(F("setup"));
Wire.setClock(400000);
Wire.begin(SDA, SCL);
sensor.init(&Wire);
driver.voltage_power_supply = 12;
driver.init();
motor.controller = MotionControlType::angle;
motor.PID_velocity.P = 0.2;
motor.PID_velocity.I = 2;
//default voltage_power_supply
motor.voltage_limit = 6;
motor.LPF_velocity.Tf = 0.02;
motor.P_angle.P = 2;
motor.velocity_limit = 2;
motor.linkSensor(&sensor);
motor.linkDriver(&driver);
motor.init();
// align encoder and start FOC
motor.initFOC();
motor.useMonitoring(Serial);
commander.add('T', onTarget, "motion control");
commander.add('M', onMotor, "motor control");
motor.monitor_downsample = 0; // disable monitor at first - optional
}
void loop() {
// Serial.print(F("angle: "));
// Serial.print(sensor.getSensorAngle());
// Serial.print(F("\r\n"));
motor.loopFOC();
motor.monitor();
motor.move();
commander.run();
}
This is the simple foc config tool view:
Any suggestions very welcome.