From 9ea70880e05b443ae5423b1c64e5107c358c03c9 Mon Sep 17 00:00:00 2001 From: MRX8024 <57844100+MRX8024@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:19:10 +0200 Subject: [PATCH 1/3] resonance_tester: Fix selection of non-adxl345 chips Corrected issue where accelerometer names were incorrectly prefixed with "adxl345", preventing the selection of other chip types when running TEST_RESONANCES. Signed-off-by: Maksim Bolgov maksim8024@gmail.com --- docs/Config_Changes.md | 4 ++++ docs/G-Codes.md | 11 +++++------ klippy/extras/resonance_tester.py | 6 +----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index cb031ee2b388..5535dc85a195 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -8,6 +8,10 @@ All dates in this document are approximate. ## Changes +20241112: Option `CHIPS=` in `TEST_RESONANCES` and +`SHAPER_CALIBRATE` requires specifying the full name(s) of the accel +chip(s). For example, `adxl345 rpi` instead of short name - `rpi`. + 20240912: `SET_PIN`, `SET_SERVO`, `SET_FAN_SPEED`, `M106`, and `M107` commands are now collated. Previously, if many updates to the same object were issued faster than the minimum scheduling time (typically diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 63c84f56db5b..da4acfce0f8f 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -1086,7 +1086,7 @@ all enabled accelerometer chips. #### TEST_RESONANCES `TEST_RESONANCES AXIS= OUTPUT= [NAME=] [FREQ_START=] [FREQ_END=] -[HZ_PER_SEC=] [CHIPS=] +[HZ_PER_SEC=] [CHIPS=] [POINT=x,y,z] [INPUT_SHAPING=[<0:1>]]`: Runs the resonance test in all configured probe points for the requested "axis" and measures the acceleration using the accelerometer chips configured for @@ -1094,10 +1094,9 @@ the respective axis. "axis" can either be X or Y, or specify an arbitrary direction as `AXIS=dx,dy`, where dx and dy are floating point numbers defining a direction vector (e.g. `AXIS=X`, `AXIS=Y`, or `AXIS=1,-1` to define a diagonal direction). Note that `AXIS=dx,dy` -and `AXIS=-dx,-dy` is equivalent. `adxl345_chip_name` can be one or -more configured adxl345 chip,delimited with comma, for example -`CHIPS="adxl345, adxl345 rpi"`. Note that `adxl345` can be omitted from -named adxl345 chips. If POINT is specified it will override the point(s) +and `AXIS=-dx,-dy` is equivalent. `chip_name` can be one or +more configured accel chips, delimited with comma, for example +`CHIPS="adxl345, adxl345 rpi"`. If POINT is specified it will override the point(s) configured in `[resonance_tester]`. If `INPUT_SHAPING=0` or not set(default), disables input shaping for the resonance testing, because it is not valid to run the resonance testing with the input shaper @@ -1114,7 +1113,7 @@ frequency response is calculated (across all probe points) and written into #### SHAPER_CALIBRATE `SHAPER_CALIBRATE [AXIS=] [NAME=] [FREQ_START=] -[FREQ_END=] [HZ_PER_SEC=] [CHIPS=] +[FREQ_END=] [HZ_PER_SEC=] [CHIPS=] [MAX_SMOOTHING=]`: Similarly to `TEST_RESONANCES`, runs the resonance test as configured, and tries to find the optimal parameters for the input shaper for the requested axis (or both X and diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index fe8717d58545..841725e28125 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -212,11 +212,7 @@ def _run_test(self, gcmd, axes, helper, raw_name_suffix=None, def _parse_chips(self, accel_chips): parsed_chips = [] for chip_name in accel_chips.split(','): - if "adxl345" in chip_name: - chip_lookup_name = chip_name.strip() - else: - chip_lookup_name = "adxl345 " + chip_name.strip(); - chip = self.printer.lookup_object(chip_lookup_name) + chip = self.printer.lookup_object(chip_name.strip()) parsed_chips.append(chip) return parsed_chips def _get_max_calibration_freq(self): From f1cee6bb1ae3c68efcea09257dc1e224d03927b2 Mon Sep 17 00:00:00 2001 From: MRX8024 <57844100+MRX8024@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:23:25 +0200 Subject: [PATCH 2/3] resonance_tester: Add accel_per_hz parameter selection in test Implemented support for selecting the `accel_per_hz` parameter when running TEST_RESONANCES. Signed-off-by: Maksim Bolgov maksim8024@gmail.com --- docs/G-Codes.md | 7 ++++--- klippy/extras/resonance_tester.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/G-Codes.md b/docs/G-Codes.md index da4acfce0f8f..8c7ae99bfa60 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -1086,7 +1086,7 @@ all enabled accelerometer chips. #### TEST_RESONANCES `TEST_RESONANCES AXIS= OUTPUT= [NAME=] [FREQ_START=] [FREQ_END=] -[HZ_PER_SEC=] [CHIPS=] +[ACCEL_PER_HZ=] [HZ_PER_SEC=] [CHIPS=] [POINT=x,y,z] [INPUT_SHAPING=[<0:1>]]`: Runs the resonance test in all configured probe points for the requested "axis" and measures the acceleration using the accelerometer chips configured for @@ -1113,8 +1113,9 @@ frequency response is calculated (across all probe points) and written into #### SHAPER_CALIBRATE `SHAPER_CALIBRATE [AXIS=] [NAME=] [FREQ_START=] -[FREQ_END=] [HZ_PER_SEC=] [CHIPS=] -[MAX_SMOOTHING=]`: Similarly to `TEST_RESONANCES`, runs +[FREQ_END=] [ACCEL_PER_HZ=][HZ_PER_SEC=] +[CHIPS=] [MAX_SMOOTHING=]`: +Similarly to `TEST_RESONANCES`, runs the resonance test as configured, and tries to find the optimal parameters for the input shaper for the requested axis (or both X and Y axes if `AXIS` parameter is unset). If `MAX_SMOOTHING` is unset, its diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index 841725e28125..e9d4e9d92c53 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -65,6 +65,8 @@ def prepare_test(self, gcmd): self.freq_start = gcmd.get_float("FREQ_START", self.min_freq, minval=1.) self.freq_end = gcmd.get_float("FREQ_END", self.max_freq, minval=self.freq_start, maxval=300.) + self.accel_per_hz = gcmd.get_float("ACCEL_PER_HZ", + self.accel_per_hz, above=0.) self.hz_per_sec = gcmd.get_float("HZ_PER_SEC", self.hz_per_sec, above=0., maxval=2.) def run_test(self, axis, gcmd): From daa7bd95cbe0378b3d5d430eec27ac7b58370132 Mon Sep 17 00:00:00 2001 From: MRX8024 <57844100+MRX8024@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:24:34 +0200 Subject: [PATCH 3/3] docs: Update TEST_RESONANCES + SHAPER_CALIBRATE with missing parameters and bracket corrections Signed-off-by: Maksim Bolgov maksim8024@gmail.com --- docs/G-Codes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 8c7ae99bfa60..b50f2af94eaf 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -1084,10 +1084,10 @@ is enabled (also see the all enabled accelerometer chips. #### TEST_RESONANCES -`TEST_RESONANCES AXIS= OUTPUT= +`TEST_RESONANCES AXIS= [OUTPUT=] [NAME=] [FREQ_START=] [FREQ_END=] [ACCEL_PER_HZ=] [HZ_PER_SEC=] [CHIPS=] -[POINT=x,y,z] [INPUT_SHAPING=[<0:1>]]`: Runs the resonance +[POINT=x,y,z] [INPUT_SHAPING=<0:1>]`: Runs the resonance test in all configured probe points for the requested "axis" and measures the acceleration using the accelerometer chips configured for the respective axis. "axis" can either be X or Y, or specify an @@ -1114,7 +1114,7 @@ frequency response is calculated (across all probe points) and written into #### SHAPER_CALIBRATE `SHAPER_CALIBRATE [AXIS=] [NAME=] [FREQ_START=] [FREQ_END=] [ACCEL_PER_HZ=][HZ_PER_SEC=] -[CHIPS=] [MAX_SMOOTHING=]`: +[CHIPS=] [MAX_SMOOTHING=] [INPUT_SHAPING=<0:1>]`: Similarly to `TEST_RESONANCES`, runs the resonance test as configured, and tries to find the optimal parameters for the input shaper for the requested axis (or both X and