585,932 active members*
3,684 visitors online*
Register for free
Login
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2008
    Posts
    522

    G-code step-and-repeat

    OK, I have an L-shaped part which is just a load of G-code in a subroutine.

    I will need to do a step-and-repeat where I rotate the part 180 deg and XY offset it enough to clear the previous part.

    G68 rotates the coordinate system. But it also says it rotates the work offset, which would be horrible.
    G10 can set the origin and G52 can do a temporary offset... but Mach3 says G92 offsets CANNOT be used with G52. Which would be a problem.

    I'm really frustrated. I can't remake the G-code as relative moves or anything, it's CAM-generated. The idea was to do a M98 call of the routine, rotate the coordinate system 180 deg and XY offset, then call again (lather, rinse, repeat). But is this even possible??

    Should I maybe try to get the work offsets from the parameter list, zero the actual offsets, rotate the system, then reassign the work offset along with the necessary XY stepping?

  2. #2
    Join Date
    Mar 2004
    Posts
    1542
    More than one solution here. On my control (not Mach), I'd set up work offsets for each part - G54 for part 1, G55 for part 2, and so on. Then just do your new offset and rotate before the routine call.

    Karl

  3. #3
    Join Date
    Dec 2004
    Posts
    1865
    Quote Originally Posted by MechanoMan View Post
    OK, I have an L-shaped part which is just a load of G-code in a subroutine.

    I will need to do a step-and-repeat where I rotate the part 180 deg and XY offset it enough to clear the previous part.

    G68 rotates the coordinate system. But it also says it rotates the work offset, which would be horrible.
    G10 can set the origin and G52 can do a temporary offset... but Mach3 says G92 offsets CANNOT be used with G52. Which would be a problem.

    I'm really frustrated. I can't remake the G-code as relative moves or anything, it's CAM-generated. The idea was to do a M98 call of the routine, rotate the coordinate system 180 deg and XY offset, then call again (lather, rinse, repeat). But is this even possible??

    Should I maybe try to get the work offsets from the parameter list, zero the actual offsets, rotate the system, then reassign the work offset along with the necessary XY stepping?
    If the part is relatively simple and you are trying to "nest" them to make better use of the available stock,then I would draw out the layout you need in the cad program and then run it through the CAM again.
    Warning: DIY CNC may cause extreme hair loss due to you pulling your hair out.

  4. #4
    Join Date
    Mar 2003
    Posts
    4826
    I' ve never used coordinate system rotation, but have you played with it to see if rotating the work offset is 'horrible' or not? It may be a matter of what you think is going on, and what really goes on are two different things.

    In my mind, I can sort of visualize that not rotating the work offset could in fact, be a problem, depending on which coordinate systems are active.

    I'd take the sure route and program a right and a left, and then repeat that, rather than dealing with a bunch of complexity.
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  5. #5
    Join Date
    Nov 2008
    Posts
    522
    Quote Originally Posted by TOTALLYRC View Post
    If the part is relatively simple and you are trying to "nest" them to make better use of the available stock,then I would draw out the layout you need in the cad program and then run it through the CAM again.
    Not gonna happen. CAM is a difficult process and requires some post-editing. Depending on what I have for stock, I may step-and-repeat different ways.

    Quote Originally Posted by HuFlungDung
    I' ve never used coordinate system rotation, but have you played with it to see if rotating the work offset is 'horrible' or not? It may be a matter of what you think is going on, and what really goes on are two different things.
    Oh yeah it's horrible. See I've got a hole I align for the origin. So I run the machine over the stock where I need that to be, and use G92 to set that as origin, say it's actually X=5.123 in machine coords (I never use machine coords at all). Well, that moves the origin way the hell over in the wrong direction when the code tries to do a G68 rotation from part 1 to part 2. Basically the 180 deg rotation moves the ORIGIN to X=-5.123 on machine coords.

    The G52 Temporary Offsets look like they have the same sort of problem, it clobbers the original work offset. So you try to step over 1" by saying G52 X1, but that clobbers the G92 offset, putting it at MACHINE coord X=1, meaning the G52 X1 resulted in a relative move by X-4.123, and it's unpredictable at that, since changing stock and resetting the work offsets will totally change what the G-code does.

  6. #6
    Join Date
    Nov 2008
    Posts
    522
    Ah-ha, it IS possible! I was a bit confused initially, betwen G92 offsets and WORK offsets. I didn't realize how they were different.

    This allows me to start with a G92 offset and offset angle (used when the stock doesn't totally line up with the axis), and restores them when done.
    The only thing is, if you see a problem in the run, pull a Stop, and then start again from the beginning, you will have corrupted offsets. If you didn't have any G92 or angular offset to begin with, then can just zero them and restart. As such I'd kinda recommend not setting up with stock with G92 offsets but by setting the Work offset, and avoiding using the angle if you can.

    This took way too many hours to figure out...

    Code:
    #100=#5211 (initial G92/G52 x-offset, #5211 is a Mach3 system param)
    #101=#5212 (initial G92/G52 y-offset, #5212 is a Mach3 system param)
    #102=0  (incremental rotation, Mach3 will not provide the initial offset so there is no way to figure it out, but by doing incrementals and recording the change alone, that'll allow us to work off it and restore it)
    
    #10=0        #11=0  #12=90  M98 P5 
    M98 P2 (O2 is the part to be repeated)
    #10=[#25]  #11=-50 #12=-90 M98 P5 
    M98 P2
    #10=[#50]  #11=0  #12=90  M98 P5
    M98 P2
    
    (cleanup at end)
    G52 X[#100] Y[#101]      (restore original G92/G52 offsets)
    G68  a0 b0 r[-1*#102] i0 (undo any previous inc rotation)
    M30 (end of program)
    
    O5 (Step, Rotate, and Repeat Offset)
    (#10=x offset, #11=y offset, #12=angle)
    
    G68 a0 b0 r[-1*#102] i0 (undo any previous inc rotation)
    G52 X[#100+#10] Y[#101+#11] (XY stepping)
    G68  a0 b0 r[#12] i0  (set inc rotation)
    #102=[#12] (remember new inc rotation state)
    M99

  7. #7
    Join Date
    Aug 2011
    Posts
    27
    Well I'm not proud. I'm just gonna ask someone to show me how so I can get some actual cutting done.

    (I'm trying to surface a spoilboard)

    N0 G1 X20.0 F80 (Run 20 inches to the right)
    N1 G1 Y+=0.0100 (Increment Y by some partucular amount?)
    N2 G1 X0.000 (X back to zero)
    N3 G1 Y+=0.0100 (Increment Y again)
    N4 G? N0 L30 (repeat the whole mess 30 x)

    Any takers?
    Or point me in some direction, please.

Similar Threads

  1. whole G-Code REPEAT command ??
    By LockTech in forum G-Code Programing
    Replies: 14
    Last Post: 08-08-2010, 04:21 PM
  2. g code for repeat the previous move
    By woffler in forum G-Code Programing
    Replies: 6
    Last Post: 03-27-2008, 04:07 AM
  3. Step by step 3d wireframe Stl. to G-code
    By josh cbr900 in forum Mastercam
    Replies: 7
    Last Post: 11-12-2007, 12:43 PM
  4. AVR G Code Interpreter/ Step-Dir Macro Recorder
    By bitmannz in forum CNC Machine Related Electronics
    Replies: 5
    Last Post: 02-01-2007, 07:07 AM
  5. Repeat g-code with y offset
    By tpaulson in forum G-Code Programing
    Replies: 19
    Last Post: 11-29-2004, 08:36 PM

Posting Permissions

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