Automated measuring of Z offset
-
@Danal has done several things for automating XY+Z offsets of the nozzle. take a peek-see on the forum for some of his amazing work. Alot of it probably applies only to Duet3+pi directly, but you should be able to take some inspiration.
-
@Luke-sLaboratory
Thank you! I will take a look. -
I have a script that does something very similar to what you describe for multiple tools. It then prints a G10 command, ready to put in config.g, for each.
I believe it could be easily changed to be even closer to what you want. In fact, it may do exactly what you want, for a "single tool".
See ZTATP.py at https://github.com/DanalEstes/TAMV
Note: These are written in Python and designed to run on a Raspberry Pi. That Pi can be, but is NOT required to be the Pi in a Duet3+Pi configuration.
The only absolute requirement is that the printer be reachable over the network from the machine where ZTATP runs.
-
Not sure if this will be good enough for you, as it's not "automated" but I made 2 macro's which I run to get z-offset easily (run from dwc console):
z height macro 1:
M561 ; transform identity: cancels previous bed-plane (mesh)
G21 ; work in mm
G92 E0 ; reset extruder count
M220 S100 ; reset speed multiplierM104 S160 ; set hot-end to 120C & do not wait
M190 S50 ; set bed temp to 50C & wait
M109 S140 ; set hot-end to 140C & wait
G1 E-10 F2500 ; e -10mm (retract) @ 2500mm/min
M109 S200 ; set hot-end to 200C & waitG91 ; relative co-ords (from last position not origin)
G1 Z5 F500 H1 ; z 5mm @ 500mm/min (ensure it's below probe trigger height)
G1 X-500 Y-500 F3000 H1 ; x & y -500mm [relative] (> max) @3000mm/min - until limit sw. detects
G1 X-500 H1 ; x -500mm [relative] (> max) @ 3000mm/min - until limit sw. detects
G1 Y-500 H1 ; y -500mm [relative] (> max) @ 3000mm/min - until limit sw. detects
G1 X5 Y5 F500 ; x & y 5mm @ 500mm/min
G1 X-10 H1 ; x -10mm @ 500mm/min - until limit sw. detects
G1 Y-10 H1 ; y -10mm @ 500mm/min - until limit sw. detectsG90 ; absolute co-ords (relative to origin)
G1 X172.5 Y172.5 F15000 ; x & y 172.5mm [absolute] @ 15000mm/min
G1 X177.5 Y177.5 F1000 ; x & y 177.5mm [absolute] (bed-centre) @ 1000mm/min
G30 ; raise bed until probe triggered & set z to trigger height
G1 Z5 F1000 ; z 5mm [absolute] @ 1000mm/min (max speed)
M564 S0 ; disable axis limitsM118 S"jog bed until feeler gauge () just grips between nozzle & bed"
then, z height macro 2:
G92 Z0 ; set z=0 in firmware
G1 Z5 F500 H1 ; lower bed clear of probeG30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probe
G30 S-1 ; raise bed until probe triggers & report z height
G1 Z5 F1000 H1 ; lower bed clear of probeM140 S-273 ; absolute 0 (switch bed heater off) & do not wait
M109 S120 ; set hot-end to 120C & wait
G1 E10 F500 ; e 10mm (extrude) @ 500mm/min (cancel previous retract)
M104 S0 ; set hot-end to 0C & do not waitG91 ; relative co-ords (from last position, not origin)
G1 X-500 Y-500 F3000 H1 ; x & y -500mm [relative] (> max) @3000mm/min - until limit sw. detects
G1 X-500 H1 ; x -500mm [relative] (> max) @ 3000mm/min - until limit sw. detects
G1 Y-500 H1 ; y -500mm [relative] (> max) @ 3000mm/min - until limit sw. detects
G1 X5 Y5 F500 ; x & y 5mm @ 500mm/min
G1 X-10 H1 ; x -10mm @ 500mm/min - until limit sw. detects
G1 Y-10 H1 ; y -10mm @ 500mm/min - until limit sw. detects
G1 Z300 F1000 H1 ; z 300mm @ 1000mm/min
G1 Z100 F150 H3 ; z 100mm (> max) @ 150mm/min [until endstop] & set temporary z max (until power-cycled)
G90 ; absolute co-ords (relative to origin)M118 S"mesh compensation has been cancelled. re-run mesh compensation macro after updating config.g g31 z value with average of values calculated above (sum all, divide by 10)."
Adjust values per your printers speed values etc.
Edit: I use 0.05mm on a feeler gauge rather then the industry standard piece of paper.
hth,
e_p -
Thanks for your help! This looks really interesting. I need to try something like this in the next days.
Is there a chance to get something like this as a native GCODE command in a feature release of RRF3?
e.g.:
M9999 - Measure Z offset of tool
Parameters
- Tnnn Select tool
- Xnnn X Position to measure Z offset
- Ynnn Y Position to measure Z offset
- C"name" Digital input to detect (electric contact of nozzle with frame, push button etc.)
- Fnnn Feedrate to measure Z offset
- Onnn Extra offset in millimeter to adjust measurement (e.g. to compensate trigger distance of push button)
-
Help me understand the difference between what you are requesting, assuming wiring exactly like you specify, vs a macro that says:
M558 P5 C"nil" ; Free up the pin used for Z probe. ; This might need to be an M574 nil, ; depending on what is in config.g for a Z switch or probe. M558 K0 P5 C"pin" F200 ; Define the wire between the tool and the grounded bed as a probe. Tx ; Select tool G1 Xnnn Ynnn ; Position to measure. G30 S-1 ; Measure M558 P5 C"nil" ; Free up the pin used for Z probe. This might need to be an M574 nil. M558 or M574 ; Copied from config.g. To set things back to normal. T-1 ; Put away the tool.
Feedrate, C"pin", and extra offset for switch (should be minimal on a touch arrangement) are specified in the probe definition, the M558.
This appears to report exactly what you are seeking, and can be coded as a Macro (which effectively makes it available in the Web interface), right now today. No conditional g-code needed, and no waiting for a firmware feature. It works; this is part of how I align multi-tool printers.
-
To define the wire between the tool and the grounded bed temporary as a new Z probe, seems to be a nice little trick.
But, as far as i understand, this macro just reports the Z offset only (G30 S-1). So i need to modify the config.g by the measured Z offset?
-
@TopperHarley said in Automated measuring of Z offset:
To define the wire between the tool and the grounded bed temporary as a new Z probe, seems to be a nice little trick.
But, as far as i understand, this macro just reports the Z offset only (G30 S-1). So i need to modify the config.g by the measured Z offset?
What would you wish the new gcode to do?
-
In a perfect world, the measured Z offset will be saved for the selected tool. So there is no need to edit the config.g by hand. This would allow to change the nozzle of a tool followed by an automated measuring of the Z offset.
Your scripts are a big step forward and im allready really happy with this solution. But a new GCODE to fully automate this process would be perfect.
-
Sorry to just keep asking questions... but... update what?
A G10 command in config.g? Some other command? Update them in config.g, or config-override.g? Etc. Etc. The Duet core philosophy of "Gcode everywhere" implies we are going to create or update a G-Code configuration command. Specifically, which one?
Example of why I'm asking these questions: Today, nothing updates config.g (other than the human, via an editor). That would be a huge line to cross, a huge philosophic change. Therefore, it is important to be pedantically specific regarding what "...saved for the current tool..." means.
By the way, having said the above, I am considering having ZTATP (and TAMV) place a file in /sys with their results. Such as "ToolOffset.g" or similar. Then config.g could contain a 'M98 P"/sys/ToolOffset.g"', if a given person chose to link these things together for full automation.