• G-Codes
  • Configuration
  • Develop
  • About us
  • Privacy Policy

Repetier-Firmware - Configuration - Bed Calibration

Introduction

For a perfect print the first layer is quite important. You will need a nearly constant distance between nozzle and bed. Only then you will get a good bonding to the bed and the print will stick during the whole print. There are some factors that add an error to the distance:

  • Bed has a slight rotation compared to x and y axis.
  • Bed is not even and has some bumps.
  • Bed changes shape when hot.
  • X axis is so heavy that it bends towards the center.
  • Distance has changed due to hotter temperatures.
  • An error in geometry causes a z change over xy plane. This is especially a problem of delta type printers where geometry errors cause this problem.

The simplest solution is also the best. Use some adjustment screws on the bed and lavel it to be square to xy movements. Together with a plane bed you will get perfect results once z min end stop is calibrated.

All other methods to correct the error depend on software and a z probe that can measure a distance between current position and bed. With this knowledge the firmware can adjust z during moves to keep the error within acceptable limits. If z moves correct an error the z axis moves more and might wear of the spindle more. On modern printers this should be no problem compared to old printers using a M8 rod as Z axis. None the less it requires a backlash free z move or there will be another error added. To reduce correction to minimum make sure the bed is as parallel as possible to xy movement of the extruder.

The complete leveling stuff is separated into 3 parts which might be implemented differently to adjust to different needs. Combining one of each of the parts allows a lot of possible combinations, so every printer should be able to find a working solution. The parts are:

  • Z probe type
  • Measurement method
  • Correction method

Z Probe Types

No Z-Probe

Set ZPROBE_TYPE Z_PROBE_TYPE_NONE to tell firmware that there is z probe at all. All automatic leveling functions will not work.

Standard Z-Probe

Most z probes fit this category. They have a digital switch that changes the signal level at some distance. The z axis will lower until it switches and then will retract to untrigger. Depending on configuration this will be repeated several times to use an average height. For the configuration you need the following part in Configuration.h:

#define Z_PROBE_TYPE Z_PROBE_TYPE_DEFAULT
#define Z_PROBE_HEIGHT 5             // Distance bed-nozzle when trigger switches
#define Z_PROBE_BED_DISTANCE 10      // Optimal starting distance
#define Z_PROBE_SPEED 5              // Speed fo z testing
#define Z_PROBE_X_OFFSET 12          // x offset relative to extruder 0,0 offset
#define Z_PROBE_Y_OFFSET 18          // y offset relative to extruder 0,0 offset
#define Z_PROBE_COATING 0            // Coating thickness if not detected by probe
#define Z_PROBE_DELAY 0              // Extra delay before starting again. Only needed on electronic probes keeping state for a while
#define Z_PROBE_REPETITIONS 1        // How often should we probe, 1 is minimum
#define Z_PROBE_USE_MEDIAN 1         // 0 = use average, 1 = use middle value after ordering z
#define Z_PROBE_SWITCHING_DISTANCE 1 // Minimum distance required to safely untrigger probe - used for faster repeated measurement
#define Z_PROBE_BORDER 2              // Safety border to ensure position is allowed
#define Z_PROBE_START_SCRIPT ""
#define Z_PROBE_FINISHED_SCRIPT ""
#define Z_PROBE_RUN_AFTER_EVERY_PROBE ""
// Define ZProbe by referencing a endstop defined
CONFIG_VARIABLE_EQ(EndstopDriver, *ZProbe, ZPROBE_ADDRESS)

Nozzle Z-Probe

Here a nozzle acts as trigger - either directly using a build in switch that detects some force or indirect with force feedback sensor on the bed. The special problem here is that any molten plastic on the nozzle will cause the trigger to happen too early. To prevent this, probing should only happen when the nozzle is hot so the blob is at least flexible and will spread on the bed so the metal of the nozzle will in the end cause the trigger signal.

