diff --git a/K-ShakeTune/IS_vibrations_measurements.cfg b/K-ShakeTune/IS_vibrations_measurements.cfg index 59a3b87..7ebe8ad 100644 --- a/K-ShakeTune/IS_vibrations_measurements.cfg +++ b/K-ShakeTune/IS_vibrations_measurements.cfg @@ -2,40 +2,17 @@ ###### VIBRATIONS AND SPEED OPTIMIZATIONS ###### ################################################ # Written by Frix_x#0161 # -# @version: 2.1 +# @version: 2.2 # CHANGELOG: +# v2.2: allow custom accel values and set sane defaults (3k) to avoid using very high accels that produce bad results # v2.1: allow decimal entries for speed and increment and added the E axis as an option to be neasured # v2.0: added the possibility to measure mutliple axis # v1.0: first speed and vibrations optimization macro -### What is it ? ### -# This macro helps you to identify the speed settings that exacerbate the vibrations of the machine (ie. where the frame resonate badly). -# It also helps to find the clean speed ranges where the machine is silent. -# I had some strong vibrations at very specific speeds on my machine (52mm/s for example) and I wanted to find all these problematic speeds -# to avoid them in my slicer profile and finally get the silent machine I was dreaming! - -# It works by moving the toolhead at different speed settings while recording the vibrations using the ADXL chip. Then the macro call a custom script -# to compute and find the best speed settings. The results can be found in your config folder using Fluidd/Mainsail file manager. - -# The goal is to make it easy to set, share and use it. - -# This macro is parametric and most of the values can be adjusted with their respective input parameters. -# It can be called without any parameters - in which case the default values would be used - or with any combination of parameters as desired. - -# Usage: -# 1. DO YOUR INPUT SHAPER CALIBRATION FIRST !!! This macro should not be used before as it would be useless and the results invalid. -# 2. Call the VIBRATIONS_CALIBRATION macro with the speed range you want to measure (default 20 to 200mm/s with 2mm/s increment). -# Be carefull about the Z_HEIGHT variable that default to 20mm -> if your ADXL is under the nozzle, increase it to avoid a crash of the ADXL on the bed of the machine. -# 3. Wait for it to finish all the measurement and compute the graph. Then look at it in the results folder. - - [gcode_macro VIBRATIONS_CALIBRATION] gcode: - # - # PARAMETERS - # {% set size = params.SIZE|default(60)|int %} # size of the area where the movements are done {% set direction = params.DIRECTION|default('XY') %} # can be set to either XY, AB, ABXY, A, B, X, Y, Z {% set z_height = params.Z_HEIGHT|default(20)|int %} # z height to put the toolhead before starting the movements @@ -45,16 +22,18 @@ gcode: {% set max_speed = params.MAX_SPEED|default(200)|float * 60 %} # maximum feedrate for the movements {% set speed_increment = params.SPEED_INCREMENT|default(2)|float * 60 %} # feedrate increment between each move {% set feedrate_travel = params.TRAVEL_SPEED|default(200)|int * 60 %} # travel feedrate between moves - {% set accel = params.ACCEL|default(config.printer["max_accel"])|float %} + {% set accel = params.ACCEL|default(3000)|int %} # accel value used to move on the pattern {% set accel_chip = params.ACCEL_CHIP|default("adxl345") %} # ADXL chip name in the config - # - # COMPUTED VALUES - # {% set mid_x = printer.toolhead.axis_maximum.x|float / 2 %} {% set mid_y = printer.toolhead.axis_maximum.y|float / 2 %} {% set nb_samples = ((max_speed - min_speed) / speed_increment + 1) | int %} + {% set accel = [accel, printer.configfile.settings.printer.max_accel]|min %} + {% set old_accel = printer.toolhead.max_accel %} + {% set old_accel_to_decel = printer.toolhead.max_accel_to_decel %} + {% set old_sqv = printer.toolhead.square_corner_velocity %} + {% set direction_factor = { 'XY' : { 'start' : {'x': -0.5, 'y': -0.5 }, @@ -157,7 +136,10 @@ gcode: M83 G90 - SET_ACCEL_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel} + + # Set the wanted acceleration values (not too high to avoid oscillation, not too low to be able to reach constant speed on each segments) + SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel} SQUARE_CORNER_VELOCITY={[(accel / 1000), 5.0]|max} + # Going to the start position G1 Z{z_height} G1 X{mid_x + (size * direction_factor[direction].start.x) } Y{mid_y + (size * direction_factor[direction].start.y)} F{feedrate_travel} @@ -188,4 +170,7 @@ gcode: {% endif %} RUN_SHELL_COMMAND CMD=plot_graph PARAMS="VIBRATIONS {direction}" + # Restore the previous acceleration values + SET_VELOCITY_LIMIT ACCEL={old_accel} ACCEL_TO_DECEL={old_accel_to_decel} SQUARE_CORNER_VELOCITY={old_sqv} + RESTORE_GCODE_STATE NAME=STATE_VIBRATIONS_CALIBRATION diff --git a/docs/macros/vibrations_tuning.md b/docs/macros/vibrations_tuning.md index 8042863..309ad27 100644 --- a/docs/macros/vibrations_tuning.md +++ b/docs/macros/vibrations_tuning.md @@ -17,6 +17,7 @@ Call the `VIBRATIONS_CALIBRATION` macro with the direction and speed range you w |DIRECTION|"XY"|direction vector where you want to do the measurements. Can be set to either "XY", "AB", "ABXY", "A", "B", "X", "Y", "Z", "E"| |Z_HEIGHT|20|z height to put the toolhead before starting the movements. Be careful, if your ADXL is under the nozzle, increase it to avoid a crash of the ADXL on the bed of the machine| |VERBOSE|1|Wether to log the current speed in the console| +|ACCEL|3000 (or max printer accel)|accel in mm/s^2 used for all the moves. Try to keep it relatively low to avoid bad oscillations that affect the measurements, but but high enough to reach constant speed for >~70% of the segments| |MIN_SPEED|20|minimum speed of the toolhead in mm/s for the movements| |MAX_SPEED|200|maximum speed of the toolhead in mm/s for the movements| |SPEED_INCREMENT|2|speed increments of the toolhead in mm/s between every movements|