diff --git a/README.md b/README.md index e122131a6..d90d67341 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ See the [Danger Features document](https://dangerklipper.io/Danger_Features.html - [shaper_calibrate: store and expose accel_per_hz](https://github.com/DangerKlippers/danger-klipper/pull/224) +- [resonance_tester: accepts ACCEL_PER_HZ in TEST_RESONANCES](https://github.com/DangerKlippers/danger-klipper/pull/312) + - [mcu: support for AT32F403](https://github.com/DangerKlippers/danger-klipper/pull/284) If you're feeling adventurous, take a peek at the extra features in the bleeding-edge-v2 branch [feature documentation](docs/Bleeding_Edge.md) diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 8a5f019b1..b2fa39e75 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -1270,8 +1270,8 @@ all enabled accelerometer chips. `TEST_RESONANCES AXIS= OUTPUT= [NAME=] [FREQ_START=] [FREQ_END=] [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 +[POINT=x,y,z] [ACCEL_PER_HZ=] [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 arbitrary direction as `AXIS=dx,dy`, where dx and dy are floating @@ -1280,10 +1280,10 @@ point numbers defining a direction vector (e.g. `AXIS=X`, `AXIS=Y`, or 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) -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 +named adxl345 chips. If POINT or ACCEL_PER_HZ are specified, +they will override the corresponding fields 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 enabled. `OUTPUT` parameter is a comma-separated list of which outputs will be written. If `raw_data` is requested, then the raw accelerometer data is written into a file or a series of files diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index bfa772408..3e9825ffe 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -241,6 +241,7 @@ def _run_test( raw_name_suffix=None, accel_chips=None, test_point=None, + test_accel_per_hz=None, ): toolhead = self.printer.lookup_object("toolhead") calibration_data = {axis: None for axis in axes} @@ -252,6 +253,9 @@ def _run_test( else: test_points = self.test.get_start_test_points() + if test_accel_per_hz is not None: + self.test.accel_per_hz=test_accel_per_hz + for point in test_points: toolhead.manual_move(point, self.move_speed) if len(test_points) > 1 or test_point is not None: @@ -327,6 +331,7 @@ def cmd_TEST_RESONANCES(self, gcmd): axis = _parse_axis(gcmd, gcmd.get("AXIS").lower()) chips_str = gcmd.get("CHIPS", None) test_point = gcmd.get("POINT", None) + test_accel_per_hz = gcmd.get("ACCEL_PER_HZ", None, above=0.0) if test_point: test_coords = test_point.split(",") @@ -340,6 +345,12 @@ def cmd_TEST_RESONANCES(self, gcmd): " where x, y and z are valid floating point numbers" ) + if test_accel_per_hz: + try: + test_accel_per_hz = float(test_accel_per_hz) + except ValueError: + raise gcmd.error("Accel Per Hz value has to be larger than 0") + accel_chips = self._parse_chips(chips_str) if chips_str else None outputs = gcmd.get("OUTPUT", "resonances").lower().split(",") @@ -373,6 +384,7 @@ def cmd_TEST_RESONANCES(self, gcmd): raw_name_suffix=name_suffix if raw_output else None, accel_chips=accel_chips, test_point=test_point, + test_accel_per_hz=test_accel_per_hz, )[axis] if csv_output: csv_name = self.save_calibration_data(