586,345 active members*
3,227 visitors online*
Register for free
Login
Results 1 to 20 of 20
  1. #1
    Join Date
    Sep 2004
    Posts
    13

    Repeat g-code with y offset

    I have some g-code to mill 2 pockets in a box. The final fixture will have 5 of these pocket pairs with a 2.5" Y offset. That way I can mill 5 boxes at a time. Is there a way to have the g-code I already have repeat 4 more times, offseting the Y 2.5" each time?

    I have attached a zip file containing the g-code and the dxf showing all of the pockets.

    Thanks
    Tim
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2003
    Posts
    106
    There are several ways to do this but I think the simplest would be to save your existing program as a subroutine and then call it up after changing the "start" position. Your "start" position, or Y offset, can be changed in your program several ways also. You can use G10 to input the offsets, you can use G52 to shift the offsets or you can set the 5 positions with G54-G59 and call a new offset before running the subroutine. You didn't say what machine or control you are using so check your manuals for the proper way to use the G-codes and subroutines.

  3. #3
    Join Date
    Sep 2004
    Posts
    13
    E-stop
    Thanks for the reply.

    I am pretty new to g-code. Could give me a short snippet of code demonstrating one of the methods you suggest?

    I am using a gantry style cnc router like this one.
    http://cgi.ebay.com/ws/eBayISAPI.dll...847964271&rd=1

    I use CNCZeus to control the router.

    Thanks
    Tim

  4. #4
    Join Date
    Mar 2003
    Posts
    106
    I'm not at all familiar with the CNCZeus control but here's the way I would do it, if your control accepts the G10 command.

    G10G90L2P2X0Y0 <---Sets G55 to X0 Y0
    G10G90L2P3X0Y2.5 <---Sets G56 to X0 Y2.5
    G10G90L2P4X0Y5.0 <---Sets G57 to X0 Y5.0
    G10G90L2P5X0Y7.5 <---Sets G58 to X0 Y7.5
    G10G90L2P6X0Y10. <---Sets G59 to X0 Y10.0

    The G10 is a command to load or store the offsets
    The G90 is for Absolute input.
    The L2 designates a fixture offset (as opposed to tool offsets or something else)
    The P# designates which fixture offset. P1=G54, P2=G55, ect.
    Then the X and Y values are self explanitory.

    Then for your program you would call the G55 and run the subprogram (which is the G-code program that you already have. When the first part is done then call G56 and run the subprogram again. And repeat.

    %
    G0G40G90G17
    G10G90L2P2X0Y0
    G10G90L2P3X0Y2.5
    G10G90L2P4X0Y5.0
    G10G90L2P5X0Y7.5
    G10G90L2P6X0Y10.0
    G0G40G90G55
    M98P1234 <<<<<M98 CALLS THE SUBROUTINE; P IS THE PROGRAM NUMBER OF THE SUB.
    G0G40G90G56
    M98P1234
    G0G40G90G57
    M98P1234
    G0G40G90G58
    M98P1234
    G0G40G90G59
    M98P1234
    M30
    %

    Something like that. You'll have to check you manuals for the correct usage of offsets and subprograms but that's the basic idea behind it. Hope this helps.

  5. #5
    Join Date
    Sep 2004
    Posts
    13
    E-stop
    Thanks!!!!
    Your code helped a great deal, I think I understand now.
    I didn't get a chance to try it last night. I will let you know if I have any problems.

    Tim

  6. #6
    Join Date
    Apr 2003
    Posts
    1873
    I thank you as well E-Stop, very informative.

    Ken

  7. #7
    Join Date
    Sep 2004
    Posts
    77
    I am new to G-Code programming too, and I solved this problem using one of the other techniques E-Stop recommended. "Changing the Start Position" I do this a lot with my code.

    Maybe this would help someone, so here is an example of that:

    G0 X0 Y0
    M98P1000
    G0 X0 Y2.5
    M98P1000
    G0 X0 Y5
    M98P1000
    G0 X0 Y7.5
    M98P1000

    Another Possibility would be to put the Y-Offset in the subroutines first line using G91 relative coordinates. (G0 G91 Y2.5) Then you could LOOP the M98 command like this:

    M98P1000 L5 -- (Where L10 means loop 5 times)

  8. #8
    Join Date
    Sep 2004
    Posts
    13
    E-stop
    I tried the code you suggested, but it did not offset the X Y locations. It just repeated the subrouting in the same 0, 0 location.

    I have not tried Swami suggestion yet.

    Is there something I need to change in the sub program to get it to use the offsets?

    Here are the first few lines of my subroutines code:

    O1234
    (Created 8:32:10 AM 10/27/2004 from thum-bl-5fixture-y-rev.dxf)
    (Post = ISO G-Code - Non Modal)
    (Tool 1 = .125 End)
    N0001 T1 M03 S30000
    N0003 G00 X3.1125 Y1.3325 Z1.0000
    N0005 G00 X3.1125 Y1.3325 Z1.0000
    N0007 G01 X3.1125 Y1.3325 Z-0.0600 F20.00
    N0009 G01 X3.3375 Y1.3325 Z-0.0600 F15.00
    N0011 G01 X3.3375 Y1.7075 Z-0.0600

  9. #9
    Join Date
    Mar 2003
    Posts
    106
    Sorry so long answering. I've been out and busy for awhile.

    Your code for the subroutine looks fine. It's what comes before the subroutine that will change the start position of your pocket. The fixture offsets need to be "loaded" into the G54-G59 fixture offsets and then one of the offsets needs to be "called" before the subroutine is run. When the subroutine is done, call another fixture offset and run the subroutine again.

  10. #10
    Join Date
    Sep 2004
    Posts
    13
    E-stop
    I have the code you suggested beform the start of my subroutine(see below).
    I think it my be a problem with CNCZeus not handling the offsets via code correctly.


    G10 G90 L2 P2 X0 Y0 (<---Sets G55 to X0 Y0)
    G10 G90 L2 P3 X0 Y3 (<---Sets G56 to X0 Y3)
    G10 G90 L2 P4 X0 Y5.5
    G10 G90 L2 P5 X0 Y8
    G10 G90 L2 P6 X0 Y10.5
    G0 G40 G90 G55
    M98 P1234 (<<<<<M98 CALLS THE SUBROUTINE P IS THE PROGRAM NUMBER OF THE SUB.)
    G0 G40 G90 G56
    M98 P1234
    G0 G40 G90 G57
    M98 P1234
    G0 G40 G90 G58
    M98 P1234
    G0 G40 G90 G59
    M98 P1234
    M30

    O1234
    (Created 8:32:10 AM 10/27/2004 from thum-bl-5fixture-y-rev.dxf)
    (Post = ISO G-Code - Non Modal)
    (Tool 1 = .125 End)
    N0001 T1 M03 S30000
    N0003 G00 X3.1125 Y1.3325 Z1.0100
    N0005 G00 X3.1125 Y1.3325 Z1.0100
    N0007 G01 X3.1125 Y1.3325 Z-0.0600 F20.00
    N0009 G01 X3.3375 Y1.3325 Z-0.0600 F15.00
    N0011 G01 X3.3375 Y1.7075 Z-0.0600
    N0013 G01 X3.1125 Y1.7075 Z-0.0600
    N0015 G01 X3.1125 Y1.3325 Z-0.0600
    .....other code
    N0045 M5
    N0045 M99

  11. #11
    Join Date
    Jan 2004
    Posts
    258
    Try removing the "G90" this could be causing the problem. You do not need this to input "G10's" into the work offsets.

  12. #12
    Join Date
    Mar 2003
    Posts
    106
    Leave the G90. It may be redundant but it is safe. The G90 inputs an absolute value into the offset, G91 an incremental value. So if for some reason the control was in incremental mode as it reads the G10 lines, those values will be added to the values already in the offset. It is correct that the G90 is not needed to input the offsets with G10, I just always feel safer with it there. Operators have a way of making things happen that aren't supposed to so any additional safegaurds in place are a plus.

    tpaulson... Do you have an offset page where you can verify that the offsets have loaded correctly? I still can't see any problems with the code itself. Does your control support parametric programming? If so, you could do it with variables. It's not as easy but it works.

  13. #13
    Join Date
    Jan 2004
    Posts
    258
    E-Stop,
    The line that should be before the "G10's" should contain the "G90" as well as all the other g codes to cancel drilling, cut comp etc. I also like to use a "G49" to make sure that the "G10's" don't double load the work offsets. The "G49" is a pretty important command in this line, however there can be times in setup that if it is read after a tool offset it can result in the tool moving to the "0" offset position. I personally do not put the "G90" in my "G10" line and have my posts built to not output it. I do make sure that it gets called before and after the "G10" lines. I have places in my programs where I use "G91" but I always make sure that the next line has "G90" even if it is a forth axis index move. I agree with the statement about the operators I have built macro's and all kinds of insurance into my programs too keep operators from having problems, but they still from time to time find a way to get in trouble.

  14. #14
    Join Date
    May 2003
    Posts
    20
    is the G10 supported in cnc zeus?

  15. #15
    Join Date
    Sep 2004
    Posts
    13
    Quote Originally Posted by rob2424
    is the G10 supported in cnc zeus?
    That appears to be the problem. According to CNCZeus support, currently G10 is Not supported.

    I guess I will just have to generate the code for each box instead of doing a subprogram. Not a big deal, I just figured there was any easy way to repeat the code with offsets. Which there is, but CNCZeus doesn't support it. I will probably look at using Mach2 sometime in the future, but CNCZeus works well for now.

    Thanks again
    Tim

  16. #16
    Join Date
    Sep 2004
    Posts
    77
    You can still subroutine. Just write the subroutine with all G91 codes. When the subroutine is over, move to a new absolute location (G90) and fire the subroutine again, as often as needed. Does that make sense? You just keep using G90s to get the cutter in your "start" position.

    Swami

  17. #17
    Join Date
    Sep 2004
    Posts
    13
    Swami
    I am very new to G code, but I think I understand. The problem is that the software I usually use to create the g-code from dxf doesn't appear to have the ability to generate incremental programming. DeskCNC is the only software I currently have access to that can create pockets.
    Is there other software available inexpensive or free that will generate relative g-code for pockets?

    Thanks
    Tim

  18. #18
    Join Date
    Jan 2004
    Posts
    258
    If this is an older fanuc controller 11 or 15, I can give you the option code to turn on the option. think that it is 9102 bit O.

  19. #19
    Join Date
    Sep 2004
    Posts
    77
    Oh! No incremental...I understand why you needed to do it with G10 then now....

    I dont know of a program that will generate the pocket using G91, but you could manually edit the code most likey.

    Assume your machine is at 0,0 (or something else convenient). Program your first pocket You should be able to take that code and just append G91 (or remove G90) codes from what was produced. When you could make that modified code into a subroutine (by putting O1000 to start the block and M99 to end it) Now you should have a block of code that will work from whatever startingpoint you are at prior to calling it.

    Example:
    G0 G90 X0 Y0
    M98P1000

    G0 G90 X7 Y0
    M981000

    Hopefully that can help you out.

    I was wondering, if you have a DXF to code generator, why not DXF all the pockets you want to make and let the program write the whole thing? Sheetcam would be very good for that. www.sheetcam.com

    Good Luck,
    Swami

  20. #20
    Join Date
    Sep 2004
    Posts
    13
    Swami
    Thanks for your help.

    Quote Originally Posted by Swami
    I was wondering, if you have a DXF to code generator, why not DXF all the pockets you want to make and let the program write the whole thing? Sheetcam would be very good for that. www.sheetcam.com
    I ended up letting the software generate all of the pockets like you mentioned.

    The main reasons why I was trying subroutines was:
    1. To allow for quick changes of pocket size. Just make the change on one pocket location in the DXF instead of 5.
    2. The subroutine method would also complete an entire box before moving to the next box. Having the g-code generater create all pockets, creates code to make the first pocket on all 5 boxes before creating the second pocket on the first box. This is a waste of time if I only need to make one box instead of all 5.
    3. Easily change the number of boxes to be machined in a run

    Tim

Similar Threads

  1. parametric programming
    By Karl_T in forum CamSoft Products
    Replies: 21
    Last Post: 05-24-2005, 08:58 PM
  2. How to set up Tool Offset in MACH2?
    By High Seas in forum Mach Software (ArtSoft software)
    Replies: 7
    Last Post: 09-09-2004, 06:54 PM
  3. I need sample G code program
    By bunalmis in forum G-Code Programing
    Replies: 1
    Last Post: 08-24-2004, 09:50 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
  •