Hello Guest it is March 29, 2024, 11:41:22 AM

Author Topic: Mach4 Lathe Tool Probing (Help)  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Lathe Tool Probing (Help)
« on: March 21, 2021, 07:14:33 AM »
Hi, i am new and excuse my inperfect english (german guy)...

I have searched for some days and I can't find anything that suits my problem. I converted a chinese mini lathe to CNC and now I want to measure the tools
automatically. I printed a fixture for a TLS, so i can touch Z and X.

My thoughs are, that i put some kind of Master tool in and set the position Z0 by touch off. Then I change the Tool and hit a button or have some M-Code to touch off automatically and after probing the difference in lengh compared to the Master is calculated and set to the tool table.

For X I would turn a diameter to calibrate the TLS-Position to a specific diameter. So any tool can be touched off and the offset is calculated to the tool table. The calibration will be needet once and the position can be part of the lua code.

I hope someone can understand this and will help, my abilities in software programming are very low. To adjust a M6 macro to my milling mashine took me several weekends 2 years ago... ::)


Re: Mach4 Lathe Tool Probing (Help)
« Reply #1 on: March 21, 2021, 12:53:29 PM »
Have a look at this video from Newfangled Solutions: https://www.youtube.com/watch?v=SDuZWZHVU0s
You will probably have to watch it several times since the presenter is clicking things before he tells you what he is doing.
If you have set up a pin gauge with an insulating sleeve you could attach a probe wire to the pin and one to your tool and use a probe command for touch and then use the set tool offset buttons.  Read the lathe manual on tool setting and get familiar with the tool table and all of the input methods since it is different than working on a mill.

HTH
RT

RT
Re: Mach4 Lathe Tool Probing (Help)
« Reply #2 on: March 21, 2021, 02:01:31 PM »
Thx, but this is not the answer to my question.  ???
I am an professional CNC mashinist (if this is so called) and tool setting by scraping is not what I want, even this is just a hobby.
My thaugts are if you can probe a tool on a mill on Mach4 so you should be able to do this on a lathe too, like industry standart. The tool is positioned in front of the sensor, hit the button, the mashine drives in to the sensor and the tool table is written.

The difference between probing on a mill and a lathe in Mach4 is, that you have to write the tool table for lathe tools. The M6 macros I can find for milling or router mashines shift the offset by comparing the distance between old and new tool as part of the tool change cycle so the tool table isn't in use.
If I could adapt the m6 macro code to write the tool table I would do that, but I'm not able...

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Mach4 Lathe Tool Probing (Help)
« Reply #3 on: March 21, 2021, 09:39:44 PM »
On a lathe it is normal to use a fixed point for reference, in most cases this is the face of the chuck and the spindle centre line of a drilling tool holder are stored in the G54 fixture offset relative to home.

Then 2 values are calculated relating to the z distance to the tool setter z trigger point and the x diameter of the setters x trigger face.  Depending on the type of tool setter you may need 4 saved values to allow for internal and external tools and front and rear edges of tips e.g. grooving and parting tools.

In Mach4 you then use the work shift to set the length to the work face, distance from chuck face to end of finished part.  Not the end of the material as you need some material to face to length.

When you touch a tool on the setter the macro used the known values to work out the offset.

« Last Edit: March 21, 2021, 10:54:11 PM by Graham Waterworth »
Without engineers the world stops
Re: Mach4 Lathe Tool Probing (Help)
« Reply #4 on: March 22, 2021, 01:04:28 AM »
I know that. On a "real" Maschine you have to calibrate the tool sensor at first. So you turn a diameter and set the offset of the tool manual, then you  can calibrate the sensor with this tool. This is do for the outer and inner diameter and for backwards cutting tools. The position for normal cutting tools in Z is not relevant, so you calibrate the sensor in relation to this direction for backwards cutting tools. This sensors are also not in the turning center.

There for I have made the fixture for my sensor, so I can touch off in 3 directions without moving it. It will be relativ center on point of rotation, but is not really needed like abovementioned.
When I set zero to the face of the sensor with a mastertool so I have the referenz for the other tools in length. (Tool setting by scratching is the same in this point)
Where the sensor really stays is not relevant by this method, as long the position in x is the same, and this will be given by the fixture.
Re: Mach4 Lathe Tool Probing (Help)
« Reply #5 on: March 24, 2021, 02:50:37 AM »
Hi,
very interesting discussion!
also i use lathe with mach4.
I wondered if it was possible to do this!
Re: Mach4 Lathe Tool Probing (Help)
« Reply #6 on: March 24, 2021, 12:49:15 PM »
Hi,
very interesting discussion!
also i use lathe with mach4.
I wondered if it was possible to do this!

Possible for sure, but i have no idea how... i only have a scheme in mind. 

After pressing the button (you will need one for each direction):

-Get actual tool number
-Get Z0 of the fixture offset
-drive incremental some distance in to the sensor
-if no touch off after the distance it should promt a massage with an error
-if it touches off
then
-hitting Z: calculation the position in relation to the fixture offset Z0
-write the difference into the tool table in Z
or
-hitting in X direction it just writes the calibrated position in X
then
-back of a couple millimeters

Touching from behind is in my opinion not necessary. Turning in +Z direction is so rare on a simple lathe, the tool can be scratched at the workpiece to measure it.


I think, with parts from the code some one can do a useful touch off sequence. The TLS has to replace the buttons on the screnn, simply spoken.  This are the codes of the "set offset buttons" from the lathe screen:

Code: [Select]
--SetToolXOffset
local m_inst, m_currentOffset, m_dia, m_diaMode, m_currentTool, m_side, m_machinePos, m_dir, offset

m_inst = mc.mcGetInstance()
m_currentOffset = mc.mcCntlGetPoundVar(m_inst, mc.SV_CUR_LENGTH_INDEX)

if (m_currentOffset > 0) and (m_currentOffset < 100) then --A valid tool number is active
    m_dia = scr.GetProperty('droSetX', 'Value')
m_diaMode = mc.mcCntlGetDiaMode(m_inst)
m_currentTool = mc.mcCntlGetPoundVar(m_inst, mc.SV_CUR_TOOL_NUMBER)
m_side = mc.mcToolGetData(m_inst, mc.MTOOL_LATHE_TOOLSLIDE, m_currentOffset)
m_machinePos = mc.mcAxisGetMachinePos(m_inst, mc.X_AXIS)
m_dir = 1

if (tonumber(m_side) <= 0) then--If this is negitive we need to flip the tool
m_dir = -1
end

if (m_diaMode) then
m_dia = m_dia/2
end
offset = m_machinePos - (m_dia  * m_dir)

mc.mcCntlSetPoundVar(m_inst, 10000, 0.0000) --Zero X wear offset
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_X, m_currentOffset, offset) --Set the Offset
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_X_W, m_currentOffset, 0) --Clear the wear offset
else
    wx.wxMessageBox("!!! A valid tool offset must be active to set it !!!\n\nPlease activate a valid tool offset and try again.")
end

Code: [Select]
--SetToolZOffset
local m_inst, FixOffset, Pval, FixNum, whole, frac, PoundVarX, PoundVarY, PoundVarZ, CurrentFixture, m_dist, m_currentTool, m_currentOffset, m_ZMachine, CurFixZ, offset

m_inst = mc.mcGetInstance();

FixOffset = mc.mcCntlGetPoundVar(m_inst, mc.SV_MOD_GROUP_14)
Pval = mc.mcCntlGetPoundVar(m_inst, mc.SV_BUFP)

if (FixOffset ~= 54.1) then --G54 through G59
    whole, frac = math.modf (FixOffset)
    FixNum = (whole - 53)
    PoundVarX = ((mc.SV_FIXTURES_START - mc.SV_FIXTURES_INC) + (FixNum * mc.SV_FIXTURES_INC))
    CurrentFixture = string.format('G' .. tostring(FixOffset))
else --G54.1 P1 through G54.1 P100
    FixNum = (Pval + 6)
    CurrentFixture = string.format('G54.1 P' .. tostring(Pval))
    if (Pval > 0) and (Pval < 51) then -- G54.1 P1 through G54.1 P50
        PoundVarX = ((mc.SV_FIXTURE_EXPAND - mc.SV_FIXTURES_INC) + (Pval * mc.SV_FIXTURES_INC))
    elseif (Pval > 50) and (Pval < 101) then -- G54.1 P51 through G54.1 P100
        PoundVarX = ((mc.SV_FIXTURE_EXPAND2 - mc.SV_FIXTURES_INC) + (Pval * mc.SV_FIXTURES_INC))
    end
