Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: barneskite28 on April 04, 2021, 07:27:10 AM
-
Hi Guys,
I am having an issue with a fixed tool setter and the m6 macro.
I'm no expert at Lua - and thats being generous!
I have tried a few different scripts to allow a manual tool change followed by a tool height probe to a fixed tool setter. I tried DazTheGaz's script but my machine just froze and didnt move. I found the script for the m6 toolchange on the mach4 basics video (https://www.youtube.com/watch?v=6-4JkDv9AgM) and all seemed good but a bit clunky. The machine did its thing, then measured the tool all good. The problem comes it does not set the WCS zero correctly so is basically useless.... not sure what is going on or if im missing something in the tool change/offsets !!
Any advice is very welcome!!
TIA Tim
-
here is my macro code, i'm sure i just have 1 or 2 things missing but im struggling to wade through lua script, any help much appreciated!
-
This might help with Lua.
Use the last one from 6_22_2020
https://www.machsupport.com/forum/index.php?topic=43260.msg279695#msg279695
-
Hi, thanks for that looks like a useful document, good work! with my current macro, it will measure the tool ok but when it comes back to the workpeice it is generally way off.. The more complex script doesn't seem to function properly
-
You might need to do a G43 to turn on Tool Length Offset
-
You might need to do a G43 to turn on Tool Length Offset
Maybe right! Would i call g43 before the tool change or after? I have been using mach4 for a while now but just finished my new machine which is ATC capable - just need to get this worked out before i add the ATC script.
-
G43 is normally called before the first Z move
E.g. G00 G90 G43 Z10. H1
-
G43 is normally called before the first Z move
E.g. G00 G90 G43 Z10. H1
In the m6 script or in the program for the job? Sorry for all the questions!
-
It may need it to be in both, if you are using tool length compensation you have to have a G43 active and G49 to turn it off.
-
Are you trying to run a one tool wonder machine?
If so you likely don't need to use the TLO's :)
If you're running a M6 with multiple tools then shoot me your script and I'll take a look.
You need to make sure the TLO (G43) is called before the zeroing of your Z axis to the material.
This way if multiple tools are called we are then just compensating for the difference between the tools rather than the entire tool length after zeroing.
You can see this happen if you have no TLO called and then zero your Z to the material, when your first G43 is called you'll be in a world of trouble.
I don't typically have the TLO called inside the M6 as it's normally called by the post in GCODE.
There are a lot of different ways to tackle this issue it's really what works best for you.
I really like to put a button on screen called "Job Setup" or something similar then call the TLO's and everything else I like prior to cutting with the click of a button.
-
Are you trying to run a one tool wonder machine?
If so you likely don't need to use the TLO's :)
If you're running a M6 with multiple tools then shoot me your script and I'll take a look.
You need to make sure the TLO (G43) is called before the zeroing of your Z axis to the material.
This way if multiple tools are called we are then just compensating for the difference between the tools rather than the entire tool length after zeroing.
You can see this happen if you have no TLO called and then zero your Z to the material, when your first G43 is called you'll be in a world of trouble.
I don't typically have the TLO called inside the M6 as it's normally called by the post in GCODE.
There are a lot of different ways to tackle this issue it's really what works best for you.
I really like to put a button on screen called "Job Setup" or something similar then call the TLO's and everything else I like prior to cutting with the click of a button.
So to recap, many years ago i was a cnc machinist, life change of career etc i didn't touch a machine for 17 years or so.
I got a Chinese 6040 about 4 years ago and had some success as a one tool wonder machine on mach3 then after a rebuild mach4. Just manual tool changes if anything.
I have now built a bigger stronger machine from scratch, and got an ATC spindle and a fixed tool setter. I haven't set up the carousel yet, i don't think i dare before i get the tool setter measuring correctly.
At the moment i use the code below, but the z0 is not setting up properly.
It may be my method, something i'm missing etc... not sure. In my mind the tool setter should update the tool length of each tool in machine coordinates, and it will have its comparison. Then set wpc z0 with any tool and the rest should compensate accordingly even tool 1. Am i doing it all messed up? i even manually set tool 0 and touched off the spindle face but still not working right.
Here is the code..
function m6()
local inst = mc.mcGetInstance()
----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines. Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.
--AUTO LINES
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z-5\nG53 G0 X200.0 Y20.0")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
else
mc.mcCntlToolChangeManual(inst, true);
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. " Previous Tool == " .. tostring(currenttool))
mc.mcToolSetCurrent(inst, selectedtool)
--local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 X24.0 Y436.0")--
mc.mcCntlSetLastError(inst, "Probing in Progress!")
mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-95. F150.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
local NewOffset = probedz
mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end
end
if (mc.mcInEditor() == 1) then
m6()
end
-
Update..
using this script there are some bugs with the tool table... i will try and make a video and post it on here.
I just ran through the following in mdi
m6 t1
m6 t2
m6 t3
m6 t4
The machine cycled endlessly through the tool changes, measured the same tool repeatably, but if i stop the cycle, the tool table would mess up.
say for example i press cycle stop after probing t1, then t2 updates in the tool table to t1 length. One time it changed all 4 of the tool lengths!
So i tried mdi
m6 t1 g43 h1
m6 t2 g43 h2 etc.... got wildly different results..
I'm confused now!
Any help appreciated
-
Try it like this :-
function m6()
local inst = mc.mcGetInstance()
----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines. Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.
--AUTO LINES
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z-5\nG53 G0 X200.0 Y20.0")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
do return end
end
mc.mcCntlToolChangeManual(inst, true);
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. " Previous Tool == " .. tostring(currenttool))
mc.mcToolSetCurrent(inst, selectedtool)
--local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 X24.0 Y436.0")--
mc.mcCntlSetLastError(inst, "Probing in Progress!")
mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-95. F150.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
local NewOffset = probedz
mc.mcToolSetCurrent(inst, SelectedTool)
mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end
if (mc.mcInEditor() == 1) then
m6()
end
-
By the way you can NOT use G91 in G53 mode
-
By the way you can NOT use G91 in G53 mode
AHH maybe that could be the issue... I will test tomorrow.
I didn't even notice that was there.... It could be why my tool heights are moving
-
This was a video made yesterday to show some of the issues...
https://www.youtube.com/watch?v=l6MMqYhT8xc (https://www.youtube.com/watch?v=l6MMqYhT8xc)
-
you cannot zero the DRO for the axis while you have the machine co-ordinates selected these can only be set by the homing routine not the operator
uncheck machine co-ordinates and you can zero the DRO
stuart
-
you cannot zero the DRO for the axis while you have the machine co-ordinates selected these can only be set by the homing routine not the operator
uncheck machine co-ordinates and you can zero the DRO
stuart
Yes, as you can see in the video i did that :)
-
Here is the updated code running, i still cant get to re-zero. Mach4 seems really buggy for todays day and age!
https://www.youtube.com/watch?v=sswY4xx-OOU (https://www.youtube.com/watch?v=sswY4xx-OOU)
-
Any idea?
-
The tool offsets are loaded into the dialog when the dialog is opened. The dialog is not updated on the fly. That tool offset dialog is meant for modifying the offsets within the dialog, not outside of the dialog. Also, the offsets are not written (even if modified in the dialog) until you close the dialog with the X in the upper right hand corner or by pressing the "Quit" button. I would not consider this a bug because it is just not how it works. If you want something that is updated constantly, make a screen that displays the tool offsets from the G code variables. So close the tool offset dialog and reopen it after the tool change/probe and see if the value is updates. If the value does not update, then you need to further develop your M6 script.
Steve
-
The tool offsets are loaded into the dialog when the dialog is opened. The dialog is not updated on the fly. That tool offset dialog is meant for modifying the offsets within the dialog, not outside of the dialog. Also, the offsets are not written (even if modified in the dialog) until you close the dialog with the X in the upper right hand corner or by pressing the "Quit" button. I would not consider this a bug because it is just not how it works. If you want something that is updated constantly, make a screen that displays the tool offsets from the G code variables. So close the tool offset dialog and reopen it after the tool change/probe and see if the value is updates. If the value does not update, then you need to further develop your M6 script.
Steve
Thanks Steve, my problem is that i only have the tool table open to verify, and i can see the values updating as the tools are measured. But regardless the tools are not auto adjusting for the work piece zero on the top surface.. and this is my problem. I have updated the gcode with a g90 instead of g91 - and while the values in the tool table are very different with g90 it still does not take into account the correct zero from the workpeice. I have tried to zero the workpeice from the main screen, (by pressing zero axis) also from the offsets screen, using a slip guage, with g43 on, also with g43 off. I still can't get this working right... my toolsetter is working ok, as it is repeating the same measurements time after time in the table. Maybe im doing something wrong, but it just doesn't seem to work.. I'm not sure what is wrong but i need help with this! I am upgrading from a one tool wonder machine, so the tool table and offsets are a new dimension that i have never used in mach4. The video on the auto setter from mach4 basics seemed ok, and thats what i have based the macro code on, but on reflection the video also does not show the tools being at the same zero height after measuring...
-
By the way you can NOT use G91 in G53 mode
Noted, though it is strange that is the code supplied by mach support on the youtube video