What's new
VORON Design

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members!

Klipper TMC Autotune

Looks like an interesting extension!

At face value, it sounds awesome. However, the official Klipper documentation warns against changing currents or modes on-the-fly as it can introduce positioning errors, reduce torque, or even lead to increased motor heating. So those are things you would want to be aware of.

Klipper docs for reference:
 
Has anyone used this? https://github.com/andrewmcgr/klipper_tmc_autotune
Looks very interesting but for me it lacks examples, instructions and just how to use it.

If someone is using it can they explain this to me and extrapolate on the script?
Just add into your config ( for example )

[autotune_tmc stepper_x] //section for what stepper you will use it
motor: ldo-42sth48-2004mah // type of stepper what you have

you can also add additional parametrs from listed ones on github
like

[autotune_tmc stepper_x] //section for what stepper you will use it
motor: ldo-42sth48-2004mah // type of stepper what you have
sg4_thrs: 80 //for TMC2209 sensorless homing - read note on GitHub - > homing_speed should be numerically greater than rotation_distance for those axes using sensorless homing

And that's all you need to do.

So far no issues at all, steppers are quiter than before. Just saves you from calculating parametrs by you ( and excel ) , you can manually do that and add it in your printer config, After that you wont need this scipt at all.
 
Just add into your config ( for example )



you can also add additional parametrs from listed ones on github
like



And that's all you need to do.

So far no issues at all, steppers are quiter than before. Just saves you from calculating parametrs by you ( and excel ) , you can manually do that and add it in your printer config, After that you wont need this scipt at all.
Can you show me a real example of the config? Not pulled from the github?
Where do you see the outcome from the tune so you can add the parameters to your config?
 
I have this for AB steppers
[autotune_tmc stepper_x]
motor: tmc-qsh4218-51-10-049
sgt: 2
voltage: 48

[autotune_tmc stepper_y]
motor: tmc-qsh4218-51-10-049
sgt: 2
voltage: 48

Where you can see it? Well, on SPI / UART bus or on oscilloscope ( if you know how ). Otherwise you can't.
That plugin is just simplified whole TMC tuning . It will ( simply said ) fill all TMC parameters for you. Like if you take TMC tuning xls sheet, fill all values and add them in your printer config.

Like ( just random code from internet with real values, not related to my config ! )

[tmc2209 stepper_x]
uart_pin: PE7
interpolate: False
stealthchop_threshold: 0
sense_resistor: 0.110
run_current: 0.976
driver_TBL: 1
driver_TOFF: 3
driver_HSTRT: 0
driver_HEND: 3

I hear it ( less noise from steppers - same as if i use that xls and fill values manually). At least from what i recognized intermediately.
 
Ohhhhhh, I get it now. It's not Auto Tuning, it's just auto setting the parameters that are default.
Well, that is a little disappointing. I thought it was going to go through all settings testing them. It can still be useful, just not what I was hopping for.
 
Well there won't be too many options for static parameters . Like for one specific stepper with one specific current you end up with just one set of specific numbers. They would change slightly with current but not that much ( atleast from my experience ).
But it is autotuning in some way because it will do all that math for you, default parametrs are different from what this will use. It wil automaticly tune parameters for given stepper and current, so that's why autotune.

Full automatic testing all parametrs ( include current ) will require some additional measuremets ( and sensors ) i'm affraid. As far as i think with my very limited knowledge.
 
I had a little time to mess with it this afternoon, and it seems to work fine on Z and extruder for me, I cannot get it to work with my XY motors. I use sensorless homing with 2209's and ldo-42sth48-2804ah motors and its not playing nice all together. I cannot get the motors to trigger when homing. I get the error, no trigger after full movement and I tried going with a high and low trigger value from my default of 60.
 
I had a little time to mess with it this afternoon, and it seems to work fine on Z and extruder for me, I cannot get it to work with my XY motors. I use sensorless homing with 2209's and ldo-42sth48-2804ah motors and its not playing nice all together. I cannot get the motors to trigger when homing. I get the error, no trigger after full movement and I tried going with a high and low trigger value from my default of 60.
I have same issue. My X with sgt: 1 works. But on Y just crashes into Y. When I remove autotune but work on sgt: 1
 
It also doesn't work (does nothing) with my LDO motors:
Code:
[autotune_tmc stepper_x]
motor: ldo-35sth52-1504ah

[autotune_tmc stepper_y]
motor: ldo-35sth52-1504ah

[autotune_tmc stepper_z]
motor: ldo-42sth25-1004cl200et

[autotune_tmc extruder]
motor: ldo-36sth20-1004ahg
interpolate: true or false with no difference. All of these are present in the database. Do I miss something?
 
It also doesn't work (does nothing) with my LDO motors:
Code:
[autotune_tmc stepper_x]
motor: ldo-35sth52-1504ah

[autotune_tmc stepper_y]
motor: ldo-35sth52-1504ah

[autotune_tmc stepper_z]
motor: ldo-42sth25-1004cl200et

[autotune_tmc extruder]
motor: ldo-36sth20-1004ahg
interpolate: true or false with no difference. All of these are present in the database. Do I miss something?
You have to set the type of tuning you want per motor.
Like the following:
####################
# T M C A U T O T U N E
####################
[autotune_tmc stepper_x]
motor: omc-17hs19-2004s1
tuning_goal: performance

