Skip to content

Instantly share code, notes, and snippets.

@varazir
Forked from adelyser/biqu_bx_klipper.md
Last active August 6, 2025 17:11
Show Gist options
  • Save varazir/f8994b0ebbe4ce2d1e1cdf88fb65621d to your computer and use it in GitHub Desktop.
Save varazir/f8994b0ebbe4ce2d1e1cdf88fb65621d to your computer and use it in GitHub Desktop.
Klipper on the BIQU BX V3

Klipper on the BIQU BX V3

NOTE: If you have a V2 board/screen(HDMI),click here

First, a few requirements:

  1. You need Klipper setup on your Raspberry PI ( borad that support DSI) with your favorite control interface (Octoprint, Fluidd, Mainsail, etc..).
  2. Install the Drivers for V3 screen https://github.com/bigtreetech/BIQU-BX/tree/master/Firmware/RPi-Linux-RPi-7inch-DSI
  3. You need your favorite Touchscreen UI installed (unless you just want to run headless).
  4. You MUST have removed the Z endstop physical switch. Not disconnected, but completely removed.

NOTE: CAN will not work on this board due to a hardware mis-configuration
NOTE: I2C is not quite working yet!

Ok, so let's get started.


Klipper firmware configuration

When configuring the klipper firmware to run on the BTT SKR SE BX board, there are a couple things to know about.

  1. Use the main klipper branch.
  2. In order for the toucscreen to work, you will need to set GPIO pins PB5 and PE5 to an initial state during the config
  3. Use the config/printer-biqu-bx-2021.cfg file for your intial printer.cfg
  4. Once you are setup, you will need to calibrate your sensorless homing: https://www.klipper3d.org/TMC_Drivers.html?h=sensorless+ho#sensorless-homing

Klipper Firmware Configuration

A note on connection methods:

There are 4 different connections you can make from the Raspberry Pi to the mainboard, 2 Serial and 2 USB.

Communication Interface

  • Serial (on UART4 PA0/PA1) <--- For v3 board/screen you need to use this

To use serial connections, you have to enable the serial port on the raspberry pi and compile the correct serial port for the BX mainboard. Once you have the serial port enabled on the raspberry pi, it will show up as /dev/ttyAMAx, with x being the port number.

Once you have it setup, your printer.cfg should then contain the following under the MCU section: serial: /dev/ttyAMAx, substituting the x for your port number.


HDMI configuration

As v3 uses DSI you don't need any HDMI settings

Drivers for V3 screen

Config.txt

Example on /boot/config.txt

Make sure this are in the config.txt file, some wil be added by the drivers installation skript.
[all]
dtparam=i2c_vc=on
dtparam=i2c_arm=on
enable_uart=1
dtoverlay=disable-bt
dtoverlay=vc4-kms-dsi-btt-bxv3-7inch
disable_splash=1

Slicer configuration

For your slicer, you need to call the PRINT_START macro instead of any preliminary gcode. The NOZZLE and BED temps get passed in as arguments. Some examples for the more popular slicers:

  • Cura: PRINT_START BED={material_bed_temperature_layer_0} NOZZLE={material_print_temperature_layer_0}
  • PrusaSlicer: PRINT_START NOZZLE=[first_layer_temperature] BED=[bed_temperature]
  • Ideamaker: PRINT_START NOZZLE={temperature_heatbed} BED={temperature_extruder1}
  • Simplify3D: PRINT_START NOZZLE=[extruder0_temperature] BED=[bed0_temperature]
  • Kiri:Moto: PRINT_START NOZZLE={temp} BED={bed_temp}

Klipper Functionality

Here are some notes on how I have Klipper setup and working quite well for my machine.

Touchscreen Sleep

The Touchscreen will go dark when the printer idle timeout occurs. This happens when there is not a print job in action and currently set for 5 minutes. Pressing the Menu Knob on the display will wake up the Touchscreen.

LEDS

The Neopixels are setup and will cycle through colors on bootup. I have the idle timeout set to shut off the LEDS when the printer is inactive. The LEDs automatically come on when a print is started or when the LCD is wakened.

