Runout sensor problem

Basic Information:

Printer Model: diy
MCU / Printerboard: rpi2 + mks Lgen 1.0

Hello

newly registered a few days ago :slight_smile:

I have a small problem with my configuration, everything works very well except for one point, the end of filament sensor

it is plugged into my mks Lgen motherboard on a free input

it is implemented with the attached code

runoutsensor.txt (1.9 KB)

contained in a specifc file and “included” in the config.cfg file

it works, so if the “switch” is triggered the machine pauses and resumes if you click on “resume”

BUT

when it resumes I have a shift of the Z of a layer, which means that it does not work at all :frowning:

moreover the system is far too sensitive, the slightest trigger of a few micro seconds and it pauses! , there must be a way to add a delay to the sensor? (it does not pause on its own while the filament is present)

to know that my printer is perfectly adjusted and absolutely never misses a single step

2A “large” motor, tmc2209 in uart, mks Lgen 1.0, and of course klipper mainsail :), core XY configuration

if you have any idea?

Cordially

As far as I see the problem lies in this line:

    {% set park_z = [th.position.z + params.Z_LIFT|default(z_lift)|int, th.axis_maximum.z]|min %}

You add a z_list value (20) to the actual z-position.

And in this line you park at that new position:

    G0 X{park_x} Y{park_y} Z{park_z} F{park_feedrate}

When you resume, ( I don’t know what code you use for that), you have to lower the Z value again.

thank’s :slight_smile:

okay the problem is the code ! the code picked up on “tuto” in web

i adapt little bit for my printer , and no idea to change for not add value to Z position (juste move for decal to manual purge )

and i idea for add “hysteresis” on my sensor ?

thank’s

nobody have any idea for correcting the code ? , or correct code for runout sensor.cfg ?

thank’s :slight_smile:

This is what I have in my printer.cfg:

[filament_switch_sensor E_0]
pause_on_runout: True
runout_gcode: outoffilament_0
#insert_gcode:
event_delay: 3.0
pause_delay: 0.5
switch_pin: ^PA0

[gcode_macro outoffilament_0]
gcode:
  PARK_MACRO_0
  M117 Out of Filament E 0

[gcode_macro PARK_MACRO_0]
gcode:
  {% set X = params.X|default(0)|float %}
  {% set Y = params.Y|default(0)|float %}
  {% set Z = params.Z|default(30)|float %}
  M117 Parking E 0
  G91
  G1 Z{Z} F1500
  G90
  G1 X{X} Y{Y} F3000