[autotune_tmc stepper_y]
motor: omc-17hs19-2004s1
tuning_goal: performance

[autotune_tmc stepper_z]
motor: omc-17hs19-2004s1
[autotune_tmc stepper_z1]
motor: omc-17hs19-2004s1
[autotune_tmc stepper_z2]
motor: omc-17hs19-2004s1
#[autotune_tmc stepper_z3]
#motor: omc-17hs19-2004s1

[autotune_tmc extruder]
motor: fysetc-g36hsy4405-6d-80a

The tuning goals are:

auto, silent, performance, and autoswitch but autoswtich isn't advised per the manual - too experimental.
 
You have to set the type of tuning you want per motor.
Like the following:
####################
# T M C A U T O T U N E
####################
[autotune_tmc stepper_x]
motor: omc-17hs19-2004s1
tuning_goal: performance

[autotune_tmc stepper_y]
motor: omc-17hs19-2004s1
tuning_goal: performance

[autotune_tmc stepper_z]
motor: omc-17hs19-2004s1
[autotune_tmc stepper_z1]
motor: omc-17hs19-2004s1
[autotune_tmc stepper_z2]
motor: omc-17hs19-2004s1
#[autotune_tmc stepper_z3]
#motor: omc-17hs19-2004s1

[autotune_tmc extruder]
motor: fysetc-g36hsy4405-6d-80a

The tuning goals are:

auto, silent, performance, and autoswitch but autoswtich isn't advised per the manual - too experimental.
Sorry for the resurrection but I was looking at this and didn’t see where it said to add the goals into the .cfg.
 
Hi all,

I re-implemented the chopper-resonance-tuner as a Klipper Extension and added some very nice features:
  • Implemented an optimizer that doesn't require you to search the whole register value combinations. Running iterations=2 on an axis takes around 10-15 minutes (under 200 samples), compared to 10+ hours (+6500 samples) with the original GCode Macro implementation, and I still get lower than 0.5% percentile results (I can consistently hit the best 20-30 results out of 6500 samples of the brute force method).
  • For CoreXY printers, my tool does the tests along the A/B logical axis and isolates the A/B motors (compared to the original one where it triggers two of the steppers and sets the register values for the 2 steppers at the same time).
  • Because my implementation is directly interacting with Klipper, it doesn't require the accelerometer data to be saved to a CSV file and it doesn't have any memory requirement, where as the GCode Macro version requires ~700 MB space in /tmp, which depends on your printer's RAM and might crash your printer as it will consume all the memory.
  • I added a 4th order Butterworth filter, so the high frequency noise is filtered from the accelerometer data, and also I trim the data based on the percentile (20-80%) (instead of the start and end of the sequence), which increases the consistency and again removes a lot of high frequency noise and disturbances caused buy the tool starting or stopping movement.
  • For an axis both directions can be tested separately (- -> + or + -> -), compared to only one direction of the original tool (i.e. - -> +).
  • My implementation offers the config values to be saved with SAVE_CONFIG at the end of the measurement.
  • Because the tool is written in Python, the graph generation also happens inside the chopper tune class, and it is very fast compared to the original, as I don't re-parse any CSV values.
Limitations:
  • I think I limited the code to work just with ADXL345 accelerometer. But I might fix it soon.
  • It adds a couple of dependencies like: scipy, matplotlib etc.
  • Oh, it might require Python 3.9+, but if this becomes a huge problem, I can go as low as Python 3.8 (not sure about Python 3.7). my printers are running Python 3.9 and 3.11.
  • As far as I understand and measure correctly, the extension uses around 50-60 MB of memory, as I need to import Python libraries like numpy and scipy. I don't mind this, but if you do, after the optimization, just comment the "[include chopper_tune.cfg]" section in your printer.cfg.
Here is the repo:


It is used exactly the same way the original GCode Macro version is used, but just has some aditional arguments. To trigger the adaptive optimization set SEARCH_METHOD=adaptive to the command, and the FIND_VIBRATIONS=1 is renamed to FIND_RESONANCES=1 as it better reflects the action:

CHOPPER_TUNE AXIS=X FIND_RESONANCES=1

and then the tool will report the speed where the most highest accelerations are recorded, do your test on that speed or any other peak values that you see on the graphs.

CHOPPER_TUNE AXIS=X ITERATIONS=2 MIN_SPEED=175 MAX_SPEED=175 DIRECTION=1 SEARCH_METHOD=adaptive

I tested it with my Sovol SV08 and Ender 3 Pro. Both are using the same LDO stepper motors. Surprisingly, the accelerometer inside the SV08 produces more noise than the one I attach to the Ender3.

Anyways, please use the tool, and if you have any issues just report in https://github.com/eoyilmaz/chopper-resonance-tuner/issues

I'm currently actively developing the tool and also created a PR to Maxim's repository, but I'm not sure if he'll ever merge my code or not.

Enjoy

Erkan Ozgur Yilmaz
 
Yeah I saw these commits posted on Github. Some very nice improvements. I will be testing them soon.
 
Top