IR Probe Firmware Setup (Marlin 1.1.0-RC4+)

From Aus3D Wiki
Jump to: navigation, search
IR Probe

Configuration.h setup

We will be setting up the firmware for a probe connected to the ZMIN endstop pin. If you have the probe connected to a different pin you may need to make some changes, but the overall process should be much the same.

The pull-up for the pin the IR sensor is connected to should be enabled. You may enable pull-ups for all endstop pins with the line:


Or, if you only want to enable pull-ups for the IR sensor pin in particular, you can enable the specific pullup:

    // fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined

The probe registers logic-high when triggered, and logic-low when not triggered - i.e. it is non-inverting, behaving much like a regular normally-open switch. Make sure that the inverting setting is disabled for the pin you are using:

  #define Z_MIN_ENDSTOP_INVERTING false 

Now we need to configure the probe settings. First is the probe type. These probes have no moving parts and do not require a servo motor to activate, so they are considered a fixed probe - the easiest type to configure. Uncomment the line:


Next, the XY offset between the nozzle and the probe needs to be set. This is done with the lines:


The offset will vary from one hardware setup to the next, and you may have to measure it to get accurate numbers. When the probe is mounted to an E3D V6 / Lite6 HotEnd's fan duct, the probe is 30mm from the nozzle in one axis and 0mm in the other. Refer to the notes in Marlin's configuration file for more details on the probe offset.

