586,471 active members*
3,318 visitors online*
Register for free
Login
Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2004
    Posts
    1543

    Mach Parametric programming systax

    I'm trying to teach somebody parametric programming. He has a mach control. I am experienced but have never used Mach.

    Just GOTO, variables, loops, comments, sub routine calls. Or nothing real advanced. I need examples or a syntax manual.

    Karl

  2. #2
    Join Date
    Mar 2003
    Posts
    35538
    See the G-Code section at the back (section 10) of the Mach3 manual. http://www.machsupport.com/wp-conten...3Mill_1.84.pdf

    Mach3 doesn't supports Goto and loops.
    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)

  3. #3
    Join Date
    Mar 2004
    Posts
    1543
    Well, THAT sux.

    OK I see mach supports sub calls. This is just a bit confusing on first read. I could really use an example if somebody could help. Could somebody finish this up so its all ready from my friend to run?


    lets say my subroutine is:

    O100
    G1 X1
    Y1
    X0
    Y0
    G91
    G1 Z-0.1
    G90
    <return from sub code??>


    Main program

    G0 Z.5
    X0
    Y0
    M3
    M7
    Z0
    M98 P100 L5
    M5
    M9
    G0 Z.5
    <does Mach need end of program code??>
    <does Mach need line #>
    <is there a comment character??>








    10.8.7 Call subroutine - M98
    This has two formats:
    (a) To call a subroutine program within the current part program file code M98 P~ L~ or
    M98 ~P ~Q The program must contain an O line with the number given by the P word of
    the Call . This O line is a sort of "label" which indicates the start of the subroutine. TheO
    line may not have a line number (N word) on it. It, and the following code, will normally be
    written with other subroutines and follow either an M2, M30 or M99 so it is not reached
    directly by the flow of the program.
    (b) To call a subroutine which is in a separate file code M98(filename)L~
    for example M98 (test.tap)
    For both formats:
    The L word (or optionally the Q word) gives the number of times that the subroutine is to
    be called before continuing with the line following the M98. If the L (Q) word is omitted
    then its value defaults to 1.
    By using parameters values or incremental moves a repeated subroutine can make several
    roughing cuts around a complex path or cut several identical objects from one piece of
    material.
    Subroutine calls may be nested. That is to say a subroutine may contain a M98 call to
    another subroutine. As no conditional branching is permitted it is not meaningful for
    subroutines to call themselves recursively.

  4. #4
    Join Date
    Mar 2004
    Posts
    1543
    Second question, so I put it in another message.

    Does mach have a conversational module? That is, on many controls you can click "pocket", answer a series of questions and the machine will cut your pocket.

    Karl

  5. #5
    Join Date
    Mar 2013
    Posts
    13
    Thanks for posting. I was thinking (wishing) there was a "loop" or "goto" string that would complete a routine and then Z down until a set point; kinda like the drilling peck function but with X's and Y's in the string.

  6. #6
    Join Date
    Mar 2003
    Posts
    35538
    I don't use subs, so can't really help there.

    <does Mach need end of program code??>
    No, but if the last line doesn't have a carriage return, it will be ignored. As long as you click "enter" at the end of your last line in your editor, it should be fine. Or, to gaurantee you'll always be safe, you can add a % as the last line.

    <does Mach need line #>
    No, line numbers are optional. If you use them, they need to start with N.
    N1, N01, N001 are all valid options.

    <is there a comment character??>
    Put parenthesis around all comments.

    N250 T1 M6 (Tool Change)
    (Set Spindle Speed)
    N260 S5000
    ...


    There is a workaround for the goto and loop issues. You can create your own M codes in Mach3, which contain VB script. But it's very easy to run into "issues" (bugs?) when mixing g-code and scripting, so a lot of trial and error testing would be in order if you go this route.

    Mach4 is currently under development, and should remove all the current limitations. It's already taken several years, and may be at least 1 more before it's ready.
    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)

  7. #7
    Join Date
    Mar 2004
    Posts
    1543
    Pryotex:

    Load the below program in your control and let me know what happens.

    It *should* machine a 1 by 1 box, take Z down 0.1 inch and repeat five times resulting in a 1 X 1 box 0.5 deep.

    suggest you do it cutting air. You break less tooling that way


    G0 Z.5
    X0
    Y0
    M3
    M7
    Z0
    M98 P100 L5
    M5
    M9
    G0 Z.5
    %

    O100
    G91
    G1 Z-0.1 F2
    G90
    G1 X1 F10
    Y1
    X0
    Y0
    %

  8. #8
    Join Date
    Mar 2013
    Posts
    13
    Mach is not "seeing" the last %. It completes one cycle and then stops at Y0 and leaves the Z at -0.100

    Right now I need to do this (Part of it) Keep repeating with a Z step.
    G00X3.4830
    G00Y0.1270
    G01Z-0.100
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.200
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.300
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.400
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.500
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.600
    G01X5.1270
    G01Y-0.1270
    G01X3.4830
    G01Y0.1270
    G01Z-0.700

  9. #9
    Join Date
    Mar 2004
    Posts
    1543
    Tony,
    There's nothing at all wrong with just writing it out. it will work just fine. use copy paste in your favorite editor.

    If we can get this looping subroutine to work, you'll have a template for all future programs like this.
    I like this route better. Looping REALLY reduces the amount of code to write.

    Looks to me like the example program is missing an "end sub" command. probably an M code.

    Karl

    Edit try M99

    G0 Z.5
    X0
    Y0
    M3
    M7
    Z0
    M98 P100 L5
    M5
    M9
    G0 Z.5
    %

    O100
    G91
    G1 Z-0.1 F2
    G90
    G1 X1 F10
    Y1
    X0
    Y0
    M99
    %

  10. #10
    Join Date
    Mar 2003
    Posts
    35538
    Try this.

    G0 Z.5
    X0
    Y0
    M3
    M7
    Z0
    M98 P100 L5
    M5
    M9
    G0 Z.5
    M2 (End Program)

    O100
    G91
    G1 Z-0.1 F2
    G90
    G1 X1 F10
    Y1
    X0
    Y0
    M99 (Return from Sub)
    %
    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)

  11. #11
    Join Date
    Mar 2013
    Posts
    13
    That one worked The one from Karl could not generate the tool path for some reason (Mach3 does that when you load the code) It would hang. Now I need to streamline mine and see how it works.

    THANK YOU Karl for posting it here and thanks everyone for spitballing this. You CAN repeat a sequence and add Z to it :banana:

  12. #12
    Join Date
    Mar 2004
    Posts
    1543
    PROGRESS

    Get used to doing this. next learn to use G41 G42. This will let you write the Gcode from the part print, then select tooling later. Also lets you "adjust" clearance.

    Maybe you're never noticed, but some firearms don't fit exactly per print

    Let me know when you are ready.

    Karl

  13. #13
    Join Date
    Mar 2003
    Posts
    35538
    Be aware that Mach3 has some G41/G42 bugs that will occasionally rear their heads. Especially in subs I think.

    However, I use G41/G42 all the time, and rarely encounter them. But I have run across the occasional part where comp just won't work.
    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)

Similar Threads

  1. Parametric programming.
    By chrisryn in forum Parametric Programing
    Replies: 33
    Last Post: 12-03-2014, 02:33 AM
  2. Xilog 3 Parametric Programming Offline Programming
    By julioykaly in forum Commercial CNC Wood Routers
    Replies: 1
    Last Post: 04-27-2013, 09:22 PM
  3. New to Parametric Programming
    By dougdownunder in forum Parametric Programing
    Replies: 4
    Last Post: 09-11-2011, 02:32 PM
  4. Parametric Programming
    By gene rhodes in forum Parametric Programing
    Replies: 15
    Last Post: 07-26-2010, 10:32 AM
  5. Parametric Programming
    By gene rhodes in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 1
    Last Post: 06-30-2010, 12:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •