Marlin firmware, a widely used open-source software for 3D printers, includes a "Bed Leveling" feature designed to compensate for irregularities in the alignment between the printer's nozzle and the build plate. This feature works by taking measurements of the bed-nozzle distance at multiple points and adjusting the nozzle position throughout a print job to maintain a consistent distance from the bed. To achieve accurate and reliable measurements, the firmware must be configured to ensure that the probe can only operate within a physically reachable area, preventing the printer from attempting to move the nozzle or probe beyond its mechanical limits. The provided documentation outlines the key parameters that define these boundaries and the methods for determining them.
The configuration process begins with understanding the relationship between the printer's physical bed and its mechanical limits. In Marlin, the "bed size" is defined as the usable print area, which may not always match the physical dimensions of the bed. For example, a printer might have a physical bed measuring 235 mm in width, but due to the printer's construction, the nozzle may not be able to reach the very edges of the bed. In such cases, the configured bed size must be adjusted to reflect the actual area the nozzle can access. The documentation emphasizes that the minimum X and Y positions are often negative relative to the front-left corner of the bed, which is defined as the coordinate (0,0). This is a critical concept for setting the machine limits correctly.
To determine the precise machine limits, a procedure is outlined that requires an LCD display or a software connection (such as PronterFace, Repetier Host, or OctoPrint) to move the nozzle in a controlled manner. The process involves first building Marlin with X_MIN_POS and Y_MIN_POS set to 0, and X_BED_SIZE and Y_BED_SIZE set to their correct physical dimensions. After flashing the firmware, the user should home the X and Y axes using the command G28 X Y. The next step is to move the nozzle to the front-left corner of the bed using G0 X0 Y0. If the nozzle is positioned correctly over the bed's corner, the minimum positions are likely set correctly. However, if the nozzle is not at the edge or is outside the bed, it indicates that the printer cannot reach the entire bed. The recommended solution is to redefine the bed size to only include the area the nozzle can reach. For instance, if the nozzle is 8 mm in from the edge when at the X minimum position, X_MIN_POS should be set to 0, and X_BED_SIZE should be reduced by 8 mm.
Determining the maximum positions (X_MAX_POS and Y_MAX_POS) is a simpler process once the minimum positions are set. The procedure involves homing X and Y with G28 X Y, disabling software endstops with M211 S0, moving the nozzle near the center of the bed, and then carefully moving it to the right (for X) and to the back (for Y) until it reaches the physical limit. The coordinates at these limits are then recorded and configured in the firmware. It is important to note that if the nozzle cannot reach the right or back edges of the bed, the bed size may need to be reduced further.
Once the machine limits are defined, specific probe-related parameters must be configured to ensure the probe operates within the reachable area. These parameters include MESH_INSET, NOZZLE_TO_PROBE_OFFSET, and PROBING_MARGIN. The MESH_INSET parameter sets the distance from the bed edges that the mesh will cover, effectively creating a margin where probing will not occur. The NOZZLE_TO_PROBE_OFFSET defines the physical offset between the nozzle and the probe, which is crucial for accurate measurements. The PROBING_MARGIN is used to define a margin around the bed where probing is allowed, ensuring the probe does not attempt to measure points outside the reachable area.
The documentation also describes various probe types that can be used with Marlin, each requiring specific configuration. These include:
- FIX_MOUNTED_PROBE: For fixed switches or inductive probes.
- NOZZLE_AS_PROBE: When the nozzle itself is used as the probe.
- Z_ENDSTOP_SERVO_NR: For probes mounted on a servo-driven arm.
- SOLENOID_PROBE: For switches mounted on a solenoid.
- BLTOUCH: A compact probe specifically designed for 3D printers.
- Z_PROBE_SLED: A switch mounted on a sled that can be docked.
- Z_PROBE_ALLEN_KEY: A probe used on delta printers.
- PROBE_MANUALLY: An option for measuring bed-nozzle distance without a probe.
For each probe type, there are specific configuration options and pin assignments. For example, if a probe is connected to the Z-Min endstop pin, the Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN option must be enabled. If the probe is connected to any other pin, Z_MIN_PROBE_ENDSTOP should be enabled (for Marlin 2.0.5.2 and earlier). The probe-specific pin is defined with Z_MIN_PROBE_PIN, which can be overridden if necessary.
The documentation also highlights the importance of other probe-related settings. The Z_MIN_PROBE_ENDSTOP_INVERTING should be set to true if the probe uses normally-open (NO) switches, though normally-closed switches are recommended for their failsafe state and reduced susceptibility to false positives. The ENDSTOPPULLUP_ZMIN_PROBE can be used to disable the endstop pullup if an external pull-down resistor is present. Additionally, USE_ZMAX_PLUG and USE_ZMIN_PLUG must be enabled if the probe is connected to the Z-Max or Z-Min endstop pin, respectively.
For users employing PROBE_MANUALLY, the documentation describes a guided process where the nozzle moves to each point and pauses, allowing the user to adjust the Z height until the nozzle touches the bed. This process continues until all points are probed. The LCD_BED_LEVELING option provides a guided process to assist with manual probing, while without it, users must send G29 to move to the next point and G1 (or use buttons in host software) to adjust the Z axis.
In summary, setting the boundaries for probing in Marlin firmware involves a systematic approach to defining the machine's mechanical limits and configuring probe-specific parameters. This ensures that the bed-leveling process operates within the physically reachable area, leading to accurate measurements and improved print quality. The key steps include determining the minimum and maximum X and Y positions, adjusting the bed size accordingly, and configuring the probe type and associated settings. By following these procedures, users can optimize their 3D printer's performance and achieve consistent first-layer adhesion.