need tool change stop to be conditional


Results 1 to 8 of 8

Thread: need tool change stop to be conditional

  1. #1
    Member QuinnSjoblom's Avatar
    Join Date
    Nov 2017
    Location
    bigfork
    Posts
    591
    Downloads
    0
    Uploads
    0

    Default 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.

    Similar Threads:


  2. #2
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default 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
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default 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
    Member QuinnSjoblom's Avatar
    Join Date
    Nov 2017
    Location
    bigfork
    Posts
    591
    Downloads
    0
    Uploads
    0

    Default 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.

    Last edited by QuinnSjoblom; 07-05-2019 at 03:24 PM.


  5. #5
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default 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
    Member QuinnSjoblom's Avatar
    Join Date
    Nov 2017
    Location
    bigfork
    Posts
    591
    Downloads
    0
    Uploads
    0

    Default 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
    Member ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    35538
    Downloads
    1
    Uploads
    0

    Default 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
    [URL]http://www.thecncwoodworker.com/2017.html[/URL]

    Mach3 2010 Screenset
    [URL]http://www.thecncwoodworker.com/2010.html[/URL]

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

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


  8. #8
    Member QuinnSjoblom's Avatar
    Join Date
    Nov 2017
    Location
    bigfork
    Posts
    591
    Downloads
    0
    Uploads
    0

    Default Re: need tool change stop to be conditional

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



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

need tool change stop to be conditional

need tool change stop to be conditional