Results 1 to 6 of 6

Thread: Conditional gcode execution in Mach3

  1. #1
    Registered
    Join Date
    Nov 2006
    Location
    usa
    Posts
    106
    Downloads
    0
    Uploads
    0

    Conditional gcode execution in Mach3

    Hi Folks, I just posted an article in the gcode forum describing how I am using conditional code execution in Mach with my Tormach for complex multi-part fixturing, among other uses.

    You can read the long-winded posting here:
    Condition gcode execution is possible in Mach3

    The abbreviated version is this:

    Set a binary flag (0 or 1) depending on your condition, then multiply this flag by the intended subroutine label on the M98 line to either execute the subroutine or to execute subroutine 0, which is coded to return immediately. This is an example of an if-then clause. An if-then-else clause can be constructed by adding the flag to a base label number. If the flag is clear, the base subroutine is called, if it is set then a different subroutine label is called (base+1).

    Example:
    Code:
     
    #5 = 0                 (this enable flag must be 0 or 1)
    M98 P[ #5 * 20 ]   ( if( #5 is 1 ) then call sub 20, else nothing )
    M98 P[ #5 + 21 ]   ( if( #5 is 1 ) then call sub 22, else call sub 21 )
    M30
     
    O0 (do nothing subroutine)
    M99
     
    O20 (operation subroutine)
    ... (do stuff)
    M99
     
    O21 (flag clear subroutine)
    ...
    M99
     
    O22 (flag set subroutine)
    ...
    M99


  2. #2
    Registered zephyr9900's Avatar
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,026
    Downloads
    0
    Uploads
    0
    Very nice, bobeson. It is a powerful tool, and I might have an immediate application for it, one I was just thinking about this afternoon. Thank you for this!

    Randy


  3. #3
    Registered
    Join Date
    Mar 2005
    Location
    Canada
    Posts
    134
    Downloads
    0
    Uploads
    0
    I've always wondered about doing something like this. Thanks for the great info, I know I can use it to clean up some of my current files.


  4. #4
    Registered
    Join Date
    Feb 2009
    Location
    usa
    Posts
    84
    Downloads
    0
    Uploads
    0
    What kind of application would one ever use a conditional statement in the CNC world? I'm new to the CNC stuff and I'm sure this question shows it. lol


  • #5
    Registered
    Join Date
    Mar 2005
    Location
    Canada
    Posts
    134
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by banctecbobn View Post
    What kind of application would one ever use a conditional statement in the CNC world? I'm new to the CNC stuff and I'm sure this question shows it. lol
    For me the best use is if I'm making a batch of 20-50 items in one run and want some of them to be slightly different. For example if I want a third to have one company logo and the other 2 thirds to have no logo.


  • #6
    Registered zephyr9900's Avatar
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,026
    Downloads
    0
    Uploads
    0
    I realized my change could actually be done in the postprocessor.

    My primary spindle tools 1-99, Proxxon tools are 100 and up. At the toolchange, I normally have M998 to raise the head to toolchange position. As this is excessive for Proxxon toolbits, I have been hand-replacing M998 with G00 Z3.0000 in the gcode when I'm using the Proxxon (separate thread for TTS-type operation with the Proxxon).

    But now in the Sheetcam postprocessor, I have a test for the tool number, and write the appropriate line to the file.

    Still credit to bobeson for the inspiration.

    Randy


  • Similar Threads

    1. Condition gcode execution is possible in Mach3
      By bobeson in forum G-Code Programing
      Replies: 2
      Last Post: 12-05-2009, 02:20 PM
    2. Conditional loop problem
      By eagle73 in forum Controller & Computer Solutions
      Replies: 0
      Last Post: 12-19-2008, 05:14 PM
    3. Replies: 7
      Last Post: 12-14-2006, 01:33 PM
    4. Shoptask CNC Lathe and Mach3: Gcode delima
      By KaptainKarst in forum Shopmaster/Shoptask
      Replies: 20
      Last Post: 08-05-2006, 06:55 PM
    5. Does Mach3 tool diameter override gcode setting?
      By WarrenW in forum Mach Software (ArtSoft software)
      Replies: 1
      Last Post: 04-27-2006, 09:09 AM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.