Trying to close the velocity loop sensorless

zero_electric_angle should always be 0 for the sensorless observer.

I’ve tried velocity mode with it before and got a bit of wobble in the velocity. I didn’t mess with it for very long, and changed to torque mode with voltage_limit acting as a speed setting (no good for a record player). I normally set I to about 10x P and D=0, so next time I’ll try I=0 and see how it goes.

One possibility would be to use closed-loop angle mode and step the target similar to how open-loop velocity does it. I think observer tracks full rotations, so angle mode will probably work. It will go wonky if you keep spinning long enough due to floating point precision, and there’s currently no solution for it, but I wrote a proposal here a while back https://github.com/simplefoc/Arduino-FOC/issues/302

It will probably work better if you use the experimental angle_nocascade mode to bypass the velocity PID entirely. It requires so little modification, I find it easier to edit my local SimpleFOC source rather than trying to merge it from github. Just add the enum for it in FOCMotor.h, and copy the code in BLDCMotor::move. All it does is replace the velocity PID code with current_sp = P_angle(shaft_angle_sp - shaft_angle); if controller is nocascade. The stuff in BLDCMotor::init is non-essential. You can set P_Angle.limit in your setup function (after calling motor.init, else it will be overwritten) to get the same effect.

The PID values for it are totally different than anything else I’ve encountered. Usually velocity P is around 0.05-0.2 and I around 1-10, and angle P around 10-20 and angle I=0. But in nocascade mode, angle P=100 and I=10000.

Just now I tried playing with angle D as well, and for once it actually helps rather than causing chaos. I have it set to 0.25 (I guess than means I should try values like 0.00025 with regular velocity mode), and it smooths out the motion when doing this angle stepping pseudo-velocity mode, so it should be good for your record player. You can reduce P and I to smooth it more. It results in slower response to disturbances, but that’s not an issue in your case. I’m tuning steppers for a CNC machine, so I want very precise positioning and fast response to step/dir signals.

1 Like