Need Help! Automatic Tool Change C Code


Page 1 of 2 12 LastLast
Results 1 to 12 of 20

Thread: Automatic Tool Change C Code

  1. #1
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Automatic Tool Change C Code

    Hi Tom,

    We are trying to write the C Code for the tool change so that we can send a video of it doing everything.

    When I compile and run the Automatic Tool Change Example from the Dynomotion Wiki the console screen shows an error: "Unable to open/read file:c:\Temp\ToolChangerData.txt"

    Is this going to impact the program? How do I correct this error? I'm running windows 10.

    Thanks,
    Dan

    Similar Threads:


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2236
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Dan,

    That is the file used to keep track of the last loaded tool. It should just contain a number. You might use notepad and create it. Use -1 to do indicate no tool loaded.

    But if KMotionCNC is running and the file isn't valid the operator should be asked to enter the last loaded tool. Is KMotionCNC running?

    Regards

    TK
    http://dynomotion.com


  3. #3
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Tom,

    Yeah I get a message at the start every time to identify the last loaded tool. If the file isn't valid that won't impact anything?

    Thanks,
    Dan



  4. #4
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2236
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Dan,

    I don't understand what you mean by that and you didn't answer my question whether you are running KMotionCNC.

    Is the Operator asked which Tool is loaded?

    Does your Windows C Drive have a C:\Temp Directory?

    The code is written such that if it can't determine if or which tool is loaded it will not load any tool and will Halt the GCode.

    Regards

    TK
    http://dynomotion.com


  5. #5
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Quote Originally Posted by TomKerekes View Post
    Hi Dan,

    I don't understand what you mean by that and you didn't answer my question whether you are running KMotionCNC.

    Is the Operator asked which Tool is loaded?

    Does your Windows C Drive have a C:\Temp Directory?

    The code is written such that if it can't determine if or which tool is loaded it will not load any tool and will Halt the GCode.

    Regards
    Currently I'm writing the C code in the Kmotion C Code editor. I have the Machine Initialized using the KmotionCNC. When I want to run the tool change code I click the "Save/Compile/Download/Run" Button.

    KmotionCNC then asks which tool is in the tool changer. I type 1 and then it begins the unload sequence (that's as far as I am).

    Is there a better way to test my code? Should I assign my test code to the M6 command in the KmotionCNC Tool Setup Screen?

    When I look at the C Drive there is no C:\Temp folder, can I make a new folder anywhere and then reference that new folder? (I tried this and got the same error message)



  6. #6
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2236
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Dan,

    Currently I'm writing the C code in the Kmotion C Code editor. I have the Machine Initialized using the KmotionCNC. When I want to run the tool change code I click the "Save/Compile/Download/Run" Button.

    KmotionCNC then asks which tool is in the tool changer. I type 1 and then it begins the unload sequence (that's as far as I am).

    Is there a better way to test my code? Should I assign my test code to the M6 command in the KmotionCNC Tool Setup Screen?
    You can test your code using either of those methods but if you run the code from the C Code Editor you should be aware that the code expects the tool number to be loaded into persist Variable #9. So you should manually set that value the same as what the M6 Txx would do automatically. The definition shown below is what determines where the Tool number is expected:

    #define TOOL_VAR 9 // Tool changer desired new tool Var




    When I look at the C Drive there is no C:\Temp folder, can I make a new folder anywhere and then reference that new folder? (I tried this and got the same error message)
    It isn't clear to me what you actually tried. But this definition in the code determines what folder is to be used to find which file. (note the double slashes are needed in C to specify a single slash as the slash character is an "escape" character used to treat the following character in a special manner):

    #define TOOL_DISK_FILE "c:\\Temp\\ToolChangerData.txt"


    HTH
    Regards

    TK
    http://dynomotion.com


  7. #7
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Ok thanks that all makes sense. The double/single slash part I had no idea about. I'll try it the correct way this time.



  8. #8
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Quote Originally Posted by slimneill View Post
    Ok thanks that all makes sense. The double/single slash part I had no idea about. I'll try it the correct way this time.

    Hey Tom I got the Tool change working, which I thought would take us a lot longer. Now that I'm debugging it there are a few things that I noticed that I would like to address.

    1. The bigger issue that I'm facing is that I have a number of fail safes built into the tool change and if at any point in the code a fail safe is tripped the tool change is aborted, which is good. But there is no logic for the tool change to ask me what tool is currently in the spindle after a failed tool change attempt. For example, I perform a tool change T2 M6 with current tool being T1. The tool change gets all the way to installing T2 into spindle and then quits outs (Tool 2 is now in the spindle). When I try to do a tool change again it still thinks Tool 1 is the tool in the spindle and try's to drop off Tool 2 into a loaded tool holder. Is there a simple way to add the question of what tool is in the spindle at the moment the machine spits out an error message and aborts the tool change?

    2. If I notice that the tool holder isn't going into the desired location (See issue 1 above) I hit the feed hold button which is set up in my initialization file. But when I go this it only stops the motion, the tool change process continues on with dumping the tool and only aborts when it doesn't sense the new tool. I never really noticed that the C code continues on with the feedhole button activated hit until now. Is there a simple way to change this? Do I modify the Initialization file to freeze all commands or do I do something in the C Code for tool change?

    3. I also noticed that now that I have the tool change Code in the M6 command. When ever I change the Tool on the KmotionCNC Tool ID drop down box the machine automatically does a tool change to that tool even if I'm just flipping through them. Which I don't want it to do during a job setup when I'm working around that area. Is there a way to prevent the tool change feature from activating off of the Tool ID Drop down box?

    Thanks for your help!
    Dan



  9. #9
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2236
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Dan,

    1. The bigger issue that I'm facing is that I have a number of fail safes built into the tool change and if at any point in the code a fail safe is tripped the tool change is aborted, which is good. But there is no logic for the tool change to ask me what tool is currently in the spindle after a failed tool change attempt. For example, I perform a tool change T2 M6 with current tool being T1. The tool change gets all the way to installing T2 into spindle and then quits outs (Tool 2 is now in the spindle). When I try to do a tool change again it still thinks Tool 1 is the tool in the spindle and try's to drop off Tool 2 into a loaded tool holder. Is there a simple way to add the question of what tool is in the spindle at the moment the machine spits out an error message and aborts the tool change?
    One thought would be to set the LastTool as 0 (undefined/unknown) using SaveCurrentTool(0) on any Tool Change Abort. That should cause the Operator to be prompted whenever the next tool is to be loaded.

    2. If I notice that the tool holder isn't going into the desired location (See issue 1 above) I hit the feed hold button which is set up in my initialization file. But when I go this it only stops the motion, the tool change process continues on with dumping the tool and only aborts when it doesn't sense the new tool. I never really noticed that the C code continues on with the feedhole button activated hit until now. Is there a simple way to change this? Do I modify the Initialization file to freeze all commands or do I do something in the C Code for tool change?
    Feed Hold only stops the axes that are defined in the Coordinate System. I suppose you could sprinkle in tests for Feed Hold (CS0_StoppingState != 0) in all your wait loops and do what is appropriate. Such as stop all the axes (Jog to zero speeds), or disable axes, or whatever and then abort.

    3. I also noticed that now that I have the tool change Code in the M6 command. When ever I change the Tool on the KmotionCNC Tool ID drop down box the machine automatically does a tool change to that tool even if I'm just flipping through them. Which I don't want it to do during a job setup when I'm working around that area. Is there a way to prevent the tool change feature from activating off of the Tool ID Drop down box?
    Well that is supposed to be what the Tool drop down is for. Why would you be flipping through Tools? Do you have "M6 on Tool Table Changes" selected in Tool Setup | Trajectory Planner? That will cause the tool to be reloaded whenever the Tool Table is Changed/Closed.

    Regards

    TK
    http://dynomotion.com


  10. #10
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Tool Change In Action, Thanks for the Awesome Support Tom!

    More videos to come of the drill and laser in action.







  11. #11
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2236
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Hi Dan,

    Wow. Impressive machine. Can't wait for the other videos with it actually doing something

    Any chance your willing to share your final Tool Changer Code?

    Regards

    TK
    http://dynomotion.com


  12. #12
    Registered
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    189
    Downloads
    0
    Uploads
    0

    Default Re: Automatic Tool Change C Code

    Thanks Tom,

    Its not done yet, this was just as far as I was able to get in one weekend. Once everything is operational and bugs ironed out i'll post the code. I've tried to add to the wiki before but it didn't work when I tried to add the part zero probe code.

    On a side note, the machine still automatically performed a tool change when you select a different tool in the drop down box tool selection box even when the perform M6 command option is unchecked in the tool setup screen. Is there something in my code that needs to be changed or the KmotionCNC?

    Thanks,
    Dan



Page 1 of 2 12 LastLast

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

Automatic Tool Change C Code
Automatic Tool Change C Code