586,094 active members*
4,071 visitors online*
Register for free
Login
Page 2 of 2 12
Results 21 to 27 of 27
  1. #21
    endurance_robots Guest
    some software http://endurancerobots.com/download-center-lasers/ for creating gcode

  2. #22
    Join Date
    Feb 2008
    Posts
    216

    Re: Automatic Tool Change C Code

    Hi Tom,

    I've cleaned up the tool change and it's about 95% where I want it to be but fully functional for now. It's gotten more complicated since the last video now that the tools travel down alleys between holders so that they don't run into each other when going to the back row

    My issue is that I can't get a watch dog to work to prevent or bail on a tool change if the spindle gets turned on. I have an input from the VFD IO 1046 which goes Low when ever the VFD turns on the spindle.

    I've tried watch dog in different parts of the main file and it seems to hang up in the watch dog loop and not complete the tool change. Is there a better way to have the watch dog only active during the tool changing sequence and then turn off once complete?

    Current Code attached...
    Thanks,
    Dan

  3. #23
    Join Date
    May 2006
    Posts
    4045

    Re: Automatic Tool Change C Code

    Hi Dan,

    I don't fully understand your requirement. It seems you want to monitor IO 1046 and if it ever goes low during the Tool Change Sequence to abort the Tool Change Sequence? Wouldn't it be better to somehow prevent the Spindle from being turned on during the Tool Change Sequence?

    But to do the former I think you would need to "sprinkle" in tests throughout the code to check for IO Bit 1046 and if low return an error code. You would only need the check in places that wait for something to happen (sections of code that execute instantly would require any checks). So mainly time delays and wait while loops. You might create a new function int DelayAndCheckAllOK(double delay) that you could call instead of Delay_sec that would include the check (and possibly others) and return an error code if the spindle turned on.

    You could add a check right at the beginning to prevent anything from happening if the IO Bit is already low.

    HTH
    Regards
    TK
    http://dynomotion.com

  4. #24
    Join Date
    Feb 2008
    Posts
    216

    Re: Automatic Tool Change C Code

    Thanks Tom,

    My understanding of how the Watchdog worked was wrong. I thought it worked in the background or in parallel instead of in series with the rest of the C code in the Main program.

    My fix was to have the Tool Change code check that the spindle was turned off before starting. (i.e. Verify that IO 1046 is high). Then flag an Output IO high for the duration of the tool change.

    I then updated my C-code for spindle CW On command to look for the status of the new flag IO and abort the any attempted SPINDLE ON command if it finds it’s state to be high. (Which only occurs during tool changes) The flag then turns off at the end of the tool change.

    I’ve tested this at every step of the tool change code by trying to turn on the spindle with the on screen spindle button and it just completes whatever line of Tool change code it’s executing at the time and then stops all motion & activity. Which is safer than having the spindle turn on!

    Perhaps you can help me understand how Kflop handles multiple C code routines at once? I thought it was handle multiple routines in parallel based on which thread the code is loaded in. So I would have assumed that it would continue the tool change routine regardless of pressing the Spindle on command if both C code programs are on separate Threads? (I think I’m using different threads but would have to double check that). But I’ve noticed that if I’m running a C code routine like Homing or Part Zeroing and I click certain buttons in KmotionCNC it hangs on what it was doing. Is this due to how Kmotion CNC ranks the priority of activities? It’s not a big deal, we just don’t click anything during these routines, I’d just like to understand better how it’s working.

    Thanks,
    Dan

  5. #25
    Join Date
    May 2012
    Posts
    537

    Re: Automatic Tool Change C Code

    Thats basically how I did mine as well. Setting an output is probably fine, but the best thing for something like this is to set a persist.userdata variable. Simply use the code: persist.UserData[xxx] = 1; and then set it back to 0 at the end of toolchange program, and have your spindle program check for it. I check for toolchanger or rigid tapping active and if either is running the M3 program will end. Code is: if (persist.UserData[161] || persist.UserData[163]) return 0; // If toolchanger or tapping active, end

    These persist.userdata variables work great, they work between all programs and in different threads and i use em all over the place to set something in one program and have another program check for it. Good idea to set it equal to 0 in your init file too on start up.

  6. #26
    Join Date
    Jun 2004
    Posts
    355

    Re: Automatic Tool Change C Code

    For a simple check, setting a bit (either a virtual or spare output) is probably better than using a persist variable. Persist variables are doubles (64bit floating point number), so it's a bit overkill for a simple flag.

    Regarding C programs, threads, and priorities, nothing gets priority. Every thread gets an equal amount of processing time. It's up to you to ensure they don't conflict with each other, or overwrite existing threads when loading another program. If you're getting hangs when loading new programs, you've got a conflict somewhere. It could be you're overwriting an existing running thread that hasn't completed something, or you're using variables/bits in more than one thread that's causing a conflict (I.e. you're using the same VAR setting in KMontionCNC to transfer values for more than one purpose).

  7. #27
    Join Date
    May 2006
    Posts
    4045

    Re: Automatic Tool Change C Code

    Hi Dan,

    Perhaps you can help me understand how Kflop handles multiple C code routines at once? I thought it was handle multiple routines in parallel based on which thread the code is loaded in. So I would have assumed that it would continue the tool change routine regardless of pressing the Spindle on command if both C code programs are on separate Threads? (I think I’m using different threads but would have to double check that). But I’ve noticed that if I’m running a C code routine like Homing or Part Zeroing and I click certain buttons in KmotionCNC it hangs on what it was doing. Is this due to how Kmotion CNC ranks the priority of activities? It’s not a big deal, we just don’t click anything during these routines, I’d just like to understand better how it’s working.
    Your thinking is correct. Programs in different Threads should operate concurrently and in parallel without any priority. They all always get their Time Slice deterministically. See:

    KMotion/KFlop Multi-tasking

    However if you command a Program to run in a Thread that already has something in progress running, then the previous program will be killed at wherever it was. I suspect you are using the same Thread for multiple things that you expect to function in parallel.

    HTH
    Regards
    TK
    http://dynomotion.com

Page 2 of 2 12

Similar Threads

  1. DIY CNC - Automatic Tool change with Mach3
    By khanhnguyen in forum Mach Software (ArtSoft software)
    Replies: 0
    Last Post: 07-17-2016, 10:06 AM
  2. manual automatic tool change
    By krymis in forum Benchtop Machines
    Replies: 1
    Last Post: 08-15-2011, 08:01 AM
  3. Automatic Tool Change (ATC) - Help!
    By spotlite in forum Mach Wizards, Macros, & Addons
    Replies: 5
    Last Post: 05-18-2008, 11:16 AM
  4. Fanuc OI-mc Automatic Tool Change
    By dsgent in forum Fadal
    Replies: 3
    Last Post: 12-20-2007, 11:45 PM
  5. Manual Automatic Tool Change
    By ynneb in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 09-29-2004, 06:21 PM

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
  •