#define Z_PROBE_TYPE Z_PROBE_TYPE_NOZZLE
#define Z_PROBE_HEIGHT 5             // Distance bed-nozzle when trigger switches
#define Z_PROBE_BED_DISTANCE 10      // Optimal starting distance
#define Z_PROBE_SPEED 5              // Speed fo z testing
#define Z_PROBE_DELAY 0              // Extra delay before starting again. Only needed on electronic probes keeping state for a while
#define Z_PROBE_TEMPERATURE 170      // Temperature for type 2
#define Z_PROBE_REPETITIONS 1        // How often should we probe, 1 is minimum
#define Z_PROBE_USE_MEDIAN 1         // 0 = use average, 1 = use middle value after ordering z
#define Z_PROBE_SWITCHING_DISTANCE 1 // Minimum distance required to safely untrigger probe - used for faster repeated measurement
#define Z_PROBE_BORDER 2              // Safety border to ensure position is allowed
#define Z_PROBE_START_SCRIPT ""
#define Z_PROBE_FINISHED_SCRIPT ""
#define Z_PROBE_RUN_AFTER_EVERY_PROBE ""
// Define ZProbe by referencing a endstop defined
CONFIG_VARIABLE_EQ(EndstopDriver, *ZProbe, ZPROBE_ADDRESS)

BLTouch Z-Probe

The BLTouch Z-Probe is a pin controlled by a servo signal. The signal can deploy the pin and pull it up. This sensor need special handling especially in error case and because the signal will only last 10ms if triggered. Plus that you need a servo to control it. This can easily cause many problems, so we designed a specialized z-probe type that tries to hide most problems from you. To make this work you need to create a servo in configuration_io.h with the name ZProbeServo and as assign ZPROBE_ADDRESS the address of the signal pin.

// Servo for z-probe
IO_OUTPUT(Servo1Pin, 4)
SERVO_ANALOG(ZProbeServo, 0, Servo1Pin, 500, 2500, 1473)
// Set to nullptr for no zprobe or &endstopName for a switch
#undef ZPROBE_ADDRESS
#define ZPROBE_ADDRESS &IOEndstopZMin

The z axis will lower until it switches and then will retract to untrigger. Depending on configuration this will be repeated several times to use an average height. For the configuration you need the following part in Configuration.h:

#define Z_PROBE_TYPE Z_PROBE_TYPE_BLTOUCH
#define Z_PROBE_HEIGHT 5             // Distance bed-nozzle when trigger switches
#define Z_PROBE_BED_DISTANCE 10      // Optimal starting distance
#define Z_PROBE_SPEED 5              // Speed fo z testing
#define Z_PROBE_X_OFFSET 12          // x offset relative to extruder 0,0 offset
#define Z_PROBE_Y_OFFSET 18          // y offset relative to extruder 0,0 offset
#define Z_PROBE_COATING 0            // Coating thickness if not detected by probe
#define Z_PROBE_DELAY 0              // Extra delay before starting again. Only needed on electronic probes keeping state for a while
#define Z_PROBE_REPETITIONS 1        // How often should we probe, 1 is minimum
#define Z_PROBE_USE_MEDIAN 1         // 0 = use average, 1 = use middle value after ordering z
#define Z_PROBE_SWITCHING_DISTANCE 1 // Minimum distance required to safely untrigger probe - used for faster repeated measurement
#define Z_PROBE_BORDER 2              // Safety border to ensure position is allowed
#define Z_PROBE_START_SCRIPT ""
#define Z_PROBE_FINISHED_SCRIPT ""
#define Z_PROBE_RUN_AFTER_EVERY_PROBE ""
// Define ZProbe by referencing a endstop defined
CONFIG_VARIABLE_EQ(EndstopDriver, *ZProbe, ZPROBE_ADDRESS)

Measurement methods

None

Offers the interface to compile but does nothing.

#define LEVELING_METHOD 0

3 Points

This is th emost simple and fastest leveling method. To measure a bed rotation you need exactly 3 points. For best result they need a big distance and they must not lay on one line.

#define LEVELING_METHOD 3
#define L_P1_X 60
#define L_P1_Y 130
#define L_P2_X 137
#define L_P2_Y 45
#define L_P3_X 137
#define L_P3_Y 210

Positions are in the coordinate system of the printer.

Grid Measurement

Firmware will put a grid on the reachable bed area with BED_LEVELING_GRID_SIZE x BED_LEVELING_GRID_SIZE points. If some points are not reachable, e.g. because you have a delta printer with round bed, the not reachable points will be skipped. For a rotation computation 3 valid points are necessary. Each extra point will be used to compute a regression plane that minimizes the distance to all points.

This type is the only method allowing to also fix bumps on the bed. The measured points will be used to follow the waves in the bed. More points increase resolution but also memory usage. Each point takes 4 byte of ram. So a 5x5 grid takes 5*5*4 = 100 byte. A 7x7 grid already uses 196 byte and 10x10 needs 400 byte. This is a problem especially for AVR boards having only 8kB RAM and 4kB EEPROM. Another point to consider is that the correction requires cpu intensive interpolations. Depending on CPU speed this may require to reduce level 2 block frequency.

