Skip to content

Wanhao Duplicator 9: build again, Wanhao's factory settings and Y directions, power-loss recovery, endstop noise filter - #1205

Merged
thinkyhead merged 12 commits into
MarlinFirmware:import-2.1.xfrom
Le-Syl21:wanhao-d9-fixes
Oct 14, 2026
Merged

thinkyhead merged 12 commits into
MarlinFirmware:import-2.1.xfrom
Le-Syl21:wanhao-d9-fixes

Conversation

@Le-Syl21

@Le-Syl21 Le-Syl21 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

Any of the twelve Wanhao/Duplicator 9 examples (MK1, MK1u2, MK2, MK3 × 300 / 400 / 500), on the WANHAO_D9 board.

Description

Eleven commits, each standing on its own:

  1. Build again. None of the twelve D9 examples has built on bugfix-2.1.x since 🔧 Enable HOST_ACTION_COMMANDS by default Marlin#28442. They enabled HOST_START_MENU_ITEM and HOST_SHUTDOWN_MENU_ITEM, which now require MarlinUI, and the D9 runs a DGUS display. Both are back to the template's disabled form.
  2. MK1 probe. The MK1's inductive probe on Z_MIN pulls the pin low when it triggers. Wanhao's own MK1 firmware sets Z_MIN_ENDSTOP_INVERTING and Z_MIN_PROBE_ENDSTOP_INVERTING true, and Klipper's printer-wanhao-duplicator-9-2018.cfg reads it as !PH3 — both LOW, where these examples had HIGH.
  3. Power-loss recovery. POWER_LOSS_RECOVERY is enabled and on by default. This commit used the power-fail input on pin 63, declared in pins_WANHAO_D9.h; commit 10 turns that pin off again.
  4. MK3 Y. Wanhao's own download page for the D9 says "the D9 MK3 Y axis motor has been positioned near the touching screen side", and its MK3 firmware (V1.1.3) inverts Y. The MK3 examples had kept the MK2's direction.
  5. MK2 500 Y. The same factory firmwares keep Y not inverted on every MK2 size, including the 500 that Wanhao rebuilt in July 2019 (V1.1.2.1). The 500 example had been switched to an inverted Y after one owner's report (Wanhao D9: Fix INVERT_E0_DIR for MK1 and INVERT_Y_DIR for MK2/500 based on owner feedback #1182); it goes back to the factory direction.
  6. Factory settings. Steps/mm, maximum feedrate and acceleration, hotend PID and probe offsets now match Wanhao's firmware for each model: 81 / 81 / 400.5 / 94.3 steps, 500 mm/s² and probe X 15, Y 0 on the MK1 (V0.164(B), its last MK1 firmware); 80.2 / 80.2 / 400.3 / 94.3 steps and 3000 mm/s² on the others, with probe Y −10 on the MK1u2 kit and Y 0 on the MK2 and MK3; PID 33.41 / 1.47 / 189.27 everywhere. The Z probe offsets are unchanged, since Wanhao's firmware left Z to be set on the screen.
  7. Endstop noise. An MK2 300 owner hit Homing Failed whenever the bed started far from the Y switch: the fast move stopped a few millimetres short, and the slow re-approach could not reach the switch. ENDSTOP_NOISE_THRESHOLD 2 fixed it on his printer ([BUG] Homing failed with Marlin 2.0.x Marlin#16371 describes the same symptom). The same commit keeps M503, which the examples had disabled; flash stays at 50–52 %.
  8. The rest of Wanhao's settings. Commit 6 only took what could be read out of the binaries. This one compares every option active in Wanhao's four published sources, run through the preprocessor, with the examples' effective values, and takes the machine ones: probing margins (Wanhao kept the first column 10 mm in from the edge; ours put the nozzle at X 0, where an MK2 300 owner's nozzle hit the bed clips during G29), probe clearances, probe and homing feedrates, HOMING_BUMP_DIVISOR, BLTOUCH_DELAY, thermal protection periods, TEMP_HYSTERESIS, bed max temperature, classic jerk, park position, preheat values and FAN_SOFT_PWM on the BLTouch models. The MK3 has no published source: comparing the constants in its V1.1.3 binary with the MK2's V1.1.2 and V1.1.2.1 shows the same values except the bed max temperature (105 °C, 90 °C on the 500). Three values cannot follow Wanhao: HEATER_0_MAXTEMP stops at 305 because thermistor 1's table ends at 320 °C with the 15 °C overshoot, the mesh stays 5×5 because DGUS Reloaded requires it, and the min temperatures stay at 5 °C so a disconnected thermistor is still caught.
  9. Keep stored settings across updates. EEPROM_INIT_NOW wiped the EEPROM on the first boot of every new build, so each update lost the probe Z offset and the mesh. EEPROM_AUTO_INIT still resets a store that doesn't match.
  10. Power-loss recovery without the outage pin. On an MK2 300, pin 63 reads low as soon as a print starts heating, and every print stopped at once with a power outage, again after each resume. Wanhao's MK2 source never reads that pin (it only appears in a developer menu of another model), so POWER_LOSS_PIN is -1: the job is saved on each Z change instead, and a print can still be resumed after a real outage. Tested on that printer: prints run.
  11. Centre after levelling. Probing ends at the back corner, so the bed stays forward, in front of the touchscreen, and an MK2 300 owner asked for the head to come back. EVENT_GCODE_AFTER_G29 raises Z to 10 mm and moves to the bed centre (150, 200 or 250). Tested on an MK2 300: the 25 points probe, then the head stops at X150 Y150 Z10.

