Filament Sensing – X5S & MKS SBase

I had my first ever print run out of filament today. Usually I’m much more consciencous about keeping on top of it, but the print without going to the basement aspect that octoprint + abl obviously has me being lazy and I didn’t check the spool properly.

Off I went on a quest to add automatic filament runout sensing to the X5S running smoothieware.

Turns out that filament sensing (at least basic versions) is super simple. There are loads of parts on thingiverse that use microswitches and printed rollers to sense, however I decided to use one that uses an optical sensor instead. Inpart that’s because they’re more straightforward, but mostly it’s because I have a bag of 20 optical endstops kicking around I’d not used a single one of.

I started out with this sensor from thingiverse and did a very slight amendment to it to allow it to mount at 45 degrees on a 2020 extrusion. The remix is here.

You just use one of these ‘standard’ optical endstops and slot it straight into the hole in the part:


Smoothie configuration is also super straightforward. You configure a switch module to suspend when triggered (in this case when it’s off):

switch.filamentout.enable true # Enable this module
switch.filamentout.input_pin 1.25^ # Pin where sensor is connected X+
switch.filamentout.output_on_command suspend # Suspend command

The documentation has resume bound to a button. As this seems a bit cludgy to me I’m using a custom menu command, and also added a pause menu command

custom_menu.resume.enable true # Resume #
custom_menu.resume.command resume # 
custom_menu.pause.enable true # Pause #
custom_menu.pause.command suspend #

Lastly we need to configure the behaivour before and after a suspend or resume (remembering that suspend runs the buffer out before stopping):

after_suspend_gcode G91_G0E-5_G0Z5_G90_G0X0Y0 #retract, drop bed 5mm then go to 00
before_resume_gcode G91_G0E1_G90 #prime 1mm then back to absolute positioning.

This is super easy to test, just set a print running and snip the filament. I’d suggest you mount the sensor as close to the extruder as practical to minimise wastage, but really you can put it where you like.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s