#define LEVELING_METHOD 1
#define GRID_SIZE 5
#define ENABLE_BUMP_CORRECTION 1          // CPU intensive, so only activate if required
#define BUMP_CORRECTION_START_DEGRADE 0.5 // Until this height we correct 100%
#define BUMP_CORRECTION_END_HEIGHT 2      // From this height on we do no correction
#define BUMP_LIMIT_TO 2                   // Maximum allowed correction up/down

4 Point Symmetric

Use case is a bed that is supported somewhere in the middle and has 2 points that cause no flexing of bed and beside this measurement will flex the bed, but you can assume that it will flex the same left and right of the supported position. An example of this support type are Felix printers. This measurement will use the symmetric error to remove it computationally and from this build the rotation matrix.

Definition:

#define LEVELING_METHOD 2
#define L_P1_X 60
#define L_P1_Y 130
#define L_P2_X 137
#define L_P2_Y 45
#define L_P3_X 137
#define L_P3_Y 210

P1 and P2 are the 2 points on the supported axis. P3 one of the side points where bed will flex. 4th point will be computed by mirroring P3 on the P1-P2 axis. So make sure both are reachable!

Correction method

Software Leveling

The motion system contains a rotation matrix that allows it to change coordinates between ideal and real positions by rotating positions around the origin. This is the simplest solution to correct a rotated bed. As a result the z axis will move up and down while you move along x or y axis.

This solution has the big drawback, that only at one position the z distance will be as expected. If you have multiple nozzles that should be at the same z height this is not possible. Think of a dual x axis which is mirroring the moves of the left extruder to the right one. Distance will be perfect for left extruder and the right extruder will have a z error. Same with dual extruders at same height. Here both extruders must copy the same bed tilt to prevent the problem. No problem are dual extruders that move inactive extruders up. Here the z offset each extruder has can correct the difference.

#define LEVELING_CORRECTOR 0

Hardware Leveling 3 Points

The best solution is to have a physically squared bed. This can be done by manually adjusting the bed or adjust it automatically with some motors. Only if the bed is supported with exactly 3 points it is possible to adjust each axis individually without bending the bed.

For the correction you have to set the 3 points where the bed is anchored. Point 1 is assumed to be the fixed point that has no motor. P2 and P3 can change the height using a motor. The Motors should hold position when being disabled. There exist 2 different design that can do this. Most popular are beds having 3 Z motors, typically one in the back and 2 in front - left and right. For z moves all are used in sync. For correction 2 of the motor get moved individually during correction. The other design has one z motor to move the complete platform and the bed has 2 points with extra motors.

#define LEVELING_CORRECTOR 1
// Bed fixture coordinates for motor leveling
#define LC_P1_X 55
#define LC_P1_Y 130
#define LC_P2_X 137
#define LC_P2_Y 45
#define LC_P3_X 137
#define LC_P3_Y 210
#define LC_P2_MOTOR AL1Motor
#define LC_P3_MOTOR AL2Motor
#define LC_STEPS_PER_MM 3382
#define LC_Z_SPEED 0.2 // Correction speed
// Uncomment to limit correction per autoleveling iteration. Value is the max. correction in mm
// #define LIMIT_MOTORIZED_CORRECTION 0.5
// > 0 will move bed down and wait for removal (heater removed) and will pause another LC_WAIT_BED_REMOVE seconds
#define LC_WAIT_BED_REMOVE 0

LC_P1-P3 are the bed support coordinates. For P2 and P3 you need to tell the stepper drivers. If you have 2 extra steppers, do not forget to add them in the stepper list as well. If you have 3 mirrored motors for z do not use the mirror driver. Use the dependent 2 drivers at P2 and P3 instead. No need to put these into motor list.

For the case that the 2 extra motors are somehow blocked by a bed, e.g. bed magnets adding much friction so motors can stall, you can set LC_WAIT_BED_REMOVE > 0. In that case the bed must be hot pluggable. After probing the bed will move down 50% of z height and wait for bed removal. Once bed is removed it will wait LC_WAIT_BED_REMOVE seconds to be sure bed has really been removed and not only the contact removed. Only then firmware will move the motors, which are now friction less.