-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_shaper_macros.cfg
108 lines (94 loc) · 5.22 KB
/
input_shaper_macros.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#####################################################################
# Input Shaper Macros
#####################################################################
################################################
###### STANDARD INPUT_SHAPER CALIBRATIONS ######
################################################
# Written by Frix_x#0161 #
# @version: 1.3
# CHANGELOG:
# v1.3: added possibility to override the default parameters
# v1.2: added EXCITATE_AXIS_AT_FREQ to hold a specific excitating frequency on an axis and diagnose mechanical problems
# v1.1: added M400 to validate that the files are correctly saved to disk
# v1.0: first version of the automatic input shaper workflow
# -------------------------------------------------------------------------------------------------------------------------
# If you want to use it into your own config, please install it as a standalone macro as described in the
# installation section of this file: docs > features > is_workflow.md
# -------------------------------------------------------------------------------------------------------------------------
### What is it ? ###
# This macro helps you to configure the input shaper algorithm of Klipper by running the tests sequencially and calling an automatic script
# that generate the graphs, manage the files and so on. It's basically a fully automatic input shaper calibration workflow.
# Results can be found in your config folder using FLuidd/Maisail file manager.
# The goal is to make it easy to set, share and use it.
# Usage:
# 1. Call the RESONANCES_TEST macro, wait for it to end and compute the graphs. Then look for the results in the results folder.
# 2. Call the BELT_TEST macro, wait for it to end and compute the graphs. Then look for the results in the results folder.
# 3. If you find out some strange noise, you can use the EXCITATE_AXIS_AT_FREQ macro to diagnose the origin
[gcode_macro RESONANCES_TEST]
description: Run input shaper test
gcode:
{% set user = printer["gcode_macro _USERVARIABLE"] %}
{% set verbose = params.VERBOSE|default(true) %}
{% set min_freq = params.FREQ_START|default(5)|float %}
{% set max_freq = params.FREQ_END|default(133.3)|float %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
_CG28 ; Home if needed
LED_INPUT_SHAPER
TURN_OFF_HEATERS ; Turn off heaters
M107 ; Turn off fans
RESPOND TYPE=command MSG="INPUT SHAPER: Noise values, check if sensor is installed."
MEASURE_AXES_NOISE ; Get noise value
RESPOND TYPE=command MSG="INPUT SHAPER: Resonance Tests starting."
RESPOND TYPE=command MSG="INPUT SHAPER: Measure X axis."
TEST_RESONANCES AXIS=X FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
M400
RESPOND TYPE=command MSG="INPUT SHAPER: Measure Y axis."
TEST_RESONANCES AXIS=Y FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
M400
RESPOND TYPE=command MSG="INPUT SHAPER: Resonance tests done."
RESPOND TYPE=command MSG="INPUT SHAPER: Generating graphs."
RUN_SHELL_COMMAND CMD=plot_graph PARAMS=SHAPER
LED_STANDBY
[gcode_macro BELT_TEST]
description: Run resonance test to analyze belts
gcode:
{% set user = printer['gcode_macro _USER_VARIABLE'] %}
{% set min_freq = params.FREQ_START|default(5)|float %}
{% set max_freq = params.FREQ_END|default(133.33)|float %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
_CG28 ; home if needed
LED_INPUT_SHAPER
TURN_OFF_HEATERS ; turn off heaters
M107 ; turn off fan
{% if user.hw.chamber.fan %} M141 {% endif %} ; exhaust fan off
{% if user.hw.filter.ena %} _SET_FILTER {% endif %} ; filter off
_PRINT_AR T="BELT TEST: Noise values, check if sensor is installed"
MEASURE_AXES_NOISE ; get noise value in log
_PRINT_AR T="BELT TEST: Resonance Tests starting ..."
_PRINT_AR T="BELT TEST: Mesasure B belt"
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=b FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
M400
_PRINT_AR T="BELT TEST: Mesasure A belt"
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=a FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
M400
_PRINT_AR T="BELT TEST: Resonance Tests done"
_PRINT_AR T="BELT TEST: Generate graph in backround"
RUN_SHELL_COMMAND CMD=plot_graph PARAMS=BELT
LED_STANDBY
# Shell Comand is not supported by a default klipper installation
[gcode_shell_command plot_graph]
command: bash /home/pi/klipper_config/script/plot_graph.sh
timeout: 60.0
verbose: True
[gcode_macro EXCITATE_AXIS_AT_FREQ]
description: Maintain a specified input shaper excitating frequency for some time to diagnose vibrations
gcode:
{% set FREQUENCY = params.FREQUENCY|default(25)|int %}
{% set TIME = params.TIME|default(10)|int %}
{% set AXIS = params.AXIS|default("x")|string|lower %}
TEST_RESONANCES OUTPUT=raw_data AXIS={AXIS} FREQ_START={FREQUENCY-1} FREQ_END={FREQUENCY+1} HZ_PER_SEC={1/(TIME/3)}
M400
[gcode_shell_command PLOT_GRAPH]
command: bash /home/pi/printer_data/config/script/plot_graph.sh
timeout: 60.
verbose: True