Homing Routine

I have programmed a reliable homing routine that works well for me, however you can adjust or setup your own to taste. My routine will do the following:

  1. Raise the Z axis
  2. Home the X axis
  3. Home the Y axis
  4. Move the probe to the center of the bed (different than the nozzle at center)
  5. Home the Z with the probe.
  • When starting a print, additionally:
  1. After the bed reaches temp, the printer waits for 90 seconds with the probe close to the bed to warm up the probe.
  2. Steps 1-5 are repeated with a warm probe
  3. Move to the origin to start the print.
@Cracoukas
Copy link

Cracoukas commented Jun 15, 2024

I am now able to connect to the MCU using using pin 6-8-10 of the PI and the TFT pins of the SKR-SE-BX-V3.0 (crossing Rx and Tx).
The TFT display is useless (just to confirm that the MCU is flashed correctly).

and configuring serial USART1 PA10/PA9

@varazir
Copy link
Author

varazir commented Jun 15, 2024

I am now able to connect to the MCU using using pin 6-8-10 of the PI and the TFT pins of the SKR-SE-BX-V3.0 (crossing Rx and Tx). The TFT display is useless (just to confirm that the MCU is flashed correctly).

Strange that you need to do that.
Well it's not the best screen. I have issue that it's all white until it's "warm"

@Lymperis79
Copy link

I had problem connecting to the printer even after following the step described. My settings are the original as varazir adviced. After some research i found that my problem was fixed after removing the section "console=serial0,11520" from '/boot/cmdline.txt' with a text editor.
Now i am able to see the printer using

@aynotka
Copy link

aynotka commented Jan 22, 2025

Здравствуйте, столкнулся с проблемой при установке Klipper.
На сайте когда водишь IP Raspberry pi 4, первым делом появляется вот такое сообщение:

mcu 'mcu': Unable to connect
Once the underlying issue is corrected, use the
"FIRMWARE_RESTART" command to reset the firmware, reload the
config, and restart the host software.
Error configuring printer
Много чего перепробовал.

@aynotka
Copy link

aynotka commented Jan 22, 2025

У меня возникли проблемы с подключением к принтеру даже после выполнения описанных шагов. Мои настройки являются исходными, как и советовал Варазир. После некоторых исследований я обнаружил, что моя проблема была решена после удаления раздела «console=serial0,11520» из «/boot/cmdline.txt» с помощью текстового редактора. Принтер использует

Вы смогли решить проблему?

@valpackett
Copy link

valpackett commented May 4, 2025

Hello everyone,

I have recently acquired this printer and "reverse engineered" the modified drivers.

The device tries to present an interface similar to the official RPi 800x480 7" touchscreen, but it's larger and weirder. The display panel can actually be declared as a "panel-dpi" and there's no need to add it to the simple panel driver (and that works even in mainline Linux).

Tthe touchscreen works as a "edt,edt-ft5506"sort of. First of all, only the raspberrypi/linux version of the driver has the necessary polling mode support for now. Then, the hardware nonsense here: the coordinates wrap around weirdly beyond the 800x480 rectangle, so the modified edt-ft5x06 driver they compiled includes a quirk to handle that.

The DT overlay is just this:

