Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: DAAD on April 16, 2020, 02:34:32 PM

Title: Return to current fixture after running gcode run
Post by: DAAD on April 16, 2020, 02:34:32 PM
I'm writing a script which involves using G59 fixture to locate my spindle and router setup to a specific point.
After the code has run i want it to return to the current fixture for example G54/G55.
Anyone who knows with api or variable i need to call and save to get this information?

I've looked trough the list, but don't seem to find the aswer to my question.

Is this even possible?

added som code to show what i want to do:

Code: [Select]
function zControl.ProbeMBZ()
mc.mcCntlSetLastError(inst, "Goto machine bed probe point")
mc.mcCntlGcodeExecute(inst, "G00 G90 G53 Z-20 A-20\n G59 X0 Y0\n G54 ") --Use G59 as workpiece zero for position Return to G54
wx.wxMessageBox("Load the correct tool & lower the bit within 50mm before probing. Attach the MAGNET!!!","If not abort",16)
mc.mcCntlSetLastError(inst, "Probing in progress!")
mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-50 F200")
--local ToolSet = -12.8 -- Toolset plate difference machine bed / plate
mc.mcAxisSetPos(inst, mc.Z_AXIS, ToolSet)
mc.mcCntlGcodeExecute(inst,"G00 G90 G53 Z-20")
end

Adam

Keep Safe!
Title: Re: Return to current fixture after running gcode run
Post by: Graham Waterworth on April 16, 2020, 05:32:20 PM
Fixture offsets # numbers

#2501 = G54 X or #5221
#2601 = G54 Y or #5222
#2701 = G54 Z or #5223

#2502 = G55 X or #5241
#2602 = G55 Y or #5242
#2702 = G55 Z or #5243
Title: Re: Return to current fixture after running gcode run
Post by: DAAD on April 16, 2020, 05:43:10 PM
Thanks!

What i want is that the script “chooses” the correct fixture i am in. For example i am in g56 and do a probe. It returns automatically to the fixture i was in. This way i would prevent screw ups if i dont goto the correct fixture offset.
Title: Re: Return to current fixture after running gcode run
Post by: Graham Waterworth on April 16, 2020, 05:50:16 PM
#4014 holds the current fixture offset
Title: Re: Return to current fixture after running gcode run
Post by: DAAD on April 16, 2020, 05:54:05 PM
Thank you sir!

Will try to script it tomorrow.
Title: Re: Return to current fixture after running gcode run
Post by: DAAD on April 17, 2020, 06:32:10 AM
worked out perfectly!

code below:

Code: [Select]
function ProbeMBZ()
mc.mcCntlSetLastError(inst, "Goto machine bed probe point")
local val = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_14) --PoundVar 4014 coordinates sytem
local msg = "G00 G90 G53 Z-20 A-20\n G59 X0 Y0\nG"..val--Use G59 as workpiece zero for position Return to current fixture
mc.mcCntlGcodeExecute(inst, msg) --Use G59 as workpiece zero for position Return to G54
wx.wxMessageBox("Load the correct tool & lower the bit within 50mm before probing. Attach the MAGNET!!!","If not abort",16)
mc.mcCntlSetLastError(inst, "Probing in progress!")
mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-50 F200")
--local ToolSet = -12.8 -- Toolset plate difference machine bed / plate
mc.mcAxisSetPos(inst, mc.Z_AXIS, ToolSet)
mc.mcCntlGcodeExecute(inst,"G00 G90 G53 Z-20")
end