Hi there,
I’m trying to tune the parameters for controlling a small (35cm diameter ~100kv) gimbal motor.
Open loop velocity works. Sensor (PWM) is noisy but works and gives reasonable values.
But Closed loop controls are very weird.
I’m very new to simpleFOC / FOC and electronics in general. So any help / tip would be appreciated.
Velocity OpenLoop (Working) : https://youtu.be/R0iWiCJPCEg
Angle Closed Loop (Not Working ) : https://youtu.be/Qii1fvOAYJw
Torque Closed Loop (Not working ) : https://youtu.be/A69SmBep4cM
Thanks so much in advance!
Edit: Just noticed that none of the parameters are actually visible in the video due to poor quality recording.
Essentially for torque control I’ve set the PID parameters to all 0, (I think in the video the I gain is actually 3 but I’ve tried many combinations including the default).
For the other PID values I’ve also tried many combinations. Starting with setting all to 0 (which I would expect that angle control etc will just not do anything? But the large oscillation still exists)
I’ve tried to eliminate the error being the weird new UI I’m using by writing the arduino code:
Problem is still the same though.
void setup_torque_test(){
// initialize encoder sensor hardware
sensor.init();
sensor.enableInterrupt(doPWM);
// link the motor to the sensor
motor.linkSensor(&sensor);
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 10;
driver.init();
// link driver
motor.linkDriver(&driver);
// aligning voltage
//motor.voltage_sensor_align = 5;
// set motion control loop to be used
motor.torque_controller = TorqueControlType::voltage;
motor.controller = MotionControlType::torque;
// add current limit
//motor.phase_resistance = 3.52; // [Ohm]
//motor.current_limit = 0.5; // [Amps] - if phase resistance defined
motor.PID_current_d.P = 0;
motor.PID_current_d.I = 0;
motor.PID_current_d.D = 0;
motor.PID_current_q.P = 0;
motor.PID_current_q.I = 0;
motor.PID_current_q.D = 0;
// use monitoring with serial
Serial.begin(115200);
// comment out if not needed
motor.useMonitoring(Serial);
// initialize motor
motor.init();
// align sensor and start FOC
motor.initFOC();
// set the initial motor target
// motor.target = 0.2; // Amps - if phase resistance defined
motor.target = 2; // Volts
// add target command T
// command.add('T', doTarget, "target current"); // - if phase resistance defined
command.add('T', doVoltageTarget, "target voltage");
Serial.println(F("Motor ready."));
Serial.println(F("Set the target using serial terminal:"));
_delay(1000);