603,310 active members*
2,683 visitors online*
Register for free
Login
Page 4 of 6 23456
Results 61 to 80 of 101
  1. #61
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    I dunno - I got lost somewhere along the thread. Too much name-calling.
    This is my method for production work under mach3. It may have been mentioned already.

    #1=0 % Initial X offset
    ...
    m98 p10 L10 % make 10 parts along the X axis
    ....
    M30

    % subroutine to make one part
    o10
    g0 x[#1+5] y0
    g1 y10
    g1 x[#1+10]
    g1 y0
    g1 x[#1+5] % basically, mill out a square, but it doesn't matter
    #1=[#1+20.00] % move X reference point by 20 mm for NEXT part
    m99

    What I am doing is (obviously) adding my own offset parameter (#1) to EVERY X position in the subroutine, and incrementing the offset for each subroutine call.
    The wonderful thing about this method is that mach3 correctly displays the tool path for all 10 parts. I found that with some other methods you only got to see one part because the mach3 display code could not handle other forms of origin shifts.
    Limitation: all 10 parts must be at the same separation - in this case 20.00 mm on the X axis.
    I suspect that CAM programs canNOT do this sort of code generation, so you end up with very long programs which are a bit (very) opaque.

    HTH
    Roger

  2. #62
    Join Date
    Mar 2010
    Posts
    813

    Re: Help G54, G55, G56

    Quote Originally Posted by RCaffin View Post
    I dunno - I got lost somewhere along the thread. Too much name-calling.
    This is my method for production work under mach3. It may have been mentioned already.

    #1=0 % Initial X offset
    ...
    m98 p10 L10 % make 10 parts along the X axis
    ....
    M30

    % subroutine to make one part
    o10
    g0 x[#1+5] y0
    g1 y10
    g1 x[#1+10]
    g1 y0
    g1 x[#1+5] % basically, mill out a square, but it doesn't matter
    #1=[#1+20.00] % move X reference point by 20 mm for NEXT part
    m99

    What I am doing is (obviously) adding my own offset parameter (#1) to EVERY X position in the subroutine, and incrementing the offset for each subroutine call.
    The wonderful thing about this method is that mach3 correctly displays the tool path for all 10 parts. I found that with some other methods you only got to see one part because the mach3 display code could not handle other forms of origin shifts.
    Limitation: all 10 parts must be at the same separation - in this case 20.00 mm on the X axis.
    I suspect that CAM programs canNOT do this sort of code generation, so you end up with very long programs which are a bit (very) opaque.

    HTH
    Roger

    Thanks Roger this is great info. rcs60 suggested and showed a subroutine on the first page of this thread, but what he showed making a single part in different offsets(54,55,etc). Is it possible to have a subroutine within a subroutine? Make the 10 parts than moving to different offset and repeating?




    Quote Originally Posted by rcs60 View Post
    i would write it as a subroutine
    this is from a haas control similar to fanuc(may have to be writen as a seperate program then called up )(O1011 instead of N1011)


    N1
    ( 3/8 FLAT ENDMILL DIA. - .375 )
    T1 M06

    S6100 M03 T2
    G00 G90 G54 X-0.156 Y-0.4 A0.
    G43 H01 Z1.
    M08
    M97 P1011


    G55 X-0.156 Y-0.4
    M97 P1011

    G56 X-0.156 Y-0.4
    M97 P1011

    G57 X-0.156 Y-0.4
    M97 P1011

    N100
    G00 Z1. M09
    G91 G28 Z0. M05
    M30

    N1011
    G00 Z0.107
    G01 Z0. F50.
    Y1.3 F72.
    X0.156
    Y-0.4 F72.
    G00 Z1.
    M99

  3. #63
    Join Date
    Sep 2006
    Posts
    6463

    Re: Help G54, G55, G56

    Hi.....a sub routine relies on having the second or other parts, vices, fixtures etc at exact positions relative to one another, like on a machined jig plate with tool nests etc......same with a Macro as long as the control supports it.

    I've found now that I can create the multi tool machining code by copying and pasting it in Notepad then editing it slightly......this works with a second vice or fixtures that are not remotely related position wise to each other.......each needs to have the G54 55 56 offset created first in Mach 3 for each position.

    The real gain for the multi position mode is if you have something like a plate with many positions the same on it but not spaced the same apart, especially where you have largish holes that require a facing operation first followed by helical interpolation to cut the holes.....that's a tedious exercise to repeat each time, after you've got it right first time.
    Ian.

  4. #64
    Join Date
    Mar 2010
    Posts
    813

    Re: Help G54, G55, G56

    Quote Originally Posted by handlewanker View Post
    Hi.....a sub routine relies on having the second or other parts, vices, fixtures etc at exact positions relative to one another, like on a machined jig plate with tool nests etc......same with a Macro as long as the control supports it.

    I've found now that I can create the multi tool machining code by copying and pasting it in Notepad then editing it slightly......this works with a second vice or fixtures that are not remotely related position wise to each other.......each needs to have the G54 55 56 offset created first in Mach 3 for each position.

    The real gain for the multi position mode is if you have something like a plate with many positions the same on it but not spaced the same apart, especially where you have largish holes that require a facing operation first followed by helical interpolation to cut the holes.....that's a tedious exercise to repeat each time, after you've got it right first time.
    Ian.

    Sorry lan I'm just not getting it...lol

    Wouldn't the subroutine shown by rsc60 do the same thing as long as you have your x0 y0 set in each offset you use and where you want in Mach?

  5. #65
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    Is it possible to have a subroutine within a subroutine?
    Absolutely!
    In theory (programming language theory) you should be able to nest subroutines as deep as you like. There are known language technlogies for this. In the case of Mach3 you should be a shade careful as Mach3 can get a bit confused if you nest too deeply -beyond 4 or 5 levels. A design fault in the implementation I am afraid.

    rcs60 used M97 to call a subroutine. That is not standard NIST g-code as far as I know, but if the controller mfr uses it, ...

    Wonderous things are possible with parameters and subroutines.

    Cheers
    Roger

  6. #66
    Join Date
    Mar 2010
    Posts
    813

    Re: Help G54, G55, G56

    Quote Originally Posted by RCaffin View Post
    Is it possible to have a subroutine within a subroutine?
    Absolutely!
    In theory (programming language theory) you should be able to nest subroutines as deep as you like. There are known language technlogies for this. In the case of Mach3 you should be a shade careful as Mach3 can get a bit confused if you nest too deeply -beyond 4 or 5 levels. A design fault in the implementation I am afraid.

    rcs60 used M97 to call a subroutine. That is not standard NIST g-code as far as I know, but if the controller mfr uses it, ...

    Wonderous things are possible with parameters and subroutines.

    Cheers
    Roger
    I made a test program of a 12" x 12" square and was having trouble getting it to work. I replaced the M97 with M98(Thank you) and replaced N with O for the subroutine and it worked flawless. I successively cut the same part in three different offsets(54,55,56) and each offset set with a different x0 and y0. Below is the code I used.



    O0000 (offset test)

    G20 G40 G80 G17

    N1 (FLAT 1-4 IN 2F EC SCB)
    G00 G90 G43 G54 X-0.125 Y-0.125
    T1 M6
    Z1.
    S8000 M3
    M9
    M98 P0001


    G55 X-0.125 Y-0.125
    M98 P0001

    G56 X-0.125 Y-0.125
    M98 P0001

    G91 G28 X0 Y0
    M30

    o0001
    G00 Z0.5
    G01 Z-0.5 F144.
    Y12.125 F288.
    X12.125
    Y-0.125
    X-0.125
    G00 Z1.
    M99

  7. #67
    Join Date
    Jan 2005
    Posts
    15362

    Re: Help G54, G55, G56

    Dan911

    Just change the end of your program you could quite easy have a crash G91 G28 Y0 Z0 Never do a Z axes move with an Axes move always move the Z out the way first, then you can do both axes X and Y on the Same line it you want like if you like using a G91 G28

    G91 G28 Z0.
    G91 G28 Y0.

    This line also o0001 needs to be O0001

    O0000 (offset test)

    G20 G40 G80 G17

    N1 (FLAT 1-4 IN 2F EC SCB)
    G00 G90 G43 G54 X-0.125 Y-0.125
    T1 M6
    Z1.
    S8000 M3
    M9
    M98 P0001


    G55 X-0.125 Y-0.125
    M98 P0001

    G56 X-0.125 Y-0.125
    M98 P0001

    G91 G28 Y0 Z0
    M30

    o0001
    G00 Z0.5
    G01 Z-0.5 F144.
    Y12.125 F288.
    X12.125
    Y-0.125
    X-0.125
    G00 Z1.
    M99
    Mactec54

  8. #68
    Join Date
    Jan 2005
    Posts
    15362

    Re: Help G54, G55, G56

    Quote Originally Posted by RCaffin View Post
    rcs60 used M97 to call a subroutine. That is not standard NIST g-code as far as I know, but if the controller mfr uses it, ...
    Wondrous things are possible with parameters and subroutines.Roger
    M97 is a normal standard Code it's a different way the sub can be used and only some controls use it, here is an explanation of it and how to use it

    "What is M-CODE M97, M98 & M99 (Sub Programs or Sub Routines) Mean in CNC Programming"
    M-Code M97, M98 and M99 Sub programming M-Codes
    M97 Local Sub-Program Call (P, L):
    M97 is the M-code Used to call a Subprogram with the reference of the line number N within the same program. Pxxxx code is used as a line number to be repeated. Xxxx is the line number in the same program. This is used for the simple program within the program and does not require complication of creating a sub program. A local sub-program must end with an M99. If there is a repetition of the loop of subprogram L count on the M97 line, the sub-program will be repeated L number of times.
    M97 Program Format:
    M97 Pxxxx Lnn
    Whereas, xxxx is the line number
    nn is the number of repetitions
    Example:
    Main program:
    O01234 (Program number and Start of main program)
    N0001 T02 M06;
    N0002 T03
    N0003 G54 G90 G00 Z50
    ...
    ...
    ... (Part program)
    ...
    M97 P0015 L3 (Jumps to line N0015, after the M30, to execute a local sub-program for 3 times)
    ... (The M99 at the end of the sub-program will cause it to jump back here.)
    ...
    ...
    ... (Finish part program)
    ...
    M30 (End of main program)
    N0015 (Identifies the start of the Local Sub-Program called up by M97 P0015)
    Mactec54

  9. #69
    Join Date
    Mar 2010
    Posts
    813

    Re: Help G54, G55, G56

    Quote Originally Posted by mactec54 View Post
    Dan911

    Just change the end of your program you could quite easy have a crash G91 G28 Y0 Z0 Never do a Z axes move with an Axes move always move the Z out the way first, then you can do both axes X and Y on the Same line it you want like if you like using a G91 G28

    G91 G28 Z0.
    G91 G28 Y0.

    This line also o0001 needs to be O0001

    O0000 (offset test)

    G20 G40 G80 G17

    N1 (FLAT 1-4 IN 2F EC SCB)
    G00 G90 G43 G54 X-0.125 Y-0.125
    T1 M6
    Z1.
    S8000 M3
    M9
    M98 P0001


    G55 X-0.125 Y-0.125
    M98 P0001

    G56 X-0.125 Y-0.125
    M98 P0001

    G91 G28 Y0 Z0
    M30

    o0001
    G00 Z0.5
    G01 Z-0.5 F144.
    Y12.125 F288.
    X12.125
    Y-0.125
    X-0.125
    G00 Z1.
    M99

    Yes it will, and has caused me problems some time ago. I copied and pasted from some old code I had on this comp that I no longer use for designing and generating Gcode, I use just for online.. My Alphacam PP been modified since than, I edited the post. Regardless...The G00 Z1 in subroutine already moved the Z.



    Quote Originally Posted by mactec54 View Post
    M97 is a normal standard Code it's a different way the sub can be used and only some controls use it, here is an explanation of it and how to use it

    "What is M-CODE M97, M98 & M99 (Sub Programs or Sub Routines) Mean in CNC Programming"
    M-Code M97, M98 and M99 Sub programming M-Codes
    M97 Local Sub-Program Call (P, L):
    M97 is the M-code Used to call a Subprogram with the reference of the line number N within the same program. Pxxxx code is used as a line number to be repeated. Xxxx is the line number in the same program. This is used for the simple program within the program and does not require complication of creating a sub program. A local sub-program must end with an M99. If there is a repetition of the loop of subprogram L count on the M97 line, the sub-program will be repeated L number of times.
    M97 Program Format:
    M97 Pxxxx Lnn
    Whereas, xxxx is the line number
    nn is the number of repetitions
    Example:
    Main program:
    O01234 (Program number and Start of main program)
    N0001 T02 M06;
    N0002 T03
    N0003 G54 G90 G00 Z50
    ...
    ...
    ... (Part program)
    ...
    M97 P0015 L3 (Jumps to line N0015, after the M30, to execute a local sub-program for 3 times)
    ... (The M99 at the end of the sub-program will cause it to jump back here.)
    ...
    ...
    ... (Finish part program)
    ...
    M30 (End of main program)
    N0015 (Identifies the start of the Local Sub-Program called up by M97 P0015)

    I already read this when googling/researching why rcs60 subroutine wasn't working. Not sure if it was changing the M97 to M98 or the N to O on the subroutine that fixed it. He(rcs60) did note this on his original post on first page of thread.

  10. #70
    Join Date
    Jan 2005
    Posts
    15362

    Re: Help G54, G55, G56

    Quote Originally Posted by Dan911 View Post
    I already read this when googling/researching why rcs60 subroutine wasn't working. Not sure if it was changing the M97 to M98 or the N to O on the subroutine that fixed it. He(rcs60) did note this on his original post on first page of thread.
    The O would stop it, but if you are running Mach3 almost anything will run

    I already said M97 does not run on all controls, it would have to be also formatted correctly also,if it was going to run, it is different from the M98
    Mactec54

  11. #71
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    Hi Mactec

    if you are running Mach3 almost anything will run
    Most anything - as long as it is valid NIST-compliant g-code.

    I am not sure I am understanding the M97 bit correctly. It this right?

    m98 p10 L3
    ...
    m30

    o10
    ...
    m99

    %-----------

    N20 m97 N50 L3
    ...
    N40 m30

    N50 g1 ...
    ...
    N80 m99

    In other words, M97 calls a subrountine by line number, while M98 calls a subrotine by subroutine name?
    If so, there's damn all difference except that M97 means you have to have line numbers everywhere. I cannot be bothered with that myself.

    Cheers
    Roger

  12. #72
    Join Date
    Mar 2010
    Posts
    813

    Re: Help G54, G55, G56

    Quote Originally Posted by mactec54 View Post
    The O would stop it, but if you are running Mach3 almost anything will run

    Huh???? Using the O in front of the subroutine call is what got it to run in Mach3. I didn't capitalize O but the lower case works. Please read post before commenting. Post #64, try the code it works!

  13. #73
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    Chuckle chuckle snigger snigger
    And now for something a little more esoteric.

    You have a subroutine o10 which you want to call at several different places across the job. But those places are NOT a neat and tidy grid with a fixed dX and dY between them.Oh no: the ref positions are scattered far and wide. But there ARE a lot of them: far too many to manually edit N copies of the SR. How?

    #10=0.0 % X for part 0
    #11=3.8 % for part 1
    #12=5.6 % part 2
    #13=8.2 % etc

    #20=0.0 % Y for part 0
    #21=2.6 % Y for part 1
    #22=4.5 % etc
    #23=7.8

    #30=4 % N parts (N=4 here)

    #1=0 % Point to part 0
    m98 p10 L#30 % call sub N times
    ...
    m30

    o10
    #1=#[#1+10] % next X ref
    #2=#[#1+20] % next Y ref
    g0 x#1 y#2 % go to next ref pt
    g1 x[#1+5] y#2
    ......
    #1=[#1+1] % jog index pointer to next place
    m99

    To explain: suppose #1=2 (for part 2)
    Then [#1+10] = 12
    Then #[#1+10] = #12 = 5.6
    And so on. We have built an indexed array! 100% legal (and logical) in Mach3.

    Cheers
    Roger

  14. #74
    Join Date
    Sep 2006
    Posts
    6463

    Re: Help G54, G55, G56

    Hi....getting a bit complicated.......what happens when you run out of G54.....G59 offsets?....that gives you only 6 position to zero in on.......what happens if you need more than 6?.....it's hardly likely that anyone would mount 6 vices or loose fixtures on a mill table.

    If the only solution is to go to a sub routine, you'd need to have some method to align all of the vice jaws each true to the X axis and each spacing too......precisely...... to enable the X or Y move to take place......that would be a huge set-up.

    As far as I can see there would be no time gain with a multi set-up apart from the operator not having to open the door that often. .....the time to mount and cut each part remains a product of the number of parts be it for one or 100.....not something that I'll indulge in too frequently.

    What I've learned now is the different functions with sub routines where M97 and M98 are used.
    Ian.

  15. #75
    Join Date
    Jan 2005
    Posts
    1943

    Re: Help G54, G55, G56

    Some controllers have more offsets.

    LinuxCNC as 9: G54-G59, G59.1, G59.2, G59.3 (9 total)

    Haas has G54-G59 and G110-G129 (that's 26 total)

    Others have G54-G59 and G54.1 Pxxx where Pxxx defines another offset. The range is dependent on controller, sometimes as many as 254

    Others have G54-G59 and G59.1 Pxxx where Pxxx defines another offset. The range is dependent on controller, sometimes as many as 254

  16. #76
    Join Date
    Sep 2006
    Posts
    6463

    Re: Help G54, G55, G56

    Hi.....thanks for that....not sure what my controller supports....I'll probably not want to go beyond the G59 but it's nice to know you could......if I do a test G code sequence and type G59-1, and the code is accepted.....woopee do... another success story.
    Ian.

  17. #77
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    that gives you only 6 position to zero in on
    Just so. Which is why it is useful to have other methods.
    I often machine 10 units at a time, using the #1 offset method shown above.
    But it does not have to be 10 separate vises on the table: often I am cutting 10 units out of one bit of plate.

    You can change the offsets in the table using the G10 L1 command. This can go on for ... hours. You can also reset the offsets for entry n using G10 L2 Pn X~ Y~ Z~ ... (Note that G10 L1 is a bit strange - caution!)
    If you use G10 L2, you can then use G59 Pn to select offset n from the 256 entry offset table.

    If you don't want to use the offset table. you can do a temporary offset using G52 X~ Y~ Z~ A~ B~ C~ (or G92, but do NOT mix them). I use G52 quite a lot at times, but cut air the first time to make sure your offsets are in the right direction!

    Cheers
    Roger

  18. #78
    Join Date
    Sep 2006
    Posts
    6463

    Re: Help G54, G55, G56

    Hi.....yes.....many parts cut from one bit of plate....a sub routine would be the way to go as the positions can be allocated to specific dimension/spacings for each and the procedure is clamp the plate and hit the button to go.

    I'm going to have to delve more deeply into the sub routine process as it's still a puzzle to me.
    Ian.
    .

  19. #79
    Join Date
    Jun 2010
    Posts
    4259

    Re: Help G54, G55, G56

    Hi Ian

    There is no mystery. Good programming starts with a clear statement of what you want to do. And I am dead serious here.

    Cheers
    Roger

  20. #80
    Join Date
    Jan 2005
    Posts
    15362

    Re: Help G54, G55, G56

    Quote Originally Posted by Dan911 View Post
    Huh???? Using the O in front of the subroutine call is what got it to run in Mach3. I didn't capitalize O but the lower case works. Please read post before commenting. Post #64, try the code it works!
    Using a O in any program is normal, no one said it was wrong, having it Lower Case will cause a problem, in a normal Control, As I said Mach3 will except wrongly written Code that other controls will Fault out
    Mactec54

Page 4 of 6 23456

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
  •