dzid26 / StepperServoCAN

Closed loop stepper motor controller with CANbus capabilities. This Project open source hardware and code, support platformio build and upload firmware.
https://shop.retropilot.org/product/stepperservocan
19 stars 5 forks source link

High current - stall torque ripples #21

Open dzid26 opened 8 months ago

dzid26 commented 8 months ago

When a high current is commanded (e.g. 3Amp), the torque is choppy. The effect is especially noticeable when coupled with a gearbox - due to springiness/stiction in the gearbox - causing vibration and snapping when backdriving. https://github.com/dzid26/StepperServoCAN/issues/15#issuecomment-1789928695

Precisely, there are 4 torque peaks/troughs per electrical rotation. Some are stronger than others.

dzid26 commented 8 months ago

Calibration was performed with CALIBRATION_TABLE_SIZE 200U to have a point per full step. The variation is less than +/-0.1deg at 3.3A command. Default - double pass.

And single pass, to avoid potential influence of data averaging:

image
OxygenLiu commented 8 months ago

Is it simple feedback closeloop control? Did you check the step response of sPID controller? Probably there is much overshooting and/or ringing.

dzid26 commented 8 months ago

Close loop would refer here to simply using position feedback to precisely set commutation currents based on read position (corrected with calibration table). No PID is involved in torque mode. Basically, we read the angle and apply current based on where we are in between the motor teeth.

Above (the calibration) is done in "open-loop". Full steps are applied - position is read back and stored. This procedure generally should be done without significant load, so we always know what the angle is for given full step (1.8deg * n step). We compare that to position from the sensor and store it in a table. If steps are commanded with high current, the bumps appear in the table. While they don't matter for normal operation (since they are so small), they are an indication that something is happening to angle reading under high current.

I want investigate if that is significant for the issue.

OxygenLiu commented 7 months ago

Calibration was performed with CALIBRATION_TABLE_SIZE 200U to have a point per full step. The variation is less than +/-0.1deg at 3.3A command. Default - double pass.

What is the meaning of variation +/-0.1deg at 3.3A? Is it the difference of calibration table between low and high currents?

Can we use FEMM model to evaluate the influence on encoder readings by phase currents? And place the magnet a bit further away from coils with a plastic gasket.

dzid26 commented 7 months ago

+/-0.1deg refers to those little jumps

image

3.3Amps is the default calibration current. It is high by default to overcome (light) loads on the motor (external gears, etc).

I quickly ran the test:

The torque is still notchy at high current and the periodic noise in the calibration is still present:

image

One more test:

image

Looks and feels the same.

So spacing and magnet strength doesn't seem to matter.

I went back to no spacers. I run it with 1Amp calibration:

image

It's even more pronounced.

The variation doesn't seem proportional to current after all.

I run the same thing but slower to avoid resonances:

image

It is better.

I run it slow again, but with 200mA:

image

Again quite pronounced.

Increased oversampling to 30: image

Oversampling at 300:

image

Oversampling at 0:

image

But the torque ripple feels same.

I am having Déjà vu. Ok, I remember. Oversampling is adding some delay. Without it, the calibration progresses too fast and some resonance shows up.

Again, 0 oversampling, but with 100ms stabilization delay:

image

It's back to where we were.

I am starting to remember that I was trying to figure out this variation in the past... I think it might be just the nonlinearity of the TLE5012b sensor.

I think this variation is too small to explain the choppiness. It's only ~5 electrical deg. Besides, the fact that it shows up in calibration means it would be compensated already.

With the scope measurement of phases current, I can precisely see when the snap occurs in each quadrant. However, the drop is very nonlinear. I am afraid it might be some weird stepper teeth magnetic interaction. I will still investigate.

OxygenLiu commented 7 months ago

Excellent investigation! Some observations and questions,

It seems quite challenging to control the current indirectly through Vref to achieve stable torque output under overloading conditions. Hopefully the voltage control can provide better performance.

dzid26 commented 7 months ago

But 100ms makes calibration slow. Based on testing last year, default oversampling was providing good quick calibration with my motors. I measured how much compute time oversampling takes:

By going this fast, the calibration is basically slow continuous rotation. I think I chose that to avoid mechanical resonances due to stopping and going. There were diminishing returns going slower. And since there are two passes, even if something is lagging it averages itself out.

In any case,

I don't think it's worth pursuing optimizing calibration timing. (Unless some motors have resonance issues).

Whether it looks like this (200 points, 100ms stabilization delay):

image

, or like this (50 samples, 100ms stabilization delay):

image

Filters out all periodic variation.

, or default 50 samples and 0ms stabilization delay (single pass):

image

, or default 50 samples and 0ms stabilization delay (default double pass): image

...it all is indistinguishable during operation. And all of them experience the high torque choppiness.