Installing Marlin Firmware on RAMPS 1.4

If you build up a 3d printer from scratch, you must install a firmware on the controller board. This article descripes the steps when you install the Marlin firmware on a RepRap controller using the combination of an Arduino Mega 2560 and the RAMPS 1.4 shield.

Preconditions:

As preconditions for the next steps you need some software packages from different sources. You need as follows:

Download the latest version of Marlin download page and unzip it into a folder by your own decision.

If you want to run your RAMPS 1.4 together with the Full Graphic Display, you also must download the u8glib library from https://github.com/olikraus/U8glib_Arduino. After downloading the package zu unzip it and copy then the complete subdirectory into the location of your Arduino development environment into the subdirectory 'libraries'.

Step 1 - USB-driver installation:

The Arduino development environment already contains a driver for the "Arduino 2560". As soon as you connect the Arduino to your computer, the device will be automatically recognized. The connectd Arduino board will be assigned automatically to a COM port on your computer. You can determine the assigned COM port by opening the device manager of your Windows installation and navigate to the COM & LPT entry. 

Step 2 - Setting up your Arduino development environment:

After you installed the Arduino development environment and you unpacked the Marlin Firmware in a directory on your computer, you can start with the configuration for your own 3d printer. You start this step by choosing 'File/open' within the Arduino compiler. Then you choose the directory where you unzipped the Marlin Firmware and select the file 'Marlin.ino'. The Arduino dev environment then opens all files belonging to the firmware.

07-RUMBA-Marlin-ino

As next you select the file 'Configuration.h' to start with the configuration of the Firmware for your 3d printer:

08-RUMBA-Configuration-h

To ensure that compiling and transmission of the firmware your Arduino will work, you must open the menu 'Tools/Board' and select as type 'Arduino Mega 2560 or Mega ADK'.

09-RUMBA-Board


As next step you must select in the menu 'Tools/Serial Port' to which your Arduino is assigned in the device manager.

10-RUMBA-port


Now you can try to compile the Marlin Firmware. The compiling of the firmware will be started by clicking the checkmark symbol direct below the menu item 'File'.
In some cases you might experience problems with compiling/transmitting the firmware. Most recent causes are:

  • The Arduino development environment does not match the Marlin Firmware, as there are discrepancies in the library includes
  • The board wasn't selected correctly in the Arduino development environment
  • The COM port wasn't selected correctly

 

Step 3 - tuning the Configuration.h for your Arduino with RAMPS 1.4:

Nearby the top of the file you will find the setting of the Baudrate, with which your board will be accept transmissions over the USB connection. In the current version the default setting is '250000'. For some computers or USB ports this setting may lead to problems. For a more stable setting it might be a good idea to change this value to 115200.

// This determines the communication speed of the printer
// This determines the communication speed of the printer
#define BAUDRATE 115200

In the actual Marlin Firmware all supported printer boards are listed within the file "boards.h". This file contains the following entries for the RAMPS 1.4:

#define BOARD_RAMPS_13_EFB 1010 // RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_13_EEB 1011 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_13_EFF 1012 // RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_13_EEF 1013 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_13_SF 1014 // RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_14_EFB 1020 // RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_14_EEB 1021 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_14_EFF 1022 // RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_14_EEF 1023 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_14_SF 1024 // RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_PLUS_EFB 1030 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_PLUS_EEB 1031 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_PLUS_EFF 1032 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_PLUS_EEF 1033 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_PLUS_SF 1034 // RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)

The most common version may be the variant <Extruder, Fan, Bed>. In this case you have to set the value as the following lines show.

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_RAMPS_13_EFB
#endif

RepRapDiscount Smart Controller

If you have a RepRapDiscount Smart Controller (40x2 character display), uncoment the entry in line 1770:

//=============================================================================
//======================== LCD / Controller Selection =========================
//======================== (Character-based LCDs) =========================
//=============================================================================
//
// RepRapDiscount Smart Controller.
// http://reprap.org/wiki/RepRapDiscount_Smart_Controller //
// Note: Usually sold with a white PCB.
#define REPRAP_DISCOUNT_SMART_CONTROLLER

 RepRapDiscount Full Graphic Display

