Skip to content

Commit

Permalink
feat/resonance_tester: accepts ACCEL_PER_HZ in TEST_RESONANCES
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlz committed Jun 21, 2024
1 parent 260d992 commit eea901f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,8 @@ all enabled accelerometer chips.
`TEST_RESONANCES AXIS=<axis> OUTPUT=<resonances,raw_data>
[NAME=<name>] [FREQ_START=<min_freq>] [FREQ_END=<max_freq>]
[HZ_PER_SEC=<hz_per_sec>] [CHIPS=<adxl345_chip_name>]
[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=<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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions klippy/extras/resonance_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:
Expand Down Expand Up @@ -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(",")
Expand All @@ -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(",")
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit eea901f

Please sign in to comment.