dtso source, compile like so: `dtc -O dtb -@ -L biqu-bx.dtso >biqu-bx.dtbo`, USE WITH `dtovelay=upstream` (even with the rpi kernel), I'll try to make a non-upstream overlay too
/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2835";

	fragment@0 {
		target = <&i2c_csi_dsi>;

		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			ts@38 {
				compatible = "btt,btt-ft5506";
				reg = <0x38>;
				vcc-supply = <&reg_display>;
				reset-gpio = <&reg_display 1 1>;
				touchscreen-size-x = <1024>;
				touchscreen-size-y = <600>;
				touchscreen-inverted-x;
				touchscreen-inverted-y;
			};

			reg_display: reg_display@45 {
				compatible = "raspberrypi,7inch-touchscreen-panel-regulator";
				reg = <0x45>;
				gpio-controller;
				#gpio-cells = <2>;
			};
		};
	};

	fragment@1 {
		target = <&dsi1>;

		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			port {
				dsi_out: endpoint {
					data-lanes = <1 2>;
					remote-endpoint = <&bridge_in>;
				};
			};

			bridge@0 {
				// Actually a chipone,icn6211 inside… controlled by an STM32G0 though.
				compatible = "toshiba,tc358762";
				reg = <0>;
				vddc-supply = <&reg_bridge>;

				ports {
					#address-cells = <1>;
					#size-cells = <0>;

					port@0 {
						reg = <0>;
						bridge_in: endpoint {
							data-lanes = <1 2>;
							remote-endpoint = <&dsi_out>;
						};
					};

					port@1 {
						reg = <1>;
						bridge_out: endpoint {
							remote-endpoint = <&panel_in>;
						};
					};
				};
			};
		};
	};

	fragment@2 {
		target-path = "/";

		__overlay__ {
			panel_disp: panel_disp {
				compatible = "panel-dpi";
				backlight = <&reg_display>;
				power-supply = <&reg_display>;

				width-mm = <154>;
				height-mm = <86>;
				bus-format = <0x1009>;

				panel-timing {
					clock-frequency = <25979000>;
					hactive = <1024>;
					hfront-porch = <2>;
					hback-porch = <46>;
					hsync-len = <2>;
					hsync-active = <0>;
					vactive = <600>;
					vfront-porch = <7>;
					vback-porch = <2>;
					vsync-len = <21>;
					vsync-active = <0>;
					de-active = <1>;
					pixelclk-active = <1>;
				};

				port {
					panel_in: endpoint {
						remote-endpoint = <&bridge_out>;
					};
				};
			};

			reg_bridge: reg_bridge {
				compatible = "regulator-fixed";
				regulator-name = "bridge_reg";
				gpio = <&reg_display 0 0>;
				vin-supply = <&reg_display>;
				enable-active-high;
			};
		};
	};
};

and the basic diff for the driver module is basically:

download the file, rename, apply the following with `patch` and compile like any out-of-tree kernel module, install, run depmod, reboot
--- og-ft5x06.c 2025-05-04 01:58:23.684680853 -0300
+++ btt-borked-ft5x06.c 2025-05-04 01:40:18.597591216 -0300
@@ -14,6 +14,12 @@
  *    http://www.glyn.com/Products/Displays
  */

+/*
+ * THIS is a quirky version for the Biqu BX gen3 display "btt,btt-ft5506"
+ * that has very strange wrap-around coordinates between 800x480 and 1024x600
+ * Recreated by Val Packett, https://val.packett.cool
+ */
+
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
@@ -369,6 +375,11 @@

                x = get_unaligned_be16(buf) & 0x0fff;
                y = get_unaligned_be16(buf + 2) & 0x0fff;
+
+               /* WTF: The Biqu BX Touchscreen has misaligned coordinates outside of the 800x480 range */
+               x += (x > 1024) ? -3872 : 224;
+               y += (y > 600) ? -3976 : 120;
+
                /* The FT5x26 send the y coordinate first */
                if (tsdata->version == EV_FT)
                        swap(x, y);