If you have a Full Graphic Display Controller (DOT Matrix 128x64) connected to your RAMPS you must remove the both '//' in front of the DEFINE around line 1910. So this part in the source code should look like the following lines show. But you must keep in mind, that you have to add the u8glib to your Arduino environment (see Preconditions!).

// IMPORTANT: The U8glib library is required for Graphical Display!
// https://github.com/olikraus/U8glib_Arduino
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER


Now you made the base configuration for your RAMPS 1.4 board. If you transmitt this version to your board (klicking the button with the arrow to the right), then your display of your 3d printer should show the first signs of live.

Ok, it's time to make the adjustments specific to your 3d printer. You might first check the setting for the amount of extruders at around line 145. Most 3d printer rookies may start with one extruder, so the default entry of '1' is quite sufficient.

// This defines the number of extruders
#define EXTRUDERS 1

At around line 70 you have to set up the thermistors connected to the RAMPS for the extruder and the heatbed. Depending on your hardware configuration you have to change the last value in the defines.

#define TEMP_SENSOR_0
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 0
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0

The define for TEMP_SENSOR_0 determins which thermistor type is assembled at the hotend of extruder 1. This termistor has to be connected to the first sensor input (see also wiring schema). The thermistor for the heatbed has to be connected to the second sensor input. The thermistor type is configured with the define line of 'TEMP_SENSOR_BED'. If you use a thermistor of the type EPCOS B57560G104F (100K, Beta = 4036), you write the value '1' into the matching define. In case you have a thermistor with 100k and Beta = 3950, you have to set the value '60' in the corresponding define. So the defines will look e.g.:

For EPCOS (Beta = 4036) on hotend and heatbed:

#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_BED 1

For Beta = 3950 on hotend and heatbed:

#define TEMP_SENSOR_0 60
#define TEMP_SENSOR_BED 60

If you like, you can tune the DEFINES for HEATER_x_MINTEMP and HEATER_x_MAXTEMP. But that's not really necessary. The predefined values ensure, that the printer will stop in case of a NTC failure or cable break.

// Below this temperature the heater will be switched off
// because it probably indicates a broken thermistor wire.
#define HEATER_0_MINTEMP   5
#define HEATER_1_MINTEMP   5
#define HEATER_2_MINTEMP   5
#define HEATER_3_MINTEMP   5
#define HEATER_4_MINTEMP   5
#define HEATER_5_MINTEMP   5
#define HEATER_6_MINTEMP   5
#define HEATER_7_MINTEMP   5
#define BED_MINTEMP        5
// Above this temperature the heater will be switched off.
// This can protect components from overheating, but NOT from shorts and failures.
// (Use MINTEMP for thermistor short/failure protection.)
#define HEATER_0_MAXTEMP 275
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
#define HEATER_4_MAXTEMP 275
#define HEATER_5_MAXTEMP 275
#define HEATER_6_MAXTEMP 275
#define HEATER_7_MAXTEMP 275
#define BED_MAXTEMP      150

Starting on line 1058 you can adjust the turn directions how your stepper motors.

// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#define INVERT_X_DIR false
#define INVERT_Y_DIR true
#define INVERT_Z_DIR false
// @section extruder
// For direct drive extruder v9 set to true, for geared extruder set to false.
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
#define INVERT_E6_DIR false
#define INVERT_E7_DIR false

In this section you have to adjust the direction of the stepper motors matching you version of a 3d printer. The easiest way is to move one axis for some units into one direction. This may be done by using the display (if you have one installed) or with the host software (e.g. printrun or repetier). If you moved the axis, you check wheter the motor turns into the right direction. In case not, you change the value behind the matching INVERT_?_DIR entry from true to false or vice versa.

ATTENTION: Don't use homing of the axis at this point!

With homing the firmware moves all axis until it hits the endstop. If the stepper turns into the wrong direction the head or the bed will run into the wrong direction until it hits the mechanical end of the axis. You can only stop this by resetting the printer or turn of the power.

Short hint:
After turning power on, the Marlin Firmware sets the current position to 0/0/0. In the initial configuration Marlin allows moving the axis only to positiv positions. With homing the printhead and bed move to the endstops and the firmware starts from there with 0/0/0.

With the next line you have to calibrate (roughly) the axis by setting the necessary steps per unit (Marlin uses [mm]). Therefore you have to set the correct amount of steps the firmware has to use per millimeter. The numbers in the brackets set the values as follows: { x-axis, y-axis, z-axis, extruder}.

