Wanhao D9 firmware
English

Filament sensors

From v2.0.5 these firmwares read two kinds of sensor: Wanhao's runout switch, and the BTT Smart Filament Sensor V2.0, which also notices when the filament stops moving (tangled spool, jam, stripped filament). Runout detection is on by default on every model, and jam detection is off.

The sensor plug

Wanhao D9 main board: the 4-pin sensor plug left of POWER-DET, pins D9, D8, GND and 5V, wired to a BTT Smart Filament Sensor V2.0

The 4-pin plug to the left of POWER-DET, below the endstop plugs, carries D9, D8, GND and 5V, in that order. The pin names come from a wiring diagram by Wanhao that dustovich found and shared on the Discord; the back of the board prints the same four pins as CTRL, BTN, GND and VCC.

Printer switched off while you plug or unplug anything on the board.

On the screen

With DGUS Reloaded 2.0 on the screen (firmware v2.0.9 or later): Settings → Filament → Filament sensor.

  • Runout detection turns all detection on or off, like M412 S1 / M412 S0.
  • Jam detection turns jam detection on with the length below, or off (L0).
  • Jam length: − and + change it by 1 mm; tap the number to type it.
  • The Filament dot is green while the runout switch sees filament, red when it does not.
  • Changes apply at once. Save stores them, like M500. The back arrow leaves without saving: the stored settings come back at the next start.
Filament sensor page of DGUS Reloaded 2.0: runout and jam detection switches, jam length with minus and plus buttons, filament indicator and Save button
Settings → Filament → Filament sensor

The M412 commands

Everything is set over USB from a serial terminal (Pronterface, the terminal of your slicer or of OctoPrint, 250000 baud). Parameters can be combined in one command, for example M412 S1 L10.

CommandWhat it does
M412Shows the state, for example Filament runout ON ; Distance 5.00mm ; Motion distance 0.00mm.
M412 S1Turns detection on: the runout switch, and jam detection too if the jam length is not 0.
M412 S0Turns all detection off, switch and jam.
M412 D5Once the switch sees no filament, keeps printing 5 mm before pausing, to use the filament left between the sensor and the nozzle. Default 5 mm.
M412 L10Turns jam detection on (BTT sensor only): pauses when 10 mm of filament go through the extruder without the sensor's wheel moving.
M412 L0Turns jam detection off and leaves the runout switch as it is. This is the default.
M500Saves the settings. Without it, a change is lost when the printer is switched off.
M119The filament line reads TRIGGERED with filament loaded, open without.

M412 L0, and L used on its own, come from our change to Marlin (MarlinFirmware/Marlin#28585), built into these firmwares. In Marlin without it, L alone is ignored and L0 pauses the print as a jam at once.

Wanhao's runout switch

It tells the firmware whether filament is there. When it goes missing, the print pauses after 5 more mm of filament and the screen starts a filament change.

It is on by default on every model, since v2.0.8. With nothing plugged into D8, the board's pull-up holds the pin at 5 V, which reads as "filament present": detection then never triggers, so it can stay on whether or not a sensor is fitted. Plug a runout switch into D8 and it works straight away.

BTT Smart Filament Sensor V2.0

This sensor has two outputs, and the firmware reads them differently:

Wiring

5V to 5V, GND to GND, the runout switch signal to D8 and the motion signal to D9. The names printed on the sensor's cable may differ.

Turning it on

M412 S1 L10
M500

If prints pause without a reason, raise the jam length: M412 L15 then M500. To keep only the runout switch: M412 L0 then M500.

Checking it

Jam detection was tested on an MK2 300 without the sensor (a 2 mm jam length triggers, L0 never does), but not yet with the BTT sensor itself. If the switch reads the wrong way round (open with filament loaded), tell us on Discord.

Updating from v2.0.5 or v2.0.6

Those releases had no way to turn jam detection off, so they used a jam length too long to ever be reached: 100 m in v2.0.5 (too short in fact: about a third of a 1 kg spool, after which a printer left on could pause for nothing) and 10 km in v2.0.6. When the printer starts, v2.0.7 loads those two values as L0. A real length you set for a BTT sensor, such as L10, is kept. From v2.0.4 or earlier, the 5 mm runout distance is loaded instead of the 0 those versions saved.