Airtripper's 3D Printer and Arduino Blog » 3D Printer Firmware http://airtripper.com 3D Printer usage and modifications plus Arduino powered electronic projects and 3D Printing designs. Fri, 09 May 2014 01:20:57 +0000 en-US hourly 1 http://wordpress.org/?v=3.8.3 Marlin Firmware v1, Basic Configuration Set-up Guidehttp://airtripper.com/1145/marlin-firmware-v1-basic-configuration-set-up-guide/?utm_source=rss&utm_medium=rss&utm_campaign=marlin-firmware-v1-basic-configuration-set-up-guide http://airtripper.com/1145/marlin-firmware-v1-basic-configuration-set-up-guide/#comments Mon, 14 Jan 2013 03:42:02 +0000 http://airtripper.com/?p=1145 Marlin Firmware v1 on 20x4 LCD Panel Display

Marlin Firmware v1 on 20×4 LCD Panel Display

I’ve just updated the Marlin firmware on my Sumpod 3d printer since I’m always keen to have the latest features and bug fixes. To be honest, I don’t mess with the firmware that much, and if it wasn’t for the configuration file from my last version, I would struggle to remember what sort of configuration I would need to set in the latest firmware version.

Anyway, while my latest experience with 3d printer firmware is still fresh in the mined, I’ll share some notes about what settings you need to know to get a basic Marlin firmware configured enough to get a 3d printer working. The notes will focus on the Marlin firmware v1 and will include setting up a click encoder and LCD panel. But before going straight into getting the Marlin firmware configured, I’ll first quickly introduce you to a handy tool called WinMerge.

UPDATE  Sep 10, 2013

While the latest Marlin firmware continues to be developed, with many new features being added all the time,  I’ve decided to maintain a snapshot of the firmware that this guide is based on. Using this guide with the firmware it is based on will give you the smoothest 3d printer set-up experience.

To download the firmware, click on the “Download ZIP” button located at the bottom of the right column on the GitHub page.

https://github.com/Airtripper/marlin_01

WinMerge

WinMerge can compare both folders and files

WinMerge can compare both folders and files – Marlin Firmware being compared

For anybody that’s in the business of editing and configuring 3d printer firmware files such as the Marlin firmware, I would suggest downloading a copy of WinMerge. It’s free, open source software, and is cross platform, so the same tool will run on Windows and Linux.

You can use WinMerge to compare a clean version of your Marlin firmware against your edited version that you are using on your 3d printer. This will help to keep track and note all the changes made to the files that you might want to transfer to a newer firmware version.

You can open just two files to compare or you can open two folders to compare. Comparing 3d printer firmware folders will allow you to quickly spot which files that have been edited.

Marlin Firmware Basic Configuration

RAMPS 1.3 on the underside of the Sumpod 3D Printer

RAMPS 1.3 on the underside of the Sumpod 3D Printer

Some motherboards listed in the Marlin firmware configuration file may not have support for some of the options or features available to configure. The notes will be biased towards the Ramps 1.3 board, but the note will still be valid for any Marlin firmware compatible board.

This Marlin firmware will be useful to those who wish to configure their own 3d printer firmware and want information that expands on the comments already made in the Marlin firmware. The notes are a brief guide on what the settings are and how to use them, leaving it up to the person who is configuring the 3d printer to decide what the final settings should be. I don’t guarantee that the information in this Marlin firmware guide is accurate, however, if you spot any mistakes please leave a comment at the end of the post. The Marlin firmware guide is likely to be updated to improve the information where necessary after publishing.

Arduino 0023 IDE - showing line number location

Arduino 0023 IDE – showing line number location

For Marlin Firmware V1 you will need Arduino 0023 IDE to save, compile and upload to the 3d printer motherboard. In the following notes, to edit the firmware, I’ll be using line numbers to reference the location of the code in the Marlin firmware configuration file. Although there is no line numbering in the IDE editor window,  you will see the line number at the bottom left of the IDE showing the current cursor position. Just move the cursor to any line with the mouse to update the line number.

To get the 3d printer up and running you only need to configure one file in the Marlin firmware and that file is the  Configuration.h

