Skip to content

Commit

Permalink
Make frequencies default on [resonance_tester] settings (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon authored Jun 17, 2024
1 parent a9c7a84 commit b98d103
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
25 changes: 12 additions & 13 deletions shaketune/commands/axes_shaper_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,32 @@


def axes_shaper_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
min_freq = gcmd.get_float('FREQ_START', default=5, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=133.33, minval=1)
printer = config.get_printer()
toolhead = printer.lookup_object('toolhead')
res_tester = printer.lookup_object('resonance_tester')
systime = printer.get_reactor().monotonic()
toolhead_info = toolhead.get_status(systime)

min_freq = gcmd.get_float('FREQ_START', default=res_tester.test.min_freq, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=res_tester.test.max_freq, minval=1)
hz_per_sec = gcmd.get_float('HZ_PER_SEC', default=1, minval=1)
accel_per_hz = gcmd.get_float('ACCEL_PER_HZ', default=None)
axis_input = gcmd.get('AXIS', default='all').lower()
if axis_input not in {'x', 'y', 'all'}:
raise gcmd.error('AXIS selection invalid. Should be either x, y, or all!')
scv = gcmd.get_float('SCV', default=None, minval=0)
scv = gcmd.get_float('SCV', default=toolhead_info['square_corner_velocity'], minval=0)
max_sm = gcmd.get_float('MAX_SMOOTHING', default=None, minval=0)
feedrate_travel = gcmd.get_float('TRAVEL_SPEED', default=120.0, minval=20.0)
z_height = gcmd.get_float('Z_HEIGHT', default=None, minval=1)

if accel_per_hz == '':
accel_per_hz = None

printer = config.get_printer()
gcode = printer.lookup_object('gcode')
toolhead = printer.lookup_object('toolhead')
res_tester = printer.lookup_object('resonance_tester')
systime = printer.get_reactor().monotonic()

if scv is None:
toolhead_info = toolhead.get_status(systime)
scv = toolhead_info['square_corner_velocity']

if accel_per_hz is None:
accel_per_hz = res_tester.test.accel_per_hz

gcode = printer.lookup_object('gcode')

max_accel = max_freq * accel_per_hz

# Move to the starting point
Expand Down
20 changes: 11 additions & 9 deletions shaketune/commands/compare_belts_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@


def compare_belts_responses(gcmd, config, st_process: ShakeTuneProcess) -> None:
min_freq = gcmd.get_float('FREQ_START', default=5.0, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=133.33, minval=1)
hz_per_sec = gcmd.get_float('HZ_PER_SEC', default=1.0, minval=1)
printer = config.get_printer()
toolhead = printer.lookup_object('toolhead')
res_tester = printer.lookup_object('resonance_tester')
systime = printer.get_reactor().monotonic()

min_freq = gcmd.get_float('FREQ_START', default=res_tester.test.min_freq, minval=1)
max_freq = gcmd.get_float('FREQ_END', default=res_tester.test.max_freq, minval=1)
hz_per_sec = gcmd.get_float('HZ_PER_SEC', default=1, minval=1)
accel_per_hz = gcmd.get_float('ACCEL_PER_HZ', default=None)
feedrate_travel = gcmd.get_float('TRAVEL_SPEED', default=120.0, minval=20.0)
z_height = gcmd.get_float('Z_HEIGHT', default=None, minval=1)

if accel_per_hz == '':
accel_per_hz = None

printer = config.get_printer()
gcode = printer.lookup_object('gcode')
toolhead = printer.lookup_object('toolhead')
res_tester = printer.lookup_object('resonance_tester')
systime = printer.get_reactor().monotonic()

if accel_per_hz is None:
accel_per_hz = res_tester.test.accel_per_hz

gcode = printer.lookup_object('gcode')

max_accel = max_freq * accel_per_hz

# Configure the graph creator
Expand Down
16 changes: 8 additions & 8 deletions shaketune/dummy_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ gcode:
[gcode_macro COMPARE_BELTS_RESPONSES]
description: dummy
gcode:
{% set freq_start = params.FREQ_START|default(5) %}
{% set freq_end = params.FREQ_END|default(133.33) %}
{% set freq_start = params.FREQ_START %}
{% set freq_end = params.FREQ_END %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1) %}
{% set accel_per_hz = params.ACCEL_PER_HZ %}
{% set travel_speed = params.TRAVEL_SPEED|default(120) %}
{% set z_height = params.Z_HEIGHT %}
{% set params_filtered = {
"FREQ_START": freq_start,
"FREQ_END": freq_end,
"FREQ_START": freq_start if freq_start is not none else '',
"FREQ_END": freq_end if freq_end is not none else '',
"HZ_PER_SEC": hz_per_sec,
"ACCEL_PER_HZ": accel_per_hz if accel_per_hz is not none else '',
"TRAVEL_SPEED": travel_speed,
Expand All @@ -65,8 +65,8 @@ gcode:
[gcode_macro AXES_SHAPER_CALIBRATION]
description: dummy
gcode:
{% set freq_start = params.FREQ_START|default(5) %}
{% set freq_end = params.FREQ_END|default(133.33) %}
{% set freq_start = params.FREQ_START %}
{% set freq_end = params.FREQ_END %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1) %}
{% set accel_per_hz = params.ACCEL_PER_HZ %}
{% set axis = params.AXIS|default('all') %}
Expand All @@ -75,8 +75,8 @@ gcode:
{% set travel_speed = params.TRAVEL_SPEED|default(120) %}
{% set z_height = params.Z_HEIGHT %}
{% set params_filtered = {
"FREQ_START": freq_start,
"FREQ_END": freq_end,
"FREQ_START": freq_start if freq_start is not none else '',
"FREQ_END": freq_end if freq_end is not none else '',
"HZ_PER_SEC": hz_per_sec,
"ACCEL_PER_HZ": accel_per_hz if accel_per_hz is not none else '',
"AXIS": axis,
Expand Down

0 comments on commit b98d103

Please sign in to comment.