Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Mesh bed leveling without M557

    Scheduled Pinned Locked Moved
    Gcode meta commands
    2
    5
    332
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pietundefined
      Piet
      last edited by

      Dear users,

      I noticed there is a possibility to create a mesh.g file and I'm wondering if i can use it to do the following. (I'm not totally sure how to use it so please enlighten me)

      I have some hysteresis in my Z-probe. This means that if I run the G29 command and automatically probe all the predefined points, the value starts to shift to a point that the mesh is unusable. Normally before probing I measure the analog value of the probe and set a new threshold by adding a value to that measured value. Is there a way I can set a new threshold to trigger before every probe move in the mesh.g. I already have this code set up for regular bed leveling but I'm assuming I can't use the G30 command to do mesh bed leveling. Is this correct?

      This is the code i already use:
      probe.g

      if !exists(param.X) || !exists(param.Y)														;if parameter X and Y are given
      	echo "Make sure parameter X and Y are given (C and S optional). Aborting probe move."	;notify user
      	
      G1 X{param.X} Y{param.Y} Z{sensors.probes[0].diveHeight} F6000								;move to given X and Y coordinates and predefined diveheight
      M400																						;wait for moves to finish
      
      M291 R"Waiting for extruder." P" " S1
      M116 P0 S2																					;wait for extruder to reach temperature
      
      M568 P0 A0																					;turn the extruder heater off (interference changes sensor reading)
      
      G4 S1																						;wait 1 second
      
      M98 P"preprobe.g"																			;call macro to determine triggervalue and see if it is okay to proceed probing
      M292
      
      M291 R"Probing." P" " S1
      
      if global.proceedProbe = true																;if its okay to proceed probing
      	if exists(param.C)																		;if parameter C is given
      		if exists(param.S)																	;if parameter S is given
      			G30 X{param.X} Y{param.Y} P{param.C} S{param.S} Z-9999							;probe move
      		else																				;otherwise
      			G30 X{param.X} Y{param.Y} P{param.C} Z-9999										;probe move
      	elif exists(param.S)																	;if parameter S is given
      		G30 X{param.X} Y{param.Y} S{param.S} Z-9999											;probe move
      	else																					;otherwise
      		G30 X{param.X} Y{param.Y} Z-9999													;probe move
      		
      elif (global.proceedProbe = false)															;if it isnt okay to proceed probing
      	echo "Aborting probe move"																;notify user
      
      M292
      
      M568 P0 A1																					;set the extruder heater to standby
      

      preprobe.g

      if !exists(global.proceedProbe)																										;if variable doesnt exist yet
      	global proceedProbe = false																										;initialize variable
      	
      if exists(global.triggerVal)																										;if a triggervalue has been defined
      	if sensors.probes[0].value[0] <= 922 && sensors.probes[0].value[0] >= 200														;if the sensorvalue is within acceptable range
      		var measuredVal = {sensors.probes[0].value[0]}																				;measure the sensor value
      		G31 P{var.measuredVal + global.triggerVal}																					;set the triggervalue to the measured value + the triggervalue
      		;echo "Measured sensor value is", {var.measuredVal}, ". Triggervalue has been set to", {sensors.probes[0].threshold}, "."	;notify user
      		set global.proceedProbe = true																								;set variable so probing can proceed
      	
      	else																															;otherwise
      		echo "Measured sensor voltage is out of range at ", {(var.measuredVal * 5)/1024}, "V."										;notify user
      		set global.proceedProbe = false																								;set variable so probing wont proceed
      		
      else																																;otherwise
      	echo "The variable triggerVal has not been declared in the config.g file (default = 100)"										;notify user
      	set global.proceedProbe = false																									;set variable so probing wont proceed
      	
      

      So instead of using the G30 command to probe i use M98 P"probe.g".

      T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
      • T3P3Tonyundefined
        T3P3Tony administrators @Piet
        last edited by T3P3Tony

        @piet if you cant change the way your probe works to not have the analogue hysteresis then you could manually create the mesh by carrying out the "G30" probes you want to, using G30 S-1:

        G30 S-1 ; Probe the bed at the current XY position. When the probe is triggered, do not adjust the Z coordinate, just report the machine height at which the probe was triggered.

        You would need to format the outputs in the same manner as heightmap.csv, potentially you could do this with a macro that stepper through the points you want and echoed it to a file using the ">>" construct.

        www.duet3d.com

        Pietundefined 1 Reply Last reply Reply Quote 1
        • Pietundefined
          Piet @T3P3Tony
          last edited by

          @t3p3tony Smart! I don't have a heightmap saved, do you by any chance have an example so i can see how it's formatted?

          T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
          • T3P3Tonyundefined
            T3P3Tony administrators @Piet
            last edited by

            @piet

            here is an example

            RepRapFirmware height map file v2 generated at 2021-04-28 22:58
            xmin,xmax,ymin,ymax,radius,xspacing,yspacing,xnum,ynum
            5.00,290.00,10.00,190.00,-1.00,15.00,15.00,20,13
              0.088,  0.103,  0.097,  0.082,  0.103,  0.097,  0.088,  0.060,  0.049,  0.049,  0.049,  0.082,  0.090,  0.103,  0.114,  0.123,  0.133,  0.140,  0.139,  0.135
              0.043,  0.058,  0.035,  0.037,  0.058,  0.059,  0.042,  0.021,  0.040,  0.037,  0.044,  0.051,  0.045,  0.076,  0.089,  0.100,  0.109,  0.116,  0.116,  0.110
              0.024,  0.040,  0.018,  0.019,  0.043,  0.037,  0.002,  0.001, -0.004, -0.002,  0.000,  0.026,  0.039,  0.052,  0.040,  0.075,  0.088,  0.089,  0.091,  0.087
              0.013,  0.017, -0.002,  0.027,  0.023,  0.013,  0.013, -0.017,  0.005,  0.002,  0.005,  0.014,  0.023,  0.034,  0.031,  0.057,  0.070,  0.074,  0.073,  0.067
              0.002,  0.008, -0.012,  0.017,  0.012, -0.017,  0.002,  0.001, -0.001, -0.007, -0.001,  0.003, -0.017,  0.024,  0.041,  0.047,  0.058,  0.061,  0.062,  0.055
             -0.003,  0.004,  0.005, -0.022,  0.002, -0.006, -0.010, -0.014, -0.013, -0.014, -0.012, -0.008,  0.002,  0.013,  0.030,  0.036,  0.046,  0.049,  0.048,  0.042
             -0.009, -0.003,  0.001, -0.003, -0.003, -0.013, -0.018, -0.022, -0.025, -0.024, -0.021, -0.018, -0.006,  0.003,  0.019,  0.027,  0.037,  0.039,  0.036,  0.030
             -0.006, -0.001, -0.004, -0.004, -0.008, -0.017, -0.021, -0.026, -0.030, -0.031, -0.028, -0.022, -0.013, -0.001,  0.012,  0.020,  0.029,  0.033,  0.030,  0.023
             -0.005, -0.006, -0.007, -0.004, -0.007, -0.018, -0.023, -0.027, -0.030, -0.033, -0.031, -0.025, -0.014, -0.004,  0.011,  0.020,  0.029,  0.031,  0.027,  0.022
              0.001,  0.003, -0.000,  0.000, -0.005, -0.014, -0.020, -0.026, -0.031, -0.033, -0.032, -0.024, -0.018, -0.005,  0.004,  0.020,  0.027,  0.030,  0.027,  0.022
              0.005,  0.007,  0.004,  0.004,  0.001, -0.007, -0.016, -0.021, -0.026, -0.026, -0.027, -0.021, -0.015, -0.002,  0.010,  0.020,  0.029,  0.033,  0.029,  0.026
              0.022,  0.026,  0.019,  0.018,  0.014,  0.008,  0.001, -0.006, -0.013, -0.014, -0.016, -0.008,  0.001,  0.013,  0.026,  0.033,  0.039,  0.041,  0.039,  0.035
              0.043,  0.044,  0.035,  0.035,  0.019,  0.020,  0.013,  0.007,  0.002, -0.015,  0.000,  0.003,  0.013,  0.022,  0.035,  0.042,  0.028,  0.052,  0.049,  0.046
            

            www.duet3d.com

            1 Reply Last reply Reply Quote 0
            • Pietundefined
              Piet
              last edited by

              For future reference, this works.
              The probe file can be adjusted to allow for different types of probing.

              if !exists(param.X) || !exists(param.Y)														;if parameter X and Y are given
              	echo "Make sure parameter X and Y are given (C and S optional). Aborting probe move."	;notify user
              	
              G1 X{param.X} Y{param.Y} Z{sensors.probes[0].diveHeight} F6000								;move to given X and Y coordinates and predefined diveheight
              M400																						;wait for moves to finish
              
              M98 P"waitForHeaters.g" H01
              
              M568 P0 A0																					;turn the extruder heater off (interference changes sensor reading)
              
              G4 S1																						;wait 1 second
              
              M98 P"preprobe.g"																			;call macro to determine triggervalue and see if it is okay to proceed probing
              
              ;M291 R"Probing." P" " S1
              
              if global.proceedProbe = true																;if its okay to proceed probing
              	if exists(param.C)																		;if parameter C is given
              		if exists(param.S)																	;if parameter S is given
              			G30 X{param.X} Y{param.Y} P{param.C} S{param.S} Z-9999							;probe move
              		else																				;otherwise
              			G30 X{param.X} Y{param.Y} P{param.C} Z-9999										;probe move
              	elif exists(param.S)																	;if parameter S is given
              		G30 X{param.X} Y{param.Y} S{param.S} Z-9999											;probe move
              	else																					;otherwise
              		G30 X{param.X} Y{param.Y} Z-9999													;probe move
              		
              elif (global.proceedProbe = false)															;if it isnt okay to proceed probing
              	echo "Aborting probe move"																;notify user
              
              ;M292
              
              M568 P0 A1																					;set the extruder heater to standby
              
              if global.bedLeveled == 0	
              	G32
              
              M98 P"probe.g" X525 Y250
              
              echo >"heightmap.csv" "Height map file generated at", state.time
              echo >>"heightmap.csv" "xmin,xmax,ymin,ymax,radius,xspacing,yspacing,xnum,ynum"
              echo >>"heightmap.csv" global.xMin,",",global.xMax,",",global.yMin,",",global.yMax, ", -1 ,",global.xSpacing,",",global.ySpacing,",",global.xNum,",",global.yNum
              var y = global.yMin
              var i = 0
              
              G90
              
              while var.i < global.yNum
              	var x = global.xMin
              	var j = 0
              	while var.j < global.xNum
              		M98 P"probe.g" X{var.x} Y{var.y} S-1
              		M400
              	
              		if var.j == 0
              			set global.meshLine = sensors.probes[0].lastStopHeight - sensors.probes[0].triggerHeight
              		else 
              			set global.meshLine = global.meshLine ^ "," ^ sensors.probes[0].lastStopHeight - sensors.probes[0].triggerHeight
              		
              		set var.x = var.x + global.xSpacing
              		set var.j = var.j + 1
              	
              	echo >>"heightmap.csv" global.meshLine
              	set var.y = var.y + global.ySpacing
              	set var.i = var.i + 1
              
              1 Reply Last reply Reply Quote 2
              • Phaedruxundefined Phaedrux moved this topic from My Duet controlled machine
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA