resonance_tester: Apply input shaper params on SHAPER_CALIBRATE
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
parent
16c53992d6
commit
624d360a34
|
@ -8,6 +8,9 @@ All dates in this document are approximate.
|
|||
|
||||
## Changes
|
||||
|
||||
20230519: `SHAPER_CALIBRATE` command immediately applies input shaper parameters
|
||||
if `[input_shaper]` was enabled already.
|
||||
|
||||
20230407: The `stalled_bytes` counter in the log and in the
|
||||
`printer.mcu.last_stats` field has been renamed to `upcoming_bytes`.
|
||||
|
||||
|
|
|
@ -1032,7 +1032,9 @@ frequency responses and the different input shapers values are written
|
|||
to a CSV file(s) `/tmp/calibration_data_<axis>_<name>.csv`. Unless
|
||||
specified, NAME defaults to the current time in "YYYYMMDD_HHMMSS"
|
||||
format. Note that the suggested input shaper parameters can be
|
||||
persisted in the config by issuing `SAVE_CONFIG` command.
|
||||
persisted in the config by issuing `SAVE_CONFIG` command, and if
|
||||
`[input_shaper]` was already enabled previously, these parameters
|
||||
take effect immediately.
|
||||
|
||||
### [respond]
|
||||
|
||||
|
|
|
@ -287,6 +287,8 @@ class ResonanceTester:
|
|||
if not self.is_valid_name_suffix(name_suffix):
|
||||
raise gcmd.error("Invalid NAME parameter")
|
||||
|
||||
input_shaper = self.printer.lookup_object('input_shaper', None)
|
||||
|
||||
# Setup shaper calibration
|
||||
helper = shaper_calibrate.ShaperCalibrate(self.printer)
|
||||
|
||||
|
@ -306,6 +308,9 @@ class ResonanceTester:
|
|||
"Recommended shaper_type_%s = %s, shaper_freq_%s = %.1f Hz"
|
||||
% (axis_name, best_shaper.name,
|
||||
axis_name, best_shaper.freq))
|
||||
if input_shaper is not None:
|
||||
helper.apply_params(input_shaper, axis_name,
|
||||
best_shaper.name, best_shaper.freq)
|
||||
helper.save_params(configfile, axis_name,
|
||||
best_shaper.name, best_shaper.freq)
|
||||
csv_name = self.save_calibration_data(
|
||||
|
|
|
@ -334,6 +334,18 @@ class ShaperCalibrate:
|
|||
configfile.set('input_shaper', 'shaper_freq_'+axis,
|
||||
'%.1f' % (shaper_freq,))
|
||||
|
||||
def apply_params(self, input_shaper, axis, shaper_name, shaper_freq):
|
||||
if axis == 'xy':
|
||||
self.apply_params(input_shaper, 'x', shaper_name, shaper_freq)
|
||||
self.apply_params(input_shaper, 'y', shaper_name, shaper_freq)
|
||||
return
|
||||
gcode = self.printer.lookup_object("gcode")
|
||||
axis = axis.upper()
|
||||
input_shaper.cmd_SET_INPUT_SHAPER(gcode.create_gcode_command(
|
||||
"SET_INPUT_SHAPER", "SET_INPUT_SHAPER", {
|
||||
"SHAPER_TYPE_" + axis: shaper_name,
|
||||
"SHAPER_FREQ_" + axis: shaper_freq}))
|
||||
|
||||
def save_calibration_data(self, output, calibration_data, shapers=None):
|
||||
try:
|
||||
with open(output, "w") as csvfile:
|
||||
|
|
Loading…
Reference in New Issue