584,842 active members*
4,201 visitors online*
Register for free
Login
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2017
    Posts
    591

    need tool change stop to be conditional

    I want to eliminate unneeded tool change stops for my mill turn setup. The milling spindle uses tools 1-100 and requires a manual change. Gang turning tools are 101 and up and do not require a stop, just correct offset applied which i have already done, then continue with program. So basically if old tool and new tool are both less than 101, i need a stop. If new tool is greater than 100, i dont need a stop. Also if old tool is greater than 100 and new tool is less than 101, i may or may not need a stop depending on whether or not its requesting a milling tool that was already in the milling spindle. For that i think im going to need to add a dro that stores the milling spindle tool so the script can refer to that when switching from a gang tool to milling tool.

    I understand how to write most of this but have a couple questions. First of all, how do i get an m6 to run without a stop between m6 start and m6 end? Currently i have the box checked in tool change configuration for "stop spindle, wait for cycle start" which gives the stop. I assumed i would just check "automatic tool change" instead and it would just run m6 start, then m6 end, then continue with program with no stops, but it just runs m6 start and then stops. Is "automatic tool change" just eliminating m6 end and i need to put the whole macro in m6 start instead?

    Once i get that figured out, what is the best way to trigger a stop and wait for cycle start in my macro? I was thinking i would just use a code "M1" and message when it meets the conditions for a needed stop, but is that the proper way to do it? I thought i read somewhere that its a bad idea to use M codes within M codes, but maybe they just meant dont call a full on macro within a macro.

    Next question, the conditional stop is going to happen long after the current tool has been set to selected tool, So when running through the conditions for the stop later on, i can no longer refer to current tool as the old tool since its already been set to the new tool. If i define the current tool as "old tool" in the beginning of the macro, then set current tool to selected tool, can i later on refer to "old tool" in my conditional stop? Or does my created variable "old tool" just take on the value of selected tool when i set current tool to selected tool? Not sure if created variables get redefined when you redefine the thing they were defined by.

    Still a newb at this scripting stuff, but slowly getting little bits of it.

  2. #2
    Join Date
    Dec 2013
    Posts
    5717

    Re: need tool change stop to be conditional

    M1 is the normal code for an Optional Stop. Exactly how this would be integrated with your macros I'm not sure. I guess that I would not use tool 100 under any condition, that way the code is a bit simpler, >100 or <100. I would think that 99 tools should be more than enough for any job.

    I need to think about your last question a bit.
    Jim Dawson
    Sandy, Oregon, USA

  3. #3
    Join Date
    Dec 2013
    Posts
    5717

    Re: need tool change stop to be conditional

    Regarding your last question, this is how my code works for my lathe:

    variable names (could be anything compatible with your system)
    TOOLNUM = CURRENT TOOL
    TOOLNEXT = NEW TOOL

    On a M6 the TOOLNEXT is passed to the tool change code.

    [tool change code here]

    and as the last step TOOLNUM is set to TOOLNEXT

    TOOLNUM is held in memory until the next tool change. (Also written to a parameter file so the current tool is saved on a reboot so the turret does not have to be homed on powerup)

    My actual code would be meaningless for your application.
    Jim Dawson
    Sandy, Oregon, USA

  4. #4
    Join Date
    Nov 2017
    Posts
    591

    Re: need tool change stop to be conditional

    Ok, as long as i know its ok to use m1 within a macro, i should be good to figure it out from there.

    heres an example of my variable naming question, lets say i come to a T2 M6 with tool 1 currently in the spindle. At the beginning of my m6 i define 2 variables like this:

    oldTool = GetCurrentTool() //variable oldTool is defined as 1
    newTool = GetSelectedTool() //variable newTool is defined as 2

    then i set the current tool to selected tool like this:

    SetCurrentTool(newTool) //current tool is set to 2

    now, after this point if i use the variable "oldTool", like in my conditional stop arguments, will it give a value of 1? or 2? Earlier it was defined as 1 with "oldTool = GetCurrentTool()", but did it get redefined as 2 when i called "SetCurrentTool(newTool)? Or does "oldTool" keep its value of 1, even though i redefined what was defining it?

    Regardless, its probably best to wait until the end of the m6 to set the current tool to selected tool, then it doesnt matter either way, but im still curious if a variable you created gets redefined when the source that defined it in the first place gets redefined. That might still be hard to follow lol. Ill found out soon enough when i actually write the thing.

  5. #5
    Join Date
    Dec 2013
    Posts
    5717

    Re: need tool change stop to be conditional

    Quote Originally Posted by QuinnSjoblom View Post

    Regardless, its probably best to wait until the end of the m6 to set the current tool to selected tool, then it doesnt matter either way, but im still curious if a variable you created gets redefined when the source that defined it in the first place gets redefined. That might still be hard to follow lol.
    The TOOLNUM variable gets redefined at the end of the tool change code. The TOOLNUM variable is only stored in the tool change controller. This is only used so the controller knows where it is when the M6 is issued, and thus knows how many tool positions to advance and in which direction for the shortest path.

    In a different system the variable could be stored in the CNC program, we are almost comparing apples to oranges here because of the vast differences in our two systems. But the logic is about the same.
    Jim Dawson
    Sandy, Oregon, USA

  6. #6
    Join Date
    Nov 2017
    Posts
    591

    Re: need tool change stop to be conditional

    ok, ill write it and see how it behaves. Maybe Gerry will chime in on the mach3 specifics.

    I also still need to know this part:
    "how do i get an m6 to run without a stop between m6 start and m6 end? Currently i have the box checked in tool change configuration for "stop spindle, wait for cycle start" which gives the stop. I assumed i would just check "automatic tool change" instead and it would just run m6 start, then m6 end, then continue with program with no stops, but it just runs m6 start and then stops. Is "automatic tool change" just eliminating m6 end and i need to put the whole macro in m6 start instead?"

  7. #7
    Join Date
    Mar 2003
    Posts
    35538

    Re: need tool change stop to be conditional

    Is "automatic tool change" just eliminating m6 end and i need to put the whole macro in m6 start instead?
    Yes, Automatic Tool Change runs M6 Start only,so put all of your code into M6Start.
    M1 is probably OK to use, because it's not running a macro.
    Personally, I'd just use a Message Box. This will Pause the macro until you click OK. So, you'll be clicking OK in the Message box to continue, rather than Cycle Start.

    If you are worried about overwriting variables, just add more to store any data that might get overwritten.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  8. #8
    Join Date
    Nov 2017
    Posts
    591

    Re: need tool change stop to be conditional

    Perfect, message box will work fine if its still only one click

Similar Threads

  1. Few questions: Cycle Stop, tool change and
    By chjade84 in forum UCCNC Control Software
    Replies: 5
    Last Post: 08-18-2016, 10:42 PM
  2. Spindle start and stop and tool change
    By inman20k in forum BobCad-Cam
    Replies: 1
    Last Post: 09-15-2012, 10:35 PM
  3. Spindle stop prior to tool change?
    By nitemare in forum Mori Seiki Mills
    Replies: 6
    Last Post: 04-21-2009, 12:37 PM
  4. What G Code to Stop for Tool Change?
    By teamtexas in forum G-Code Programing
    Replies: 1
    Last Post: 09-10-2008, 02:12 AM
  5. Tool Change - Can I set it to auto stop?
    By inthezone in forum Fanuc
    Replies: 16
    Last Post: 01-23-2008, 12:56 AM

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
  •