@@ -1594,37 +1605,19 @@
 };

 static const struct i2c_device_id edt_ft5x06_ts_id[] = {
-       { .name = "edt-ft5x06", .driver_data = (long)&edt_ft5x06_data },
-       { .name = "edt-ft5506", .driver_data = (long)&edt_ft5506_data },
-       { .name = "ev-ft5726", .driver_data = (long)&edt_ft5506_data },
-       { .name = "ft5452", .driver_data = (long)&edt_ft5452_data },
-       /* Note no edt- prefix for compatibility with the ft6236.c driver */
-       { .name = "ft6236", .driver_data = (long)&edt_ft6236_data },
-       { .name = "ft8201", .driver_data = (long)&edt_ft8201_data },
-       { .name = "ft8719", .driver_data = (long)&edt_ft8719_data },
        { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id);

 static const struct of_device_id edt_ft5x06_of_match[] = {
-       { .compatible = "edt,edt-ft5206", .data = &edt_ft5x06_data },
-       { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data },
-       { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data },
-       { .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data },
-       { .compatible = "evervision,ev-ft5726", .data = &edt_ft5506_data },
-       { .compatible = "focaltech,ft5426", .data = &edt_ft5506_data },
-       { .compatible = "focaltech,ft5452", .data = &edt_ft5452_data },
-       /* Note focaltech vendor prefix for compatibility with ft6236.c */
-       { .compatible = "focaltech,ft6236", .data = &edt_ft6236_data },
-       { .compatible = "focaltech,ft8201", .data = &edt_ft8201_data },
-       { .compatible = "focaltech,ft8719", .data = &edt_ft8719_data },
+       { .compatible = "btt,btt-ft5506", .data = &edt_ft5x06_data },
        { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match);

 static struct i2c_driver edt_ft5x06_ts_driver = {
        .driver = {
-               .name = "edt_ft5x06",
+               .name = "btt_ft5x06",
                .dev_groups = edt_ft5x06_groups,
                .of_match_table = edt_ft5x06_of_match,
                .pm = pm_sleep_ptr(&edt_ft5x06_ts_pm_ops),

I'll… look into sending a PR to the raspberrypi kernel I guess? But this is such a strange quirk, I'm not sure how to even generalize it (something like btt,touchscreen-relative-wraparound-x = <800 1024>; btt,touchscreen-relative-wraparound-y = <480 600>; ???)

I guess I can also make an easy packaged installation script like the original, but source-based, without blobs bound to a particular kernel build.

@varazir
Copy link
Author

varazir commented May 4, 2025

Hello everyone,

I have recently acquired this printer and "reverse engineered" the modified drivers.

The device tries to present an interface similar to the official RPi 800x480 7" touchscreen, but it's larger and weirder. The display panel can actually be declared as a "panel-dpi" and there's no need to add it to the simple panel driver (and that works even in mainline Linux).

Tthe touchscreen works as a "edt,edt-ft5506"sort of. First of all, only the raspberrypi/linux version of the driver has the necessary polling mode support for now. Then, the hardware nonsense here: the coordinates wrap around weirdly beyond the 800x480 rectangle, so the modified edt-ft5x06 driver they compiled includes a quirk to handle that.

The DT overlay is just this:

dtso source, compile like so: dtc -O dtb -@ -L biqu-bx.dtso >biqu-bx.dtbo, USE WITH dtovelay=upstream (even with the rpi kernel), I'll try to make a non-upstream overlay too
and the basic diff for the driver module is basically:

download the file, rename, apply the following with patch and compile like any out-of-tree kernel module, install, run depmod, reboot
I'll… look into sending a PR to the raspberrypi kernel I guess? But this is such a strange quirk, I'm not sure how to even generalize it (something like btt,touchscreen-relative-wraparound-x = <800 1024>; btt,touchscreen-relative-wraparound-y = <480 600>; ???)

I guess I can also make an easy packaged installation script like the original, but source-based, without blobs bound to a particular kernel build.

Cool, I have been thinking of doing got some help to start and I could get more if I needed but never got around to it as It's working on my printer.

@varazir
Copy link
Author

varazir commented May 4, 2025

@valpackett can this be scripted? Just to make it easier for most using this printer ?

@davydcr
Copy link

davydcr commented Jul 26, 2025

Hi everyone!

I have a BIQU BX with a V3 board and a Raspberry Pi 3B+, currently running Marlin with OctoPrint since 2023. I'm planning to switch to Klipper and, after thoroughly reviewing the documentation, I feel confident about the process.

However, I’d like to ensure I have a rollback option in case something goes wrong. Does anyone know if the binary available in the following repository is compatible with the V3 board?

🔗 https://github.com/bigtreetech/BIQU-BX/tree/master/Firmware/Copy%20to%20microSD%20to%20update

Any help is greatly appreciated!

@varazir
Copy link
Author

varazir commented Jul 26, 2025

Rollbacks would to have the the old firmware and use a new sdcard for your klipper.

@davydcr
Copy link

davydcr commented Jul 26, 2025

Rollbacks would to have the the old firmware and use a new sdcard for your klipper.

That's exactly the problem: I'm not sure if the firmware available in the BIGTREETECH repository is the V3 version that's compatible with my printer.

@davydcr
Copy link

davydcr commented Jul 26, 2025

It worked! I followed the instructions and now Klipper is installed on my printer.

Thanks a lot for your help!

@varazir
Copy link
Author

varazir commented Jul 26, 2025

Rollbacks would to have the the old firmware and use a new sdcard for your klipper.

That's exactly the problem: I'm not sure if the firmware available in the BIGTREETECH repository is the V3 version that's compatible with my printer.

You can use the community version.

@davydcr
Copy link

davydcr commented Jul 27, 2025

Hi everyone!

I managed to install Klipper and set everything up, but I'm still not satisfied with the print quality. I'm getting an accelerometer to enable input shaping and see if that improves the results.

I also miss having a working filament change macro. I haven’t been able to create one that works as well as what I had with Marlin. On top of that, I'm getting overheating errors on the Z-axis drivers:

TMC 'stepper_z' reports error: DRV_STATUS: c0170103 otpw=1 (OvertempWarning!) ot=1 (OvertempError!) t120=1 cs_actual=23 stealth=1 stst=1

Can anyone help me properly set up sensorless homing for the Z axis? Also, is it necessary to physically jumper the DIAG pin to PB13 on the board for this to work? If so, could someone explain exactly where those pins are located on the Biqu BX and how to wire them?

If anyone could share their printer.cfg, it would be really helpful so I can compare and see what I can improve in my setup.

I really appreciate any help!

@varazir
Copy link
Author

varazir commented Jul 28, 2025

@davydcr
Copy link

davydcr commented Jul 28, 2025

@varazir
Copy link
Author

varazir commented Jul 28, 2025

can you access this ? https://github.com/varazir/KlipperBXBackup/tree/2727dc40ea7f8b8fa28e30c6faf9d3aba017192c/config

No, error 404.
I added you as colab on the repo

@davydcr
Copy link

davydcr commented Jul 28, 2025

can you access this ? https://github.com/varazir/KlipperBXBackup/tree/2727dc40ea7f8b8fa28e30c6faf9d3aba017192c/config

No, error 404.
I added you as colab on the repo

I was able to access it now, thank you!

Did you have to jumper the DIAG pin to the stepper driver for the Z axis? I checked your configuration and it’s identical to mine, but I keep getting frequent overheating warnings on the Z stepper driver.

@varazir
Copy link
Author

varazir commented Jul 28, 2025

can you access this ? https://github.com/varazir/KlipperBXBackup/tree/2727dc40ea7f8b8fa28e30c6faf9d3aba017192c/config

No, error 404.
I added you as colab on the repo

I was able to access it now, thank you!

Did you have to jumper the DIAG pin to the stepper driver for the Z axis? I checked your configuration and it’s identical to mine, but I keep getting frequent overheating warnings on the Z stepper driver.

Never change that. Maybe check on the Facebook https://www.facebook.com/groups/1012996125813700 forum or https://discord.gg/zBnEGScT you can find pinouts here https://github.com/bigtreetech/BIQU-BX

@davydcr
Copy link

davydcr commented Jul 30, 2025

Now that I've noticed, the 5020 fan on the board isn't turning on.

Any tips?

@varazir
Copy link
Author

varazir commented Jul 30, 2025

Now that I've noticed, the 5020 fan on the board isn't turning on.

Any tips?

it should be on when you start printing.
I guess you can map the port in the config.

@davydcr
Copy link

davydcr commented Jul 30, 2025

Now that I've noticed, the 5020 fan on the board isn't turning on.
Any tips?

it should be on when you start printing. I guess you can map the port in the config.

After a thorough check of the wiring diagram, comparing my settings to yours, and even swapping out the fan port and testing with another 24V fan, I finally pinpointed the problem: the 5020 fan had died. I'm still unsure if it was an existing issue that Marlin simply didn't report, or if something went wrong during the Klipper migration. A new fan is already on its way. I appreciate your patience throughout this process.

@get-chill
Copy link

Hey guys, I'm getting this erros when my printer boots up, any toughts on whats happening?

mcu 'mcu': Unable to open serial port: [Errno 2] could not open port /dev/serial/by-id/: [Errno 2] No such file or directory: '/dev/serial/by-id/'

My printer is a V3
This is my mcu at printer.cfg

[mcu]
serial: /dev/ttyAMA0
restart_method: command

@get-chill
Copy link

image At first it tries to start, but then fails image

@davydcr
Copy link

davydcr commented Aug 5, 2025

Hey guys, I'm getting this erros when my printer boots up, any toughts on whats happening?

mcu 'mcu': Unable to open serial port: [Errno 2] could not open port /dev/serial/by-id/: [Errno 2] No such file or directory: '/dev/serial/by-id/'

My printer is a V3 This is my mcu at printer.cfg

[mcu] serial: /dev/ttyAMA0 restart_method: command

Hello,

I encountered a similar issue before. I recommend checking the contents of the /boot/cmdline.txt file.

Before making any changes, create a backup of the file:

sudo cp /boot/cmdline.txt /boot/cmdline.txt.bak

Then, open the file for editing:

sudo nano /boot/cmdline.txt

If the line looks something like this:

console=serial0,115200 console=tty1 root=PARTUUID=ea30a571-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=BR

Remove the console=serial0,115200 parameter, keeping the rest of the line unchanged. This can help avoid conflicts with the default serial output.

After saving the changes, reboot the system to apply them:

sudo reboot

@get-chill
Copy link

This worked really well, thank you so much
(funcionou perfeitamente mano, valeu kkkk, vi agora no seu perfil q você é br)
Which macros are you using?

@davydcr
Copy link

davydcr commented Aug 5, 2025

This worked really well, thank you so much (funcionou perfeitamente mano, valeu kkkk, vi agora no seu perfil q você é br) Which macros are you using?

Saudações de Santa Catarina!

Here is the macros that my friend @varazir shared with me.

########################################
## MACROS
########################################

# Slicer setup: "print_start NOZZLE=<temp> BED=<temp>
# This macro does a preheat on the probe for better accuracy and needs
# the temps passed in. examples:
# Cura: PRINT_START BED={material_bed_temperature_layer_0} NOZZLE={material_print_temperature_layer_0}
# PrusaSlicer: PRINT_START NOZZLE=[first_layer_temperature] BED=[bed_temperature]
#   Use PRINT_END for the slicer ending script
[gcode_macro PRINT_START]
gcode:
    BED_MESH_PROFILE LOAD="default"
    # SKEW_PROFILE LOAD="default"
    # Turn on screen if it's not on
    SET_PIN PIN=screen VALUE=1
    #Home so that the probe is positioned to heat    
    SET_LED LED=led BLUE=0.94 RED=0.63 GREEN=0.13
    M117 Initial homing sequence.
    G28
    
    SET_LED LED=led BLUE=0.0 RED=1.0 GREEN=0.0
    M117 Getting the heaters up to temp!
    M104 S170                                                          ; Set Extruder temperature, no wait
    M140 S60                                                            ; Set Heat Bed temperature
    M190 S60                                                            ; Wait for Heat Bed temperature
    
    M117 Lets dance!
    G4 S90 
    Z_TILT_ADJUST
    
    M117 Mash it!
    BED_MESH_CALIBRATE
    
    M117 Lats park it!
    Smart_Park
    
    M117 Getting the extruder up to temp
    M140 S{params.BED}      ; Set Heat Bed temperature
    M104 S{params.NOZZLE}    ; Set Extruder temperature
    M109 S{params.NOZZLE}    ; Wait for Extruder temperature
    M190 S{params.BED}    ; Wait for Heat Bed temperature
    
    M117 Purging
    LINE_PURGE
    SET_LED LED=led BLUE=1.0 RED=1.0 GREEN=1.0
    
    M117 Lets make
    
[gcode_macro PRINT_END]
gcode:
    TURN_OFF_HEATERS    ;turn off heaters... 
    SAVE_GCODE_STATE NAME=END_state
    M83                 ;set relative extrusion
    G92 E0              ;reset extrusion amount
    M204 S10000         ;set max acceleration
    G1 E-2 F4000        ;retract 2mm
    M204 S3000          ;set max acceleration

    ;move the toolhead out of the way
    ;if the tool is less than 30mm away from Z Max, move it to Z max, otherwise, move Z up 30mm
    
    ;Obtain the Z axis limit from the [stepper_z] section of the config file and make
    ;  a decision where to move the Z axis based on the current toolhead 
    {% if printer.toolhead.position.z|float + 30 >= printer.configfile.config["stepper_z"]["position_max"]|float %}
    G90                  ;set absolute extrusion
    G1 Z{printer.configfile.config["stepper_z"]["position_max"]|float} F1000 ;Move tool
    {% else %}

    G91                  ;set relative extrusion
    G1 Z30 F1000         ;move Z axis up 30mm
    {% endif %}

    RESTORE_GCODE_STATE NAME=END_state
    G1 X0 Y200 F24000    ;park tool at back of printer
    M107                
    #UNLOAD_FILAMENT     ;this is a good spot to call an unload 
                         ;filament macro, if you are into that sort of thing
    # SET_GCODE_OFFSET Z=0 ;reset whatever babystepping you have done
    M84                  ;disable motors
    CLEAR_PAUSE          ;clear whatever PAUSE state you may have if you have it
    #print a message on your LCD    test
    M117 DONE!!!
    SET_SKEW CLEAR=1

[gcode_macro LOAD_FILAMENT]
gcode:
    {% set speed = params.SPEED|default(300) %}
    {% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity %}
    SAVE_GCODE_STATE NAME=load_state
    M300 # beep
    G91
    G92 E0
    G1 E25 F{max_velocity} # fast-load
    G1 E15 F{speed} # purge
    M300
    M300
    RESTORE_GCODE_STATE NAME=load_state

[gcode_macro UNLOAD_FILAMENT]
gcode:
    {% set speed = params.SPEED|default(300) %}
    {% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity %}
    SAVE_GCODE_STATE NAME=unload_state
    G91
    M300 # beep
    G92 E0
    G1 E25 F{speed} # purge
    G1 E-50 F{max_velocity} # fast-unload
    M300
    M300
    RESTORE_GCODE_STATE NAME=unload_state


[gcode_macro _bot_data]
variable_lapse_video_size: 0
variable_lapse_filename: 'None'
variable_lapse_path: 'None'
gcode:
   M118 Setting bot lapse variables

#[pwm_cycle_time BEEPER_pin]
#pin: PA14
   
[gcode_macro M300]
gcode:
    # Use a default 1kHz tone if S is omitted.
    {% set S = params.S|default(1000)|int %}
    # Use a 10ms duration is P is omitted.
    {% set P = params.P|default(100)|int %}
    SET_PIN PIN=beeper VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
    G4 P{P}
    SET_PIN PIN=beeper VALUE=0

@get-chill
Copy link

Thank you, I was looking for some filament loading and unloading macros

@varazir
Copy link
Author

varazir commented Aug 6, 2025

Thanks for help out, I haven't used my BX for almost a year now. I bought a Bambulab A1 and both my Wanhao and BX printer started to collect dust so I moved them to the attic storage.

@davydcr
Copy link

davydcr commented Aug 6, 2025

Thanks for help out, I haven't used my BX for almost a year now. I bought a Bambulab A1 and both my Wanhao and BX printer started to collect dust so I moved them to the attic storage.

Kind of sad to see those machines sitting idle, especially knowing what the BX is capable of! But I totally get it, the Bambulab A1 really makes everything so much easier. I still keep my old printers up and running; each one has its strengths and is useful for certain types of prints. Who knows, maybe one day the urge will come back to fire up the old veterans and get them running again.
IMG_20250802_094017877

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment