Chopper tuning guide - altzbox/Chopper-tuning-guide GitHub Wiki

The project moved to a real programmer :).

https://github.com/MRX8024/chopper-resonance-tuner/tree/main
Installation of the script, macros and creation of graphs are automated. Test times have been optimized.


This is not a Klipper TMC Autotune extension. The method is based on Trinamic manual on behavioral chopper configuration.

  1. Install the script on a host with Klipper.

Create a directory
mkdir scripts.
Copy the script file chopper_plot.py into it.
Go to the scripts directory
cd scripts
Grant permission to run
chmod +x chopper_plot.py.
Install the necessary libraries
sudo apt install python3-pandas python3-numpy python3-tqdm python3-plotly python3-natsort.

  1. Install the macro in Klipper. Copy the file chopper_tune.cfg for a gantry with 2 motors stepper_x and stepper_y or chopper_tune_awd.cfg if you have a gantry configuration with 4 motors: stepper_x, stepper_x1, stepper_y, stepper_y1.
    Write the file in printer.cfg
    [include chopper_tune_awd.cfg].

  2. Connect the accelerometer to the print head.

  3. Calibration.
    4.1 Determine the "resonance" speeds.
    In the Klipper console, enter the command
    DUMP_TMC STEPPER=stepper_x REGISTER=chopconf.
    In the output we get the current parameters of the chopper.
    CHOPCONF: 224181f8 toff=8 hstrt=7 hend=3 tbl=3 tpfd=4 mres=2(64usteps) dedge=1
    Run the macro with your current chopper parameters given by the dump, run_current from printer.cfg and a speed from 20 to 150 mm/s.
    Example:
    img_1

CHOPPER_TUNE_AWD CURRENT_MIN_mA=2000 CURRENT_MAX_mA=2000 TBL_MIN=0 TBL_MAX=0 TOFF_MIN=8 TOFF_MAX=8 HSTRT_HEND_MAX=10 MIN_HSTRT=7 MAX_HSTRT=7 MIN_HEND=3 MAX_HEND=3 MIN_SPEED=20 MAX_SPEED=150 TRAVEL_DISTANCE=150 ITERATIONS=1.

The print head will make runs at the specified speeds in 1mm/sec increments.

At the beginning of the macro execution, the console will display a text with a command of the kind "Use the following command to process the generated files: python3 chopper_plot.py --current_min=2000 --current_max=2000 --tbl_min=0 --tbl_max=0 --toff_min=8 --toff_max=8 --hstrt_hend_max=10 --min_hstrt=5 --max_hstrt=5 --min_hend=5 --max_hend=5 --min_speed=20 --max_speed=150 --iterations=1." It is better to copy it beforehand - it will come in handy for plotting the graph.

After the macro is finished, csv files with accelerometer data for each run will appear in the /tmp/ directory. These files should be processed using a script.
Using the host console, enter the command we copied at the beginning of the macro.
python3 chopper_plot.py --current_min=2000 --current_max=2000 --tbl_min=0 --tbl_max=0 --toff_min=8 --toff_max=8 --hstrt_hend_max=10 --min_hstrt=7 --max_hstrt=7 --min_hend=3 --max_hend=3 --min_speed=20 --max_speed=150 --iterations=1.

Download the interactive_plot.html file from the /tmp/ directory and open it in a browser.
img_2.png

There will normally be 2 peaks on the plot. At speeds around 50mm/s and 100mm/s. These are the "resonance" speeds. We need the lower of these speeds. For example, 55mm/s.
Delete all files from the /tmp/ directory

4.2 Run the macro to search all the chopper variants at the previously selected speed. Check the free disk space on the host. 575MB is required for data.
img_3.png

CHOPPER_TUNE_AWD CURRENT_MIN_mA=2000 CURRENT_MAX_mA=2000 TBL_MIN=0 TBL_MAX=3 TOFF_MIN=2 TOFF_MAX=8 HSTRT_HEND_MAX=10 MIN_HSTRT=0 MAX_HSTRT=7 MIN_HEND=2 MAX_HEND=15 MIN_SPEED=55 MAX_SPEED=55 TRAVEL_DISTANCE=150 ITERATIONS=1.
Data collection will take about 2 hour, the output will be about 1200 csv files. Once the macro is finished, run the script with the parameters from the Klipper console. In our example it is: python3 chopper_plot.py --current_min=2000 --current_max=2000 --tbl_min=0 --tbl_max=3 --toff_min=2 --toff_max=8 --hstrt_hend_max=10 --min_hstrt=0 --max_hstrt=7 --min_hend=2 --max_hend=15 --min_speed=55 --max_speed=55 --iterations=1.

You get a graph like this
img_4.png

In this example, the minimum vibrations are at tbl=0 and toff=8. We enlarge this area.
img_5.png

We select the chopper variant with the minimum magnitude value - these are the chopper parameters we are looking for. It should also be taken into account that with large values of tbl and toff, the chopper frequency decreases, which leads to the appearance of audible noise. You can repeat the procedure with smaller chopper variations, for example, only tbl=0 and toff=8 and search hstrt and hend, but with more iterations. In this case the graph will be plotted against the average results to reduce the influence of mechanical factors on the readings.

I would be grateful if you find me on Discord altzbox#4007 or Telegram @altzbox and send me your plots including the motor model, driver and printer. I want to further optimize the algorithm and create a database with chopper parameters.