Another G0704 Conversion - Page 2


Page 2 of 2 FirstFirst 12
Results 21 to 36 of 36

Thread: Another G0704 Conversion

  1. #21
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    I have added a toolsetter to the mill. I bought one of those cheap Chinese one's from Ebay. When it arrived I could instantly tell that it was broken. The center shaft that attaches the tip probe surface had sheared where it was threaded. I fabricated a new shaft to get it working.



    It is mounted on the table at the far left position so that I can leave it there. I wired it into the main probe signal. As you can see in the photo I did not hook up the air hose but I will probably have to eventually as it probing surface gets covered with chips.

    I started with the toolsetter code that was in the Mach 4 LUA scripting guide to create a GCode M1005 macro. Each time I change a tool the mill measures the length of it and updates the tool length offset in in the tool table.

    Attached Thumbnails Attached Thumbnails Another G0704 Conversion-2018-02-25-12-24-05-jpg  


  2. #22
    Member gd.marsh's Avatar
    Join Date
    Aug 2008
    Location
    USA
    Posts
    962
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    +1

    I've been using a shop made tool setter that touches off each tool before use for quite some time now ..
    And I'm totally spoiled by it .. for the little bit of time it takes for the machine measuring each tool as part of every tool change .. it's well worth it in my book!

    Gary



  3. #23
    Member coherent's Avatar
    Join Date
    Apr 2003
    Location
    Arizona, USA
    Posts
    540
    Downloads
    2
    Uploads
    0

    Default Re: Another G0704 Conversion

    Great job! Just as an FYI, I made some oldham couplers when I did my conversion. I used aluminum rod for the coupler ends and delrin rod to machine the hubs. They're a pretty easy project for a CNC mill. They can get pretty pricey and it cost a heck of a lot less to make a few.



  4. #24
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion



    Here is the macro that runs the toolset process. It is written for Mach 4. It has some shortcomings in that it currently relies on a accurate home switch on the Z axis. I will be updating it to improve accuracy by using a dedicated reference tool.


    -----------------------------------------------------------------------------
    -- 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_TouchPos-------Z position of touch off surface (machine position)
    TS_ProbeH---------Height of probe above touch off surface
    TS_MaxToolLen-----Maximum allowed tool length
    TS_Retract--------Retract distance after probe touch
    TS_ProbeRate------Rate of probing movement
    ]]

    ------------------------------------------------------
    function m1005()
    debug = 0
    local inst = mc.mcGetInstance()
    ------------- Define Vars -------------
    local ProbeSignal = mc.ISIG_PROBE

    ------------- Get current state -------------
    local StartingX = mc.mcAxisGetPos(inst, 0) --Get the current Position
    local StartingY = mc.mcAxisGetPos(inst, 1) --Get the current Position
    local StartingZ = mc.mcAxisGetPos(inst, 2) --Get the current Position
    local CurTool = mc.mcToolGetCurrent(inst) --Get the current tool #
    local CurToolLength = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool) --Get the tool length
    local CurFeed = mc.mcCntlGetPoundVar(inst, 2134) --Get the current Feed rate
    local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
    local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)

    ------------- Get touch off parameters -------------
    local Xpos = GetRegister("TS_XPos")
    local Ypos = GetRegister("TS_YPos")
    local TouchPos = GetRegister("TS_TouchPos")
    local ProbeHeight = GetRegister("TS_ProbeH")
    local RetractDistance = GetRegister("TS_Retract")
    local MaxToolLength = GetRegister("TS_MaxToolLen")
    local ProbeRate = GetRegister("TS_ProbeRate")

    ------------- Clear the Messages -------------
    mc.mcCntlSetLastError(inst, " ")
    local Message = ""
    local GCodeText = ""

    ------------- Make sure the tool length isn't something crazy -------------
    local test = MaxToolLength - CurToolLength
    if (test < 0) then
    CurToolLength = MaxToolLength
    end

    ------------- Check Probe -------------
    local hsig = mc.mcSignalGetHandle(inst, ProbeSignal)
    local ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState == 1) then
    mc.mcCntlSetLastError(inst, "ERROR: Probe signal is ALREADY activated before toolset start.")
    do return end
    end

    ------------- Calculations for Gcode -------------
    local StartHeight = 0
    local ProbeStrokeLength = 0
    if (CurToolLength == 0) then
    StartHeight = TouchPos + ProbeHeight + MaxToolLength + .5
    ProbeStrokeLength = MaxToolLength -2
    else
    StartHeight = TouchPos + ProbeHeight + CurToolLength + .5
    ProbeStrokeLength = 1
    end
    if (debug == 1) then
    Message = "DEBUG:\n"
    Message = Message .. string.format(" Current Tool # %d Length = %.4f \n", CurTool, CurToolLength)
    Message = Message .. string.format(" Maximum Tool Length = %.4f \n", MaxToolLength)
    Message = Message .. string.format(" Touch Position = %.4f \n", TouchPos)
    Message = Message .. string.format(" Probe Height = %.4f \n", ProbeHeight)
    Message = Message .. string.format(" Probe Start Height = %.4f \n", StartHeight)
    Message = Message .. string.format(" Probe Stroke Length = %.4f \n", ProbeStrokeLength)
    wx.wxMessageBox(Message)
    end

    ------------- Probing Phase 1. Generate GCode -------------
    GCodeText = ""
    GCodeText = GCodeText .. "G00 G80 G40 G49 G90\n" --Rapid Move, Canned Cycle Cancel, Tool Rad Comp Cancel, Length Offset Cancel, Abs Mode
    GCodeText = GCodeText .. "G00 G53 Z0.0\n" --Rapid Move, Machin Coord System, Goto Z
    GCodeText = GCodeText .. string.format("G00 G53 X%.4f Y%.4f\n", Xpos, Ypos)
    GCodeText = GCodeText .. string.format("G00 G53 Z%.4f\n", StartHeight)
    GCodeText = GCodeText .. string.format("G91 G31 Z-%.4f F%d.\n", ProbeStrokeLength, ProbeRate) --Incremental Mode, Probe Mode, Move Z Axis, Feed Rate
    if debug == 1 then
    wx.wxMessageBox("DEBUG: Probe Phase 1. Sending:\n" ..GCodeText)
    end
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)

    --Check probe contact phase 1
    ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState == 0) then
    mc.mcCntlSetLastError(inst, "ERROR: No contact with probe when performing Phase 1 of touch.")
    ReturnToHome()
    do return end
    end

    ------------- Probing Phase 2. Generate GCode -------------
    GCodeText = ""
    GCodeText = GCodeText .. string.format("G91 G00 Z%.4f\n", RetractDistance)
    GCodeText = GCodeText .. string.format("G91 G31 Z-%.4f F%d.\n", ProbeStrokeLength, (ProbeRate/2))
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)

    --Check probe contact phase 2
    ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState == 0) then
    mc.mcCntlSetLastError(inst, "ERROR: No contact with probe when performing Phase 2 of touch.")
    ReturnToHome()
    do return end
    end

    ------------- Probing Complete, Return to top. -------------
    ReturnToHome()

    ------------- Get probe position and set offset -------------
    local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.

    local NewToolOffset = 0
    -- For this to work then the spindle face touching the table is registry value TS_TouchPos, Maximum negative Z value for machine.
    -- Also the presetter height must be entered into the registry value TS_ProbeH.

    NewToolOffset = math.abs(TouchPos + ProbeHeight - ZProbed)

    if (debug == 1) then
    Message = "DEBUG:\n"
    Message = Message .. string.format(" Current Tool # %d Was Length = %.4f \n", CurTool, CurToolLength)
    Message = Message .. string.format(" Probed absolute Z value = %.4f \n", ZProbed)
    Message = Message .. string.format(" Touch Position = %.4f \n", TouchPos)
    Message = Message .. string.format(" Probe Height = %.4f \n", ProbeHeight)
    Message = Message .. string.format(" New Tool Length = %.4f \n", NewToolOffset)
    wx.wxMessageBox(Message)
    end

    mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool, NewToolOffset)
    mc.mcCntlSetLastError(inst, string.format("Tool set complete, Tool = %d , Old Length = %.4f New Length = %.4f", CurTool, CurToolLength, NewToolOffset))

    ------------- Return to where we were befor start -------------
    mc.mcCntlSetPoundVar(inst, 2134, CurFeed)
    mc.mcCntlSetPoundVar(inst, 4001, CurFeedMode)
    mc.mcCntlSetPoundVar(inst, 4003, CurAbsMode)
    local GCodeText = ""
    GCodeText = GCodeText .. string.format("G00 X%.4f Y%.4f\n", StartingX, StartingY)
    GCodeText = GCodeText .. string.format("G00 Z%.4f\n", StartingZ)
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)
    end

    -----------------------------------------------------
    -- Move the head back to the home position
    ------------------------------------------------------
    function ReturnToHome()
    local inst = mc.mcGetInstance()
    mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
    end

    -----------------------------------------------------
    --Get Register READ and WRITE--
    -- must be defined in the "macrofunctions" file--
    ------------------------------------------------------
    function GetRegister(regname)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
    return mc.mcRegGetValueString(hreg)
    end

    function WriteRegister(regname, regvalue)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
    mc.mcRegSetValueString(hreg, tostring(regvalue))
    end

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



  5. #25
    Member
    Join Date
    Oct 2013
    Location
    United States
    Posts
    543
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    That is a very cool addition to your machine, good job. I can also appreciate the effort writing the code to make the tool setter happen and think it's wonderful that you posted it for all to see.

    Thanks,

    Stuart & Nick

    "THE GRIZZ" photo album - https://goo.gl/photos/yLLp61jooprtYzFK7
    Youtube - https://www.youtube.com/channel/UCT2lq9obzEnlEu-M56ZzT_A


  6. #26
    Member jalessi's Avatar
    Join Date
    Feb 2007
    Location
    United States
    Posts
    4553
    Downloads
    1
    Uploads
    0

    Default Re: Another G0704 Conversion

    Maxspongebob,

    How much did the tool setter cost? Do you have any images of the damage and parts that you fabricated?

    It would be nice to see what you fabricated so that others can duplicate your efforts if they also receive a damaged tool setter.

    Have a most awesome day!

    Jeff...



    Quote Originally Posted by maxspongebob View Post
    I have added a toolsetter to the mill. I bought one of those cheap Chinese one's from Ebay. When it arrived I could instantly tell that it was broken. The center shaft that attaches the tip probe surface had sheared where it was threaded. I fabricated a new shaft to get it working.



    It is mounted on the table at the far left position so that I can leave it there. I wired it into the main probe signal. As you can see in the photo I did not hook up the air hose but I will probably have to eventually as it probing surface gets covered with chips.

    I started with the toolsetter code that was in the Mach 4 LUA scripting guide to create a GCode M1005 macro. Each time I change a tool the mill measures the length of it and updates the tool length offset in in the tool table.


    Patience and perseverance have a magical effect before which difficulties disappear and obstacles vanish.


  7. #27
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    I have received a few questions concerning my toolsetter script, so I will provide some additional explanation here.

    My tool length offset method:


    First note a few items just for background.


    1. Each time you zero your Z axis the position that is set for the machine's zero may be different. This is because, if you are using limit switches, the switch may trigger at a slightly different position each time. Some switch types are more accurate than others, but for a mechanical switch a few thousandths of an inch is typical.

    2. A reference tool is an easy way to mitigate for the variability defined in item 1 above.

    3. It is important to start the process of measuring your tools knowing the approximate length of each tool beforehand. Enter the approximate value in the tool table for each tool. This will speed the measurement process and will reduce the risk of crashing a tool into the toolsetter.

    4. There are a couple of different ways to use tool offsets. They are explained well here. https://zero-divide.net/?shell_id=15...-code-h-offset




    For my script I use a reference tool with a known length. In Mach 4, I have assigned this tool #99 in the tool offset table. Also, I use the Register File plugin to save values associated with the script and tool measurement process. See the associated photos below.


    The process:
    1. Reference All the Axes.
    2. Open the Tool table and verify that the reference tool is the correct length (Just a precaution. If it is not, the tool may crash the toolsetter).
    3. Insert the reference tool and set the current tool to the reference tool#. It is important to measure the reference tool each time the Z axis is zeroed and it must be the first tool you measure. This is where the limit switch correction is determined.
    4. From the MDI screen run the command M1005 or whatever you choose to name your script.
    5. Press start.


    What will happen when you start the script:
    1. The system will load the values from the registry.
    2. It will look to see what the current tool is and figure out a starting point for X, Y, and Z.
    3. Verifies that the probe is ready.
    4. Moves the tool to the very top and then starts the first probe cycle. This one is a little faster than the final measurement cycle.
    5. When the probe strikes it will stop and then back off.
    6. Then another probe cycle is done at half speed to get a final measurement.
    7. After the measurement is taken the tool will return to the top position.
    8. If the tool is the reference tool the measured value is used to calculated the error of the Z axis limit switches. The correction factor is stored in the registry for later use measuring other tools. If it is not the reference tool, a new tool offset value is calculated and stored in the tool table.


    Proceed to measure all the remaining tools.

    Another G0704 Conversion-register-file-png

    Attached Thumbnails Attached Thumbnails Another G0704 Conversion-register-file-png  


  8. #28
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Here is the latest version of the script. It has been running well for a while.

    -----------------------------------------------------------------------------
    -- Auto Tool Setting Macro 5-13-2018
    -----------------------------------------------------------------------------
    --[[
    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_TablePos----------Z position of base of table surface (machine position)
    TS_ProbeH------------Height of probe above touch off surface
    TS_MaxToolLen--------Maximum allowed tool length
    TS_Retract-----------Retract distance after probe touch
    TS_ProbeRate---------Rate of probing movement
    TS_RefToolNum--------ID which tool is the reference tool
    TS_ZCorrection-------The correction factor to compensate for home switch error
    ]]


    ------------------------------------------------------
    function m1005()
    debug = 0
    local inst = mc.mcGetInstance()
    ------------- Define Vars -------------
    local ProbeSignal = mc.ISIG_PROBE


    ------------- Get current state -------------
    local StartingX = mc.mcAxisGetPos(inst, 0) --Get the current Position
    local StartingY = mc.mcAxisGetPos(inst, 1) --Get the current Position
    local StartingZ = mc.mcAxisGetPos(inst, 2) --Get the current Position
    local CurTool = mc.mcToolGetCurrent(inst) --Get the current tool #
    local CurToolLength = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool) --Get the tool length
    local CurFeed = mc.mcCntlGetPoundVar(inst, 2134) --Get the current Feed rate
    local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
    local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)


    ------------- Get touch off parameters -------------
    local XPos = GetRegisterNum("TS_XPos")
    local YPos = GetRegisterNum("TS_YPos")
    local TablePos = GetRegisterNum("TS_TablePos")
    local ProbeHeight = GetRegisterNum("TS_ProbeH")
    local RetractDistance = GetRegisterNum("TS_Retract")
    local MaxToolLength = GetRegisterNum("TS_MaxToolLen")
    local ProbeRate = GetRegisterNum("TS_ProbeRate")
    local RefToolNum = GetRegisterNum("TS_RefToolNum")
    local ZHomeCorrFact = GetRegisterNum("TS_ZCorrection")


    ------------- Clear the Messages -------------
    mc.mcCntlSetLastError(inst, " ")
    local Message = ""
    local GCodeText = ""


    ------------- Figure out if this is the reference tool measurement -------------
    -- After Mach is started, you must reference the axis and then measure the reference tool.
    -- If you try to measure a tool without doid the reference tool first you will not be able to
    -- correct for the homing switch error. So measure the ref tool first.
    if (ZHomeCorrFact >= 1) then
    local testtool = CurTool - RefToolNum --See if this is the reference tool. If so, then update the correction factor.
    if (testtool ~= 0) then
    mc.mcCntlSetLastError(inst, "ERROR: You must measure the reference tool first before any other tool.")
    do return end
    end
    end


    ------------- Make sure the tool length isn't something crazy or set to zero -------------
    local test = MaxToolLength - CurToolLength
    if (test < 0) then
    CurToolLength = MaxToolLength
    end
    if (test == 0) then
    CurToolLength = MaxToolLength
    end


    ------------- Check Probe Status -------------
    local hsig = mc.mcSignalGetHandle(inst, ProbeSignal)
    local ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState >= 1) then
    mc.mcCntlSetLastError(inst, "ERROR: Probe signal is ALREADY activated before toolset start.")
    do return end
    end


    ------------- Calculations for Gcode to do probing -------------
    local StartHeight = 0
    local ProbeStrokeLength = 0
    if (CurToolLength == 0) then
    StartHeight = TablePos + ProbeHeight + MaxToolLength + .5
    ProbeStrokeLength = MaxToolLength -2
    else
    StartHeight = TablePos + ProbeHeight + CurToolLength + .5
    ProbeStrokeLength = 1
    end
    if (debug >= 1) then
    Message = "DEBUG:\n"
    Message = Message .. string.format(" Current Tool # %d Length = %.4f \n", CurTool, CurToolLength)
    Message = Message .. string.format(" Toolsetter Coordinates = X%.4f Y%.4f \n", XPos, YPos)
    Message = Message .. string.format(" Maximum Tool Length = %.4f \n", MaxToolLength)
    Message = Message .. string.format(" Table Position = %.4f \n", TablePos)
    Message = Message .. string.format(" Toolsetter Probe Height = %.4f \n", ProbeHeight)
    Message = Message .. string.format(" Probe Start Height = %.4f \n", StartHeight)
    Message = Message .. string.format(" Probe Stroke Length = %.4f \n", ProbeStrokeLength)
    Message = Message .. string.format(" Reference Tool Number = %d \n", RefToolNum)
    Message = Message .. string.format(" Home Correction Factor = %.4f \n", ZHomeCorrFact)
    wx.wxMessageBox(Message)
    end


    ------------- Probing Phase 1. Generate GCode -------------
    GCodeText = ""
    GCodeText = GCodeText .. "G00 G80 G40 G49 G90\n" --Rapid Move, Canned Cycle Cancel, Tool Rad Comp Cancel, Length Offset Cancel, Abs Mode
    GCodeText = GCodeText .. "G00 G53 Z0.0\n" --Rapid Move, Machin Coord System, Goto Z
    GCodeText = GCodeText .. string.format("G00 G53 X%.4f Y%.4f\n", XPos, YPos)
    GCodeText = GCodeText .. string.format("G00 G53 Z%.4f\n", StartHeight)
    GCodeText = GCodeText .. string.format("G91 G31 Z-%.4f F%d.\n", ProbeStrokeLength, ProbeRate) --Incremental Mode, Probe Mode, Move Z Axis, Feed Rate
    if debug >= 2 then
    wx.wxMessageBox("DEBUG: Probe Phase 1. Sending:\n" ..GCodeText)
    end
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)


    --Check probe contact phase 1
    ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState == 0) then
    mc.mcCntlSetLastError(inst, "ERROR: No contact with probe when performing Phase 1 of touch.")
    ReturnToHome()
    do return end
    end


    ------------- Probing Phase 2. Generate GCode -------------
    GCodeText = ""
    GCodeText = GCodeText .. string.format("G91 G00 Z%.4f\n", RetractDistance)
    GCodeText = GCodeText .. string.format("G91 G31 Z-%.4f F%d.\n", ProbeStrokeLength, (ProbeRate/2))
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)


    --Check probe contact phase 2
    ProbeState = mc.mcSignalGetState(hsig)
    if (ProbeState == 0) then
    mc.mcCntlSetLastError(inst, "ERROR: No contact with probe when performing Phase 2 of touch.")
    ReturnToHome()
    do return end
    end


    ------------- Probing Complete, Return head to top. -------------
    ReturnToHome()


    ------------- Get probe position and calculate the tool offset -------------


    local CorrectedToolLength = 0
    local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.
    local NewToolOffset = math.abs(TablePos + ProbeHeight - ZProbed) -- Calculate the tool length based on the probing values and registry info.


    local testval = CurTool - RefToolNum --See if this is the reference tool. If so, then update the correction factor.
    if (testval == 0) then
    ZHomeCorrFact = CurToolLength - NewToolOffset -- Calculate the error of the home switch for this session.
    WriteRegister("TS_ZCorrection", ZHomeCorrFact) -- Save the correction factor for other tool measurements.
    Message = string.format("Tool set complete, Tool = REFERENCE, New Z Correction = %.4f", ZHomeCorrFact)
    else
    CorrectedToolLength = NewToolOffset + ZHomeCorrFact -- Fix the new tool offset caused by the home switch error.
    mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool, CorrectedToolLength) -- Save the tool offset to the tool table.
    Message = string.format("Tool set complete, Tool = %d , Old Length = %.4f New Length = %.4f", CurTool, CurToolLength, CorrectedToolLength)
    end


    mc.mcCntlSetLastError(inst, Message) --Display the results in the Mach History bar.


    if (debug >= 1) then
    Message = "DEBUG:\n"
    Message = Message .. string.format(" Current Tool # %d Was Length = %.4f \n", CurTool, CurToolLength)
    Message = Message .. string.format(" Probed absolute Z value = %.4f \n", ZProbed)
    Message = Message .. string.format(" Z Home Correction Factor = %.4f \n", ZHomeCorrFact)
    Message = Message .. string.format(" Measured Length before Correction = %.4f \n", NewToolOffset)
    Message = Message .. string.format(" Measured Length After Correction = %.4f \n", CorrectedToolLength)
    wx.wxMessageBox(Message)
    end


    ------------- Return to where we were befor start -------------
    mc.mcCntlSetPoundVar(inst, 2134, CurFeed)
    mc.mcCntlSetPoundVar(inst, 4001, CurFeedMode)
    mc.mcCntlSetPoundVar(inst, 4003, CurAbsMode)
    local GCodeText = ""
    GCodeText = GCodeText .. string.format("G00 Z%.4f\n", StartingZ)
    GCodeText = GCodeText .. string.format("G00 X%.4f Y%.4f\n", StartingX, StartingY)
    mc.mcCntlGcodeExecuteWait(inst, GCodeText)
    end


    -----------------------------------------------------
    -- Move the head back to the home position
    ------------------------------------------------------
    function ReturnToHome()
    local inst = mc.mcGetInstance()
    mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
    end


    -----------------------------------------------------
    --Get Register READ and WRITE--
    -----------------------------------------------------
    function GetRegisterString(regname)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
    return mc.mcRegGetValueString(hreg)
    end


    function GetRegisterNum(regname)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
    local regstring = mc.mcRegGetValueString(hreg)
    return tonumber(regstring)
    end


    function WriteRegister(regname, regvalue)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
    local oldval = mc.mcRegGetValueString(hreg)
    if oldval ~= regval then -- Compare the existing value to the new and only write if different.
    mc.mcRegSetValueString(hreg, tostring(regvalue))
    end
    end


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



  9. #29
    Registered
    Join Date
    Nov 2005
    Location
    Slovakia
    Posts
    9
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    maxspongebob thank you very much for the excellent write-up. I personally use AC servos and I'm homing on the index signal so its precise. I tried your previous version of the macro today as my modified version from LUA scripting guide was not working correctly. To find out values for registers I'm touching with my spindle shaft (without ER nut) both table and switching point of the touch probe (touch probe height). I have same probe as you as I wrote you. I dont fill tool table by hand, I just modified your macro so its expecting to have long tool and waits for switch (feed for first probe touch is not that slow for me). I was debugging it over and over again and I still have problem with line ,,local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.,, Its not picking value when the switch was tripped, but when the head is back up in Z=0. When I move it up, before head is going up it will jump to correct value. How is it working on your machine?
    Second problem is with ,,local NewToolOffset = math.abs(TablePos + ProbeHeight - ZProbed) -- Calculate the tool length based on the probing values and registry info. If I move cursor over TablePos, Probe Height and ZProbed, I get math.abs(-265,4131+77,3372-(-188,044)) , which should be correct value -0.0319 (measuring deviation as Im measuring spindle shaft again), but the resulted newToolOffset is 187,982 (and it was set to 0 correctly few lines above).

    Do you have any idea what is my problem?

    Thank you very much.
    Michal



  10. #30
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Quote Originally Posted by CarbonMike View Post
    maxspongebob thank you very much for the excellent write-up. I personally use AC servos and I'm homing on the index signal so its precise. I tried your previous version of the macro today as my modified version from LUA scripting guide was not working correctly. To find out values for registers I'm touching with my spindle shaft (without ER nut) both table and switching point of the touch probe (touch probe height). I have same probe as you as I wrote you. I dont fill tool table by hand, I just modified your macro so its expecting to have long tool and waits for switch (feed for first probe touch is not that slow for me). I was debugging it over and over again and I still have problem with line ,,local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.,, Its not picking value when the switch was tripped, but when the head is back up in Z=0. When I move it up, before head is going up it will jump to correct value. How is it working on your machine?
    Second problem is with ,,local NewToolOffset = math.abs(TablePos + ProbeHeight - ZProbed) -- Calculate the tool length based on the probing values and registry info. If I move cursor over TablePos, Probe Height and ZProbed, I get math.abs(-265,4131+77,3372-(-188,044)) , which should be correct value -0.0319 (measuring deviation as Im measuring spindle shaft again), but the resulted newToolOffset is 187,982 (and it was set to 0 correctly few lines above).

    Do you have any idea what is my problem?

    Thank you very much.
    Michal

    I would first set the debug value in the script to 2. This will provide many messages about what the values are and what is going on. Also, it will open a message box that shows you what the G code is that it is sending to the machine. It may be helpful to use the MDI screen to send these commands one at the time.

    Also, what probe signal are you using? There are 4 possible breakout pins that can be used for probing. The easiest way to tell is by the 4 squares just above the touch button on the Mach 4 main screen.
    Another G0704 Conversion-temp-probe-png

    Attached Thumbnails Attached Thumbnails Another G0704 Conversion-temp-probe-png  


  11. #31
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Quote Originally Posted by CarbonMike View Post
    maxspongebob thank you very much for the excellent write-up. I personally use AC servos and I'm homing on the index signal so its precise. I tried your previous version of the macro today as my modified version from LUA scripting guide was not working correctly. To find out values for registers I'm touching with my spindle shaft (without ER nut) both table and switching point of the touch probe (touch probe height). I have same probe as you as I wrote you. I dont fill tool table by hand, I just modified your macro so its expecting to have long tool and waits for switch (feed for first probe touch is not that slow for me). I was debugging it over and over again and I still have problem with line ,,local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.,, Its not picking value when the switch was tripped, but when the head is back up in Z=0. When I move it up, before head is going up it will jump to correct value. How is it working on your machine?
    Second problem is with ,,local NewToolOffset = math.abs(TablePos + ProbeHeight - ZProbed) -- Calculate the tool length based on the probing values and registry info. If I move cursor over TablePos, Probe Height and ZProbed, I get math.abs(-265,4131+77,3372-(-188,044)) , which should be correct value -0.0319 (measuring deviation as Im measuring spindle shaft again), but the resulted newToolOffset is 187,982 (and it was set to 0 correctly few lines above).

    Do you have any idea what is my problem?

    Thank you very much.
    Michal


    After further thought:

    When I purchased my probe, I found that the Brown and Orange wires were reversed. I found that there are a couple different manufactures of these in china and not all have the same wiring. This could be your problem. When I got mine, I disassembled it and made a complete wiring diagram. Here it is.
    Another G0704 Conversion-toolsetterwiring-jpg
    Another thought is that you may have some noise on your grounds that is triggering the probe signal when it is not in a probing cycle. You might remedy this by moving the line of code that starts with "local ZProbed = ..." and put it at the end of the "Probing Phase 2 section" before the line that says "ReturnToHome()". This will take the Z probe position and record it before the machine does any more movements.

    Attached Thumbnails Attached Thumbnails Another G0704 Conversion-temp-probe-png   Another G0704 Conversion-toolsetterwiring-jpg  


  12. #32
    Registered
    Join Date
    Nov 2005
    Location
    Slovakia
    Posts
    9
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Thanks for tips. I tested mine, and I have probe signal as Probe (first green square LED from left), and overtravel switch as Probe1 (second green square LED from left). But I dont use Probe overtravel switch for now. Probe signal works correctly and I dont see it blinking or anything but I will take closer look. Also if it will be the case of noise, I think it will stop when moving down and will trigger "ERROR: Probe signal is ALREADY activated before toolset start."

    I have used your debugging setting 1 on top to have messages (excellent tool), but is same as I hover over variables and it will show value after debugger has passed to next line.

    My ,,local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) --Get the Absolute Machine Z of the probe strike.,, is picking value like 0,09 or so, so I feel its measuring in the end when head is up. I will try to move it as you suggested.

    One question, in ,,mc.mcAxisGetProbePos(inst, 2, 1) ,, number 2 is axis number (x=0, y=1, z=2), and 1 is ,,absolute,, value?



  13. #33
    Registered
    Join Date
    Nov 2005
    Location
    Slovakia
    Posts
    9
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    maxspongebob, what version and build of Mach4 do you have? I have Mach4 Hobby. Do you have the professional version?

    http://www.machsupport.com/wp-conten...ces_doc_a9.pdf

    There are several Macro limitations for Hobby version. I'm not sure if this is not my problem.

    I just cant get local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) to work as in your machine. I have also tried PROBE_POS_Z (var 5063) without any success. Maybe I'm just doing it wrong.



  14. #34
    Member
    Join Date
    Mar 2017
    Location
    United States
    Posts
    411
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Quote Originally Posted by CarbonMike View Post
    maxspongebob, what version and build of Mach4 do you have? I have Mach4 Hobby. Do you have the professional version?

    http://www.machsupport.com/wp-conten...ces_doc_a9.pdf

    There are several Macro limitations for Hobby version. I'm not sure if this is not my problem.

    I just cant get local ZProbed = mc.mcAxisGetProbePos(inst, 2, 1) to work as in your machine. I have also tried PROBE_POS_Z (var 5063) without any success. Maybe I'm just doing it wrong.

    I am using the hobby version. I also am using the Pokeys controller. Both have the latest version of software and are working properly.
    Originally the Mach 4 script used a different method to get the Z probe offset. I changed the script to use a LUA function. What happens if you try the original method?

    Original code:
    ZProbed = mc.mcCntlGetPoundVar(inst, 5063)

    My code:
    ZProbed = mc.mcAxisGetProbePos(inst, 2, 1)



  15. #35
    Registered
    Join Date
    Nov 2005
    Location
    Slovakia
    Posts
    9
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Okay, so I made the test to see what is going on with probe variables by looking at Register diagnostic/variables 5061-5063 in real time.
    #5061 = PROBE_POS_X
    #5062 = PROBE_POS_Y
    #5063 = PROBE_POS_Z
    After starting Mach4 I pressed reference all axes. Machine is referenced (0,0,0).

    In MDI I wrote probing gcode:
    G91 G31 Z-200 F100

    Step1:
    With feed slider at 0, I pressed touchprobe at X=0 Y=0 Z=0.
    #5061 = 0
    #5062 = 0
    #5063 = 0

    Step2:
    With feed slider at minimum a carefuly waited for Z to go -50mm and set slider to 0 feed, I pressed touchprobe at 0,0,0.
    #5061 = 0
    #5062 = 0
    #5063 = -0,025 !!! (2000x smaller value than actual -50mm)
    So #5063 is 2000x smaller. In my motor config page in Mach4 I have 2000 counts per unit.

    Step3: I restarted Mach, everything same until Step1, except I have moved all 3 axis to X=50 Y=100 Z=-50.
    #5061 = 0,025
    #5062 = 0,05
    #5063 = -0,025
    Again 2000x smaller values.

    And now the most amazing step 4!

    Step4: I restarted Mach, everything same until Step1, except I have moved all 3 axis to X=50 Y=100 Z=-50 AND pressed buttons ZERO X, ZERO Y, ZERO Z.
    #5061 = -49,975
    #5062 = -99,95
    #5063 =49,925
    Values are correct (not 2000x smaller), but signs are wrong.

    This is the reason why did I receive tiny values when doing original auto tool length measurement macro with ZProbed = mc.mcCntlGetPoundVar(inst, 5063)

    Does anyone have an idea what the hell is going on?

    Am I missing some basic setup of Mach4? Or is the gcode bad? Do you have any INITIALIZATION CODES in mach4 general tab setup?

    Thanks.



  16. #36
    Registered
    Join Date
    Nov 2005
    Location
    Slovakia
    Posts
    9
    Downloads
    0
    Uploads
    0

    Default Re: Another G0704 Conversion

    Another test, and I'm starting to understand now!

    I looked at probe MACHINE variables 5071, 5072, 5073. Those are always 2000x smaller numbers. That's why I had that strange small deviation between 5061-5063 variables and DRO values. Its because in 5061-63 variables G53 offsets were used and those tiny 5071-5073 values are added/deducted.

    I still don't understand why my Machine variables 5071-5073 are 2000x smaller numbers than they should be.



Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Another G0704 Conversion

Another G0704 Conversion