#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200.0*8/3,760*1.1} // default steps per unit for Ultimaker

At this point you have to make some calculations. You have to start with you stepper motor. You have to check the technical description and read out the amount of steps per revolution. Most used NEMA steppers will have 200 steps per revolution (1.8° step angle). This value has to be multiplied with the configured micro stepping of your stepper driver. Very common are micro steppings of 1/16 or 1/32. This means, that the driver will devide the one mechanical step of the motor into 16 or 32 micro steps. Here you have to check your setting for stepper driver!

This means:

  • 1/16 Stepping
    • 200 * 16 = 3.200 steps / revolution
  • 1/32 Stepping
    • 200 * 32 = 6.400 steps / revolution


Now you have to add into the calculation the mechanical components, which further influence the resolution per unit. A lot of 3d printers use a M8 threaded rod on the z-axis. The M8 rod has normally a thread pitch of 1.25 mm per revolution. To get the total amount of steps per unit, you have to divide the steps calculated befor through the thread pitch. Then you have the first rough setting. The values for a M8 rod then will be:

  • 1/16 Stepping
    • 200 * 16 / 1,25 = 2560
  • 1/32 Stepping
    • 200 * 32 / 1,26 = 5120


If you have different rods, like acme thread of the types TR8x1.5 or TR10x3, you have to use the pitch values of those for your calculation. You may get with several decimals. I think in practice everything behind the 4th or 5th decimal won't have a significant influence to the accuracy of your printer. So it should be sufficient to use values up to 4 or 5 fractional digits.

To adjust the Steps/Unit for X-/Y-axis, you can use this formula:

(<steps per revolution of the motor> * <microstepping>) / (<count teeths of pulley> * <belt pitch>) = steps per unit

In this example calculation we use a GT2 pulley with 20 teeth and the pitch of the standard GT2 belt with 2 mm.

  • 1/16 Stepping
    • 200 * 16 / 20 * 2 = 80
  • 1/32 Stepping
    • 200 * 32 / 20 * 2 = 160


The next point on your checklist is to adjust the stepping per unit for the extruder drive. The feedrate of the filament will be influenced by gear ratio of the extruder and the effective circumference of the filament screw. The standard Gregs Wade extruder has 11 teeth on the small and 39 on the big gear. This results in a transmission ratio of 1 : 3.54. The Wades extruder uses a M8 bold. So you have a diameter of 8mm (roughly, because hobbing will reduce the diameter). With the formula above, you will get a value of 25.1327mm.
If you have a Bulldog XL extuder from reprapdiscount, things get easier. Wrote down alread the steps per unit (for a 1/16) microstepping.
So for a Bulldog XL you can start with this values:

  • 1/16 Stepping
    • 495
  • 1/32 Stepping
    • 990


In any case you have to perform a fine tuning of this values to get the best accuracy from your printer.

The last topic for the initial setup will be setting the maximum feedrates for the distinct axis. This will ensure, that the printer will stay within its physical capabilities even when the GCode advices higher rates. This parameters depend heavily on the physical setup of your printer, like stepper motor current and moved masses of the bed and extruder. Even low feedrates can result in a humming sound of the motors and the axis won't move when the motor current is set to a low value. If you set the motor current too high, the stepper driver may overheat and overheat protection of the drier will stop the motor. Or more worse, you will damage the stepper by running with a current above its specification.

In any case the motors will stop during the print job and the printed part will be vaste.

#define DEFAULT_MAX_FEEDRATE          {300, 300, 5, 100}    // (mm/sec).

For the maximum feedrate you have to find a balance between the operating temperature of the stepper drivers and the max possible stepper current.

Ok, now you have finished the main steps for the initial setup. Now you have to send the firmware to the board by clicking on the arrow to the right.

08-RUMBA-Configuration-h

After successful compiling and transmission of the firmware the board will make a reset and the display should show the basic screen of the Marlin firmware. The next picture shows the screen in case of the full graphic lcd.

slider-3

Now you finished the basic setup and everything should work now. In any case you have to fine tune your printer by calibrating all axis and the extruder!

Please enter these characters in the following text field.

The fields marked with * are required.