Load/Unload to Filament Detection Sensor

Hi all,

Looking for some help on loading and unloading filament on a 2 in 1 out extruder system.

I have gone through what seems like hundreds of Macro’s and all seem to just define a set distance using the G1 command.

My current test system consist of the folling hardware:

2 extruders feeding into a Y-Splitter then a single tube feeding the hotend, between the extruders and the Y-Splitter, I have a filament detection switch on each line.

So very simple and basic system, I would like to do something along the line of “Homing” the filament, below is just a basic rundown on what I would like to do:

if filament is detected on switch 1 then retract T0 until switch 1 does not detect filament
if filament is detected on switch 2 then retract T1 until switch 2 does not detect filament
if filament is not detected on switch 1 then extrude T0 until switch 1 does detect filament then retract until filament is not detected on switch 1
if filament is not detected on switch 2 then extrude T1 until switch 2 does detect filament then retract until filament is not detected on switch 2

Now to calibrate the distance between the switch and the extruder, I extrude until I see filament coming from the hotend, then:

if filament is detected on switch 1 then retract T0 until switch 1 does not detect filament
if filament is detected on switch 2 then retract T1 until switch 2 does not detect filament
log the E steps used
Save the E steps
Extruder calibrated

I can do most of the above easily if I just command G1 to move the extruder a given length, but I cant work out out how to command the extruder to move until it hits the filament detection switch.

Does Klipper have a built in Macro for load to a filament switch or unoad to a filament switch?

Ive looked through the MMU2 macros, and they are way to complex for the simple tasks I would like to do, I can have the system operate okay by just defining a set distance, but I was hoping someone much more clever than I, has worked this out already.

1 Like

Caveat up front, I don’t have a filament sensor, but I do have a 6-in-1-out setup that uses a splitter and a set of “close enough” hardcoded distance values like you describe. Having true extruder stepper homing like this would be really nice.

However, I think the problem you’re going to have with doing what you’re trying to do with a macro is that you can’t interrupt a running G1 command without issuing an emergency shutdown. So there’s no way to have a macro do something like retract filament until a filament sensor is triggered. What you could do is use delayed_gcode to hack together the equivalent of a while loop that (for example) retracts 1mm of filament and then checks whether the filament sensor has been activated, and repeats doing this until the filament sensor is activated, at which point the loop breaks and the macro continues. This is a very imperfect solution though, and it has some significant downsides:

  • This method of “homing” will only be accurate to within one unit of whatever distance value you use (e.g. 1mm in the example above).
  • The extruder stepper will come to a complete stop between each successive G1 command, so stringing ten G1 E1 s together will not look the same as a G1 E10. The motion will be jerky and since extruder steppers respect acceleration too, the max extrusion speed likely won’t ever be reached, so the smaller your E value, the slower this will be.

I think the “proper” way to do what you want would be to add some core Klipper code that truly homes the extruder as with other axes. About a year ago someone attempted to do this using a physical endstop switch. It looks like they are still maintaining a Klipper fork with this functionality included. Maybe some parts of that fork could be adapted to use the currently supported filament sensors.

1 Like

Deleted: Not relivent anymore

Okay, I checked out that fork, started to get excited as it does exactl what I want…then I kept reading and seen this:

  • Limitations: It is untested on extruder steppers configured as [extruder_stepper] later synced to a particular [extruder]. No “second home” is performed.

Unfortunately I need to to only home extruder_stepper’s as both T0 and T1 are synced to the single direct drive extruder.

@theophile Thankyou for the idea on the loop, I managed to create a good working set of macro’s to home filament, after trying all sorts of things, even the Klipper CNC fork, I just sat down with ChatGPT and got some assistance on what does what in Jinja2.

I now have a fast preload macro for loading fresh filament that will suck in the filament then home it to the filament detection switch, and I have another macro that will suck the filament back rapidly from the extruder and home it to the filament detection switch, simple tasks, but a lot of work to make it happen reliably.

Making loops happen with an interupt and a decision to be made after the interupt on whether to stop or repeat the sequnce was needed.

I still think that homing filament should be a basic feature in Klipper, specially with everyone wanting to do multi filament printing now, this and proper support for a filament distance encoder.

I managed to have everything sorted, if anyone is interested, my system now homes filament when loading fresh filament and when changing filaments, fully automated filament homing.

Below is my NXG-FRS (Filament Router System), the entire thing is powered and controlled through a single USB-C cable and fully operational under Klipper!

2 Likes

Looks interesting. Are you going to release your design?

I’m using a 4in-1out splitter and this would be nice addition for filament changes.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.