If you know the Z offset at this point (for instance, if you've set up the probe on your printer before and have experimentally found the offset) then you can configure it here:


If you do not know the offset value, you should leave this offset at 0 for now.

If you are using the probe as your Z endstop, the probe will need to be on the Z_MIN endstop pin. To use this pin for both homing and probing, enable the line:


You may want to enable the repeatability test for later use:


You may adjust the deploy and travel height options if you'd like. The default options will work, though they can be made smaller (and hence the probing process faster). The exact numbers will depend on how even your bed is and how the probe is mounted, so if in doubt just use the default values.

Now that the probe is configured, we need to move on to the section on configuring the Bed Auto Leveling. Enable the line:


At the time of writing, 'grid' mode is preferable to '3-point' mode. Ensure that this mode is enabled:


Now we need to define the outermost points of the grid to be probed. If we are only probing 4 points (2x2) these will be the points probed. We want to maximise the area probed but need to consider that there is an offset between the nozzle and the probe. For instance, if your nozzle can travel 200mm in the X axis, and the probe is mounted to the left of the nozzle with an offset of 30mm, the farthest in the X axis we can probe is 170mm.

To keep things even, you could use the dimensions of your print area/bed, shrunken by the maximum offset in any axis. For instance, for a probe mounted in with a 30mm offset and 200mm bed, you might use the settings:


Allowing the 30mm offset + 5mm headroom (to avoid hitting the min end-stops or axis limits) in each axis. It's usually a good idea to maximise the area probed if possible. In the above example, if the probe is in front of the nozzle (offset in Y but not X) we could adjust the positions on the X axis like so:


Once the grid bounds are set, we can select the number of points to be probed. Often 2x2 is sufficient for most bed sizes and configurations. If your bed is particularly uneven, or otherwise tricky to level, you might consider increasing to 3x3 or even 4x4 grid points. More grid points will take a significantly longer time, and probing will be done before each print - so usually 2x2 or 3x3 are good settings to use.


If you are using the probe to home your Z axis (as we assume in this setup), you should enable Z safe homing. This ensures that the probe is always within the bounds of the bed when homing the Z axis - otherwise the probe might be outside the bed and fail to trigger. Enable this feature:

  #define Z_SAFE_HOMING

This is all of the configuration needed in the firmware to start using the probe. Depending on your machine, you may want to tweak the homing rates, grid bounds, or raise heights later.


Now that the probe is configured you will need to calibrate the Z offset. What we need to do is find the vertical distance between the point where the probe triggers, and the point where the nozzle is touching the bed at the height to print the first layer. This is our Z offset - it will likely be a negative number, as it measures how far there is in Z from the probe to the nozzle. Generally, values range from -0.5 to -3.0, but depending on your machine and probe things may be different.

Connect to your printer using a host program. The easiest way to measure this offset is to do the following:

First, let's home the printer - this moves each axis to its minimum position and sets the offset to zero. Then we'll run probe a single point.

 SEND: G28 // home each axis

Use the control panel in the software to move the probe (in the X and Y axes only) in to the approximate middle of the bed. If Z safe homing is enabled this may already be done for you. At this stage, there should be a small gap between the bed surface and the HotEnd nozzle. Now we will do a single probe at this point:

 SEND: G30 // z probe

After probing, the Z axis should stop at the probe's trigger point - where the LED on the probe switched on. We need to move the axis down until the nozzle is touching the bed.

Take a small piece of paper, and fold it over once. Folded, the two layers of paper should be approximately 0.1mm thick - which is a good thickness for the first layer of a print. Slide the folded paper underneath the nozzle - at this stage it should fit fairly easily. Assuming this is the case, and that the paper can easily slide under the nozzle, the next step is to lower the Z axis in small, countable steps - up to the point where the nozzle is touching the paper, and gripping it slightly, but where the paper should still be movable underneath the nozzle (i.e. the paper can be slid out and back under the nozzle without trouble, but there is friction from the nozzle on the paper).

Lower the Z axis 0.05mm by sending the command:

 SEND: G91
 SEND: G1 Z-0.0500 F200

Check the fit of the paper - if it seems there's still a gap between the paper and the nozzle, repeat the process. You do not need to change the value of -0.0500 each time - we are moving the axis down by this amount, not to this position. Keep track of the distance you've moved the Z axis.

If the nozzle is gripping the paper too tightly, you can raise the Z axis by using the same commands with a positive number:

 SEND: G91
 SEND: G1 Z0.0500 F200

You can also use the control panel in the printer software to move the axis using the graphical interface. If you can see that there is a significant distance between the nozzle and the bed, feel free to move in bigger increments. The important thing is to be sure to keep track of how far you've moved the axis.

Once you've got a good fit, make a note of the distance that you've moved the Z axis downwards. We need to set the Z offset stored in the firmware to this amount. If you moved the Z axis down 1.5mm:

 SEND: M851 Z-1.5
 RECV: echo:Z Offset ok

Now we will check if this offset is correct. Home all axes and do the bed probe (G30) again. After probing, the printer will consider itself to be at Z = 0 - Z_OFFSET, and not at 0. To move to 0, issue the command:

 SEND: G90
 SEND: G1 Z0 F200

The Z axis should move down by the Z offset we set above. Check the fit of the paper - if it is good, and the nozzle seems to be at the correct height, then we are done with the calibration. If not, you may need to tweak the offset further. If the nozzle is still too high, lower it until it feels correct:

 SEND: G91
 SEND: G1 Z-0.0500 F200

Once it is correct, we need to add the amount we moved by to the Z offset we previously set. If you've forgotten the offset, you can recall it with M851:

 SEND: M851 Z
 RECV: echo:Z Offset : -1.50  

If we have moved the nozzle down an additional 0.15mm, we would set the value as:

 SEND: M851 Z-1.65
 RECV: echo:Z Offset ok

Check again if the offset is correct (home, probe, move to zero) and if needed repeat this process. It may take a few iterations to get the offset dialed in correctly. It is also likely that once you start printing you will need to tweak the Z offset further, depending on your layer height, material, and other print settings - so don't get too hung up on the precision here. If the nozzle is gripping the paper but not jamming it in place that should be close enough.

Once you've found the correct offset, we need to tell the printer to save this offset to memory:

  SEND: M500
  RECV: echo:Settings Stored (380 bytes)  // number of bytes might vary depending on configuration

It's also a good idea to make a note of this value somewhere - if you ever update the printer's firmware, the saved value will be lost.

Printing / Use

To use the auto bed levelling, you'll need to run a probe before each print - after homing (as homing clears the levelling grid). The easiest way to do this is to add the command G29 (which probes the entire grid, not just the single point of G30) to your startup G-Code. This should be done in your slicing program. The startup G-Code could then look like:

  G28; home all axes
  G29; auto bed level

When you start a print, you should observe the printer home each axis, and then probe the bed according to the grid specified in the configuration file. After probing, the printer should move down by the Z offset amount and begin printing. If you observe that the first layer height is too high - or too low - adjust the Z offset (M851) accordingly.