end
PoundVarY = (PoundVarX + 1)
PoundVarZ = (PoundVarX + 2)

m_dist = scr.GetProperty('droSetZ', 'Value')
m_dist = tonumber (m_dist)-- * -1)
m_currentTool = mc.mcCntlGetPoundVar(m_inst, mc.SV_CUR_TOOL_NUMBER);
m_currentOffset = mc.mcCntlGetPoundVar(m_inst, mc.SV_CUR_LENGTH_INDEX);
m_ZMachine = mc.mcAxisGetMachinePos(m_inst, mc.Z_AXIS)
CurFixZ = mc.mcCntlGetPoundVar(inst, PoundVarZ)
--offset = ((CurFixZ * -1) + (m_dist * -1))
offset = ((m_ZMachine * -1) - (CurFixZ * -1) - (m_dist * -1))
offset = (offset * -1)

if (m_currentTool == 1) then --We are attempting to set tool 1's offset, pop up the message box

UI = {}


-- create MyDialog1
UI.MyDialog1 = wx.wxDialog (wx.NULL, wx.wxID_ANY, "Message", wx.wxDefaultPosition, wx.wxSize( 542,342 ), wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog1:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )
UI.MyDialog1 :SetForegroundColour( wx.wxSystemSettings.GetColour( wx.wxSYS_COLOUR_WINDOW ) )
UI.MyDialog1 :SetBackgroundColour( wx.wxColour( 255, 255, 255 ) )

UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )

UI.bSizer2 = wx.wxBoxSizer( wx.wxHORIZONTAL )

UI.gSizer1 = wx.wxGridSizer( 3, 1, 0, 0 )

UI.m_staticText2 = wx.wxStaticText( UI.MyDialog1, wx.wxID_ANY, "!!! Warning !!!\nSetting the tool offset for tool 1 has the potential to corrupt your entire tool table.\n\n", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxALIGN_CENTRE )
--UI.m_staticText2:Wrap( -1 )
UI.m_staticText2:Wrap( 300 )
UI.m_staticText2:SetFont( wx.wxFont( 12, 70, 90, 92, False, "" ) )
UI.m_staticText2:SetForegroundColour( wx.wxColour( 255, 0, 0 ) )

UI.gSizer1:Add( UI.m_staticText2, 0, wx.wxALIGN_CENTER + wx.wxALL, 5 )

UI.m_staticText1 = wx.wxStaticText( UI.MyDialog1, wx.wxID_ANY, "You are attempting to set the Z offset for tool #1 (Master Tool). The Z offset for tool #1 (Master Tool) should be 0 and should be set with 0 Z fixture offset. Proceed with caution!\n\nIf you are unsure what you should do play it safe and press the cancel button.\n\nIf you want to clear the offset for tool #1 press the clear button.\n\nIf you want to set tool #1's offset to the value you have in your Set Z Offset DRO press the Continue button.", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxALIGN_CENTRE )
UI.m_staticText1:Wrap( 500 )
UI.m_staticText1:SetForegroundColour( wx.wxColour( 0, 0, 0 ) )
UI.m_staticText1:SetBackgroundColour( wx.wxColour( 255, 255, 255 ) )

UI.gSizer1:Add( UI.m_staticText1, 0, wx.wxALIGN_CENTER + wx.wxALL, 5 )

UI.gSizer2 = wx.wxGridSizer( 0, 3, 0, 0 )

