Airtripper's 3D Printer and Arduino Blog » marlin 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 Home Offset Guide Using G-code M206http://airtripper.com/1799/marlin-firmware-home-offset-guide-using-g-code-m206/?utm_source=rss&utm_medium=rss&utm_campaign=marlin-firmware-home-offset-guide-using-g-code-m206 http://airtripper.com/1799/marlin-firmware-home-offset-guide-using-g-code-m206/#comments Thu, 27 Mar 2014 01:43:46 +0000 http://airtripper.com/?p=1799 This is a guide to using g-code command M206 to set the Z axis home offset in the Marlin Firmware, a guide to a method of adjusting the gap distance between the hot end nozzle and the build platform. To set the Z axis home offset on the 3d printer, you will use g-code commands including M206 for the home offset, M500 and M501 for the Marlin Firmware EEPROM feature, and G1 for controlled move to Z axis zero position.

Set Gap Between Nozzle And Bed Using G-Code, EEPROM & Marlin Firmware

Set Gap Between Nozzle And Bed Using G-Code, EEPROM & Marlin Firmware

About

Firstly, this guide may not be suitable for all 3d printers, probably those printers that are the delta type and those with the auto bed levelling feature. Apart from that, for this guide to work for you, you will need a 3d printer configured with a Z+ end stop.

On a lot of 3d printer set-ups, the gap between the nozzle tip and the build platform surface is just a fraction of a millimetre, so it does not take much to upset the gap distance. Things like levelling the build platform, changing the hot end nozzle and using different filament types can cause the first layer height to be out of calibration.

Usually, as accurately as possible, you would only adjust the final travel limit for Z axis in the Marlin Firmware, then upload the firmware to the controller motherboard. However, if adjustments are going to be made more often, it would be more convenient to adjust the final travel limit using the home offset feature.

The guide will explain a method of applying an offset to the Z axis to extend the maximum travel limit, initially set in the Marlin Firmware, using Pronterface. A combination of g-codes will be used through Pronterface so that the home offset can be set, saved and tested. An initial edit in the Marlin Firmware configuration.h file is required, but beyond that, you would only need to change the home offset value to change the gap distance between the hot end nozzle and the 3d printer build platform.

3D Printer Axis Crash Caution

3D Printer Axis Crash Caution – Axis crash is possible with manual jog when software end-stops are disabled

Removed Safeguards – Important

This guide, an extension to the Marlin Firmware v1, Basic Configuration Set-up Guide, covers editing the Marlin Firmware configuration.h file to enable EEPROM support and to disable software end-stops, and as a result of editing the configuration file, it will be important to note that some operational safeguards will be disabled; it will be possible to manually jog an axis beyond its travel limits, probably resulting in an axis crash and possibly causing damage. Accidentally pressing the 100mm jog button instead of the 10mm jog button, is an example of what could cause a 3d printer axis crash; this would normally be prevented by enabled software end-stops. Attempting to print models outside the physical print area could also cause an axis crash also.

Only use this method to set home offset, as described in this guide, if the users of your 3d printer are aware of the manual jog limits and the risk of crashing an axis when exceeding the limits. It would be recommended to include axis homing to the g-code compiler start file so that homing is automatically applied to the model g-code files at compile time. It would be good practice to manually home the 3d printer, using the printer interface such as Cura or a printer control interface, before starting each print.

Marlin Firmware Configuration

If you are attempting to configure the Marlin Firmware for the first time you will need to head over to the Marlin Firmware set-up guide here to get started with the basics.

It’s basically going to be a quick edit of the  Configuration.h before we get started with the main guide to configuring the home offset. Use the Arduino IDE search tool to quickly find the lines of code needed for editing.

3D Printer Marlin Firmware & Home Offset Set-up Example

3D Printer Marlin Firmware & Home Offset Set-up Example

Disable Software End-Stops

To configure the home offset successfully, we’ll need to be able to travel beyond the fixed travel limits set in the Marlin Firmware. When software end-stops are enabled, the home offset will not work outside the axis travel limits. If we want the axis to travel to maximum position plus home offset, we will need to disable software end-stops.

#define min_software_endstops false
#define max_software_endstops false

Software end-stops are enabled by default. To disable software end-stops, find the above lines of code in Marlin Firmware Configuration.h file and set each line to false as shown.

Enable EEPROM Suport

After setting the Z axis home offset on the 3d printer, we want to store the setting in EEPROM so that the home offset value we want to use is available automatically when the printer is started.

#define EEPROM_SETTINGS
#define EEPROM_CHITCHAT

To enable EEPROM support in the Marlin Firmware, uncomment the above code snippets by removing the  forward slashes at the start of each line of code.

Travel Limits After Homing

Ideally, we want to set a maximum travel limit that stops the hot end a good safe distance above the build platform with home offset set to zero, and then fill the gap between the nozzle and the build platform with home offset. If you change the build platform thickness by adding a glass surface for PLA and then remove glass surface for ABS, you will have to allow for the thickness of the glass also. A guide to clearing the current home off set is included further down this article.

