Posted on Leave a comment

Ultimaker – Fintuning nozzle distance from bed

This small blog-post guide can be used with any printer using the standard Gcode system.

I’m simply writing it in regards to Ultimaker as the issue has arisen from using these machines and their special kind of bed adjustment, which doesn’t provide any tools to do fine final adjustments.

Tools needed:


Go to their website and download the program for your system. File downloads for Windows, Linux and MAC.

You can also go and visit their Github repository if you want to.

After installation you select proper Com port and Baud if/as needed and hit Connect.


When you connect you automatically get a detailed readout of current settings.

I’ve noted the Extruder steps/mm as many would like to adjust these some.

The current Z-offset as defined during setup of myUltimaker is Z-12.45. The nozzle needs to be a tad closer to the bed, so I’ll change the Z-offset to Z-12.40 as raising number is closing in the distance, while lowering the number increase the distance.

Adjust Z-offset

We are using M206: Offset Axes to change the Z-offset.

We simply type M206 followed by the new value of Z-12.40
M206 Z-12.40

Save changes

Now use M500 to save the new settings to Eeprom in order for the changes to be in place after poweroff.
It will all look like this in Pronterface serial window:
>>>M206 Z-12.40
SENDING:M206 Z-12.40
echo:Settings Stored

Reconnect to verify changes are now changed. Might want to unplug USB and power the printer on and off to verify the changes are stored correctly as well.

Posted on Leave a comment

Motion Configuration on Ramps 1.4 With Marlin Firmware

Motion Configuration on Ramps 1.4 With Marlin Firmware @section Machine

This is going to be a, hopefully, complete tutorial on configuring Motion Control on 3D printers build on Ramps 1.4 using Marlin firmware. Not having Delta, or CoreXY printers included.

I am going to use Pronterface/Printrun host program to connect to my printer and issue Terminal commands (G-codes). That sounded very hairy, but it is just a simple program with a graphical interface.

Even though I’m going to use Ramps 1.4 and Marlin firmware 1.0.2, this tutorial will most likely be usefull for most setups. We are going to use the newest Arduino IDE to edit the Marlin firmware.

What we cover in this Instructables:

  1. Stepper Direction
    1. Homing Direction
  2. Software Endstops
  3. Some final tweaks
    1. Quick Home
    2. Babystepping
    3. All set

Small change since last:

My last instructable was made using Release Candidate 2 of the Marlin firwmware. Due to some incompatibilities I had to change to the latest stable firwmare, so the layout is a bit changed from the images in the previous Instructables. It means I made brand new images for this one 🙂


  1. It is required/necessary that you have setup your endstops before beginning on this Instructable.
  2. You need to have defined you steps for your steppers. You can find calculators here:

Step 1: Stepper Directions @section Machine


Place your Carriage (hotend assembly) in the middle of your X and Y axes, and connect to your printer using Pronterface/Printrun. Also power it up.

Check Endstop Status

Start by sending M119 to the printer to check endstop status. They should all show Open before continuing.

Pronterface – Check Stepper Directions

Now use the directional arrows in Pronterface to gently move the axes, using 1mm and 10mm. You might only be able to move an axis using the + for that axes.

The main thing here is to write down wheter an axis is moving the right direction or not.

Pro-tip: You might want to keep you finger near the on/off switch on your printer.

Firmware – Stepper Direction

Find INVERT_X_DIR in your Marlin firmware in the Configuration.h tab. If you use a Release Candidate of the firmware, it will be located in the @section Machine.

#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

For any axis which moves the wrong way, you change the true to false or vice versa.

Firmware – Homing direction

Next we setup homing direction.

For most printers we want to home it to our front left corner, which we define as our X and Y minimum endstops. We also want our hotend to be close to our bed, which is Z min as well.

These XYZ minimum endstops are also referred to as our Origin and will normally be 0 on their respective axes.

Find X_HOME_DIR in Configuration.h file, and set HOME_DIR for X, Y and Z to -1. – as shown in below code-block.

This tells our axes to home to the minimum endstops.

// 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

Some printers use different topologies, so you might need to change this. Ultimaker 2 homes to X min, Y max and Z max.

Verify our changes

Disconnect Pronterface, Upload firwmare and check if the axes move in the right directions. Make changes if neccessary.


When everything moves as it should , you test the homing function. You can test using the icons with a “house (home)” on it for each axis, or use the G28 command followed by the axis you want to home.

If you just type G28; you home all axes.

You can also type G28 X or G28 XY or some other combination.

Step 2: Software Endstops – @section Machine

max-pos.jpgBefore starting on this section we need to make a change in the Configuration_adv.h sketch.

Locate and make sure ENDSTOPS_ONLY_FOR_HOMING is commented out, like so:


We need to complete this step in order to get readings from any max-endstops we might have in place.

If you do not have any max-endstops, you can ignore thisstep.

G28 – Start by homing

  1. Home all axes using G28 (1)
  2. Use M114 (2) to verify that your printer is actually considering itself at 0 n all axes.
  3. Protip: The M84 (3) I send (shown in image) is to turn off motors, as they buzz while I type.

