@stuartofmt said in unable to get BLTouch mesh compensation to work properly.:
This macro may be overkill, but may help. It will calculate the probe points for you. I use it for quick calibrations (small number of probe points) t0 get the bed more-or-less level then a more comprehensive calibration.
To use you would likely need to have
global zprobe_index = 0
at the start (I use a couple of different zprobes hence the variable); Creates a mesh calibration ; Assumes the bed limits (actual area reachable by the nozzle) ; have been set with M208 ; Assumes the probe offset has been set with G31 ; ;--- Prerequisites -------------- ; global.zprobe_index MUST be defined. The probe number to use. ; ; --- CHANGE THESE SETTINGS TO YOUR REQUIREMENTS --- ; ; Heat Bed and Nozzle ? var set_temp = false ; ; Set bed and nozzle temp -- Note that this is not too critical var bed_temp = 50.0 ; set at an reasonable temp (e.g. 50 should be good enough for PLA and PETG var nozzle_temp = 150.0 ; set high enough to allow for some expansion but not enough to ooze ; ; Set margin to limit area of bed to be probed should be >= 1.0 var X_margin = 1.0 var Y_margin = 1.0 ; ; Set the number of probe points in X and Y axis var P_X_points = 0 var P_Y_points = 0 ; ; ------------------------------------------ ; --- SHOULD NOT CHANGE BELOW THIS POINT --- ;------------------------------------------- ; ;Ensure a tool is selected ; if state.currentTool < 0 ; no tool selected var msg = "Cannot run if no tool is selected" M117 {var.msg} abort {var.msg} M291 R"How Many Probe points" P"Select a number" K{"9","16","64","100","Cancel"} S4 if input = 0 set var.P_X_points = 3 set var.P_Y_points = 3 elif input = 1 set var.P_X_points = 4 set var.P_Y_points = 4 elif input = 2 set var.P_X_points = 8 set var.P_Y_points = 8 elif input = 3 set var.P_X_points = 10 set var.P_Y_points = 10 else abort "Selection cancelled" M291 R"Hot or Cold Calibration" P"Turn on Heaters" K{"YES","NO","Cancel"} S4 if input = 0 set var.set_temp = true elif input = 1 set var.set_temp = false else abort "Selection cancelled" ; ;initialize local variables var X_grid_min = 0.0 var X_grid_max = 0.0 var Y_grid_min = 0.0 var Y_grid_max = 0.0 ; Get the limits for accessible parts of the bed i.e. where nozzle can reach var X_min = move.axes[0].min var X_max = move.axes[0].max var Y_min = move.axes[1].min var Y_max = move.axes[1].max ; Set the probe offset var X_offset = sensors.probes[{global.zprobe_index}].offsets[0] var Y_offset = sensors.probes[{global.zprobe_index}].offsets[1] ; ; ------------ MACRO STARTS HERE----------------- ; G90 ; use absolute coordinates M83 ; extruder relative mode ; if var.set_temp echo "Wait for Calibration Temperatures to be reached" M104 S{var.nozzle_temp} M140 S{var.bed_temp} ; set bed temp a compromise between PLA and PETG M116 ; wait for temperatures to be reached ;G1 E-4 F3600 ; retract filament quickly so no ooze M290 R0 S0 ;remove any babysteps M561 ; reset any bed compensation ; ; Calculate X max and min probe points if var.X_offset >= 0.0 ; right hand probe point is limited set var.X_grid_min = {var.X_min + var.X_margin + var.X_offset} set var.X_grid_max = {var.X_max - var.X_margin} else set var.X_grid_min = {var.X_min + min(var.X_margin, -var.X_offset)} set var.X_grid_max = {var.X_max - var.X_margin + var.X_offset} ; X offset is negative so we add echo "X offset " ^ var.X_offset ^ " (" ^ var.X_grid_min ^ ":" ^ var.X_grid_max ^ ")" ; ; Calculate Y max and min probe points if var.Y_offset >= 0.0 set var.Y_grid_min = {var.Y_min + var.Y_margin + var.Y_offset} set var.Y_grid_max = {var.Y_max - var.Y_margin} else set var.Y_grid_min = {var.Y_min + min(var.Y_margin, -var.Y_offset)} set var.Y_grid_max = {var.Y_max - var.Y_margin + var.Y_offset} ; Y offset is negative so we add echo "Y offset " ^ var.Y_offset ^ " (" ^ var.Y_grid_min ^ ":" ^ var.Y_grid_max ^ ")" ; ; Set the grid probe points M557 X{var.X_grid_min,var.X_grid_max} Y{var.Y_grid_min,var.Y_grid_max} P{var.P_X_points,var.P_Y_points} M557 ;report the settings ; echo "Performing Mesh Calibration" G28 ; must be homed first G30 K{global.zprobe_index} ; Perform a single probe to establish Z=0 (should already be at center because of home) G29 K{global.zprobe_index} S0 ; perform mesh calibration save and load G0 Z50 F3000 ; lower bed echo "Calibration Complete" if var.set_temp G1 E4 F300 ; put filament back ; Turn off heaters M568 S0 R0 A0 ; Reset temps and turn off hotend M140 S0 R0 ; Reset bed temps M140 S-273 ; Turn of bed heater ob
I created a simpler macro that does most of what you do here, Kind of a combination of yours and Rob's.
Mine handles homing, bed and nozzle heating, and compensation. As Rob mentioned, the G92 Z0 is not very useful for me since I have a Z end stop that I set to 0.05 mm at the center of the bed. That is my reference point. Then I get a G30 S-1 at that point to find the offset there, set my config.g G31 probe offsets. This is my starting point. Then I fire off the compensation macro.
This has proven itself to work reasonably well. Certainly better than trying to manually tram the bed to any great precision. Metal plates and biosilicate glass have proven to be not very flat.
Thank you everyone!
be well,
DLC