Loading ...
Sorry, an error occurred while loading the content.

Re: First Auto Tool Change in Mach4

Expand Messages
  • aeroengraving
    Congratulations Buddy!! This is definitely on my list of things to do! I love it, great job! Werner Berry
    Message 1 of 76 , Sep 24, 2013
    View Source
    • 0 Attachment
      Congratulations Buddy!! This is definitely on my list of things to do! I love it, great job!
      Werner Berry


      --- In mach1mach2cnc@yahoogroups.com, Brian Barker <brianb@...> wrote:
      >
      > Hi, I wanted you to see what I had done last night :) I finally got the
      > toolchanger working!
      >
      > http://www.youtube.com/watch?v=aO0N3k-wACk&feature=youtu.be
      >
      > I am pleased how simple the tool change
      > Here is the tool change script :
      >
      > -----------------------------------------------------------------------------
      > -- Name: RouterToolChanger
      > -- Author: B Barker
      > -- Modified by:
      > -- Created: 09/923/2013
      > -- Copyright: (c) 2013 Newfangled Solutions. All rights reserved.
      > -- Licence: BSD license
      > -----------------------------------------------------------------------------
      >
      > m_ZtoolHeight = -3.972 -- Height of the tools in the tool rack (Abs)
      > m_PullupDist = 2.5 -- Height to pick over the tools (Inc)
      > m_X_Pullout = 0.0 -- Distance In the X to pull tool out of the tool rack
      > m_Y_Pullout = -1.1 -- Distance in the Y to pull tool out of the tool rack
      >
      > m_changePos = {} --Blank table for the toolchange positions
      > m_index = 1;
      >
      > m_ToolRelease = mc.OSIG_OUTPUT1
      >
      > function AddChangePos(Xpos, Ypos)
      > m_changePos[m_index] = {}
      > m_changePos[m_index] ['x'] = Xpos
      > m_changePos[m_index] ['y'] = Ypos
      > m_index = m_index+1
      > end
      >
      > --Set the toolchange locations in the table
      > --To add more tools simply add "AddChangePos" with (X,Y)
      > AddChangePos(26.019, -1.83)--Tool Pot 1 location
      > AddChangePos(29.6, -1.873)--Tool Pot 2 location
      > AddChangePos(33.218, -1.83933)--Tool Pot 3 location
      > --AddChangePos(22.000, 20.000)--Tool Pot 4 location
      > --AddChangePos(26.000, 20.000)--Tool Pot 5 location
      > --AddChangePos(30.000, 20.000)--Tool Pot 6 location
      >
      >
      > function m6()
      > --Get the instance of the controller
      > local inst = mc.mcGetInstance()
      > --Get current tool and next tool
      > local NewTool = mc.mcToolGetSelected(inst)
      > local CurrentTool = mc.mcToolGetCurrent(inst)
      >
      >
      > if(m_changePos[NewTool] == nil)then
      > return (false)
      > end
      >
      > if(NewTool ~= CurrentTool)then --Skip if the tool is the same
      >
      > --Get the hReg handles
      > local unclamp = mc.mcSignalGetHandle(inst, m_ToolRelease);
      >
      > if unclamp == 0 then
      > mc.mcCntlSetLastError(inst, "Register not found!.");
      > else
      >
      > end
      > if (CurrentTool > 0) then
      > --Drop off the current tool
      > local code = "G0 G53 Z0.0\n"
      > code = code .. string.format("G0 G53 X%.4f Y%.4f\n",
      > m_changePos[CurrentTool].x + m_X_Pullout, m_changePos[CurrentTool].y +
      > m_Y_Pullout)
      > code = code .. string.format("G0 G53 Z%.4f\n", m_ZtoolHeight)
      > code = code .. string.format("G0 G53 X%.4f Y%.4f\n",
      > m_changePos[CurrentTool].x, m_changePos[CurrentTool].y)
      > mc.mcCntlGcodeExecute(inst, tostring(code))
      > end
      >
      > --Release tool
      > mc.mcSignalSetState(unclamp, true);--Unclamp
      > wx.wxSleep(.75)
      >
      > --Move to new tool
      > code = string.format("G0 G53 Z%.4f\n", m_ZtoolHeight +
      > m_PullupDist)
      > code = code .. string.format("G0 G53 X%.4f Y%.4f\n",
      > m_changePos[NewTool].x, m_changePos[NewTool].y)
      > code = code .. string.format("G0 G53 Z%.4f\n", m_ZtoolHeight)
      > mc.mcCntlGcodeExecute(inst, tostring(code))
      >
      > --Clamp tool
      > mc.mcSignalSetState(unclamp, false);--Clamp
      > wx.wxSleep(.75)
      > mc.mcToolSetCurrent(inst, NewTool)
      >
      > code = string.format("G0 G53 X%.4f Y%.4f\n",
      > m_changePos[NewTool].x + m_X_Pullout, m_changePos[NewTool].y + m_Y_Pullout)
      > code = code .. string.format("G0 G53 Z0.0\n")
      > mc.mcCntlGcodeExecute(inst, tostring(code))
      >
      > end
      > end
      >
    • Brian Barker
      If you look at the functions I added you get to do that and it sets the variable in the module that I made.. I did this so later I can add more and more error
      Message 76 of 76 , Oct 2, 2013
      View Source
      • 0 Attachment
        If you look at the functions I added you get to do that and it sets the variable in the module that I made.. I did this so later I can add more and more error checking. I think in the end that is the best thing we can do


        On 10/2/2013 9:30 AM, vmax549@... wrote:

        HIYA Brian, I am not questioning you r code it looks FINE to me for a winerack tool changer. What I suggested is Create the SAME function with the positional values AS variables(parameters) so for the OP to set up the function the OP only has to plug in the positions to parameters to make it WORK for HIS table.


        Every where you have a positional value for XYZ  make it a variable then link it to a system parameter. The OP should NEVER have to be exposed to the macro code just to make the function work.


        If I had a new table with a WR tool changer I would only need to KNOW the travel height of the spindle and the locations of the actual tool holders. These things would then be set as parameter values . You would NOT have to mess with ANY macro code to make the Tool changer function work. AND remember after a tool change the TC function DOES NOT return the tool to the last position. THAT is the CAM/Programmers job.


         Same with tool comp. KEEP it out of the TC function as it belongs in the Gcode side. Remove the COMP before the M6 and apply it AFTER the M6 finishes and you are headed back to work.


        Apon set up of MAch4 you would select a tool changer function such as WR (wineRack) then define the parameters for its operation.  


        NOW IF you want to create a new macro to control that mongral tool changer NOT A PROBLEM have at it.


        (;-) TP



        ---In mach1mach2cnc@yahoogroups.com, <mach1mach2cnc@yahoogroups.com> wrote:

        Terry I don't know how to make it anymore simple and still allow you to change it. Please show me what you are thinking in pseudo code and we will see if it can be done.

        Thanks
        Brian
         

        On 9/30/2013 8:29 PM, vmax549@... wrote:

        NOW put the function code out of sight and just bring out the variables as parameters we can set . Do the same for each class of tool changer and you will have it done.  Then IF someone wants to build a tool changer they can simply build to teh class spec and it will work. Presto.


        Just a thought, (;-) TP



        ---In mach1mach2cnc@yahoogroups.com, <mach1mach2cnc@yahoogroups.com> wrote:

        Hi guys I started to make the module for Lua to make the wine rack tool
        changer seem a little more simple. Please tell me if you think this is
        any better to follow. This only took about 2 hours to make the module so
        something like this is very doable..

        Thanks
        Brian




        ----------------------------------------------------------------------------
        -- Name: RouterToolChanger
        -- Author: B Barker
        -- Modified by:
        -- Created: 09/26/2013
        -- Copyright: (c) 2013 Newfangled Solutions. All rights reserved.
        -- Licence: BSD license
        -----------------------------------------------------------------------------

        --Load the Module for the wine rack type tool changer

        local Tc = require 'WChanger'

        --Set the output to release the tool (mc.OSIG_OUTPUT1)
        Tc.SetToolRelease(mc.OSIG_OUTPUT1)

        --Set the Pull out distance (x_pullout , y_pullout)
        --This is the distance to get the tool out of the toolchanger fingers
        Tc.SetToolPullout(0.0, -1.1)

        --Position of the Z axis to engage the tool in the changer
        Tc.SetZOnToolHeight(-3.972)

        --Position of the Z axis to get from tool to tool
        Tc.SetZOffToolHeight(-1.472)

        --Set the tool change positions and the number of tools
        --Tool 1 location
        Tc.AddChangePos(26.019, -1.83)
        --Tool 2 location
        Tc.AddChangePos(29.6, -1.873)
        --Tool 3 location
        Tc.AddChangePos(33.218, -1.839)

        --Add more Tc.AddChangePos(x, y) to add more tools


        function m6()
        --Get the instance of the controller
        Tc.SetInst(mc.mcGetInstance())
        --Get current tool and next tool
        local NewTool = mc.mcToolGetSelected(inst)
        local CurrentTool = mc.mcToolGetCurrent(inst)


        if(m_changePos[NewTool] == nil)then
        return (false)
        end

        if(NewTool ~= CurrentTool)then --Skip if the tool is the same

        if (CurrentTool > 0) then
        --Drop off the current tool (nil is telling NOT to move that axis)
        Tc.MoveMachinePos(nil, nil, 0.0);
        --Move tool ahead of the toolchange finger
        Tc.MoveToPulloutTool(CurrentTool);
        --Move tool to Z change height
        Tc.MoveToolDown();
        --Move tool into changer
        Tc.MoveToTool(CurrentTool)
        --unclamp tool
        Tc.UnclampTool();
        Tc.Pause(.75);
        --Pull up off tool
        Tc.MoveToolUp();
        else
        --Unclamp if no tool in spindle
        Tc.UnclampTool();
        end

        --Get the new tool

        --Move to new tool
        Tc.MoveToTool(NewTool);
        --Move on to the tool
        Tc.MoveToolDown();
        --Clamp Tool
        Tc.ClampTool();
        Tc.Pause(.75);
        --Set current tool
        mc.mcToolSetCurrent(inst, NewTool);
        --Pull tool out of changer
        Tc.MoveToPulloutTool(NewTool);
        --Move to Z max
        Tc.MoveMachinePos(nil, nil, 0.0);
        end
        end
      Your message has been successfully submitted and would be delivered to recipients shortly.