Automatic Bed Leveling with Conditional Gcode Iterations
-
Removed the following and added it to homeall.g since I typically do a home all before changing the bed.
G1 Z{move.axes[2].userPosition+20} F1200 ; move z up 20mm for magnetic bed replacement
homeall.g
; homeall.g ; called to home all axes (G28) ; ; Warning: do not home individual axes by calling G28 X or G28 Y. It will cause errors. Instead run the macro file directly. IE M98 P"0:/sys/homex.g" ; M563 P9 S"HomeAll" ; create tool 9 to indicate homeall is in progress ; G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position M98 P"0:/sys/homey.g" ; home y M98 P"0:/sys/homex.g" ; home x G90 ; absolute positioning ; M98 P"0:/sys/homez.g" ; home z ; M563 P9 D-1 H-1 ; delete tool 9 to indicate homeall is done ; G1 Z{move.axes[2].userPosition+50} F1200 ; move z up 50mm for magnetic bed replacement
-
Thanks @mwolter!
For brevity, here is my final working version:
; bed.g ; Called to perform automatic bed compensation via G32 M561 ; Clear any bed transform G28 ; Home while iterations <=1 ; Do minimum of 2 passes G30 P0 X25 Y100 Z-99999 ; Probe near a leadscrew, half way along Y axis G30 P1 X235 Y100 Z-99999 S2 ; Probe near a leadscrew and calibrate 2 motors G90 while move.calibration.initial.deviation >= 0.002 ; perform additional tramming if previous deviation was over 0.002mm if iterations = 5 ; Perform 5 checks M300 S3000 P500 ; Sound alert, required deviation could not be achieved abort "!!! ABORTED !!! Failed to achieve < 0.002 deviation within 5 movements. Current deviation is " ^ move.calibration.initial.deviation ^ "mm." G30 P0 X25 Y100 Z-99999 ; Probe near a leadscrew, half way along Y axis G30 P1 X235 Y100 Z-99999 S2 ; Probe near a leadscrew and calibrate 2 motors G90 ; Back to absolute mode echo "Gantry deviation of " ^ move.calibration.initial.deviation ^ "mm obtained." G1 H2 Z8 F2600 ; Raise head 8mm to ensure it is above the Z probe trigger height G1 X104 Y100 F6000 ; Put head over the centre of the bed, or wherever you want to probe G30
-
@mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
@fcwilt Using that command I can be sure it raised 20mm from the previous height.
Hi,
Thanks for the reply.
Why do you think G91 G1 Z20 doesn't do that same thing?
Frederick
-
@fcwilt
It’s just a different way of doing it and like I mentioned, this way I can be sure it’s raised 20mm from its current position. The G30 command actually sets Z to about 3m. So G1 Z20 will only raise Z by 17mm. -
@Phaedrux said in Automatic Bed Leveling with Conditional Gcode Iterations:
Now you're cooking with gas!
Definitely cooking with gas now!
-
@mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
The G30 command actually sets Z to about 3m. So G1 Z20 will only raise Z by 17mm.I think you will find that a G91 G1 Z20 will raise Z by 20 unless it doesn't have that much room left on the axis.
If a G30 sets Z to 3 then a G91 G1 Z20 will take Z to 23.
At least that is my experience.
Good luck.
Frederick
-
This post is deleted! -
@fcwilt said in Automatic Bed Leveling with Conditional Gcode Iterations:
I think you will find that a G91 G1 Z20 will raise Z by 20 unless it doesn't have that much room left of the axis.
Correct. G90 moves to an absolute point, G91 is relative to the current position.
https://duet3d.dozuki.com/Wiki/Gcode#Section_G90_Set_to_Absolute_Positioning
-
@Phaedrux If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?
-
@mwolter That's a good question, and I'm not sure off the top of my head. Would have to test to see if it sticks in that format or not.
-
Another thing I noticed is repeatability with PindaV2 probe is not as consistent as BLTouchV3.1... So being that I use a bondtech bmg mosquito, I've made this modified version to scrap the Pinda and welcome the BLTouch. Will get it sorted on the printer and test it fully this weekend.
-
@Kolbi looks good! Is that SLS or MJF printed?
-
@mwolter It was done on an HP Multijet Fusion (MJF), using Nylon PA12.
-
@mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?
yes, g-code knows nothing about white space or line breaks
(optionally you can use push and pop, M120, M121)
-
@mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
@Phaedrux If the command G90 G1 Z20 is used in one line, does G91 have to be used to return to absolute mode?
G90 is absolute, G91 is relative.
Frederick
-
@fcwilt
That’s why I used that command. Pulled that command from another macro and couldn’t remember why it was created. It’s used to move some amount from the current position without needing to bounce back and forth from absolute to relative and back to absolute positioning. -
@mwolter said in Automatic Bed Leveling with Conditional Gcode Iterations:
@fcwilt
That’s why I used that command. Pulled that command from another macro and couldn’t remember why it was created. It’s used to move some amount from the current position without needing to bounce back and forth from absolute to relative and back to absolute positioning.But there is no reason not to make use of the two positioning modes, there is no downside to using them.
There is nothing to be gained by emulating relative mode using the object model as you are doing.
Frederick
-
@bearer said in Automatic Bed Leveling with Conditional Gcode Iterations:
optionally you can use push and pop, M120, M121
@bearer I read the gcode manual but these two functions still made little sense to me - best I can derive is a save state / restore state? Could you expand a little on these and give me some use examples?
Many thanks,
Kolbi -
-
@bearer Maybe because I just woke or hadn't gone on my run yet - but it is not completely crystal clear to me. Given the example below:
M120 ;push G91 ; relative positioning G0Z30 ; move Z 30mm M121 ;pop
I gather that 'M120; push' saves the current kinematic control state, then the user issues G91 & G0Z30 to relatively move the Z axis, and then returns to the previous control state by issuing an M121 - meaning that no M90 command was needed as M121 sorted that out?