TMC Adaptive Microstep Table

Okay, I made the stepper input shaper, snapshot branch is here: GitHub - nefelim4ag/klipper at stepper-shaper-20250112

So, basic approach for now:

  • Assume there are patterns at a stepper step level
  • It should be synced into steps
  • Shift around step timings to compensate for that pattern

Cause it is stepper and stepper phase-specific, it is done after input shaper and iter solver, just before step compress kicks in.
So, it is defined and tuned per stepper.

It is PoC, I think there at least should be some speed-related transformations and tuning.

I specifically used this to test cause I think it is easier to cancel out:


It is TMC2240 + offset90, so there are peaks on even full steps, and odd full steps are slightly shorter and weaker.
(also there is max_stepper_error: 0.0000025 at MCU, to force step compress to follow my small adjustments because otherwise there is something similar to meander)
There are parabolic functions underneath, and 3 params: period, amplitude, and offset.
Assume the first half and second half are the same here, so period = 512.
Offset is the virtual middle point, the middle point should be stretched and corners compressed.
Offset is where the most amplitude lies. 3/4 ~ 384 should fit.
Amplitude is multiplayer here, to control the power of changes.

I specifically chose the noisy piece of graph, where the motor seems to resonate, and do several iterations changing params till it looks better.

There are period 512, amp: 10, offset: 384

There are amp: 5, offset: 360

On lower speeds - there are no changes so far

Let’s try a different one, there are the same registers, but offset90 is disabled.
It looks just noisy and I’m not sure it can be canceled that simple, like there is a little difference between high/low.

First attempt, there are compression artifacts, Let tune max_stepper_error

Second, with `max_stepper_error: 0.000001`

Third, increased amplitude, not much success, only one peak is canceled

Fourth, no difference:

This is how it currently behaves with the current input shaper (btw, the stepper shaper lost sync here):


I don’t like things where there are a lot of configurations, it sounds like:
“If you don’t know how to configure it, how is the user supposed to do so?”

So, for now, this is completely dev/experimental stuff.
I think if I anyway compute the array to shift around step points, maybe I can do the same with the use of accelerometer data, screw the micro steps, and we have a repeated pattern, technically with this, it is possible to feed the opposite signal literally.

There are samples from different speed ranges, and there are different patterns, but they are similar to each other



I use sinf() to generate values, 2 sin rotations per 4 full steps. shifted by 128 (1/4) to make it opposite to vibration profile:

This one looks amazing

Also good

Medium speeds just got a little worse

2 Likes