29
« Last post by Cbyrdtopper on July 15, 2025, 04:26:47 PM »
You can do this with an on screen button if you'd like. You can use the Go To Work Zero button as an example and then the Go To Work Zero Function in the screen load script and copy and modify it how you would like.
But you can do this with a keyboard input if you want.
Set a keyboard button in the Keyboard Plugin. Name the input and select a Key, do not assign it a function, just click the function and close it so it says "none".
Close mach4 to initialize the change.
In the inputs tab in the Mach4 Configure, activate an input and set the input's device to Keyboard and then in the dropdown select the keyboard input you want to use.
In the screen load script (in the screen editor), use the GoToWorkZero function as an example. Copy the function and rename it whatever you like and paste it right below the gotoworkzero function.
Name it GoToToolSetter() if you want. Adjust the code to do what you want. If you have working home switches and you know what your position is going to always be, you can use G53 G00 X## Y## Z##. this will use the machine coordinates. Otherwise, just use G90 G00 X## Y## Z##.
I would suggest looking at the gotoworkzero code again, it uses a safe move to Z0 then moves XYA and the moves Z again.
At the top of the screen load script in the SigLib, there are examples of how to use and input to run a function. Copy one of those and set it to your input number you set up in the Mach4 configure and then set it to run your code.
---------------------------------------------------------------
-- Go To Tool Setter function.
---------------------------------------------------------------
function GoToToolSetter()
mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG53 G00 X2.00 Y0.50\nG53 G00 Z-1.0")--With Z moves & Machine Coords.
--mc.mcCntlMdiExecute(inst, "G90 G00 X2.00 Y0.50")--Without Z moves & Without Machine Coords.
end
[mc.ISIG_INPUT1] = function (state) -- this is an example for a condition in the signal table.
if (state == 1) then
GoToToolSetter()
end
end,