I am using the SimpleFOCShield with a Nucleo64 STM board. And a 2048 step encoder.
I can get the motor to run very well in open loop mode at slow speeds (around 3rad/s). I managed to get it sort of working with closed loop velocity mode using:
velocity.P=0.15f;
Velocity.I=45.0f;
Questions:
I am having trouble with velocity.D. If I set it to anything other other than Zero (like 0.0001 or 0.005), it causes some high pitched screetch in my motor.
the motor is very erratic at startup, moving wildly back and forth before finally heading towards the target speed. Should I use the voltage ramp to correct this? Or is there a way to start in open loop in the init() function for 5 sec and then shift to closed loop in the loop() function?
at this low speed, so far open loop is giving me better speed stability than closed loop. Can I expect to better the open loop steady state speed stability with proper fine-tuning? My load is about 3kg flywheel with very low resistance.
Would you mind sharing the code you’re testing with?
The D term is usually left at zero. Is the torque voltage mode working well? You should make sure this mode is working well before proceeding to velocity mode…
You mean after the calibration, when starting from zero velocity?
Yes , at startup it moves back and for erratically before settling into the velocity loop. Is that the calibration tho? Is it possible to save the calibration settings so that it starts cleanly each time?
You are right, I skipped over the torque loop tuning. I got intrigued when speed loop mostly worked the first time I tried with this motor. Let me go back and dial that torque mode in first before revisiting.
And I will keep velocity.D at zero.
Also, great work on the SimpleFOC project. It is awesome. I previously tried a Solo Motor Controller, but basically tossed it as I could not get it to work with any of my motors. SimpleFOC is far easier to use.
Print the electrical zero with 3 or 4 decimal places (motor.zero_electric_angle) and the native direction (motor.sensor_direction) after the calibration runs (that’s during motor.initFOC()) and pass these values to initFOC like this:
motor.initFOC(zero_angle, direction);
Note that if you change your setup, in particular if you detach the motor and/or the sensor you’ll have to recalibrate.