Check if a specific tool is selected and set it to standby
-
Hi,
I want to check if a specific tool is selected and if true, I want to unselect it.
To be precise, I want to check if T1 is active and if yes, put it in standby (if possible also with the same temperature that is currently set).
The reason is, that I have a tool changing mechanism that lowers and raises T1.
If T1 is active, it is lower (has an offset) from T0.
If T1 is active and I home the tool, It raises the tool and homes (coded in homeall.g).
But T1 stays active. That is a problem because it interferes with my t1free and t1pre macros.
When I start a print job, the tool gets deselected (from the slicer starting gcode. I cant delete that or the printer can damage itself).
Then tool 1 is deactivated, it lowers the printhead (by the t1free macro).
By that, T0 crashes into the bed, because the homing was done and now it lowers the head further.I know the gcode "T" (with no parameters) returns the current active tool.
Is there a way to check if T1 is active, then put it in standby and do the homing after that?
T : reports currently active tool
M568: Set Tool Settings
M105: Get Extruder TemperatureI thought of something like this:
if T == 1 ; if Tool 1 is selected
M568 P1 RM105 A1 ; set first tool standby temp to currently active temperature "M105"Of course I know that the bold parts in my code will be the problematic parts, but I hope you can help me out
-
@phil333 something like this?
if tools[1].state="active" then M568 P1 R{tools[1].active}
this code is untested!
-
Yes something like this
I will test and report back (in ~20min)
Ok here is the feedback @cosmowave :
It doesnt work (yet) and giving back this error:
Error: in file macro line 6 column 30: M568: expected numeric operandI'm pretty sure its the R{tools[0].active} which is not correct.
Any ideas?I also tested what the "then" does, because I thought the syntax is just "similar spaces or tabs"
For that I created a macro :
if tools[0].state="active" then echo "tool 0 (V6) ist active." if tools[1].state="active" then echo "tool 1 (Volcano) ist active."
This reports either
Tool 0 is selected
or
Tool 1 is selected
when the tool accordingly is selected.If I delete the "then" like this:
if tools[0].state="active" echo "tool 0 (V6) ist active." if tools[1].state="active" echo "tool 1 (Volcano) ist active."
it reports
tool 0 (V6) ist active.
or
tool 1 (Volcano) ist active. -
@phil333 of course... you don't need "then"! Sorry for that!
-
@cosmowave will it work when you use a variable?
var temp = {tools[1].active} ... ... ... if tools[1].state="active" then M568 P1 R{var.temp}
-
@cosmowave And one important question: which firmware are you running?
-
@cosmowave said in Check if a specific tool is selected and set it to standby:
@phil333 of course... you don't need "then"! Sorry for that!
No sorry at all! I'm really thankful that you're trying to help me out with you knowledge
On defining a variable like you said, the error remains the same:
Error: in file macro line 19 column 29: M568: expected numeric operand -
@phil333 which firmware are u using?
-
I am using as
Board: Duet 2 Ethernet (2Ethernet)
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0beta5+1 (2021-10-28) -
-
@phil333 said in Check if a specific tool is selected and set it to standby:
Error: in file macro line 19 column 29: M568: expected numeric operand
It would help if you tell us what is in line 19 of the macro file.
-
@dc42 i think first there was (with error in the last line):
if tools[1].state="active" then M568 P1 R{tools[1].active}
and then second try with variable (also error in the last line:
var temp = {tools[1].active} ... ... ... if tools[1].state="active" then M568 P1 R{var.temp}
-
@dc42 said in Check if a specific tool is selected and set it to standby:
@phil333 said in Check if a specific tool is selected and set it to standby:
Error: in file macro line 19 column 29: M568: expected numeric operand
It would help if you tell us what is in line 19 of the macro file.
Its the snippet that @cosmowave suggested:
then M568 P1 R{var.temp1}
The whole macro is:
;if tools[0].state="active" ; then M568 P0 R{tools[0].active} ; echo "tool 0 (V6) ist active." ;if tools[1].state="active" ; then M568 P1 R{tools[1].active} ; echo "tool 1 (Volcano) ist active." var temp0 = {tools[0].active} var temp1 = {tools[1].active} if tools[0].state="active" then M568 P0 R{var.temp0} echo "tool 0 (V6) ist active." if tools[1].state="active" then M568 P1 R{var.temp1} echo "tool 1 (Volcano) ist active."
-
@phil333 remove all instances of "then".
-
@dc42 sorry, forgotten to mention that. He has tried it without "then".
-
@cosmowave "then" is not valid conditional gcode so it needs to be removed from the file. Hopefully any actual error may become apparent when its not being masked by the "thens"
-
@dc42, @T3P3Tony and @cosmowave
If there is no "then" like this:
;if tools[0].state="active" ; then M568 P0 R{tools[0].active} ; echo "tool 0 (V6) ist active." ;if tools[1].state="active" ; then M568 P1 R{tools[1].active} ; echo "tool 1 (Volcano) ist active." var temp0 = {tools[0].active} var temp1 = {tools[1].active} if tools[0].state="active" M568 P0 R{var.temp0} echo "tool 0 (V6) ist active." if tools[1].state="active" M568 P1 R{var.temp1} echo "tool 1 (Volcano) ist active."
I still get this back:
M98 P"0:/macros/00_Toolselect_check"
Error: in file macro line 15 column 24: M568: expected numeric operand
tool 0 (V6) ist active.The error appears in this line:
M568 P0 R{var.temp0}
On:
Board: Duet 2 Ethernet (2Ethernet)
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0beta5+1 (2021-10-28) -
-
This post is deleted! -
@phil333
What do you get if you send
echo tools[0].active
in the console?
I think it will be true/false not numericalTry
var temp = heat.heaters[state.currentTool].active
However you need to make sure there is an active tool
So perhaps
var temp = 0 if state.currentTool > -1 set var.temp = heat.heaters[state.currentTool].active M568 P{state.currentTool} R{var.temp}
This was done on my phone so tabs won't be correct!