Hello Guest it is April 28, 2024, 10:48:22 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - barneskite28

Pages: « 1 2 3 4 5 6 7 8 »
51
Mach4 General Discussion / Re: Auto tool offset not working?
« on: May 03, 2021, 03:10:07 AM »
Hi guys, new to the forum, mach 4 and lua so please take it easy. I tried making an auto tool touch off script for tool changes with M6. Everything works as I expected other than no offset is present. The Z axis remains as if the height of the old tool was still there?

Anyways code is below, any help is appreciated.
Code is based on the mach support youtube video (https://www.youtube.com/watch?v=6-4JkDv9AgM)

--START 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

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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.mcCntlGcodeExecuteWait(inst, "G0 X0 Y0 ")--Back to work zero
   mc.mcCntlGcodeExecuteWait(inst, "G21 \nG53 G0 Z0\nG53 G0 Y-1022.41550 \nG53 G0 X-1.7780")--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!')
   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.mcCntlSetLastError(inst, "Probing in Progress!")
      mc.mcCntlGcodeExecuteWait(inst, " G91 G0 Z-5. F300.")
        mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-50. F125.")--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, "G20 G00 G53 Z0 ")--Retract
      mc.mcCntlGcodeExecuteWait(inst, "G0 X0\nG0 Y0 ")--Back to work zero
 
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

--END CODE--
Did you ever get this working?

52
Mach4 General Discussion / Re: Again with the tool setter
« on: May 03, 2021, 02:38:52 AM »
barn
i just want give you advice,if you put such long script and long question ,do you real think some one will now take hours to
test yours script and debug it?
try divide yours question into section ,try focus exactly yours question ,not so big global like" nothing work"
then i belive you will get many answers
hope i help little
Thanks Katz, noted.
really i have tried a couple of scripts that essentially 'work' - i.e. the machine does what its supposed to, but the tool offsets are the problem.  It may be me not understanding something in the procedure, thats what i'm trying to find out.  So to divide the questions..

1. Should tool offsets be on or off when probing the tool setter?

2. I expect a length of tool to be in the table, but the measurement is not the length from the gauge line.  I'm trying to find out why!

Mach4 considering it is a paid program, has little support and no updated info (videos/tutorials) for nearly 5 years, i think this is quite poor for a software that is not free!

53
Mach4 General Discussion / TLO and calculated tool length
« on: May 02, 2021, 05:08:43 PM »
So i am try but failing at setting my tool lengths from the gauge line with a tool setter and m6 script.
i have measured the spindle face (bt30 spindle) in machin coordinates at -161.2219, and when i probe the tool ( with tool offsets off) the machine coordinates are -65.4 . However the tool length being set in the tool table is -30 ish.... it should be  +90 ish.... not sure whats happening

Question, should i have tool lenght offsets on or off when probing?
How do i get the tool lengths to reflect actual lengths from the gauge line?

54
Mach4 General Discussion / Re: Again with the tool setter
« on: May 02, 2021, 04:40:57 PM »
Can anybody help with the script?

55
Mach4 General Discussion / Re: Again with the tool setter
« on: May 02, 2021, 08:18:38 AM »
Found the following code, just not sure exactly where to insert my manual tool change position and my tool height setter position? i see the variable at the top and i see that called in the probing move, but where do i set it?
Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local changeToTool = mc.mcToolGetSelected(inst)
    local changeFromTool = mc.mcToolGetCurrent(inst)
    local XPositionBeforeToolChange = mc.mcAxisGetPos(inst,0)
    local YPositionBeforeToolChange = mc.mcAxisGetPos(inst,1)
    local XToolProbePosition = "1"
    local YToolProbePosition = "1"
    local XManualToolChangePosition = "2"
    local YManualToolChangePosition = "2"
    local ColletAtProbeZCoordinate = -105 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
    local ExtraProbeDistance = 5 -- SafetyMargin
    local ProbeOperationDistance = -50 -- Length of Probemove before giving up
    local ProbePrepSpeed = 100
    local ProbeSpeed = 25
    local DefaultToolLength = 70 -- Used if tool info is not found. (Should be a value slightly longer than the longest tool in the shop :D)
        -- QUICK REFERENCE
        -- G90 - Absolute (Go to coordinate)
        -- G91 - Incremental (Godistance along axis from current position)
        -- G53 - Machine Coordinate Move

    if changeToTool == changeFromTool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0\nM5" )
    RunProbe(inst,changeFromTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n G90 G53 G0 X"..XManualToolChangePosition.." Y"..YManualToolChangePosition)
    local changeToToolDescription = mc.mcToolGetDesc(inst,changeToTool)
    wx.wxMessageBox("Please change to tool number "..changeToTool.." "..changeToToolDescription.." and press ok to continue")
    RunProbe(inst,changeToTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    mc.mcAxisSetPos(inst, 2 , ToolZCoordinate)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..XPositionBeforeToolChange.." Y"..YPositionBeforeToolChange)
    mc.mcToolSetCurrent(inst, changeToTool)
    wx.wxMessageBox("If Toolchange was Sucessful - click ok to continue")
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(finst,ftool,fXToolProbePosition,fYToolProbePosition,fDefaultToolLength,fColletAtProbeZCoordinate,fExtraProbeDistance,fProbePrepSpeed,fProbeSpeed,fProbeOperationDistance)
    mc.mcCntlGcodeExecuteWait(finst, "G90 G53 G0 X"..fXToolProbePosition.." Y"..fYToolProbePosition)
    local toollen = mc.mcToolGetData(finst, mc.MTOOL_MILL_HEIGHT, ftool)
    if toollen == 0 then
        toollen = fDefaultToolLength
        mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
    end
    local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
    local GCODE = "G91 G31 G0 Z"..probestart.." F"..fProbePrepSpeed
    GCODE = ""..GCODE.." \n G91 G0 Z1 F"..fProbePrepSpeed.." \n G91 G31 Z"..fProbeOperationDistance.." F"..fProbeSpeed
    mc.mcCntlGcodeExecuteWait(finst,GCODE)
end

if (mc.mcInEditor() == 1) then
    M6()
end

56
Mach4 General Discussion / Re: diiy pendant
« on: May 02, 2021, 08:16:06 AM »
Looks good, i'm planning to do something similar, but using an arduino for keyboard emulation and to connect the pots

57
Mach4 General Discussion / Re: Again with the tool setter
« on: May 02, 2021, 04:09:04 AM »
I put a ticket into mach support for assistance, got a reply back that said 'read the manual'..... not much support from the support!!

Bet they didn't put their name to the reply  ;D

Tweakie.
They did, but its not personal so i don't see the relevance of their name, as far as i am concerned i'm dealing with a company.

Does anyone have a similar setup to me ? could you share your method/script and help me get this working please?

58
Mach4 General Discussion / Re: Again with the tool setter
« on: May 01, 2021, 08:55:31 AM »
I put a ticket into mach support for assistance, got a reply back that said 'read the manual'..... not much support from the support!!

59
Mach4 General Discussion / Again with the tool setter
« on: May 01, 2021, 08:52:16 AM »
Ok guys, so after digging around i found some script in the Mach4 scripting manual.  The supporting paragraph describes exactly what i need, but refers to 'customization manual' that doesn't exist.
Below is the script copied direct from the manual
Code: [Select]
-----------------------------------------------------------------------------
-- Auto Tool Setting Macro
-----------------------------------------------------------------------------
--[[
 Requires the following instance registers to be defined
 TS_XPos-----------X position of probe (machine position)
 TS_YPos-----------Y position of probe (machine position)
 TS_Type-----------Offset type (1 or 2)
 TS_TouchPos-------Z position of touch off surface (machine position)
 TS_ProbeH---------Height of probe above touch off surface
 TS_DefaultL-------Default tool length guess
 TS_Retract--------Retract distance after probe touch
 Offset Type 1-----Length of tool from gauge line to tip
 Offset Type 2-----Distance from tip of tool to the touch position
]]
--The function GetRegister() must be defined for use by macros
function m1005()
 local inst = mc.mcGetInstance()

 ------------- Define Vars -------------
 local ProbeSignal = mc.ISIG_DIGITIZE
 ------------- Get current state -------------
 local CurTool = mc.mcToolGetCurrent(inst)
 local CurHNum = mc.mcCntlGetPoundVar(inst, 2032)
 local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
 local CurZOffset = mc.mcCntlGetPoundVar(inst, 4102)
26
 local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
 local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)
 ------------- Get touch off parameters -------------
 local Xpos = GetRegister("TS_XPos", 1)
 local Ypos = GetRegister("TS_YPos", 1)
 local OffsetType = GetRegister("TS_Type", 1)
 local TouchPos = GetRegister("TS_TouchPos", 1)
 local ProbeHeight = GetRegister("TS_ProbeH", 1)
 local RetractDistance = GetRegister("TS_Retract", 1)
 local ToolLengthGuess = GetRegister("TS_DefaultL", 1)
 ------------- Check Probe -------------
 local hsig = mc.mcSignalGetHandle(inst, ProbeSignal)
 local ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState == true) then
 mc.mcCntlSetLastError(inst, "ERROR: Probe signal is activated")
 do return end
 end

 ------------- Calculations for Gcode -------------
 local StartHeight = TouchPos + ProbeHeight + ToolLengthGuess + .5

 ------------- Generate GCode -------------
 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. "G00 G80 G40 G49 G90\n"
 AutoToolSetGCode = AutoToolSetGCode .. "G00 G53 Z0.0\n"
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G00 G53 X%.4f Y%.4f\n", Xpos, Ypos)
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G00 G53 Z%.4f\n", StartHeight)
 AutoToolSetGCode = AutoToolSetGCode .. "G91 G31 Z-2.0 F25.\n"

 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 --Check probe contact
 ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState ~= 1) then
 mc.mcCntlSetLastError(inst, "ERROR: No contact with probe")
 mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
 do return end
 end

 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G91 G00 Z%.4f\n", RetractDistance)
 AutoToolSetGCode = AutoToolSetGCode .. "G91 G31 Z-1.0 F10.\n"

 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 --Check probe contact
 ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState ~= 1) then
 mc.mcCntlSetLastError(inst, "ERROR: No contact with probe")
 mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
 do return end
 end

 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. "G90 G00 G53 Z0.0\n"
 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 ------------- Get touch position and set offset -------------
 local ZProbed = mc.mcCntlGetPoundVar(inst, 5063)
 local ZOffset = ZProbed - ProbeHeight + CurZOffset
 if (OffsetType == 1) then
 ZOffset = math.abs(TouchPos - ZOffset)
 end

 mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool, ZOffset)
 mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f",
ZOffset))

I have managed to touch off the spindle face in machine coords, and have the spindle face (gauge line- without holder) at -161.2219.  My tool setter position is at x24.0 y436.0

Can someone help me understand where to put these values and how to get this damn thing to work please?

Tim

60
Mach4 General Discussion / Re: Tool setter, M6, tool length offsets
« on: April 15, 2021, 10:46:25 AM »
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

Pages: « 1 2 3 4 5 6 7 8 »