Marlin Firmware

While compiling a custom Marlin 2.0 Firmware for a 3D Printer and configuring parameters use this page of website links to refer back to as a reference and a guide.

Marlin Getting Started

Marlin
https://marlinfw.org/
Open-source firmware for RepRap 3D printers, laser engravers, and CNC machines.
https://marlinfw.org/docs/basics/introduction.html
https://marlinfw.org/meta/gcode/
https://github.com/MarlinFirmware/Marlin/
https://github.com/MarlinFirmware/Configurations/
https://code.visualstudio.com/download
https://marlinfw.org/docs/basics/auto_build_marlin.html

Marlin G-Code Editing

Notepad ++ showing a .gcode file Before and After installing the G-Code_Norm3 User Defined Language Marlin 2.0 G-Code XML Upgrade With Arrow and Before and After Text
Notepad ++ showing a .gcode file Before and After installing the G-Code_Norm3 User Defined Language Marlin 2.0 G-Code XML Upgrade

When editing Marlin 2.0 G-Code with Notepad ++ I obviously would recommend using my G-Code_Norm3 User Defined Language Upgrade.

Marlin 2.0 Calibration

Your 3D Printer may have different options available in Firmware depending on your hardware and machine configuration.

Prusa Material Guide
https://help.prusa3d.com/materials/
Prusa’s material and temperature guide for multiple brands of filaments and printing surfaces.

G28 – Auto Home
https://marlinfw.org/docs/gcode/G028.html
Click your heels together 3 times and say it: “There’s no place like Home”!

G35 – Assisted Tramming
https://marlinfw.org/docs/gcode/G035.html
For 3D printers with bed tramming adjustment wheels. Take the sideline and tram the bed as close to level as possible the first time through just to be sure then next time take the express route past this station.

G29 – Bed Leveling
https://marlinfw.org/docs/gcode/G029.html
Level the playing field with mesh and matrix based bed leveling with and without a probe manually but sometimes not both.

M301-M304 – PID Autotune
https://marlinfw.org/docs/gcode/M303.html
Make your hotend and bed sing at the right tone with the right tempo.

;;;Some Generic Marlin PID AutoTune Commmands

M303 C5 E0 S200 U1 ;Run PLA Hotend PID AutoTune
M303 C5 E-1 S65 U1 ;Run PLA Bed PID AutoTune

;Probably use this one for firmware defaults
M303 C5 E0 S240 U1 ;Run PETG Hotend PID AutoTune
M303 C5 E-1 S85 U1 ;Run PETG Bed PID AutoTune

;Once you know you knew where to put the digits
M301 E0 P21.3 I2.00 D56.6 ;Hotend PID at 200C Fan 100 for PLA
M304 P73.8 I14.40 D251.7  ;Bed PID at 65C for PLA
M301 E0 P23.2 I2.24 D60.4 ;Hotend PID at 240C Fan 80 for PETG
M304 P106.9 I20.87 D364.8 ;Bed PID at 85C for PETG

M306 – Model Predictive Control (Experimental)
https://marlinfw.org/docs/gcode/M306.html
https://marlinfw.org/docs/features/model_predictive_control.html

It’s the big bad MPC! Avoid PID temperature overshoots and undershoots especially when the part fan turns on. It’s faster and more precise than PID if tuned correctly.

;;;Some Generic Marlin MPC AutoTune Commmands

M306 E0 P40.0 T ;Run MPC AutoTune for 40W Heater

;Once you know you knew where to put the digits
M306 A0.063 C13.7 E0 F0.084 H0.0056 P40.0 R0.242 ;Hotend MPC PLA
M306 A0.063 C13.7 E0 F0.084 H0.0036 P40.0 R0.242 ;Hotend MPC PETG

;Probably use this one for firmware defaults
M306 A0.063 C13.7 E0 F0.084 H0.0046 P40.0 R0.242

;Heat Capacity (H) of 1.75mm Filament for MPC
;ABS	0.00515 J/K/mm ;ASA
;Nylon	0.00522 J/K/mm ;PA
;PETG	0.0036 J/K/mm
;	0.0046 J/K/mm  ;My Firmware Default
;PLA	0.0056 J/K/mm

Temperature Test Towers
https://www.thingiverse.com/thing:3912855
Test towers for tuning printing temperatures for PLA and PETG.
https://www.thingiverse.com/thing:4723455
Test tower for tuning printing temperatures for PLA Plus.
https://www.thingiverse.com/thing:2493504
Or these simpler towers for PLA, PETG, ABS, and TPU.

Acceleration Test Tower
https://www.thingiverse.com/thing:4169896
Test tower for tuning acceleration, max printing speeds, and jerk/junction deviations.

Retraction Test Towers
https://www.thingiverse.com/thing:4057442
Discover the optimal retraction lengths and speeds with pre-compiled G-code. May require manual editing of header and about 500 lines down for 1st layer bed temp G-codes to suit your machine and materials.

;;;G-Code Header is Here

M104 S210 ;Set Hotend Temp
M140 S60 ;Set Bed Temp
M105 ;Report Temps
M109 S210 ;Wait for Hotend Temp
M190 S60 ;Wait for Bed Temp
M900 K0.085 ;Linear Advance Setup K PLA

M82 ;Absolute Extrusion Mode
M200 D1.75 L15.0 S0 T0 ;Setup Filament Parameters
M201 X1000.00 Y500.00 Z50.00 E5000.00 ;Setup Max Acceleration
M203 X200.00 Y200.00 Z25.00 E100.00 ;Setup Max Feedrate
M204 P1000.00 R5000.00 T1000.00 ;Setup Print/Retract/Travel Acceleration
;M205 X8.00 Y8.00 Z0.30 E5.00 ;Setup Jerk Off
M205 J0.08 E5.00 ;Setup Junction Deviation
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate

G28 ;Home
G29 ;Auto Bed Level
G92 E0 ;Reset Extruder Counter

;;;About 500 Lines of moves

;LAYER:1
;M140 S60 ;Turn this off to set temps once from above
M106 S85 ;Set Part Fan 85 of 255 etc
;TYPE:WALL-INNER

M900 – Linear Advance
https://marlinfw.org/docs/gcode/M900.html
https://marlinfw.org/docs/features/lin_advance.html
https://marlinfw.org/tools/lin_advance/k-factor.html
Linear Advance information and test pattern generation tool. Note the new Special K values for Linear Advance version 1.5.

M593 – Zero Vibration (ZV) Input Shaping
https://marlinfw.org/docs/gcode/M593.html
Determine and dampen resonant machine frequencies. Optionally use the Accelerometer Meter app in the Spectrum mode on an Android to observe the resonant frequency response. Print the 300 layer tall Ringing Tower STL and temporarily add the following g-code to Prusa under Printer Settings, Custom G-code, Scroll down on the right to After layer change G-code and add something like:

;AFTER_LAYER_CHANGE
;{layer_z}
G92 E0 ;Zero Extruder Counter
M593 D1.00 F{(layer_num < 2 ? 0 : 1 + 119.0 * (layer_num - 2) / 298)} ;Changes XY Dampening Frequency from 1 to 120Hz
;M593 F15.0 X ;Once you find some frequencies
;M593 F13.0 Y ;Then try a range of dampening
;M593 D{(layer_num < 2 ? 0 : (layer_num - 2) / 298)} ;Changes XY Zeta Dampening Factor from 0.00 to 1.00