How to sweep thru angle control smoothly?

I have a GBM5208-200T motor connected to V2.0.4 simpleFOC. I need to be able to sweep my gimbal motor thru an arc smoothly using the serial commander. I have written test code to iterate thru a series of serial messages commanding position e.g. T0.01, T0.02, T0.03, … etc but the motion is jerky and at times unresponsive.

How can I sweep thru angles accurately.

Thanks in advance,
L

By smooth you mean at constant speed from the first to the last angle without stops at the individual angles? If yes, then why not move straight to the last angle, which would then also cover all the angles in between? Probably I misunderstand your question…

Is there a way to moderate the speed of transit when moving to an endpoint? Right now the axis moves at the max speed from point A to point B. You describe the action I wish but I don’t know how to do it over the serial command channel. Any help is appreciated.

L

Set motor.velocity_limit to the maximum velocity you want. If the acceleration is still too jerky, reduce motor.P_angle.P and it will make smoother starts and stops.

You can see how to set up commands in the docs and examples.

Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }

void setup() {
...
  command.add('T', doTarget, "target angle");
...
}

You can create more functions to set different variables, and add them to the commander in setup().

Turns out it was a combination of my limited knowledge of python float math and not reading the manual. RTFM gets me every time. Thanks for the replies.

L