diff options
author | Dmitry Butyugin <dmbutyugin@google.com> | 2020-12-19 22:53:50 +0100 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2020-12-22 18:37:41 -0500 |
commit | 1b1a97e8bde3d523115c9facae1c795d925a1a83 (patch) | |
tree | f7519afb20c75fb10d0176c3291df735f1160974 /klippy/extras/resonance_tester.py | |
parent | a637c2f11019faecb4a4d244ea0ce9815a784b43 (diff) | |
download | kutter-1b1a97e8bde3d523115c9facae1c795d925a1a83.tar.gz kutter-1b1a97e8bde3d523115c9facae1c795d925a1a83.tar.xz kutter-1b1a97e8bde3d523115c9facae1c795d925a1a83.zip |
shaper_calibrate: Choose input shapers accounting smoothing
Improved algorithm to choose the 'optimal' shaper frequency taking
shaper smoothing into account. This may choose a frequency with
slightly more vibrations but less smoothing. Also allow users to
limit the maximum input shaper smoothing.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Diffstat (limited to 'klippy/extras/resonance_tester.py')
-rw-r--r-- | klippy/extras/resonance_tester.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index 70bea4a1..045527c8 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -82,6 +82,7 @@ class ResonanceTester: ('y', config.get('accel_chip_y').strip())] if self.accel_chip_names[0][1] == self.accel_chip_names[1][1]: self.accel_chip_names = [('xy', self.accel_chip_names[0][1])] + self.max_smoothing = config.getfloat('max_smoothing', None, minval=0.05) self.gcode = self.printer.lookup_object('gcode') self.gcode.register_command("MEASURE_AXES_NOISE", @@ -188,6 +189,9 @@ class ResonanceTester: else: calibrate_axes = [axis.lower()] + max_smoothing = gcmd.get_float( + "MAX_SMOOTHING", self.max_smoothing, minval=0.05) + name_suffix = gcmd.get("NAME", time.strftime("%Y%m%d_%H%M%S")) if not self.is_valid_name_suffix(name_suffix): raise gcmd.error("Invalid NAME parameter") @@ -244,15 +248,16 @@ class ResonanceTester: "Calculating the best input shaper parameters for %s axis" % (axis,)) calibration_data[axis].normalize_to_frequencies() - shaper_name, shaper_freq, shapers_vals = helper.find_best_shaper( - calibration_data[axis], gcmd.respond_info) + best_shaper, all_shapers = helper.find_best_shaper( + calibration_data[axis], max_smoothing, gcmd.respond_info) gcmd.respond_info( "Recommended shaper_type_%s = %s, shaper_freq_%s = %.1f Hz" - % (axis, shaper_name, axis, shaper_freq)) - helper.save_params(configfile, axis, shaper_name, shaper_freq) + % (axis, best_shaper.name, axis, best_shaper.freq)) + helper.save_params(configfile, axis, + best_shaper.name, best_shaper.freq) csv_name = self.save_calibration_data( 'calibration_data', name_suffix, helper, axis, - calibration_data[axis], shapers_vals) + calibration_data[axis], all_shapers) gcmd.respond_info( "Shaper calibration data written to %s file" % (csv_name,)) @@ -293,10 +298,10 @@ class ResonanceTester: return os.path.join("/tmp", name + ".csv") def save_calibration_data(self, base_name, name_suffix, shaper_calibrate, - axis, calibration_data, shapers_vals=None): + axis, calibration_data, all_shapers=None): output = self.get_filename(base_name, name_suffix, axis) shaper_calibrate.save_calibration_data(output, calibration_data, - shapers_vals) + all_shapers) return output def load_config(config): |