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:
Registers calibration script for TMC drivers. Contribute to eoyilmaz/chopper-resonance-tuner development by creating an account on GitHub.
github.com
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