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:

If you want to download the Marlin package from GitHub, you can klick on the Button 'Download ZIP'. You will get then the complete package within one zipfile.

If you want to run your RAMPS 1.4 together with the Full Graphic Display, you also must download the u8glib library from http://code.google.com/p/u8glib/wiki/u8glib. 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:

 tbd

As soon as the driver is installed corrrectly, you will find the device "Arduino 2560" in your device manager. It will be visible 'Input (COM & LPT)'. The COM port will be distributed automatically, so you will have a different port id on your computer. You need the port id later on for setting up your Arduino development env.

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' on 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'.

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      33   // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
#define BOARD_RAMPS_13_EEB      34   // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
#define BOARD_RAMPS_13_EFF      35   // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Fan)
#define BOARD_RAMPS_13_EEF      36   // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, 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

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 560. 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!).

// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
#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 58. 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 -1
#define TEMP_SENSOR_1 -1
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 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_1 -1
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 1

For Beta = 3950 on hotend and heatbed:

#define TEMP_SENSOR_0 60
#define TEMP_SENSOR_1 -1
#define TEMP_SENSOR_2 0
#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.

The next interesting point for configuration you will find at nearby line 320. There begins the configuration of the stepper motors.

#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to 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.

As next step you have to adjust the steps per unit for the X and Y axis. One option is to check the pitch of the timing belt. The GT2 timing belt has a pitch of 2mm. If you use a pulley with 20teeth the belt will be moved 20x2mm per revolution. So you may divde the steps you calcuted in the step before by 40.

In reality the effective circumference of the pulley will overrule. For a 20teeth pulley the diameter (d) will be around 12,23mm. If you multiply diameter with Pi (3.14159...), you get a value of 38.4216mm for the circumference. So you see, there might be some room for calibration. ;-)
If you use the value of the calculated circumference, you will get this figures for the stepping per unit:

1/16 Stepping

    • 200 * 16 / 38.4216 = 83.2864
  • 1/32 Stepping
    • 200 * 32 / 38.4216 = 166.5729

The next point on your checklist is 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.