Jump to content

Belt Tension Macro - RatOS (Rat Rig)


mvdveer

Recommended Posts

 

@Simon2.4 Was looking for this as well. Came across it on the Rat Rig Discord. Have not tested it myself yet. I posted it here as not to hijack @claudermilk's thread. 

[gcode_macro GENERATE_SHAPER_GRAPHS]
description: Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode:
  {% set freq_start = params.FREQUENCY_START|default(10)|int %}
  {% set freq_end = params.FREQUENCY_END|default(133)|int %}
  {% if params.AXIS is defined %}
    {% if params.AXIS|lower == 'x' %}
      MAYBE_HOME
      TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end}
      RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
      RESPOND MSG="Input shaper graph generated for the X axis. You'll find it in the input_shaper folder in the machine tab!"
    {% elif params.AXIS|lower == 'y' %}
      MAYBE_HOME
      TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end}
      RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
      RESPOND MSG="Input shaper graph generated for the Y axis. You'll find it in the input_shaper folder in the machine tab!"
    {% else %}
      {action_raise_error("Unknown axis specified. Expected X or Y.")}
    {% endif %}
  {% else %}
    MAYBE_HOME
    TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end}
    TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end}
    RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
    RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
    RESPOND MSG="Input shaper graphs generated for X and Y. You'll find them in the input_shaper folder in the machine tab!"
  {% endif %}
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description: Generates resonance graph used to ensure belts are equally tensioned.
gcode:
  {% set freq_start = params.FREQUENCY_START|default(10)|int %}
  {% set freq_end = params.FREQUENCY_END|default(133)|int %}
  {% if params.AXIS is defined %}
    {% if params.AXIS|lower == 'x' %}
      TEST_RESONANCES AXIS=1,1  OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end}
      TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START=10 FREQ_END=11
    {% elif params.AXIS|lower == 'y' %}
      TEST_RESONANCES AXIS=1,1  OUTPUT=raw_data NAME=belt-tension-upper FREQ_START=10 FREQ_END=11
      TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end}
    {% else %}
      {action_raise_error("Unknown axis specified. Expected X or Y.")}
    {% endif %}
  {% else %}
    TEST_RESONANCES AXIS=1,1  OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end}
    TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end}
  {% endif %}
  RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
  RESPOND MSG="Belt tension graphs generated. You'll find them in the input_shaper folder in the machine tab!"

Don't know if it needs any adjustments to work on non Rat Os printers. Maybe @claudermilk can shed light on that as he used it on his Trident. I know @Penatr8tor has a V-Minion that runs Rat OS. (Have not built mine as yet) 

 

  • Like 1
Link to comment
Share on other sites

7 hours ago, fanplastics said:

needs the shell commands and scripts that are called

Thanks for pointing that out - I am a total noob when it comes to Klipper macros. Something on my todo list - learn the language for creating macros. Too many things, too little time.

  • Like 1
Link to comment
Share on other sites

Here are my shell macro's from my V-Core 300 RatOS install.

[gcode_shell_command generate_shaper_graph_x]
command: /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout: 60.
verbose: True

[gcode_shell_command generate_shaper_graph_y]
command: /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout: 60.
verbose: True

[gcode_shell_command generate_belt_tension_graph]
command: /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout: 90.
verbose: True

[gcode_shell_command compile_binaries]
command: /home/pi/printer_data/config/RatOS/scripts/compile-binaries.sh
timeout: 600.

[gcode_shell_command change_hostname]
command: /home/pi/printer_data/config/RatOS/scripts/change-hostname.sh
timeout: 10.

[gcode_macro GENERATE_SHAPER_GRAPHS]
description: Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode:
    {% if params.AXIS is defined %}
        {% if params.AXIS|lower == 'x' %}
            MAYBE_HOME
            TEST_RESONANCES AXIS=X
            RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
            RESPOND MSG="Input shaper graph generated for the X axis. You'll find it in the input_shaper folder in the machine tab!"
        {% elif params.AXIS|lower == 'y' %}
            MAYBE_HOME
            TEST_RESONANCES AXIS=Y
            RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
            RESPOND MSG="Input shaper graph generated for the Y axis. You'll find it in the input_shaper folder in the machine tab!"
        {% else %}
            {action_raise_error("Unknown axis specified. Expected X or Y.")}
        {% endif %}
    {% else %}
        MAYBE_HOME
        TEST_RESONANCES AXIS=X
        TEST_RESONANCES AXIS=Y
        RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
        RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
        RESPOND MSG="Input shaper graphs generated for X and Y. You'll find them in the input_shaper folder in the machine tab!"
    {% endif %}

[gcode_macro MEASURE_COREXY_BELT_TENSION]
description: Generates resonance graph used to ensure belts are equally tensioned.
gcode:
    TEST_RESONANCES AXIS=1,1  OUTPUT=raw_data NAME=belt-tension-upper
    TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower
    RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
    RESPOND MSG="Belt tension graphs generated. You'll find them in the input_shaper folder in the machine tab!"

[gcode_macro COMPILE_FIRMWARE]
description: Compiles firmware with currently installed klipper version for all supported RatOS boards. Note: this may take up to 10 minutes.
gcode:
    RESPOND MSG="Compiling binaries.. This can take up to 10 minutes. Please do not turn off your Raspberry Pi!"
    RUN_SHELL_COMMAND CMD=compile_binaries
    RESPOND MSG="Firmware binaries compiled successfully! You can find them in the firmware_binaries folder in the machine tab!"

[gcode_macro CHANGE_HOSTNAME]
description: Change the hostname of your Raspberry Pi.
gcode:
    {% if params.HOSTNAME is not defined %}
        RESPOND MSG='You have to specify a new hostname with the HOSTNAME parameter. Ex: CHANGE_HOSTNAME HOSTNAME="MY_NEW_HOSTNAME"'
        RESPOND MSG="Please note: RFCs mandate that a hostname's labels may contain only the ASCII letters 'a' through 'z' (case-insensitive), the digits '0' through '9', and the hyphen. Hostname labels cannot begin or end with a hyphen. No other symbols, punctuation characters, or blank spaces are permitted."
    {% else %}
        RUN_SHELL_COMMAND CMD=change_hostname PARAMS={params.HOSTNAME}
    {% endif %}

Hope this helps.

FWIW... I need to learn more about reading these graphs. Once I get done building the current printer I'll jump back into this as I'm still getting some VFA lines on prints and it could be belt tension related, need to learn and re-check things.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...

I know this was posted a while ago but I just stumbled on it now.

Can anyone help to implement this? Most of it is over my head.

I tried to put it into its own belt_tension.cfg file & included that in my printer.cfg but I keep getting an error
"Section 'gcode_shell_command generate_shaper_graph_x' is not a valid config section"

Also what needs to be changed to make it specific to my printer size?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...