What is wrong with my "disable sensor" gcode?


I have a spool of translucent PLA filament that doesn't work well with the filament sensor on my Prusa i3 MK3. The translucency trips up the sensor, making it think the filament ran out. I thought I'd create a filament profile in Slic3r and disable the sensor in the "Start G-code" block that gets inserted at the beginning of the exported gcode file.

I've got the following code:

M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode
M406 ; Disable filament sensor
M117 Filament sensor OFF

The first line is provided by Prusa's default PLA profile. The second line should disable the sensor, and the third line should print the "Filament sensor OFF" message. If I look in the gcode, it's there:

G92 E0.0
M221 S95
M900 K30; Filament gcode
M406 ; Disable filament sensor
M117 Filament sensor OFF
G21 ; set units to millimeters
G90 ; use absolute coordinates
M83 ; use relative distances for extrusion

But if I print this gcode file, I see no message, and when checking the sensor in the "Tune" menu while printing, the sensor is still on.

I thought I might have a problem with line endings, but looking at the file in a hex editor, all the lines seem to end with a 0A line feed character, including mine.

Why isn't my printer doing anything with the M406 and M117 messages? Full gcode file here.


Posted 2018-05-15T10:53:34.563

Reputation: 183



When you download the latest version of your firmware you find the implementation of all the codes in Marlin_main.cpp. Here you see that the M406 is not implemented! Hence it does not work.


Posted 2018-05-15T10:53:34.563

Reputation: 25 570

this is original Prusa - so marlin is not used! – profesor79 – 2018-05-15T14:01:14.450


@profesor79 Download the software from Prusa itself and you will see that it does have the Marlin_main.cpp file! https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/Marlin_main.cpp

– 0scar – 2018-05-15T14:15:37.553

ok got that, another bit it the puzzles sorted :) – profesor79 – 2018-05-15T14:16:53.643

1@profesor79 Always glad to teach the professor ;) – 0scar – 2018-05-15T14:17:56.630

Interesting. So why doesn't M117 work either? – Bas – 2018-05-15T14:42:53.227

1@Bas I can't tell for sure, Prusa has implemented M117 differently (with a higher priority?). Maybe this does not work flawlessly. – 0scar – 2018-05-15T19:35:46.913


As per github PR this is not implemented - see this PR for details Please check if your printer is processing M406 by issuing it manually.

In meantime, a sticker on the sensor will help you to print :)


Posted 2018-05-15T10:53:34.563

Reputation: 1 900

Professor79 Could you give a little more detail on how to use a sticker to stop the filament sensor issue? Maybe a photograph or specific placement advice? Left to my own devices I will continue to avoid the issue by printing my shiny filaments in total darkness. There has to be a better way. Thanks, from the peanut gallery – Winky42 – 2019-05-08T14:59:52.853

@Winky42 that depends if you have a mechanical or optical sensor. if is optical then just cover the lenses, if is mechanical put down the lever. – profesor79 – 2019-05-09T11:32:30.157