Added more specific config/macro min/max values Removed more un-needed variables Added TEST_ATTEMPTS, to test again if it fails Added 1 to accel/step count so it maxes at your _STOP Cleaned up console output Added times to pattern to show time delta for different accel/velocities Added _calc_velocity to calculate maximum velocity given accel Added _calc_accel to calculate maximum accel given velocity Added _calc_travel to calculate maximum travel distance Re-implemented hard-coded _START values
Klipper Auto Speed
Klipper module for automatically calculating your printer's maximum acceleration/velocity
This module is under development: Nothing should go wrong, but please keep an eye on your printer, as this will push it to it's physical limits.
This module automatically performs Ellis' TEST_SPEED macro, and measured the missed steps on your steppers at various accelerations/velocities. Depending on your ACCEL_START and VELOCITY_START, this may take a long time to finish.
Sensorless homing: If you're using sensorless homing you may find that MAX_MISSED=1.0 is too low. the endstop variance check will tell you how many steps you lose when homing. For instance, on my printer I lose around 0-4.2 steps each home. I run AUTO_SPEED MAX_MISSED=5.0 to account for that variance. If you have one wildly different result, the default TEST_ATTEMPTS of 2 should catch it and keep going.
Table of Contents
Overview
- License: MIT
How does it work?
- Home your printer
- If your print is enclosed, heat soak it. You want to run this module at the typical state your printer is in when you're printing.
- Run
AUTO_SPEED- Check endstop variance
- Validate the endstops are accurate enough for
MAX_MISSED
- Validate the endstops are accurate enough for
- Find the maximum acceleration
- accel =
ACCEL_START - velocity =
(math.sqrt(travel/accel)*accel) / math.log10(accel)
- Home, and save stepper start steps
- Move over the pattern at
accel/velocityTEST_ITERATIONtimes - Home, and save stepper stop steps
- Check if between start and stop steps we missed more than
MAX_MISSEDsteps.- If we missed more than
MAX_MISSED, go to the next step - Otherwise, accel +=
ACCEL_STEP
- If we missed more than
- accel =
- Find maximum velocity
- velocity =
VELOCITY_START - accel =
(velocity**2/travel) * 4
- Home, and save stepper start steps
- Move over the pattern at
accel/velocityTEST_ITERATIONtimes - Home, and save stepper stop steps
- Check if between start and stop steps we missed more than
MAX_MISSEDsteps.- If we missed more than
MAX_MISSED, go to the next step - Otherwise, velocity +=
VELOCITY_STEP
- If we missed more than
- velocity =
- Stress test
- Start at max acceleration/velocity and slowly decrease both until less than
MAX_MISSEDsteps are lost afterSTRESS_INTERATIONs.
- Start at max acceleration/velocity and slowly decrease both until less than
- Check endstop variance
Using Klipper Auto Speed
Installation
To install this module you need to clone the repository and run the install.sh script
Automatic installation
cd ~
git clone https://github.com/Anonoei/klipper_auto_speed.git
cd klipper_auto_speed
./install.sh
Manual installation
- Clone the repository
cd ~git clone https://github.com/Anonoei/klipper_auto_speed.gitcd klipper_auto_speed
- Link auto_speed to klipper
ln -sf ~/klipper_auto_speed/auto_speed.py ~/klipper/klippy/extras/auto_speed.py
- Restart klipper
sudo systemctl restart klipper
Moonraker Update Manager
[update_manager klipper_auto_speed]
type: git_repo
path: ~/klipper_auto_speed
origin: https://github.com/anonoei/klipper_auto_speed.git
primary_branch: main
install_script: install.sh
managed_services: klipper
Configuration
Place this in your printer.cfg
[auto_speed]
The values listed below are the defaults Auto Speed uses. You can include them if you wish to change their values or run into issues.
[auto_speed]
z: 50 ; Z position to run Auto Speed
margin: 20 ; How far away from your axis maximums to perform the test movement
pattern_margin: 20 ; How far from your axis centers to perform the small test movement
settling_home: True ; Perform settling home before starting Auto Speed
max_missed: 1.0 ; Maximum full steps that can be missed
endstop_samples: 3 ; How many endstop samples to take for endstop variance
test_iterations: 2 ; While testing for maximum, perform the test movement this many times
test_attempts: 2 ; Re-test this many times if test fails
stress_iterations: 50 ; While finding final maximums, perform the test movement this many times
accel_start: 1000.0 ; Starting acceleration
accel_stop: 50000.0 ; Maximum possible acceleration the test will go to
accel_step: 1000.0 ; Increase accel_start by this amount each test
velocity_start: 100.0 ; Starting velocity
velocity_stop: 5000.0 ; Maximum possible velocity the test will go to
velocity_step: 50.0 ; Increase velocity_start by this amount each test
Macro
Run the klipper command AUTO_SPEED. You can also use the arguments below
| Argument | Default | Description |
|---|---|---|
| Z | 50 | Z position to run Auto Speed |
| MARGIN | 20 | How far away from your axis maximums to perform the test movement |
| PATTERN_MARGIN | 20 | How far from your axis centers to perform the small test movement |
| SETTLING_HOME | 1 | Perform settling home before starting Auto Speed |
| MAX_MISSED | 1.0 | Maximum full steps that can be missed |
| ENDSTOP_SAMPLES | 3 | How many endstop samples to take for endstop variance |
| TEST_ITERATIONS | 2 | While testing for maximum, perform the test movement this many times |
| TEST_ATTEMPTS | 2 | Re-test this many times if test fails |
| STRESS_ITERATIONS | 50 | While finding final maximums, perform the test movement this many times |
| ACCEL_START | 1000.0 | Starting acceleration |
| ACCEL_STOP | 50000.0 | Maximum possible acceleration the test will go to |
| ACCEL_STEP | 1000.0 | Increase accel_start by this amount each test |
| VELOCITY_START | 100.0 | Starting velocity |
| VELOCITY_STOP | 5000.0 | Maximum possible velocity the test will go to |
| VELOCITY_STEP | 50.0 | Increase velocity_start by this amount each test |