Introduction: How to Program a 3D Printer With Marlin and Arduino
Marlin is an Arduino project meant to be configured so it can run almost any 3D printer with the exception the 3D printer must have an Arduino on board it. You may download it here.
In order to configure it to your 3D printer you must adjust variables and comment or uncomment code in the Configuration.h file. This tutorial will explain all about that.
Step 1: Configuration.h and Arduino
So your next step is to open Marlin.ino located in the zip file I showed you in the previous step. It should be under Marlin-1.1x/Marlin/Marlin.ino. Then Marlin.ino and a whole bunch of classes should open.
Select on Configuration.h to view that file. We will be using that file throughout all of the next steps in the tutorial.
Step 2: #define BAUDRATE #
Depending on your computer and your motherboard the Baudrate will vary. If you don't know what this should be leave it alone. You can always change it in the future. You will find this in configuration.h on line 114. Baudrate can only equal either 2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, or 1000000. It can only equal one number.
Step 3: #define MOTHERBOARD "(Your Motherboard From Boards.h)"
Replace the default definition of #define MOTHERBOARD with your motherboard. It's default value is BOARD_RAMPS_14_EFB but it can be anything from boards.h in Arduino. Change it to the value of your motherboard from Boards.h. This line of code is on line 122. EFB stands for the setup up you can have with Ramps 1.4 motherboard that has one extruder, one fan, and one heated bed like most Prusa i3 variants. Here are the values you could change it to.
BOARD_RAMPS_13_EFB // RAMPS 1.3 (Power outputs: Hotend, Fan, Bed) #define BOARD_RAMPS_13_EEB // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed) #define BOARD_RAMPS_13_EFF // RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1) #define BOARD_RAMPS_13_EEF // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan) #define BOARD_RAMPS_13_SF // RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_14_EFB // RAMPS 1.4 (Power outputs: Hotend, Fan, Bed) #define BOARD_RAMPS_14_EEB // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed) #define BOARD_RAMPS_14_EFF // RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1) #define BOARD_RAMPS_14_EEF // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan) #define BOARD_RAMPS_14_SF // RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
BOARD_RAMPS_PLUS_EFB // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed) BOARD_RAMPS_PLUS_EEB // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
BOARD_RAMPS_PLUS_EFF // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1) BOARD_RAMPS_PLUS_EEF // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan) BOARD_RAMPS_PLUS_SF // RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
BOARD_3DRAG // 3Drag Controller
BOARD_K8200 // Velleman K8200 Controller (derived from 3Drag Controller)
BOARD_K8400 // Velleman K8400 Controller (derived from 3Drag Controller)
BOARD_BAM_DICE // 2PrintBeta BAM&DICE with STK drivers
BOARD_BAM_DICE_DUE // 2PrintBeta BAM&DICE Due with STK drivers
BOARD_MKS_BASE // MKS BASE 1.0 BOARD_MKS_13 // MKS v1.3 or 1.4 (maybe higher) #define BOARD_MKS_GEN_L // MKS GEN L
BOARD_ZRIB_V20 // zrib V2.0 control board (Chinese knock off RAMPS replica)
BOARD_FELIX // Felix 2.0+ Electronics Board (RAMPS like)
BOARD_RIGIDBOARD // Invent-A-Part RigidBoard
BOARD_RIGIDBOARD_V2 // Invent-A-Part RigidBoard V2
BOARD_SAINSMART_2IN1 // Sainsmart 2-in-1 board BOARD_ULTIMAKER // Ultimaker BOARD_ULTIMAKER_OLD // Ultimaker (Older electronics. Pre 1.5.4. This is rare)
BOARD_AZTEEG_X3 // Azteeg X3
BOARD_AZTEEG_X3_PRO // Azteeg X3 Pro
BOARD_ULTIMAIN_2 // Ultimainboard 2.x (Uses TEMP_SENSOR 20)
BOARD_RUMBA // Rumba
BOARD_BQ_ZUM_MEGA_3D // bq ZUM Mega 3D
BOARD_MAKEBOARD_MINI // MakeBoard Mini v2.1.2 is a control board sold by MicroMake
BOARD_CNCONTROLS_11 // Cartesio CN Controls V11
BOARD_CNCONTROLS_12 // Cartesio CN Controls V12
BOARD_CHEAPTRONIC // Cheaptronic v1.0
BOARD_CHEAPTRONIC_V2 // Cheaptronic v2.0
BOARD_MIGHTYBOARD_REVE // Makerbot Mightyboard Revision E
BOARD_MEGATRONICS // Megatronics
BOARD_MEGATRONICS_2 // Megatronics v2.0
BOARD_MEGATRONICS_3 // Megatronics v3.0
BOARD_MEGATRONICS_31 // Megatronics v3.1
BOARD_RAMBO 301 // Rambo
BOARD_MINIRAMBO // Mini-Rambo
BOARD_MINIRAMBO_10A // Mini-Rambo 1.0a
BOARD_ELEFU_3 // Elefu Ra Board (v3)
BOARD_LEAPFROG // Leapfrog #define BOARD_MEGACONTROLLER 310 // Mega controller #define BOARD_SCOOVO_X9H // abee Scoovo X9H
BOARD_GT2560_REV_A // Geeetech GT2560 Rev. A
BOARD_GT2560_REV_A_PLUS 75 // Geeetech GT2560 Rev. A+ (with auto level probe)
BOARD_MINITRONICS // Minitronics v1.0/1.1
BOARD_SILVER_GATE // Silvergate v1.0
BOARD_SANGUINOLOLU_11 // Sanguinololu < 1.2
BOARD_SANGUINOLOLU_12 // Sanguinololu 1.2 and above
BOARD_MELZI // Melzi
BOARD_MELZI_MAKR3D // Melzi with ATmega1284 (MaKr3d version)
BOARD_MELZI_CREALITY // Melzi Creality3D board (for CR-10 etc)
BOARD_STB_11 // STB V1.1
BOARD_AZTEEG_X1 // Azteeg X1
BOARD_GEN3_MONOLITHIC // Gen3 Monolithic Electronics
BOARD_GEN3_PLUS // Gen3+
BOARD_GEN6 // Gen6
BOARD_GEN6_DELUXE // Gen6 deluxe
BOARD_GEN7_CUSTOM // Gen7 custom (Alfons3 Version)
BOARD_GEN7_12 // Gen7 v1.1, v1.2
BOARD_GEN7_13 // Gen7 v1.3
BOARD_GEN7_14 // Gen7 v1.4
BOARD_OMCA_A // Alpha OMCA board
BOARD_OMCA // Final OMCA board BOARD_SETHI // Sethi 3D_1
BOARD_ANET_10 // Anet 1.0 (Melzi clone)
// // Teensyduino - AT90USB1286, AT90USB1286P //
BOARD_TEENSYLU // Teensylu
BOARD_PRINTRBOARD // Printrboard (AT90USB1286)
BOARD_PRINTRBOARD_REVF // Printrboard Revision F (AT90USB1286)
BOARD_BRAINWAVE // Brainwave (AT90USB646)
BOARD_BRAINWAVE_PRO // Brainwave Pro (AT90USB1286)
BOARD_SAV_MKI // SAV Mk-I (AT90USB1286)
BOARD_TEENSY2 // Teensy++2.0 (AT90USB1286) - CLI compile: HARDWARE_MOTHERBOARD=84 BOARD_5DPRINT // 5DPrint D8 Driver Board
Step 4: #define EXTRUDERS #
On line 137 in Configuration.h is the variable EXTRUDERS which should be equal to a number between 1-5. Change it to the number of extruders there are on your printer. If there is one leave it to your default value.
Step 5: #DEFAULT_NOMINAL_FILAMENT_DIA #
On line 140 in Arduino you see a variable known as DEFAULT_NOMINAL_FILAMENT_DIA. Change the number to the filament diameter of your printer. If it is 3mm leave it be. If you don't know what your filament diameter is research what it is for your printer. Most printers use 1.75mm or 3mm.
Step 6: #define TEMP_SENSOR_# #
Your 3D printer should have thermistors. Thermistors are variable resistors that change resistance with temperature. Hence why they are used for measuring temperature in 3D Printing. There are 5 variables on lines 289 - 294 used for declaring thermistors in each hotend. Value 0 is for the first hotend, value 1 is for your second hotend if you have one, and so on. The value on line 295 is for the heated bed. Set them accordingly to whatever thermistor you are using. The thermistors values are listed below.
-3 : thermocouple with MAX31855 (only for sensor 0)
-2 : thermocouple with MAX6675 (only for sensor 0)
-1 : thermocouple with AD595
0 : not used
1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
3 : Mendel-parts thermistor (4.7k pullup)
4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
5 : 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup)
6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
71 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
10 : 100k RS thermistor 198-961 (4.7k pullup)
11 : 100k beta 3950 1% thermistor (4.7k pullup)
12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
20 : the PT100 circuit found in the Ultimainboard V2.x
60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 *
66 : 4.7M High Temperature thermistor from Dyze Design *
70 : the 100K thermistor found in the bq Hephestos 2 *
75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor * * 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k. * (but gives greater accuracy and more stable PID) *
51 : 100k thermistor - EPCOS (1k pullup) *
52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup) *
55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) * *
1047 : Pt1000 with 4k7 pullup * 1010 : Pt1000 with 1k pullup (non standard) * 147 : Pt100 with 4k7 pullup * 110 : Pt100 with 1k pullup (non standard) * * Use these for Testing or Development purposes. NEVER for production machine. *
998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. *
999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. *
Step 7: PID Tuning
On lines 258 - 260 in configuration.h is the PID tuning variables. Change them if you know what to change them to. If you don't you are going to have to wait until your 3D printer is all configured except for those lines of code. Setting them to the wrong values can be dangerous and lead to something breaking or catching on fire. Chances are if something is wrong your printer will stop itself but not always. For more information on how to figure out what to change them to when your printer is configured follow this tutorial.
Step 8: #define PIDTEMPBED
Uncomment line 386 if you have a heated bed. If you don't it will be extremely dangerous to run your printer for your heated bed will not be easily controlled. Lines 402 - 404 are your bed's PID settings. Change them if you know them if not like I said before wait until your printer is fully configured. Then follow this tutorial.
Step 9: Endstops
Min endstops are enabled by default. Lines 473 - 478 are to enable or disable your max or min endstops. Comment out to disable or uncomment to enable the max or min endstops.
Lines 495 - 501 are for inverting your endstop's logic. Do this if you know what you are doing. If not you can invert them later if they don't work as planned.
Step 10: Inverting Axis Directions If Necessary
If you don't know what you are doing for this step don't do anything unless something is moving inverted or you know to invert something.
Lines 751 - 753 are for inverting each axis while lines 761 - 765 are for inverting each extruder if you have one. Only change these if you know what you are doing or if you have something inverted.
Step 11: LCD
If you don't have an LCD ignore this step. If you do check online if your LCD is Ultra LCD or Dog LCD because depending on if it is or isn't you will have to uncomment lines 1322 - 1323 accordingly. Uncomment to enable those lines for your LCD. Don't enable both of them at once.
Step 12: SDSUPPORT
If you don't have an LCD display or don't have an input for a sd card don't worry about this step. If you do uncomment line 1332 to enable sd card support.
Step 13: Uncomment Your LCD Screen to Enable It
Depending on what your lcd screen is it will vary upon which location it will be in marlin. Search for your lcd screen with find or replace and uncomment it. You can press CTRL + F to use it. Good luck!
Step 14: Conclusion
If there is something in here you would like to learn about in Marlin drop a comment below. Chances are I might be able to answer it. If there are any problems with this tutorial let me know. I will probably be able to help you.
You hopefully learned in this tutorial how to configure marlin in this tutorial. Good luck and let me know what you think of this tutorial. I could use some helpful criticism.