Software endstop – Travel limits after homing

In Configuration.h find max and min_software_endstops, and make sure they are set to true

#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.

Below is the default settings for software endstops.

For our purpose it is usefull if you change them to something more than your actuall axes lengths in order to move our axes as far as we need to find the max area for the printer.

Pro-tip: If you have your homing endstop at a MAX_POS, you will need to use negative values to indicate how far back it can go in order to reach the MIN_POS

// Travel limits after homing
#define X_MAX_POS 205
#define X_MIN_POS 0
#define Y_MAX_POS 205
#define Y_MIN_POS 0
#define Z_MAX_POS 200
#define Z_MIN_POS 0

Axes MAX positions

Below points are shown in the image numbered blue 1-4

  1. If you havn’t done so allready, you start by homing all axes, using G28 (1)
  2. Issue M114 command to make sure all axes are at 0.
  3. Now move all AXES as far towards MAX as you can. Either untill you hit a MAX endstop, if you have any such, or just as far as you can move it and stay within you bed – you do not have to Count!
    1. If you have Max endstops you can read the position in the terminal window.
  4. Issue M114 to get a read out on posistions. You can see it rounded up.

Update your firmware

Now go update your firmware according to your system. Notice how I substracted some 11mm due to a clip on my heated bed. You might have similar considerations.

Pro-tip: Note how I place // after the mm input and then write notes. This is a good way to keep tabs on what you did for what reason.

// Travel limits after homing
#define X_MAX_POS 227 // 227.81 MAX
#define X_MIN_POS 0
#define Y_MAX_POS 180 // 190.96 MAX - 11 for clip
#define Y_MIN_POS 0
#define Z_MAX_POS 190
#define Z_MIN_POS 0

Step 3: Final Tweaks and Famous Last Words


Some final tweaks

We might want to undo the setting we made to ENDSTOPS_ONLY_FOR_HOMING. Meaning we enable it again, in the Configuration_adv.h file.

I’m enabling it again as I want to be able to use Z-offset to tweak nozzle distance from the bed, which would be impossible with this setting enabled – I’ll see if I can’t make a simpler guide than the one I linked to. If you have no such plans, then keep it disabled as it is an extra safety measure. I’ve used it up untill now and liked it.
Notice I made a comment above the line. It’s to make it easier for me to find it.

// MDN Endstops only for homing
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing

Quick Home

I do not like waiting for the X and Y axes hóming seperately. Luckily we can make them home at the same time by ennabling (uncommenting) QUICK_HOME in the Configuration_adv.h

// MDN Quick home
#define QUICK_HOME  //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.


You can also enable BABYSTEPPING, which I do below here – it Means you can use your LCD knob to move the axes in tiny increments to tweak the printer after it has started printing. Very usefull to tweak Z-axis if it is a bit off. There is also a setting to define feedrates when using an ULTIPANEL (lcd).

Pro-tip: If you aren’t aware of it, you can bring up the search box by using CTRL+F og from Edit -> Find…

Pay attention to the warning about this functions ignores Z-min, so you can “crash” the bed against the nozzle.

In reality you have to turn the knob a lot to make the bed move.. like an entire turn to even notice the bed moving, so you have to have very quick fingers to do any harm. I know I’ve played a lot with it and took a while to even figure out that it wasindeed moving.

The Babystepping is only gong to show up in the display after you have startet printing.

// Babystepping enables the user to control the axis in tiny amounts, independently from the normal printing process
// it can e.g. be used to change z-positions in the print startup phase in real-time
// does not respect endstops!
// MDN Babystepping

All set

Now your all set with all the basic movement settings configured 🙂
I’ll recommend you read through the Configuration.h and Configuration_adv.h files and see if you find anything interesting. Like X_HOME_RETRACT_MM which tells the printer how much to retract after hittingendstop, then slowlinggoing back.

Have fun and maybe even follow me here on 🙂

Posted on Leave a comment

Configuring Endstops on Ramps 1.4 With Marlin Firmware – @section Homing

This is going to be a, hopefully, complete tutorial on configuring endstops on 3D printers build on Ramps 1.4 using Marlin firmware.

I am going to use Pronterface/Printrun host program to connect to my printer and issue terminal commands (G-codes). That sounded very hairy, but it is just a simple program with a graphical interface.

Even though I’m going to use Ramps 1.4 and Marlin firmware, this tutoral will most likely be usefull for most setups. We are going to use the newest Arduino IDE to edit the Marlin firmware.

Configuring endstops often boils down to being methodical in finding faults, which is why it is causing so many problems for many people, as many hope they can, and try to, just plug in the printer and hope it works. Which it rarely does.

If it doesn’t Work it can be tempting to do something rash in hope of a quick fix, which in turn tends to compound the issues and make it much worse.

Common symptons of faulty endstops are motors/axes which refuses to move, move in the wrong direction or move a tad this and then that way.

In short: setting up endstops correctly is not just recommended, but is mandatory before beginning to configure movement, including homing -settings for the Axes.