Wanhao's site is gone, but its Dropbox links still work. The directions and settings above were read out of those factory binaries. For the directions: in Stepper::set_directions(), each axis writes its DIR pin (PK0, PK3 and PK7 on this board, all on PORTK) first with INVERT_x_DIR, then with its complement, so the order of the set and clear instructions gives the setting. The method returns the exact values of the four source packages Wanhao published (MK1 V0.15 and V0.164(B), MK2 V1.1.2, MK2 kit V1.1.31) before being applied to the MK3 and to the 500. The binaries, the extraction script and the results are kept at https://github.com/Le-Syl21/WANHAO-Duplicator-9.

Benefits

The D9 examples build again, so they can be part of the next release builds, start from the settings Wanhao shipped, and home and probe without hitting the bed clips.

All twelve build locally against current bugfix-2.1.x (flash 49.9–50.8 %, RAM 66.4–67.2 %). The MK2 300 build runs on my printer: homing, BLTouch probing, a 5×5 G29 mesh, and M413 reporting recovery on; the noise filter was confirmed on another owner's MK2 300. I have no MK1 or MK3 to run those builds on. The board file itself gets a small update in MarlinFirmware/Marlin#28583.

Related Issues

Follows #1155 and #1182.

@Le-Syl21 Le-Syl21 changed the title Wanhao Duplicator 9: build again, fix MK1 probe and MK3 Y, add power-loss recovery Wanhao Duplicator 9: build again, fix MK1 probe and Y directions, add power-loss recovery Sep 14, 2026
Le-Syl21 added a commit to Le-Syl21/WANHAO-Duplicator-9 that referenced this pull request Sep 14, 2026
The site (docs/, GitHub Pages) helps owners identify their D9, download
the right firmware and flash it, in English and French. The 24 .hex are
rebuilt in one pass from Marlin bugfix-2.1.x and the configurations of
MarlinFirmware/Configurations#1205, so standard and Y-inverted builds all
come from the same sources.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENsGGxgZ7pU5Z87YfBS2iY
@Le-Syl21 Le-Syl21 changed the title Wanhao Duplicator 9: build again, fix MK1 probe and Y directions, add power-loss recovery Wanhao Duplicator 9: build again, Wanhao's factory settings and Y directions, power-loss recovery, endstop noise filter Sep 14, 2026
Le-Syl21 added a commit to Le-Syl21/WANHAO-Duplicator-9 that referenced this pull request Sep 16, 2026
…r levelling

- The head returns to the bed centre (Z up 10 mm) after G29, so the bed no
  longer hides the screen (EVENT_GCODE_AFTER_G29, also proposed in
  MarlinFirmware/Configurations#1205). Tested on an MK2 300.
- BTT Smart Filament Sensor V2.0: motion signal on D9, next to the runout
  input D8 on the board's sensor plug (pin names from Wanhao's wiring
  diagram, found by dustovich). Off by default, 100 m default jam length so
  a plain runout switch cannot fake a jam; M412 S1 L10 + M500 to use it.
  Settings saved by v2.0.4 or earlier hold zero runout and motion lengths,
  so these builds load the defaults instead (one line in settings.cpp).
- New Filament sensor page on the site with a wiring diagram (SVG, EN/FR).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENsGGxgZ7pU5Z87YfBS2iY
@thinkyhead
thinkyhead force-pushed the import-2.1.x branch 3 times, most recently from 6b04ca2 to 109c2b7 Compare October 3, 2026 16:21
Le-Syl21 and others added 12 commits October 14, 2026 12:28
HOST_START_MENU_ITEM and HOST_SHUTDOWN_MENU_ITEM add entries to the
MarlinUI menu, and the D9 runs a DGUS display, which has none. Since
Marlin#28442 SanityCheck rejects them without MarlinUI, so none of the
twelve D9 examples has built on bugfix-2.1.x since June.
The MK1 carries an inductive probe on Z_MIN, which pulls the pin low
when it triggers. Wanhao's own MK1 firmware sets
Z_MIN_ENDSTOP_INVERTING and Z_MIN_PROBE_ENDSTOP_INVERTING true, and
Klipper's printer-wanhao-duplicator-9-2018.cfg reads it as !PH3 —
both LOW, where these examples had HIGH.

The probe offsets were the MK2's BLTouch ones. Use Klipper's MK1
values instead: x_offset 27, y_offset 3, z_offset 1.4.
The D9 board wires a power-fail detector to pin 63 (POWER_LOSS_PIN,
POWER_LOSS_STATE LOW in pins_WANHAO_D9.h), and Wanhao's own firmware
used it to resume prints after an outage. Enable POWER_LOSS_RECOVERY
with PLR_ENABLED_DEFAULT to bring that back, and POWER_LOSS_PULLUP so a
pin left unconnected reads "power present" instead of floating low and
halting a print.

Boots on a D9 MK2 300 with M413 S1.
The MK3 head upgrade moves the Y motor from the back of the frame to the
front, and Wanhao's MK3 firmware reverses the Y direction to match, as
an owner who upgraded a D9 300 describes on r/3Dprinting ("wanhao D9
300 MK3"). The MK3 examples were copied from the MK2 and kept its
INVERT_Y_DIR false.
Wanhao's own MK2 firmwares keep Y not inverted on every size, including
the 500, which Wanhao rebuilt in July 2019 (V1.1.2.1). Reading the Y DIR
writes in Stepper::set_directions() of the published binaries shows the
same order on the 300, 400 and 500, and the method gives back the values
of Wanhao's MK2 V1.1.2 source. The 500 example had been switched to an
inverted Y for one owner's machine; go back to the factory direction.
Probing ends at the back corner, so the bed stays forward over the
screen. EVENT_GCODE_AFTER_G29 raises Z to 10 mm and moves to the bed
center (150/200/250).
@thinkyhead
thinkyhead merged commit 59b9fb5 into MarlinFirmware:import-2.1.x Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants