Open dzid26 opened 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:
Is it simple feedback closeloop control? Did you check the step response of sPID controller? Probably there is much overshooting and/or ringing.
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.
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.
+/-0.1deg refers to those little jumps
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:
One more test:
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:
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:
It is better.
I run it slow again, but with 200mA:
Again quite pronounced.
Increased oversampling to 30:
Oversampling at 300:
Oversampling at 0:
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:
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.
Excellent investigation! Some observations and questions,
The +/- 0.1 deg variation does beyond average stepper accuracy +/- 0.027 deg (+/- 1.5% of 1.8deg). Is it meaning a poor build quality of the stepper motor you are testing? Once the accumulated error when backdriving is larger than half step (0.9 deg), the commanded current may flip the direction, and then the torque snaps.
The calibration variation seems quite senstive to the stablization delay (100ms). Is it because of the coil inductance? The stepper I have is specified as 3 ohm and 5.1mH, thus the time constant is t = 5.1mH/3ohm = 1.7ms. It may take 4*t = 6.8ms to reach the target current, and another 6.8ms in slow delay mode to zero. The stablization delay of 100ms is certainly sufficient even including resonance.
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.
and if we go faster (no oversampling which slows down the routine and no explicit delay) then it looks like this
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.
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):
, or like this (50 samples, 100ms stabilization delay):
Filters out all periodic variation.
, or default 50 samples and 0ms stabilization delay (single pass):
, or default 50 samples and 0ms stabilization delay (default double pass):
...it all is indistinguishable during operation. And all of them experience the high torque choppiness.
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.