#define Z_MAX_POS 80

Normally, you will only need to change the value for Z_MAX_POS; just edit the above line of code to the maximum travel limit you want to set for your 3d printer. On my 3d printer for example, I have around 90mm of travel on the Z axis, as shown in the above code, I’ve set the Z_MAX_POS to 80, that leaves around 10mm to play with when setting the home offset.

Marlin Firmware Home Offset Guide

Some Preparation

After the Marlin Firmware is configured as above, the build platform needs to be levelled before attempting to set the Z axis home offset. You will need to be prepared to fine tune the final offset measurement while the hot end and the heated build platform are up to working temperature. You can practice setting the home offset while the 3d printer is cold, this will avoid trial and error while the nozzle is hot and not extruding for long length of time.

Pronterface - 3D Printer Interface Software

Pronterface – 3D Printer Interface Software

Setting home offset and storing to EEPROM is done through the 3d printer interface software such as Cura and Pronterface. Both Cura and Pronterface have a terminal interface that allow the user to send g-code commands to the Marlin Firmware. For this guide, Pronterface will be used because manual jog controls and terminal are in the same application window for convenience.

Terminal inputs may be case sensitive in some 3d printer software interfaces, if you get an error or no response in the terminal feedback window, check that you are typing upper-case g-code commands.

Setting & Testing Home Offset

Quick Brief

There are seven steps to follow in this guide, first two steps will be to check and clear existing offset for the Z axis, followed by five steps to set and test new home offset. If you are using the Marlin Firmware home offset feature for the first time, please be sure to read through the whole guide first before changing any settings.

The guide describes a set-up that is similar to my 3d printer only, so the Z axis measurements used in this guide are there as a set-up example and not meant to be copied for use in other 3d printer set-ups. If you’ve read the guide in full, you’ll have an idea of what measurements to use on your 3d printer to set your own home offset.

Checking & Clearing Existing Home Offset

Saving a new home offset setting will replace a previously saved offset in EEPROM, so if you’re using a 3d printer you’re not familiar with, avoid unexpected results by first checking for existing offset setting. The next two steps will help to discover and clear an existing offset.

Step 1. This is a simple check to see if an offset has been set.

Check Current Home Offset Setting Stored In EEPROM

Check Current Home Offset Setting Stored In EEPROM

  1. Not an essential step to clearing home offset, put the 3d printer in a safe position by homing each axis after powering up the printer.
  2. Enter the g-code M501 in the terminal interface text box.
  3. Press the send button to send the g-code to the 3d printer.
  4. Data stored in EEPROM is then read to the terminal window. Look for the line with M206 to find the current Z axis home offset.

Step 2. You can fine tune existing offset by jumping to later steps, or you can start a fresh by setting offset to Zero.

Step 2 - Clear Existing 3D Printer Z Axis Home Offset

Step 2 – Clear Existing 3D Printer Z Axis Home Offset

  1. An illustration of what an existing home offset looks like, which can be compromised after build platform re-levelling.
  2. Clear the current Z axis home offset by sending g-code M206 Z0 through the terminal; we set the Z axis home offset to zero.
  3. Save the new home offset to EEPROM by sending g-code M500.
  4. Confirm that the new offset was saved to EEPROM by sending g-code M501.
  5. An illustration of what zero home offset looks like, the 3d printer should be homed after home offset changes.

Setting The Initial Home Offset – 3D Printer Cold

This part of the guide describes setting up an initial home offset while the printer is cold. Basically, we are setting a new offset that will be a centimetre or two short of what we need, we will get the hot end nozzle close to the build platform while the printer is cold. Then, later in this guide, we heat up the 3d printer for fine tuning the final offset.

Step 3. We prepare the printer for the next step so that an initial offset can be measured.

Step 3 - Test Z Axis Height & Z Travel Distance

Step 3 – Test Z Axis Height & Z Travel Distance

  1. First, home the 3d printer. The illustration shows that Z_MAX_POS is much less than Z axis physical travel distance, this should give us room to set an offset.
  2. Send the Z axis to the zero position by sending g-code G1 Z0 through the 3d printer software interface terminal.
  3. The Z axis should now be positioned at zero. We are now ready to measure the initial offset in the next step.

Step 4. So, moving forward from Step 3. c, we are now going to set a rough home offset value with the 3d printer cold, no heaters switched on. If you are just fine tuning the final home offset value,  you could probably skip to Step 5.

If you have a mirrored or glass build platform, slide a sheet of paper over the platform to avoid hot end nozzle reflection that can make you think the gap between the nozzle and platform is bigger than it actually is. If you prefer, centre X and Y axis over the build platform before measuring the gap between hot end nozzle and build platform.

Step 4 - Set New Home Offset For Z Axis

Step 4 – Set New Home Offset For Z Axis

  1. With the Z axis at zero position, as in Step 3. c, use the Z axis manual jog control to bring the hot end nozzle closer to the build platform in 1mm steps. Keep a count of how many 1mm steps, and stop when you get the nozzle about 1 to 2mm away from the platform. Make a note of the total of 1mm steps made for the home offset value. If fitted, the 3d printer LCD control interface will show Z as a negative number; this can be used as the home offset value, with the value changed to positive.
  2. The 3d printer build platform and nozzle is about a millimetre or two apart and we now know the initial offset value we want to start with. For my 3d printer, the initial home offset will be 8mm; because I allowed about 10mm for home offset when setting Z_MAX_POS in the Marlin firmware.
  3. We save the initial offset value to EEPROM, send the new offset value, using the g-code command M206 Z8, through the terminal; setting 8mm as the new home offset.
  4. Immediately save the new offset to EEPROM by sending the g-code M500.
  5. Check that the new offset was saved to EEPROM by sending g-code M501. Look for the line with M206 in it.
  6. With the offset now added and saved to EEPROM, -8 position becomes the new zero position, giving the Z axis a total of 88mm of travel, as the case with my 3d printer. The offset will be updated after homing the Z axis, in the next step.

Step 5. A new home offset value has been saved to EEPROM, and confirmed. Now it’s time to mechanically test the new offset before moving on to fine tuning. The 3d printer is still cold at this point, however, the build platform can be preheated now if preferred, especially if the platform takes a long time to heat up.

Step 5 - Test New Home Offset Setting

Step 5 – Test New Home Offset Setting

  1. To avoid disturbing the X and Y axis centred over the build platform, using the 3d printer software jog controls, home only the Z axis. When the Z axis is at the end stop, the gap between the hot end nozzle and the platform should be slightly more than both Z_MAX_POS and home offset added together.
  2. If the measurements check out as above, then it should be safe to send the Z axis to zero position, send the g-code command G1 Z0 through the terminal.
  3. The 3d printer Z axis should now be at zero position, leaving a millimetre or two gap between the hot end nozzle the the build platform as expected.

Fine Tuning The Initial Home Offset – 3D Printer Hot

Step 6. If you are jumping straight into fine tuning, you need to start from step 5. Right, we’re on to fine tuning the home offset now. This is were you need to be careful, because it is recommended to have the hot end and the build platform at working temperatures while setting the first layer height or gap between the nozzle and platform.

I use A4 photocopy or printer paper as a gap feeler for setting the gap between the nozzle and the platform. You may need to cut the A4 sheet to fit inside the printer, but have the sheet at a size so that it can be handled and positioned while avoiding hands and fingers touching the hottest parts of the 3d printer.

Step 6 - Fine Tune Existing Home Offset Setting

Step 6 – Fine Tune Existing Home Offset Setting

  1. Use the -Z axis jog control to fine tune the ideal offset, get the nozzle close enough to the platform to lightly grab the A4 sheet of paper. Keep a count of each jog move size for totalling later.
  2. Using the A4 sheet as a feeler gauge, in the case of my 3d printer example, the jog moves total is 2.5mm. This would show as -2.5 on the 3d printer LCD.
  3. An offset has already been saved to EEPROM, so we need to add 2.5mm to the existing offset, this would make the total home offset value 10.5mm. Send g-code M206 Z10.5 through the terminal.
  4. Store the new offset by immediately sending g-code M500.
  5. Check that the offset has been saved by sending g-code M501.
  6. After homing the 3d printer again, the Z axis will be updated, and the -2.5 position will become the new zero position. Go to step 7 to test the new settings.

Part 7. By now, the home offset should be ready for the first 3d print test, all we need to do now is test the offset setting, like in step 5, just to confirm we are ready to go. Once the following test is complete, home the 3d printer, and switch off the heated bed and the hot end nozzle heater.

Step 7 - Test Final Home Offset Setting

Step 7 – Test Final Home Offset Setting

  1. Home the 3d printer. The illustration shows how the settings look. The 3d printer LCD would show 90.5 at Z+.
  2. If you have set the home offset carefully, and there is no risk of a Z axis crash, send g-code G1 Z0.
  3. The hot end nozzle should now be A4 paper thickness away from the platform. Congratulations, home offset set.

Closing Notes

I hope you found this guide useful, A lot of care was made to avoid mistakes, but if you find any please let me know.

The graphical illustrations should provide a quick guide for return visits to jog the memory when needing to set a new home offset. If you are feeling confident and you find the 3d printer interface software jog controls don’t give you enough fine tuning, use the G1 controlled move command.

[bodyadsrich1l]

Related Articles

Marlin Firmware v1, Basic Configuration Set-up Guide

Marlin Firmware Home Offset Guide Using G-code M206

]]>
http://airtripper.com/1799/marlin-firmware-home-offset-guide-using-g-code-m206/feed/ 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