Dockable Probe Configurator Macro
-
My current printer is a V-Core 3 500 powered by a Duet 6HC with 1LC running RRF 3.4.4 in SBC mode.
I'm running a klicky probe and wanted to write something that would help people in setting up the probes location as well as the command for docking and undocking.So what I did is created a macro which will run through some steps to determine the dock position as well as the "dock" and "load" position.
During these steps the macro will run some validations to make sure the set positions actually work when done multiple times.
When everything succeeds the
deployprobe.g
andretractprobe.g
files will be overwritten with values that correspond for loading and docking the probe.deployprobe.g
is written in such a way that you should be able to move to a position you'd want to probe, sendG30
. The current position will be remembered, probe will then be picked up and after picking up it'll move back to the original position to actually probe for ZThis script should work with any and all printers that support dockable probes
Please let me know if you come across hints for improvements and/or bugs!
; This file will help you set the location for the klicky probe. ; Warn the user about the retract & deploy files being overwritten M291 P"Continuing will overwrite deployprobe.g & retractprobe.g" R"Are you sure you want to continue?" S3 var deployFile = "/sys/deployprobe.g" var retractFile = "/sys/retractprobe.g" if exists(global.ratRepFirmwareVersion) ; Check if the user is running RatRepFirmware set var.deployFile = {global.probeKlickyDeploy} ; Set the file to klicky specific location to support switching between multiple probe types set var.retractFile = {global.probeKlickyRetract} ; Set the file to klicky specific location to support switching between multiple probe types if global.probe_type == 0 ; Probe type is set to something that doesn't need to be loaded abort "The probe is set to a type that doesn't support loading. Change the probe_type in 'sys/lib/globals/printer_specific_config.g" M564 H0 ; Allow movement without homing in order to move Z ; If the printer hasn't been homed, home it if !move.axes[0].homed || !move.axes[1].homed G28 XY G91 ; Set to relative mode G1 Z10 ; if axes homed move the bed out of the way G90 ; Set to absolute mode M561 ; Clear any bed transform M290 R0 S0 ; clear babystepping if sensors.probes[0].value[0] = 1000 M291 P"Make sure the klicky probe is mounted on the toolhead" S3 if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe doesn't seem to be attached, please attach before starting the configuration again" ; Display the popup to jog the tool to the spot where the klicky is in the dock M291 R"Move klicky to it's docking location" P"Press OK when the probe seated in the dock" S3 X1 Y1 var probeDockXLocation = move.axes[0].machinePosition ; Store the position of X when docked var probeDockYLocation = move.axes[1].machinePosition ; Store the position of Y when docked ; Display the popup to jog the tool in order to "mount" the probe M291 R"Move the tool to pull the probe from the dock" P"Press ok when the tool is in a position you like it to be" S3 X1 Y1 var probeAttachedXLocation = move.axes[0].machinePosition ; Store the position of X when attached var probeAttachedYLocation = move.axes[1].machinePosition ; Store the position of Y when attached ; Lets verify that we can move into the probe location before continuing while iterations < 3 G0 X{var.probeDockXLocation} Y{var.probeDockYLocation} M400 ; Wait for all moves to be completed if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe was detached, please start again" G0 X{var.probeAttachedXLocation} Y{var.probeAttachedYLocation} M400 ; Wait for all moves to be completed if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe was detached, please start again" ; Lets make sure we are in the docked position G0 X{var.probeDockXLocation} Y{var.probeDockYLocation} M400 ; Wait for all moves to be completed if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe was detached, please start again" ; Display the popup to jog the tool in order to "detach" the probe M291 R"Move the tool in order to detach the probe" P"Press ok when the probe is in a position where you would like it to be after detaching the probe" S3 X1 Y1 var probeDetachedXLocation = move.axes[0].machinePosition ; Store the position of X when attached var probeDetachedYLocation = move.axes[1].machinePosition ; Store the position of Y when attached ; Lets verify that we can attach and detach the probe while iterations < 3 G0 X{var.probeAttachedXLocation} Y{var.probeAttachedYLocation} ; Move to attach the probe G0 X{var.probeDockXLocation} Y{var.probeDockYLocation} ; Move into position to attach the probe G0 X{var.probeAttachedXLocation} Y{var.probeAttachedYLocation} ; Move to attach the probe G0 X{var.probeDockXLocation} Y{var.probeDockYLocation} ; Move into position to attach the probe M400 ; Wait for all moves to be completed if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe wasn't mounted, please start again" G0 X{var.probeDetachedXLocation} Y{var.probeDetachedYLocation} ; Move to detach the probe M400 ; Wait for all moves to be completed if sensors.probes[0].value[0] = 0 M564 H1 ; Don't allow movement without homing abort "The probe wasn't detached, please start again" echo > {var.deployFile} "; The deploy command for Z when using a dockable probe" ; Let's create the probe loading code file for dockable probes echo >> {var.deployFile} "if sensors.probes[0].value[0] != 0" echo >> {var.deployFile} " var originX = {move.axes[0].userPosition} ; Store the X position before grabbing the probe." echo >> {var.deployFile} " var originY = {move.axes[1].userPosition} ; Store the Y position before grabbing the probe." echo >> {var.deployFile} " G1 X" ^ {var.probeAttachedXLocation}, "Y" ^ {var.probeAttachedYLocation}, "F999999 ; Move tool in front of dock" echo >> {var.deployFile} " G1 X" ^ {var.probeDockXLocation}, "Y" ^ {var.probeDockYLocation}, "F999999 ; Move tool in position where probe is mounted" echo >> {var.deployFile} " G1 X" ^ {var.probeAttachedXLocation}, "Y" ^ {var.probeAttachedYLocation}, "F999999 ; Move tool in front of dock" echo >> {var.deployFile} " if var.originX > " ^ {var.probeAttachedXLocation}, "|| var.originY > " ^ {var.probeAttachedYLocation} echo >> {var.deployFile} " ; Move the toolhead back to the position we came from" echo >> {var.deployFile} " G1 X{var.originX} Y{var.originY} F999999" echo >> {var.deployFile} " M400" echo >> {var.deployFile} "if sensors.probes[0].value[0] != 0" echo >> {var.deployFile} " abort ""Error probe not attached - aborting""" echo > {var.retractFile} "; The retract command for Z when using a dockable probe" ; Let's create the docking code file for dockable probes echo >> {var.retractFile} "if sensors.probes[0].value[0] != 1000" echo >> {var.retractFile} " G90" echo >> {var.retractFile} " G1 X" ^ {var.probeAttachedXLocation}, "Y" ^ {var.probeAttachedYLocation}, "F999999 ; Move tool in front of dock" echo >> {var.retractFile} " M400" echo >> {var.retractFile} " G1 X" ^ {var.probeDockXLocation}, "Y" ^ {var.probeDockYLocation}, "F999999 ; Move tool in position where probe is mounted" echo >> {var.retractFile} " G1 X" ^ {var.probeDetachedXLocation}, "Y" ^ {var.probeDetachedYLocation}, "F999999 ; Move tool to detach probe" echo >> {var.retractFile} " G1 X" ^ {var.probeAttachedXLocation}, "Y" ^ {var.probeAttachedYLocation}, "F999999 ; Move tool in front of dock" echo >> {var.retractFile} " M400" echo >> {var.retractFile} "if sensors.probes[0].value[0] != 1000" echo >> {var.retractFile} " abort ""Error probe not docked - aborting""" echo "configured the location"
-
@mher why not just use deployprobe.g and retractprobe.g thats called automatically when G30 is called or when M401 and M402 are used?
-
@jay_s_uk
The main reason for this was/is the fact that there are macro's which will call retract/deploy probe in while loops. Which would cause the probe to be docked and loaded multiple times which would take a lot of time while it only needs to be loaded/docked once before and after the while loop.Lets say running bed tramming which will call g30 in 3 spots in a while loop. That will take unnecessary long when it's in the retract/deploy commands while now it's just adding the new command above and below the while loop and it's done and a lot quicker.
I have been printing myself for 2 weeks or so with this setup (before creating this script, which I really only created to help other people) without any issues and docking/loading works perfectly every time
-
@mher you should be able to call M401 manually before the first call of G30 and then it should remain undocked until you send a final M402
-
@jay_s_uk I'll do some testing tonight and potentially change the script to output the results into the retract/deploy macros. Only thing I'm slightly worried about is that it'd be overwriting any settings someone already has in there. Then again that might be a good thing
-
@jay_s_uk as promised I looked into it and I've updated the script accordingly in the start post
-
@mher Thanks for this great macro. I tried it, and most of it worked for me, but I don't see what type of probe it expects.
I configured the Klicky as z-probe switch connected to z-endstop.
I can pick it up, detach, attach etc, but after the final test is always says:M292 The probe wasnt detached, please start again
This is M558:
m558 Z Probe 0: type 5, input pin zstop, output pin nil, dive height 5.0mm, probe speeds 120,120mm/min, travel speed 6000mm/min, recovery time 0.00 sec, heaters normal, max taps 1, max diff 0.03
-
@izeman
It looks to me like the two M564 commands are indented too far.
Try aligning them with the "abort" commands -
@OwenD said in Dockable Probe Configurator Macro:
@izeman
It looks to me like the two M564 commands are indented too far.
Try aligning them with the "abort" commandsThere's several M564: Line #14,30,48,53,60,76,81. Which ones do you mean?
-
@izeman
All the ones in the if conditions which precede an abort commandif sensors.probes[0].value[0] = 1000 M291 P"Make sure the klicky probe is mounted on the toolhead" S3 if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe doesn't seem to be attached, please attach before starting the configuration again"
Should be
if sensors.probes[0].value[0] = 1000 M291 P"Make sure the klicky probe is mounted on the toolhead" S3 if sensors.probes[0].value[0] = 1000 M564 H1 ; Don't allow movement without homing abort "The probe doesn't seem to be attached, please attach before starting the configuration again"
-
@OwenD Thanks. It seems though that this was somehow auto-formated already. They all look like you said. Once you copy it here it changes the format?!
-
Reconfigured the probe now - seems it was wrong somehow.
Now I get:
M292 Error: in file macro line 270 column 7: meta command: expected string expression
-
@izeman
The first warning is a it says.
Review Klicky.g with a text editor set to show spaces and tabs.
You can see tabs before the M564 and spaces everywhere else
The second error is in a much bigger file.
Either your print file, or maybe daemon.g
Shouldn't be many files longer than 270 lines.
It'll be something like an echo or other command that doesn't have a quoted string after it. -
@OwenD I will check the file with another editor. Thanks!
But for the error in macro line 270: There is no daemon.g anywhere on the SD-card, and I'm not printing anything. I'm just calling the macro to generate deployprobe.g and retractprobe.g.
This must be some internal file that's called?!Got all the tabs removed now, and RRF doesn't complain anymore. Now everything runs fine, and in the end it throws this error:
M292 Error: in file macro line 490 column 7: meta command: expected string expression
Same error, different location ... If I knew where to search for it ...
-
@izeman
I'm guessing the version of RRF and/or DWC you're using is miscounting the line feeds or carriage returns that your editor is using.I think the actual error is caused because there were spaces in the file between "echo >" and the filename
echo > {var.deployFile} "; The deploy command for Z when using a dockable probe" ; Let's create the probe loading code file for dockable probes echo >> {var.deployFile} "if sensors.probes[0].value[0] != 0"
Should be
echo >{var.deployFile} "; The deploy command for Z when using a dockable probe" ; Let's create the probe loading code file for dockable probes echo >>{var.deployFile} "if sensors.probes[0].value[0] != 0"
See the documentation here
There must be no spaces between the > or >> symbol and <filename>. The default folder for the file is /sys.Try the attached file without editing it.
Rename it to whatever you wish
klicky_setup.g -
@OwenD Thanks for your tremendous effort, but the problem still exists.
-
I now just went to the code, and I guess I could see what it's meant to do, and basically it's not needed to be run as a macro. I can just determine the positions per hand, and then c&p the to be generated code (the last two blocks) into the .g files. I will try that.
-
Just in case someone else is looking for a deployprobe.g and retractprobe.g for a klicky probe, and got the same issues as I got. Just use the tool to determine the values, or do it manually, and c&p it into those two files:
; The deploy command for Z when using a dockable probe" ; Let's create the probe loading code file for dockable probes if sensors.probes[0].value[0] != 0 var originX = {move.axes[0].userPosition} ; Store the X position before grabbing the probe. var originY = {move.axes[1].userPosition} ; Store the Y position before grabbing the probe. G1 X238.6 Y55 F999999 ; Move tool in front of dock G1 X238.6 Y25 F999999 ; Move tool in position where probe is mounted G1 X238.6 Y55 F999999 ; Move tool in front of dock if var.originX > 238.6 || var.originY > 55 ; Move the toolhead back to the position we came from G1 X{var.originX} Y{var.originY} F999999 M400 if sensors.probes[0].value[0] != 0 abort ""Error probe not attached - aborting""
; The retract command for Z when using a dockable probe ; Let's create the docking code file for dockable probes if sensors.probes[0].value[0] != 1000 G90 G1 X238.6 Y55 F999999 ; Move tool in front of dock M400 G1 X238.6 Y25 F999999 ; Move tool in position where probe is mounted G1 X188.6 Y25 F999999 ; Move tool to detach probe G1 X238.6 Y55 F999999 ; Move tool in front of dock M400 if sensors.probes[0].value[0] != 1000 abort ""Error probe not docked - aborting""
-
@izeman
I'm afraid that error is my fault. (control character in string)
In my haste, I did a search and replace to change all the spaces to tabs to fix the first error you were having.
I did not notice that it also put tabs in the echo command (which must have only spaces)
I do not have a klicky probe, so cannot fully test this, but I have tested everything except checking the probe status and it should now work as the OP intended.
Amended file attached
klicky_setup.gBTW, you also appear to have some errors in config.g
You should runM98 P"config.g"
and investigate -
@OwenD WORKS GREAT now!! Thanks a lot!!!
-