mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-05 13:04:05 -06:00
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>
This commit is contained in:
parent
a637c2f110
commit
1b1a97e8bd
3 changed files with 120 additions and 83 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue