3D printing

How to disable Marlin cold extrusion prevention via G-Code

If you want to test your extruder, you can disable cold extrusion prevention using M302:

M302 P1

Re-enable with

M302 P0

Set the temperature (and enable) using

M302 P0 S170

In order to report the current status, run

M302

Example output if disabled:

echo:Cold extrudes are disabled (min temp 170C)

Example output if enabled:

echo:Cold extrudes are enabled (min temp 170C)

Whatever you configure will not persist after reboot. In case you want to save the settings to EEPROM in order to persist after reboot, run

M500
Posted by Uli Köhler in 3D printing, Electronics

How to unpause Marlin after M0/M1 echo:busy: paused for user

In Marlin, you can pause the firmware using M0 or M1 which will cause the firmware to loop-print

echo:busy: paused for user
echo:busy: paused for user
echo:busy: paused for user
echo:busy: paused for user
echo:busy: paused for user
echo:busy: paused for user

In order to continue or unpause, use

M108

 

Posted by Uli Köhler in 3D printing

How to reboot Marlin using G-Code

On most Marlin boards, you can use M997 to reboot/restart the microcontroller:

M997

While this is technically the command to update the firmware, on most boards this is implemented by a simple reboot, which will load the bootloader which could update the firmware e.g. if there is a firmware.bin file on the SD card. Since unless a firmware update is intended there is no such file on the SD card, the M997 command will just reboot the board.

Posted by Uli Köhler in 3D printing

How to get or set Trinamic TMC stepper motor current in Marlin firmware

In Marlin, you can dynamically configure the stepper motor current for Trinamic stepper drivers like the TMC2208 or the TMC5160.

Changing the motor current via G-Code

The easiest option is by using G-Codes. In order to set the stepper motor current for X , Y and Z to 2 Amperes (2000 mA), use M906 like this:

M906X2000Y2000Z2000

Now save the settings to the EEPROM using

M500

You can also query the current stepper motor current using

M906
X driver current: 2000
Y driver current: 2000
Z driver current: 2000
E driver current: 800
ok

Changing the motor current in the config file

You can also set default stepper motor current values in the Marlin config files. Note that these will be overridden by any value in the EEPROM.

In Configuration_adv.h, look for

#if HAS_TRINAMIC_CONFIG

which contains axis definitions like

#if AXIS_IS_TMC(X)
  #define X_CURRENT       800        // (mA) RMS current. Multiply by 1.414 for peak current.
  #define X_CURRENT_HOME  X_CURRENT  // (mA) RMS current for sensorless homing
  #define X_MICROSTEPS     32        // 0..256
  #define X_RSENSE          0.11
  #define X_CHAIN_POS      -1        // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
  //#define X_INTERPOLATE  true      // Enable to override 'INTERPOLATE' for the X axis
#endif

Change the value in the line

#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.

so, for example to set 2A (2000 mA), set it to

#define X_CURRENT 2000 // (mA) RMS current. Multiply by 1.414 for peak current.

 

Posted by Uli Köhler in 3D printing

PySerial minimal request-reply example

This example sends the M119 (print endstop status) command to an attached 3D printer and prints the response in a loop

#!/usr/bin/env python3
import serial
ser = serial.Serial("/dev/ttyACM0")

try:
    while True:
        ser.write(b"M119\n")
        response = ser.read_until(b"ok\n")
        print(response.decode("utf-8"))
finally:
    ser.close()

Example output (in a loop):

Reporting endstop status
x_max: open
y_max: TRIGGERED
z_max: TRIGGERED
ok

 

Posted by Uli Köhler in 3D printing, Embedded, Python

How to view endstop status on Marlin using G-Code?

On 3D printer mainboards running the Marlin firmware, you can use M119 to view the current state of the endstops. Example output:

M119
Reporting endstop status
x_max: TRIGGERED
y_max: TRIGGERED
z_min: TRIGGERED
ok

 

Posted by Uli Köhler in 3D printing, Electronics

How to print Marlin firmware version using G-Code

The Marlin 3d printer firmware allows you to print the firmware version (along with different firmware settings) using the M115 command. The M115 command takes no parameters.

Example output:

M115
FIRMWARE_NAME:Marlin bugfix-2.0.x (May 13 2021 14:16:08) SOURCE_CODE_URL:github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:OCTOPUS_V1_0 EXTRUDER_COUNT:4 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
Cap:SERIAL_XON_XOFF:0
Cap:BINARY_FILE_TRANSFER:0
Cap:EEPROM:1
Cap:VOLUMETRIC:1
Cap:AUTOREPORT_TEMP:1
Cap:PROGRESS:0
Cap:PRINT_JOB:1
Cap:AUTOLEVEL:0
Cap:RUNOUT:0
Cap:Z_PROBE:0
Cap:LEVELING_DATA:0
Cap:BUILD_PERCENT:0
Cap:SOFTWARE_POWER:0
Cap:TOGGLE_LIGHTS:0
Cap:CASE_LIGHT_BRIGHTNESS:0
Cap:EMERGENCY_PARSER:1
Cap:PROMPT_SUPPORT:0
Cap:SDCARD:1
Cap:REPEAT:0
Cap:SD_WRITE:1
Cap:AUTOREPORT_SD_STATUS:0
Cap:LONG_FILENAME:1
Cap:THERMAL_PROTECTION:1
Cap:MOTION_MODES:0
Cap:ARCS:1
Cap:BABYSTEPPING:0
Cap:CHAMBER_TEMPERATURE:0
Cap:COOLER_TEMPERATURE:0
Cap:MEATPACK:0
ok

 

Posted by Uli Köhler in 3D printing, Electronics

What is the difference between BIGTREE_OCTOPUS_V1 and BIGTREE_OCTOPUS_V1_USB

When building Marlin firmware for the BigTreeTech Octopus from the official BigTreeTech GitHub repository Marlin directory, you can see two different targets in PlatformIO:

  • BIGTREE_OCTOPUS_V1
  • BIGTREE_OCTOPUS_V1_USB

It is not immediately made clear what the difference between those is, but a short description can be found in ini/stm32f4.ini:

BIGTREE_OCTOPUS_V1_USB has support for using USB flashdrives directly on the board and serial-over-USB while BIGTREE_OCTOPUS_V1 has not.

In most cases, you want to build BIGTREE_OCTOPUS_V1_USB if printing via USB (e.g. via Octoprint) because the BIGTREE_OCTOPUS_V1 configuration does not allow printing via USB.
The compiler definitions for BIGTREE_OCTOPUS_V1 in ini/stm32f4.ini are:
build_flags        = ${stm32_variant.build_flags}
                     -DSTM32F446_5VX -DUSE_USB_HS_IN_FS

whereas BIGTREE_OCTOPUS_V1_USB enabled more USB-related features:

build_flags       = ${stm_flash_drive.build_flags}
                    -DSTM32F446_5VX -DUSE_USB_HS_IN_FS
                    -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5
                    -DUSBD_IRQ_SUBPRIO=6
                    -DUSBD_USE_CDC_MSC
Posted by Uli Köhler in 3D printing, Electronics, PlatformIO, STM32

How I fixed STM32CubeProgrammer CUBEPROGRAMMER_ERROR_NOT_SUPPORTED

I tried to flash the DFU bootloader on the BigTreeTech Octopus V1 3D printer mainboard. However, STM32CubeProgrammer v2.8.0 showed me the following error message when trying to connect:

CUBEPROGRAMMER_ERROR_NOT_SUPPORTED

I could only fix this by completely uninstalling STM32CubeProgrammer and then installing STM32CubeProgrammer v2.7.0 from the BigTreeTech Github Repo. Most likely downloading v2.7.0 from the ST homepage will also work but I didn’t verify this.

Posted by Uli Köhler in 3D printing, Electronics, STM32

What 4-pin connectors are used on 3D printer mainboards for stepper motors?

Most currently available mainboards use this connector for connecting a stepper motor to the mainboard:

These connectors are named JST XH 2.54mm.

While many people interface these using standard 2.54mm female connectors

they should be interfaces using the proper JST XH 2.54mm female connector.

Posted by Uli Köhler in 3D printing

How to fix Marlin Error: Build environment ‘linux_native’ is incompatible with BOARD_RAMPS_14_EFB

Problem:

When compiling Marlin for simulation, you see an error message like

Error: Build environment 'linux_native' is incompatible with BOARD_RAMPS_14_EFB. Use one of these: mega2560, mega1280

Solution:

Open Marlin/Configuration.h and change the line

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_RAMPS_14_EFB
#endif

to use the BOARD_LINUX_RAMPS board:

// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_LINUX_RAMPS
#endif

Even if the error message shows that you should use mega2560 or mega1280, you need to use BOARD_LINUX_RAMPS!

Posted by Uli Köhler in 3D printing

How to readout current PID values on Ender 3

Run

M503

which will show all EEPROM configuration values, among them these lines:

M301 P29.34 I3.58 D60.08
M304 P427.57 I84.18 D542.91

Note that the M301 line represents the Hotend PID values whereas M304 represent the Bed PID values.

Posted by Uli Köhler in 3D printing

Ender 3 MicroSwiss Hotend PID parameters

These are the Hotend PID parameters for my Ender 3 using a MicroSwiss hotend with a MicroSwiss direct drive Extruder:

Marlin Configuration.h setting:

#define DEFAULT_Kp 29.34
#define DEFAULT_Ki 3.58
#define DEFAULT_Kd 60.08

Set PID values using G-Code and save to EEPROM:

M301 P29.34 I3.58 D60.08
M500

M301 P29.34 I3.58 D60.08
M500

How to run PID autotune

If you want custom values, run PID autotune like this:

  • Start with a completely cooled down Hotend
  • Run M106 P0 S255 to turn on the first fan
  • Run M106 P1 S255 to turn on the second fan
  • Run PID autotune using M303 E0 S210 C8

then proceed like shown above.

 

Posted by Uli Köhler in 3D printing