Tool Z Offset measuring script
.Shadow 0 last edited by .Shadow 0
Currently i am working on my bachelor thesis and on a tool Z offset measuring script based on a Voron 2.4 Z endstop. I wanted to know where the G30 S-2 is stored or if it is stored somewhere in the memory. If it is hidden in the memory is there a way to save it in the config or with M500 in the override?
My script looks like this:
T-1 ;deselect any tool M400 ;wait for current movement to finish M574 (Z0) S1 P"..." ;configure active high endstop switch for none on Z ;Z0 might be too much could be deletet T4 ;select tool 4 G1 Z50 F500 ;move bed to a height where no tool can interfere G1 X... Y... ;move TCP over the probe M558 P5 K2 C"..." H60 F120 ; Probe Z to an expected 60mm with a speed of 120 M400 G30 K2 H... S-2 ;Probe the tool Z offset at the current XY position and change it so Z is 0 (M500) G91 ;set relative positioning G1 Z20 ;move the bed 20mm down T-1 ;deselect tool
Would be wonderful to get a confirmation or a better way to do it
mikeabuilder last edited by mikeabuilder
@Shadow-0 - It's not really clear to me what you're script is doing, so I can't comment directly on that, but some observations:
Line 11 - The comment makes it sound like you expect the probe to occur on execution of this line. M558 configures the probe hardware - how it's connected and how the machine will behave when during a probe command. The H parameter is the Z height the machine will move to before starting to probe and H is how fast it will move when probing.
Line 15 - when you use S-2 you reset the machine's "native" Z coordinate to zero at the probe's trigger point (ie: when the probe is triggered). At this point, you've lost the previous Z coordinate.
I've written some macros to measure depth using a Touch probe to measure the repeatability of probe detection. In my case I used a G30 S-1. The S-1 stops movement when the probe is triggered and does not re-zero the Z axis. After this, I look at the Object model to get the Z location in the current Z coordinates. The key commands are:
G30 S-1 ; probe the bed here and stop when the probe triggers set var.Z_loc = move.axes.machinePosition ; collect the current position
In my case I put the value into a variable called var.Z_loc
I've uploaded the complete macro in case you are interested. The macro takes an X and Y position to be probed as inputs and also the number of times to probe that point. Between probes it randomly moves a short distance in X and Y then returns to the target probe XY for the next point. All of the probe data plus the move direction and distance are collected in a csv file. Z_probe_evaluation.g
@mikeabuilder Line 11 could be like u said, however in the documentation od duet3d the G30 S-2 command in Line 15 should "Probe the bed at the current XY position. When the probe is triggered, adjust the Z offset of the current tool to make the current position Z=0." (G30 on Duet Documentation)
Your way an doing it looks very good and i will look more into it and might test my code and yours. Until now i had´nt the time to test it properly
Thank you for your answer so far i will update this post after my tests.
mikeabuilder last edited by
@Shadow-0 - My bad for misreading the document page, even as I re-read it while writing my response to your post.
In this case, going back to your original question. In DWC, you can use the G10 P<tool number> to display the tool offset after you do a G30 S-2. To read this from the object model, you'll need to use tools[<tool number>].offsets[<axis number>] For my printer with only one tool and axes X,Y,Z the current z offset can be put into a new variable called "Z_offset" with this command
var Z_offset = tools.offsets
If you are new to using the object model, you can read about it here -https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation
Also use the M409 to look at the object model on your printer using DWC. A good command is M409 F"vd2", with shows you the whole object model to a "depth" of 2. Once you do this, read up on using the "K" parameter in your M409 command to look at only part of the object model instead of the whole darn thing. Example:
M409 K"tools" F"vd3"
shows only the object model details under "tools".
You can play with the "2" part of the F parameter to see different levels of detail. On my system if I request more than 2 levels without a K parameter, it takes so long to build the response my network request times out, so playing with the dept is definitely neededsometimes.
@mikeabuilder Thank you very much, the printer was in use and i still had´nt the chance to test my code or your code. But now i know where you got these functioncalls from and i understand how i can modify my code to get the z offset if he does´nt override the config value for it automatically.
I am btw completly new to it and now it opens a whole new world with much more abilities to get data from the printer.
Again thank you very much for your competent help
I will report my status in a few days or tomorrow if it´s possible.
My script works with a few little tweaks and the thought that you safe the z offset for your main tool modules in your config an if you change your tool through a script it performs the z probe of the tool and saves it internally. If i use a tool more frequently like Tool4 i can safe it in the override with M500. After a restart the main tool should be taken from the config and other tools must be changed trhough the script.
The working script looks like so:
T-1 ;deselect any tool G28 ;home all M400 ;wait for current movement to finish G1 Z65 F800 ;move bed to a save height (65 as high as the filament storage) where no tool can interfere T4 P0 ;select tool 4 without running macros (P0) G1 X295 Y72.9 F4000 ;move TCP over the probe M400 G30 K2 H-0.8 S-2 ;Probe the tool Z offset at the current XY position and change it so Z is 0 M500 T-1 P0 ;deselect tool G28 U V Z ;home U and V
The endstop switches where set as new z probes:
; Tool Probes M558 K1 P8 C"duex.e5stop" H80 F200 ; Set left z probe with an expected 80mm probing height a probing speed of 200 mm/min M558 K2 P8 C"duex.e6stop" H80 F200 ; Set right z probe with an expected 80mm probing height a probing speed of 200 mm/min
I might put an output of the probed offset in the console so people can copy it from there