In this tutorial we are going to:

  1. Explorer physical endstop pin-layout on Ramps 1.4 board.
    1. Connect 2 and 3 pin endstops.
  2. Get endstop status and configure Marlin firmware @section homing using Pronterface and the newest Arduino IDE
  3. All done. Ready for motion configuration.

Step 1: Endstop Pin-layout on Ramps 1.4

Our first task is to identify the pins we are going to use on our Ramps 1.4 board.

Endstop pin-layout

When looking at the Ramps 1.4 board with the power-plugs facing left, the endstop-pins are located in the upper right corner as shown in the image.

From left to right we have X-min, X-max, Y-min, Y-max, Z-min, Z-max

The top most pins are Signal pins, the middle pins are ground and the lower pins are 5v/Vcc.

Connecting Endstops

If we use a simple limit-switch as our endstop, shown on an image here, which only uses 2 wires, we are going to connect them to the Signal and Ground pin. It does not matter in which order they are connected. Signal and Ground are the 2 top-most pins.

The limit-switch has 3 legs where 1 is for signal and the other 2 are labeled NC and NO, which means Normally Closed and Normally Open, respectively.

Choosing NC or NO

I prefer using NC which Means a current is running through it all the time. When depressing the arm on the switch the circuit is broken and it triggers a response. It also means a fault is registered if a wire breaks, a connector comes loose, or something similar.

If you use NO the Circuit is closed, a current runs through it, when the arm is depressed. This means that no alarm is triggered if a wire or connector comes.

Some years ago NO was the norm as it wasn’t as sensitve to noise and Thus did not make false positive (triggering the endstop) due to noise from motors.

The Electronics now, even on cheap Ramps 1.4 has imrpoved a lot and the noise should not be an issue any more, so I’ll recommend using the NC pin.

3-pin endstops

More advanced endstops which have LEDS or other Electronics Integrated use 3 wires. One for signal, ground and 5v/vcc.

When connecting these kinds of endstops it is vitally important that the wires are correctly connected. The Signal and Ground becomes important, as opposed to the 2-wire switches, as you risk shorting out the Electronics if you connect the signal to gnd and gnd to signal, while also using the 5v/vcc pin.

Testing wires

When you have soldered the two wires to your endstop, you should test for continuity on the wires using a Multimeter. If you do not have one, I’ll recommend you go buy one. A cheap one will do.

If you use more advanced endstops like IR sensors or similar, you should test it according to the manufacturers documentation.

Step 2: Endstop Status Using Pronterface and Setup Marlin in Arduino


Now we have successfully connected our endstop and it is time to setup our firmware.

Using Pronterface

Fire up Pronterface and connect to your printer.

You can see in the middle of the program, marked by a blue Square, I have added some custom bottoms for actions I use a lot like getting Endstop status, allowing Cold Extrusion and Vis Temperature on Extruder (Vis = show in Danish).

You do not have to create any button, but it is a nice tool. Just click the +, type in some text and the Gcode you want to use. The code for Get Endstop Status is M119

Commands can also just be written in the input boxt in lower right corner, see image, and exectud by pressing enter or send.

Using M119 command

First make sure no endstops are triggered. Move the Axes if neccessary. It makes it much easier to do this if all endstops has the same status. When all is ready you issue the M119 command.

After issueing the command you will most likely see some endstops with the status of OPEN and some with the status TRIGGERED

The ones with the OPEN status are most likely configured correctly, while the other endstops are either defective, activated by your axes or the firmware needs to be corrected.

Fault finding/verifying

Now that we have our status we check to see that all the endstop with OPEN status are working correctly. You do that by manually activating them one by one while issue in the M119 command. If the status does not change when activated it is most likely due to bad pin-wiring on Ramps, but it can also be the firmware.

If you have any endstops not behaving you turn off the printer, unplug the USB and Check the pin-connection.Correct as nesccesary.

Also check for continuity again, using a multimeter.

Make a list of the endstops which shows the staus as TRIGGERED when not triggered, or just keep pronterface open to see the output.

Configuring Marlin firmware in Arduino IDE

Open the Configuration.h file/sketch/tab and scroll Down to the @section homing – around line 330 or so.

Make sure you do not have 2 // in front of #define ENDSTOPPULLUPS. If you have, then remove them, upload the firmware to your printer and redo the tests we just did in Pronterface.

Note: remmeber you have to discconnect in Pronterface before uploading firmware or you will get an error in Arduino IDE

Now go Down a few line to “// Mechanical endstop with COM to ground and NC…” and change the value from false to true or the other way, see image, for the endstops outputting TRIGGERED when not triggered.

// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert... 
const bool Y_MIN_ENDSTOP_INVERTING = true; // set to true to invert...
const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert...
const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert...
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert..
const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert...

Upload the firmware and redo the test in Pronterface.

I changed my Z-min to true from false and it now displays correctly in Pronterface – see image.

Step 3: All Done. Ready for Motion Configuration

Congratulate yourself as you have just setup one of the most important features of your printer.

You actually don’t need to use endstops, but when you do, you really need to have them configured correctly before you can move on and setup the motion of your printer.