From 150a8ee03044685d8e975f062f1225ea9910ef7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Thu, 23 May 2024 22:46:43 +0200 Subject: [PATCH] added CoreXZ support for the belt comparison tool --- shaketune/helpers/common_func.py | 2 ++ shaketune/measurement/belts_comparison.py | 33 ++++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/shaketune/helpers/common_func.py b/shaketune/helpers/common_func.py index 106a174..b56704c 100644 --- a/shaketune/helpers/common_func.py +++ b/shaketune/helpers/common_func.py @@ -20,6 +20,8 @@ AXIS_CONFIG = [ {'axis': 'y', 'direction': (0, 1, 0), 'label': 'axis_Y'}, {'axis': 'a', 'direction': (1, -1, 0), 'label': 'belt_A'}, {'axis': 'b', 'direction': (1, 1, 0), 'label': 'belt_B'}, + {'axis': 'corexz_x', 'direction': (1, 0, 1), 'label': 'belt_X'}, + {'axis': 'corexz_z', 'direction': (-1, 0, 1), 'label': 'belt_Z'}, ] diff --git a/shaketune/measurement/belts_comparison.py b/shaketune/measurement/belts_comparison.py index 5b9bcb1..3c196fc 100644 --- a/shaketune/measurement/belts_comparison.py +++ b/shaketune/measurement/belts_comparison.py @@ -23,17 +23,32 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None: res_tester = printer.lookup_object('resonance_tester') systime = printer.get_reactor().monotonic() - accel_chip = Accelerometer.find_axis_accelerometer(printer, 'xy') + if accel_per_hz is None: + accel_per_hz = res_tester.test.accel_per_hz + max_accel = max_freq * accel_per_hz + + # Configure the graph creator + motors_config_parser = MotorsConfigParser(config, motors=None) + creator = st_thread.get_graph_creator() + creator.configure(motors_config_parser.kinematics, accel_per_hz) + + if motors_config_parser.kinematics == 'corexy': + filtered_config = [a for a in AXIS_CONFIG if a['axis'] in ('a', 'b')] + accel_chip = Accelerometer.find_axis_accelerometer(printer, 'xy') + elif motors_config_parser.kinematics == 'corexz': + filtered_config = [a for a in AXIS_CONFIG if a['axis'] in ('corexz_x', 'corexz_z')] + # For CoreXZ kinematics, we can use the X axis accelerometer as most of the time they are moving bed printers + accel_chip = Accelerometer.find_axis_accelerometer(printer, 'x') + else: + gcmd.error('Only CoreXY and CoreXZ kinematics are supported for the belt comparison tool!') + ConsoleOutput.print(f'{motors_config_parser.kinematics.upper()} kinematics mode') + if accel_chip is None: gcmd.error( 'No suitable accelerometer found for measurement! Multi-accelerometer configurations are not supported for this macro.' ) accelerometer = Accelerometer(printer.lookup_object(accel_chip)) - if accel_per_hz is None: - accel_per_hz = res_tester.test.accel_per_hz - max_accel = max_freq * accel_per_hz - # Move to the starting point test_points = res_tester.test.get_start_test_points() if len(test_points) > 1: @@ -58,11 +73,6 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None: toolhead.manual_move(point, feedrate_travel) toolhead.dwell(0.5) - # Configure the graph creator - motors_config_parser = MotorsConfigParser(config, motors=None) - creator = st_thread.get_graph_creator() - creator.configure(motors_config_parser.kinematics, accel_per_hz) - # set the needed acceleration values for the test toolhead_info = toolhead.get_status(systime) old_accel = toolhead_info['max_accel'] @@ -76,8 +86,7 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None: else: input_shaper = None - # Filter axis configurations to get the A and B axis only - filtered_config = [a for a in AXIS_CONFIG if a['axis'] in ('a', 'b')] + # Run the test for each axis for config in filtered_config: accelerometer.start_measurement() vibrate_axis(toolhead, gcode, config['direction'], min_freq, max_freq, hz_per_sec, accel_per_hz)