Driver has up to 256 microsteps, so up to 200 * 256 = 51200 of possible data points.
The Encoder has a resolution of 15 bit = 32768 positions.
(I decreased hysteresis to 0.003 degrees, so it can be noisy)
I modified the angle.py
a little, to sample each microstep 0…1023,
Export to JSON & etc.
In the end, I sampled 4 full steps, as before.
Export dicts like:
#mscnt, angle data
0: [128, 128, 127]
1: [129, 129, 128]
...
Made some computations to calculate mean angle, and extract diffs in angle for diffs in mscnt.
And convert it to um for easy reading (in the end we want to compare distance :D, right?)
I calculate stddev for each mscnt and use max one.
# For 128 microsteps
Maximum Standard Deviation across all (in degrees): 0.01083
# For 64 microsteps
Maximum Standard Deviation across all (in degrees): 0.011075156035949418
# for reference 1.8 / 256 = 0.00703
There are some graphs,
Y axis is um, X one is MSCNT as before.
I don’t want to be too optimistic, but it looks better than I expected.
Maybe it is a wrong assumption, that the encoder has better linearity than the stepper motor, but it looks like so, and it is good that the output is matched to previous graphs.
Now, I think about how to automate table tuning.
I think a good approach here will be to use direct_mode and the XTARGET interface to drive motor current directly to specific micro steps.
Those should allow us to get theoretically “perfect” sine wave for a specific motor and current for specified micro steps.
And later interpolate, encode, and validate it.
At least, I think so.
I can’t get direct_mode working.
To my surprise, full steps are also not equidistant.
I expected that at least the angle between 0, 255, 512, and 1023 would be around 1.8 ± 1%.
But in fact, it is like this:
Full Step 0 Angle expected: 1.800, actual: 1.697
Full Step 1 Angle expected: 1.800, actual: 1.839
Full Step 2 Angle expected: 1.800, actual: 1.807
Full Step 3 Angle expected: 1.800, actual: 1.829