Marlin firmware Configuration

So, to get started, open up the Marlin firmware Configuration.h in the Arduino IDE and work down the notes below. Use WinMerge to compare the changes to a clean non-edited version of Configuration.h for final review before uploading to the 3d printer motherboard.

Baud Rate – line 20

#define BAUDRATE 250000
//#define BAUDRATE 115200

Line 20 marks the start of the Marlin firmware configuration journey and this is where the baud rate is set to determine the speed of the communication between the printer interface software and the Marlin firmware. Two common baud rate options are defined with one, preceded with two forward slashes (//), commented out to disable. The default enabled option, 250000 baud rate, works well when used with Printrun/Pronterface and RepSnapper software.

RepRap Arduino Mega Pololu Shield, or RAMPS for short

RepRap Arduino Mega Pololu Shield, or RAMPS for short

Motherboard – line 49

#ifndef MOTHERBOARD
#define MOTHERBOARD 33
#endif

You will see a list of motherboards to choose from preceding the code snippet shown above in the Marlin firmware configuration file. The code snippet above defines the Ramps 1.3 as the motherboard, you can select a board just by changing the number to any board that’s on the list. The Marlin firmware will manage circuit board pin assignments to match the motherboard you have selected. Pin assignment details for each motherboard type can be found in the pins.h file of the Marlin firmware.

Marlin Firmware Thermal Settings

Now we come to the thermal settings section of the Marlin firmware where things get a bit more complicated, however, we don’t need to touch the complicated stuff to get the printer up and running. Basically all we need to do is select a temperature sensor type for each of the sensors installed on the 3d printer. If you did not install the temperature sensors yourself, you may have to investigate what sensors you do have so that you can select the best match from the list. More about thermistors on the RepRap wiki.

RAMPS 1.3 Temperature Connectors T0 & T1 Connected

RAMPS 1.3 Temperature Connectors with T0 & T1 Connected to Hot End & Heated bed sensors

Thermistor – line 78

#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 1

If you are looking at the Marlin firmware configuration file you will see a list of temperature sensor types preceding the code snippet shown above. The code snippet above is setting up the 3d printer that features one hot end and a heated build platform. The temperature sensor selected for both features is 100k thermistor.

If you are using the Ramps 1.3 motherboard with the default pin.h file in the Marlin firmware, the motherboard connectors T0 and T1 will be enabled for the hot end sensor and the heated bed sensor. Changing the 1 to a 0 will disable that sensor. Change the number to select the best match for your sensor from the list.

Maximum Temperatures – line 99

#define HEATER_0_MAXTEMP 275
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define BED_MAXTEMP 120

Some hot ends and heated build platforms might have a maximum temperature rating much less than the default settings in the Marlin firmware, reducing the default maximum temperatures will help avoid accidental damage to the 3d printer if set too high in the interface software.

Marlin firmware Mechanical Settings

The Marlin firmware Mechanical Settings section will be about configuring End Stops, Stepper Motors, Build Platform Printable area and Steps Per Unit.

Sumpod 3D Printer End Stop Locations

Sumpod 3D Printer End Stop Locations

End Stops & Pull Ups

This section will be about configuring end stops in the Marlin firmware that are the limit switches for each axis on the 3d printer. Issuing a homing command from the interface software will cause the 3d printer to mechanically move each axis towards the end stop until the limit switch is triggered.  ENDSTOPPULLUPS will need to be defined where you have limit switches that don’t supply a voltage to the signal pin to generate a digital 1. Enabling pull up resistors will ensure that the end stop signal line will read a digital 1, and when the signal line is shorted to ground by the limit switch, you get a digital 0.

For more information about end stops please refer to the RepRap wiki for Mechanical EndstopOptoEndstop 2.1 and Gen7 Endstop 1.3.1.

Coarse End Stop Pull Up Resistor – line 194

// corse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors

In the Marlin firmware ENDSTOPPULLUPS is defined by default, and ENDSTOPPULLUPS for each end stop connector on the motherboard are enabled individually from line 207. However, commenting out line 194 will only disable ENDSTOPPULLUPS that are also commented out optionally for each connector from line 197. Having this kind of fine tuning makes it easier to configure different types of end stops connected to the 3d printer. You may have mechanical end stop switches for axis X and Y that need pull up resistors enabled and optical end stops that don’t need pull up resistors enabled.

RAMPS 1.3 Mechanical End Stop Connections X-, Y- & Z+

RAMPS 1.3 Mechanical End Stop Connections X-, Y- & Z+

Fine End Stop Pull Up Resistor – line 196

#ifndef ENDSTOPPULLUPS
// fine Enstop settings: Individual Pullups. will be ignord if ENDSTOPPULLUPS is defined
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
#endif

If ENDSTOPPULLUPS at line 194 in the Configuration.h file of the Marlin firmware is commented out, then the code snippet above, starting at line 196, will execute. This code snippet will allow you to configure individual pull ups for each end stop connector on the motherboard. You would comment out a define statement for an end stop where you don’t need a pull up by preceding the line with two forward slashes. You would normally need to enable pull ups when using mechanical end stop type switches that just simply sink the signal pin to ground on the motherboard end stop connector.

3D Printer Mechanical End Stop Wired Normally Connected (NC)

3D Printer Mechanical End Stop Wired Normally Connected (NC)

Inverting End Stops – line 216

// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
// set to true to invert the logic of the endstops.
const bool X_ENDSTOPS_INVERTING = false;
const bool Y_ENDSTOPS_INVERTING = false;
const bool Z_ENDSTOPS_INVERTING = false;

For a mechanical end stop that is wired as normally connected (NC), a digital signal of 1 will be read when an axis is in contact with the limit switch. In this case End stop inverting needs to be false. End stop inverting needs to be true if the mechanical end stop is wired as normally open (NO).

For optical end stops, you will need to refer to the suppliers specification or a previous configuration.h file like the one in the Marlin firmware.

You should test the homing command while the axis is positioned at the centre of the travel distance. If you find that the axis won’t move when the home command is sent, then you may have the logic incorrectly configured. Be ready to reset the motherboard or turn off the power to avoid axis crash. Before making any test, complete the Marlin firmware configuration as much as possible. If you can reach the end stops easily, you can trigger them early before the axis has completed it’s travel for a safe test.

Disable Maximum End Stops – line 219

//#define DISABLE_MAX_ENDSTOPS

The above code snippet found on line 219 of the Marlin firmware Configuration.h file is commented out by default, which allows homing axis to end stops where end stop switches are connected to the X+, Y+ and Z+ connectors on the motherboard.

It is common to have the Z axis end stop switch connected to the Z+ connector in order to home the Z axis away from the hot end. In order to do this, line 219 needs to be commented out. Line 219 may behave differently for boards that don’t have X+, Y+ & Z+ end stop connectors.

3D Printer Metal Z Handle Fitted

Disable Z axis = true in the Marlin firmware configuration if you want to operate a Z axis handle during 3d printing

Disable Axis – line 228

// Disables axis when it’s not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z true
#define DISABLE_E false // For all extruders

Normally the above code snippet would not be changed in the Marlin firmware and all the settings would be set to false by default. However, if your 3d printer has a Z axis handle fitted like my 3d printer you might want to disable the Z axis so that the stepper motor can be turned by the Z axis handle while the 3d printer is printing. I’ve often made a Z height adjustment to fine tune the gap between the nozzle and the build bed as the first layer begins to print.

Stepper Motors

We have reached the part in the Marlin firmware configuration file where you configure stepper motor rotation direction, end stop direction, travel limits and steps per unit. As long as the end stops are configured correctly, the following settings should be easy enough to sort out during testing.

RAMPS 1.3 Stepper Motor Wire Connections

RAMPS 1.3 Stepper Motor Wire Connections

Stepper Motor Rotation direction – line 233

#define INVERT_X_DIR true
#define INVERT_Y_DIR true
#define INVERT_Z_DIR true
#define INVERT_E0_DIR true
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false

This is where we decide which direction each axis will go when we control the 3d printer through the interface software. When we send a command to move +10mm on an axis, we expect the axis to move 10mm in the direction expected. The initial stepper motor direction can be difficult to predict without switching on the printer and performing a test. So I would suggest leaving these settings till last and complete the rest of the Marlin firmware configuration before proceeding with the test.

Once the Marlin firmware Configuration file is configured enough to operate the 3d printer, you can perform a test to check that each axis move in the correct direction. Set each axis midpoint of their full travel distance and then switch on the printer. After connecting to the 3d printer through the interface software such as Printrun/pronterface, test each axis by jogging them 10mm in the positive direction. The stepper motor rotation direction for each axis can be corrected from line 233 in the Marlin firmware configuration by changing the logic.

You would need to test the extruder stepper motor direction as well. This can be done without filament loaded and bringing the hot end temperature up to 175 degrees so the Marlin firmware will allow extrusion. Send an extrude command through the 3d printer interface software and observe the direction the filament drive gear pulley rotation. The rotation direction for the extruder can be corrected from line 236 by changing the logic.

When performing axis homing and axis jogging for the first time, it is important to be ready to press the reset button or be ready to turn off the power to avoid axis crashing. Home each axis separately to confirm that the axis is homing towards the end stop. If you can reach the end stops easily, you can trigger them early before the axis has completed it’s travel for a safe test.

RAMPS 1.3 Mechanical End Stop Connections X-, Y- & Z+

RAMPS 1.3 Mechanical End Stop Connections X-, Y- & Z+. These should also match End Stop home direction.

End Stop Home Direction – line 242

// Sets direction of endstops when homing; 1=MAX, -1=MIN
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR 1

Basically you tell the Marlin firmware which end of the axis the end stop switch is located. It is common for X and Y axis to home the hot end to the Zero location and Z axis end stop home to the maximum positive location. The code snippet above and the image to the right shows that configuration.

Some motherboards like the Ramps 1.3 have a connector for each end of each axis, totalling six connectors. You will need to be sure that the settings above match the end stop connections to the motherboard.

Measuring Travel limits for Marlin Firmware Configuration

Measuring Travel limits for Marlin Firmware Configuration. Using a Dial Indicator Can Make it easier to see the measurements.

Travel Limits – line 249

#define X_MAX_POS 130
#define X_MIN_POS 0
#define Y_MAX_POS 130
#define Y_MIN_POS 0
#define Z_MAX_POS 107
#define Z_MIN_POS 0

The above defines the printable area of the 3d printer after homing. For the X and Y axis you just measure the travel length of the nozzle from the home position. The maximum travel length will either be restricted by the size of the build platform or by the maximum travel distance of the axis.

When setting up the Z axis for the first time, it is best to set the Z axis travel length a bit shorter than what is measured until a software and hardware test of the 3d printer is completed. This will help to avoid accidentally crashing the build bed into the hot end during initial tests. The Z axis travel length can be fine tuned later after the tests have been satisfied.

The measurement units are in millimeters and are defined from line 249 for the maximum positions in the Marlin firmware configuration file. The minimum positions can be left at the default 0 for this configuration.

Steps Per Unit – line 275

#define DEFAULT_AXIS_STEPS_PER_UNIT   {106.76, 106.76, 800, 48.14}

Configuring steps per unit will be one of the last bits of fine tuning you do before you start printing for the first time. Calculating steps per unit accurately will give the 3d printed parts the best start possible. However, if you are just upgrading the Marlin firmware or upgrading from any other firmware, you can get the steps per unit figures from the old configuration file if you still have it.

Steps per unit means the number of steps a stepper motor has to turn to equal 1mm of axis travel. The units at line 275 of the Marlin firmware configuration.h file are in the order of X, Y, Z and E. Getting the steps per unit from another printer of the same design would be very close to what you need, and will help you run some stepper motor tests before you get down to calculating accurate steps per unit for the Marlin firmware configuration file.

The code snippet above shows the steps per unit for my Sumpod 3d printer and is not the default setting in the Marlin firmware configuration.

Measuring travel distance for Marlin firmware steps per unit

Measuring travel distance for Marlin firmware steps per unit calculation

Steps Per Unit Calculation

To calculate steps per unit (mm) to put in the Marlin firmware configuration file, you need to find a good way to measure axis travel distance accurately. You may have to temporary remove the hot end so that the filament can be extruded in order to make measurements. Using a dial indicator in place of the hot end and a ruler taped to the bed can provide a good accurate way to measured travelled distance. To get the best accuracy you should sample at least 100mm of axis travel. You command the printer to move the chosen axis 100mm using an interface software such as Pronterface. You then measure the actual distance the the axis travelled. Using the formula below you can calculate the new steps per unit.

Steps Per Unit Formula

NewStepsPerUnit = SampleTravelDist / ActualTravelDist x OldStepsPerUnit

You then repeat the above formula as many times as necessary until the commanded travel distance matches the actual distance travelled, using the NewStepsPerUnit as the OldStepsPerUnit each time.

Marlin Firmware Basic Configuration – The End

At this point, you have done enough configuration in the Marlin firmware and can now start 3d printing. If you are interested in LCD display and click encoders, read on.

Marlin Firmware additional Features

Sumpod LCD Click Encoder Control Panel

Sumpod LCD Click Encoder Control Panel Configured with the Marlin Firmware

The last section in the Marlin firmware configuration file is for additional features, this section allows you to configure some of the optional extras you might have attached to your 3d printer. For the purpose of this guide I’m just going to include notes for the LCD 16×2 and the LCD 20×4 with click encoder control panel. The RAMPS 1.3 Arduino shield and my Marlin firmware configuration will be used for this guide.

Enabling an attached 16×2 LCD or click encoder control panel is straight forward in the Marlin firmware. However, the pin assignments for the attachment connectors need to match those in the Marlin firmware pins.h file. You can check if the LCD and click encoder panel features are supported for your motherboard by looking through the the pins.h file of the Marlin firmware. If you are just updating the Marlin firmware you can check for pin assignment changes by comparing your old pins.h configuration file with the new version of that file. Any changes found can be used to update the latest version of the Marlin firmware.

RAMPS 1.3 to LCD Pin Connections

RAMPS 1.3 to LCD Pin Connections – Marlin Firmware Default Pin Assignment For This Board.

Adding LCD Support – line 303

#define ULTRA_LCD

To enable any type of LCD support in the Marlin firmware, ULTRA_LCD needs to be defined. To add support for 16×2 LCD display, line 303 needs to be uncommented like the code snippet above, by removing the preceding forward slashes. By default, the Marlin firmware does not have LCD or click encoder control panel enabled. Enabling line 303 and nothing else will give you support for 16×2 LCD screen that is connected to the motherboard pins as assigned in the pins.h file. Pin assignments are found in the pins.h file of the Marlin firmware under each supported motherboard type.

Adding Click Encoder Support

There are two popular types of click encoder control panels that can be enabled for the RAMPS 1.3 board. The first type is the Ultipanel, which can be found on Thingiverse, and the other type is the RepRapDiscount Smart Controller. For this guide I’m just going add notes for the Ultipanel since the other type is supported by RepRapDiscount RepRap wiki for the Marlin firmware.

RAMPS 1.3 Click Encoder Pin Connections

RAMPS 1.3 Click Encoder Pin Connections – Marlin Firmware Default Pin Assignment For This Board & Ultipanel.

Enabling ULTIPANEL – line 307

#define ULTIPANEL

Enabling NEWPANEL – line 331

#define NEWPANEL

Both lines 307 and 331 are not enabled by default. To enable 20×4 LCD display and click encoder, uncomment both lines by removing the forward slashes. This would also enable SD Card support as well, a feature that will be covered in another guide. It will not be necessary to uncomment line 303 if line 307 is enabled by uncommenting. ULTRA_LCD will automatically be defined when ULTIPANEL is defined.

Marlin Firmware Guide – The End

Well that concludes the Marlin firmware guide for now, and I would expect to be making updates going forward to correct errors if any are found or just to improve certain aspects of the guide.

[bodyadsrich1l]

If you have any questions or comments about the Marlin firmware guide, please leave them below. However, if you need Marlin firmware support, this is perhaps not the best place to get it.

]]>
http://airtripper.com/1145/marlin-firmware-v1-basic-configuration-set-up-guide/feed/ 29