Hello Guest it is October 16, 2019, 01:44:09 PM

Author Topic: Creating an M6 Toolchange in Mach4 (Part 3)  (Read 6724 times)

0 Members and 1 Guest are viewing this topic.

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #10 on: January 12, 2018, 02:21:37 AM »
Mach4 has come on a long way since making these videos and lots of new commands added, there will be an updated video soon on the way i now do it but still ask away  ;)

DazTheGas
Theres always time for a choccy biccy
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #11 on: January 12, 2018, 09:20:28 AM »
Thanks for the reply. I have been running Mach3 for about 7 years W/ Screenset2010 on my diy CNC without many problems. Now for some unknown reason, while running a gcode file, about every two minutes I keep getting an error code (error 3336) pop-up that shuts the program down. ArtSoft technicians dosen't know what to do about it. So I'm trying to install Mach4 V2 to see if it will correct these problem. Screenset 2010 has an M6 manual tool change that I would like to use with Mach4, but Mach4 will not run the 2010 screensets. I was wondering if it would be possible to get your latest M6 code and help getting it into my Mach4? 
Thanks in advance for your help. If it wasn't for these forums I would never have my DIY CNC working as well as it does.
Gene 
P.S. I don't have Mach4 completely installed yet, trying to get all of the settings just right is a pain you know where >:( ??? >:D
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #12 on: January 12, 2018, 10:46:59 AM »
I will be looking forward to the new video. I have your tool change run at this time.
Thanks.
Stop Drop and Roll
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #13 on: June 12, 2018, 06:30:01 PM »
Here's hoping this update is still in the works. Thanks!

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #14 on: June 13, 2018, 05:24:00 PM »
Yep still in the pipeline, just have to get machine finished first ;-)

DazTheGas
Theres always time for a choccy biccy
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #15 on: June 26, 2018, 12:02:15 PM »
https://www.youtube.com/watch?v=uxeQrFIWq8U

change tool with servo magazine with mach 4
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #16 on: July 08, 2018, 03:14:51 PM »
Greetings to all,
I’ve installed the m6 script on my machine, (thanks for everyone’s hard work), each time it runs the message boxes remain hidden. Obviously sense they can’t be accessed, it’s not possible to complete the routine. The only thing left to do is close Mach4 down. After Mach has closed the message boxes then appear allowing them to be closed also. The other messages in Mach appear to work normally. If an m6 command is in g code the machine will retract the z, move to the tool change position etc. If the command is issued in the MDI, nothing happens but it is apparent that Mach is in a wait condition, waiting for input from the message box. I’m sure there is a simple answer for this, I just can’t find it.
Thanks, Lou
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #17 on: October 07, 2018, 03:03:01 PM »
Just adding a thankyou! :)

I Made some Modifications
- Probemove for approach probe to avoid Crash :) and back off probe before real probing.
- Lots of Variables to tune the script
---Preset for probelocation
---Preset for ToolChange position
---Preset for defaults and speeds


Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local changeToTool = 3--mc.mcToolGetSelected(inst)
    local changeFromTool = 2--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 = -103 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
    local ExtraProbeDistance = 5 -- SafetyMargin
    local ProbeOperationDistance = -30 -- 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)
    local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n 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)
    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)
    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 end
    mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
    local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
    local GCODE = "G90 G53 G31 G0 Z"..probestart.." F"..fProbePrepSpeed
    GCODE = ""..GCODE.." \n G91 G0 Z5 F"..fProbePrepSpeed.." \n G91 G31 Z-15 F"..fProbeSpeed
    mc.mcCntlGcodeExecuteWait(finst,GCODE)
end

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

how i define probeposition?
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #18 on: April 15, 2019, 01:57:00 PM »
Hello,

A big thank you to all,
Had until a few days still no idea of macro programming but there are very helpful videos and forums =)

The M6 version of DazTheGas works very well, just got it adapted to my machine.
I also understand the processes

But now I have a problem / question:
Is it possible not to adjust the Z position in the fixture table, but to adjust the tool length in the tool table.

For me it is more logical if the fixture position in Z is 0 and the height changes with the tool length.
Do I have a thinking mistake or is that a possible solution?

Does anyone happen to have such a solution?

I've tried it but can not come to a solution

Thank you

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 3)
« Reply #19 on: April 15, 2019, 04:34:34 PM »
At the time of creating the M6 Macro the tool table was limited, but as time has progressed so has mach4 and the tool table. You now have the ability to create custom user fields, this makes things much more easier and expandable.

lets say in the tool table you were to create a custom field called m6Height and make this a float value,

instead of using "toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, tool)"  you would use instead "toollen = mc.mcToolGetDataExDbl(inst,   tool,   "m6Height")

Hope that makes sense and what you were looking for...

DazTheGas
Theres always time for a choccy biccy