Jump to content

Filament run out sensor, distance after triggered??


ken226

Recommended Posts

The answer is probably obvious, since all of my searches and looking through other peoples macros hasn't helped.

I printed and assembled a filament run out switch,  then set up the basic macro from the Klipper documentation and a m600 macro.

 

it all works great.  It pauses, sets the correct LED colors and effects, parks in the right location and resumes correctly.

 

My question is:  Is there a command that will allow the printer to continue running for a specific filament linear distance after the run out switch is triggered?   

 

My switch has about two feet of Bowden tube between it and the toolhead,  and I would like the pause to occurs with only an inch or two of filament left  above the toolhead.

 

I found a macro example  here, but it just throws a bunch of errors.  

 

anyone done this?

 

 

Edited by ken226
Link to comment
Share on other sites

I found one on the Klipper discord that I was able to modify a bit and get working with my M600 filament change macro.  

So far, i've tested the macro several times by clipping my filament off between the switch and the roll, then letting it run.  It's working 100%, so far.

640mm seems to be the sweet spot. It pauses with about an inch of filament protruding from the top of the toolhead.

After the filament end passes through the switch, the printer continues running until 640mm more filament is consumed, then it triggers the M600 macro and parks itself front and center for a refill.  After refilling, the resume button on the dashboard starts it printing again.

 

Attached are the macros i'm using for this, including M600,  should anyone with the same question as me come along searching for something like this.

 

The parameter for the filament length to consume (640mm) after triggering the switch is the 4th line above "switch pin pg12", in the "[filament_switch_sensor my_sensor]", Macro.  "PAUSE_AFTER_D D={640}"

Filament runout switch..txt

Edited by ken226
  • Like 3
Link to comment
Share on other sites

  • 6 months later...

Hi, i'm looking exactly for this implementation, the attachment is no longer available. Ken, could you please re-upload the macro or just post it in here? Thanks!!

On 2/20/2023 at 7:56 PM, ken226 said:

I found one on the Klipper discord that I was able to modify a bit and get working with my M600 filament change macro.  

So far, i've tested the macro several times by clipping my filament off between the switch and the roll, then letting it run.  It's working 100%, so far.

640mm seems to be the sweet spot. It pauses with about an inch of filament protruding from the top of the toolhead.

After the filament end passes through the switch, the printer continues running until 640mm more filament is consumed, then it triggers the M600 macro and parks itself front and center for a refill.  After refilling, the resume button on the dashboard starts it printing again.

Attached are the macros i'm using for this, including M600,  should anyone with the same question as me come along searching for something like this.

The parameter for the filament length to consume (640mm) after triggering the switch is the 4th line above "switch pin pg12", in the "[filament_switch_sensor my_sensor]", Macro.  "PAUSE_AFTER_D D={640}"

Filament runout switch..txtUnavailable

 

Link to comment
Share on other sites

2 hours ago, Wikolii said:

could you please re-upload the macro

are you having trouble seeing the txt file? I was able to download it.

Here's the content.  thanks @ken226

[gcode_macro M600]
gcode:
    led_unloading
    {% set X = params.X|default(150)|float %}
    {% set Y = params.Y|default(25)|float %}
    {% set Z = params.Z|default(25)|float %}
    SAVE_GCODE_STATE NAME=M600_state
    PAUSE
    G91
    G1 E-.8 F2700
    G1 Z{Z}
    G90
    G1 X{X} Y{Y} F3000
    G91
    G1 E-15 F1000
    RESTORE_GCODE_STATE NAME=M600_state


#####################################################
# Filament Runout
#####################################################

[gcode_macro PAUSE_AFTER_D]
description: Trigger to pause the print after a further '640' mm has been extruded
variable_end_d: 0 #create variable "END_D" which is associated with the PAUSE_AFTER_D gcode macro
gcode:
  {% set d_start = printer.print_stats.filament_used|float %} #starting point is whatever the filament used is when PAUSE_AFTER_D is called
  {% set d_end = (d_start + params.D|float)|float %} #end point is start + D parameter
  SET_GCODE_VARIABLE MACRO=PAUSE_AFTER_D VARIABLE=end_d VALUE={d_end} #write the end value to the END_D gcode variable to access later
  M117 Pause at {printer["gcode_macro PAUSE_AFTER_D"].end_d|round(2)}
  UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=1 #trigger the delayed gcode below after 1 second

[delayed_gcode PAUSE_AT_D]
initial_duration: 0 #if initial_duration is zero, the delayed gcode won't start by default
gcode:
  {% set d_current = printer.print_stats.filament_used|float %} #get the current filament used
  {% if d_current < printer["gcode_macro PAUSE_AFTER_D"].end_d %} #if we aren't at the stopping point
    M117 Stopping {d_current|round(2)} {printer["gcode_macro PAUSE_AFTER_D"].end_d|round(2)}
    UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=1 #restart the timer on the delayed gcode
  {% else %}
    M600
    UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=0 #set the delayed gcode duration back to zero so it doesn't keep triggering
  {% endif %}


[filament_switch_sensor my_sensor]
pause_on_runout: False
runout_gcode:
  M117 Out of Filament
  #positions here are in printer coordinates eg if you have a 300mm bed and your sensor is 7cm past the 
  #max y position then y_offset should be 370
  #{% set x_offset = 150 %}  #approximate x location of the runout sensor
  #{% set y_offset = 370 %}    #approximate y location of the runout sensor
  #z location not used but this can be easily extended to include a z offset if needed
  #{% set current_x = printer.toolhead.position.x %}
  #{% set current_y = printer.toolhead.position.y %}
  #{% set distance = ((x_offset - current_x)**2 + (y_offset - current_y)**2)**(1/2) %}
  PAUSE_AFTER_D D={640}
insert_gcode:
  M117 Resuming
  led_loading
switch_pin: PG12


[gcode_macro RESUME]
description: Resume with LED status, return to run status
rename_existing: BASE_RESUME
gcode:
  led_printing
  BASE_RESUME { rawparams }

 

  • Like 2
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...