UI.m_buttonCancel = wx.wxButton( UI.MyDialog1, wx.wxID_ANY, "Cancel", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.gSizer2:Add( UI.m_buttonCancel, 0, wx.wxALIGN_CENTER + wx.wxALL, 5 )

UI.m_buttonClearOffset = wx.wxButton( UI.MyDialog1, wx.wxID_ANY, "Clear Offset", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.gSizer2:Add( UI.m_buttonClearOffset, 0, wx.wxALIGN_CENTER + wx.wxALL, 5 )

UI.m_buttonContinue = wx.wxButton( UI.MyDialog1, wx.wxID_ANY, "Continue", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.gSizer2:Add( UI.m_buttonContinue, 0, wx.wxALIGN_CENTER + wx.wxALL, 5 )


UI.gSizer1:Add( UI.gSizer2, 1, wx.wxEXPAND, 5 )


UI.bSizer2:Add( UI.gSizer1, 1, wx.wxEXPAND, 5 )


UI.bSizer1:Add( UI.bSizer2, 1, wx.wxEXPAND, 5 )


UI.MyDialog1:SetSizer( UI.bSizer1 )
UI.MyDialog1:Layout()

UI.MyDialog1:Centre( wx.wxBOTH )

-- Connect Events

UI.MyDialog1:Connect( wx.wxEVT_CLOSE_WINDOW, function(event)
--implements MyDialog1OnClose
UI.MyDialog1:Destroy()

event:Skip()
end )

UI.MyDialog1:Connect( wx.wxEVT_INIT_DIALOG, function(event)
--implements MyDialog1OnInitDialog

event:Skip()
end )

UI.m_buttonCancel:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_buttonCancelOnButtonClick
UI.MyDialog1:Close(true)
UI.MyDialog1:Destroy()

event:Skip()
end )

UI.m_buttonClearOffset:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_buttonClearOffsetOnButtonClick
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z_W, m_currentOffset, 0);--Clear the wear offset
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z, m_currentOffset, 0.0000);--Set the Offset
UI.MyDialog1:Close(true)
UI.MyDialog1:Destroy()

event:Skip()
end )

UI.m_buttonContinue:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_buttonContinueOnButtonClick
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z_W, m_currentOffset, 0);--Clear the wear offset
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z, m_currentOffset, offset);--Set the Offset
UI.MyDialog1:Close(true)
UI.MyDialog1:Destroy()

event:Skip()
end )


UI.MyDialog1:Show(true)
--wx.wxGetApp():MainLoop()

else
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z_W, m_currentOffset, 0);--Clear the wear offset
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_Z, m_currentOffset, offset);--Set the Offset
end
« Last Edit: March 24, 2021, 12:58:50 PM by robertd »
Re: Mach4 Lathe Tool Probing (Help)
« Reply #7 on: February 10, 2022, 06:08:48 PM »
Hi

have you solved it?
BR
Gerhard
Re: Mach4 Lathe Tool Probing (Help)
« Reply #8 on: February 11, 2022, 11:49:43 AM »
I have a system for doing exactly this but unfortunately in Mach 3!  Since M4 uses a different macro language it wouldn't be usable directly.  Anyway, it depends on three things.

First, an X axis home switch that gives me a machine coordinate zero on switch on.  This means that you don't have to reference the tools to T1, and T1 can be a real tool.

Second, a system to detect contact between any tool and a workpiece in the chuck/spindle. 

Third, a tool setter with a short MT4 taper to fit the headstock, with accurately measured OD and IDs machined on it concentric.

Then I have an extra Offsets screen with macros behind it that populates a row in the tool table with X and Z offsets.  Basically you set the tool "N" close to the setter, both in diameter and near a reference shoulder, enter the tool number, then click a button, it takes 3 readings of the contact position and calculates the tool offsets from the average.

Also on the Manual screen I have an extra 3 buttons, Touch OD, Touch ID, and Touch Z.  These can be used for more accurate setting to turn a final diameter (with OD and ID), and to find the end of the stock and set Z to zero on it.  So if I rough turn a piece to say 12.1mm with a target of getting 12mm after the finish cut, and the actual diameter after rough turning is 12.07 measured with a mike, I can do a "Touch OD" which should say 12.1, type in 12.07 which is the actual diameter, and put on the finish cut.

Happy to provide more details if this is of interest.  The macros might be a clue though they are in the wrong language, and the general workflow might be useful.
Re: Mach4 Lathe Tool Probing (Help)
« Reply #9 on: February 11, 2022, 12:25:09 PM »
Hi John

I have converted a lathe to cnc and started with Pokeys57cnc and Mach3.
Then I see Pokeys could no threading, threading is the reason why I convert my lathe.
So I purchased MACH4 today and installed it.
Tomorrow I will connect it to my lathe.
I like to use a 3D sensor, same as I use for my CNC mills.
In Mach mill there is all ready to use, in Lathe it seems so I have to develop it myself.
If you could provide your Mach3 script, I can try to convert it to Mach4.

BR

Gerhard