587,143 active members*
4,649 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > LinuxCNC (formerly EMC2) > Using G90 or G91 in "step and repeat" coding ?
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Posts
    1436

    Using G90 or G91 in "step and repeat" coding ?

    I'm coding for my own design E-chain, and have a milling program that cuts the end of one link and the start of another as a single cut.
    This will be repeated across the material in a step/repeat fashion until the sheet is covered in several lines of links.
    Onto the saw table and out pops all the pieces .
    Well, that's the idea.

    Question.
    The code I have written is in absolute movements for the single pass, and I want to be able to step the pattern by a set distance each time.
    If my code had been incremental, I can see that using an O-code repeat/endrepeat would be the way to do it, and I expect I shall have to do this.
    But is there an alternative coding method I could use, where, at the end of the "step", the code could repeat at the "new" start position ?

    Regards
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  2. #2
    Join Date
    Apr 2005
    Posts
    1778
    I would code using a subroutine, then pass the subroutine a x, y start point and change the g55 offset inside the subroutine then cut the part. You could call the subroutine from inside a do-while loop adding the necessary column offset for each link and nest that do-while loop inside another do-while loop to reset the starting column offset and increment the row offset to start the next row.

    Alan

  3. #3
    you could simply program in absolute for one part and use a looped sub call with a g52 shift .
    if you use a macro variable for the shift then it would be dead simple ( see eg below)
    g52 is one of the greatest programming tools to utilize , it saves from using a lot of code when programming multi part fixtures , if a guy picks up one work shift and uses a g 52 shift to each part then the code is shorter , easier to edit , and it makes it much easier to set up a job because only one shift needs to be picked up rather than a pile of work shifts
    I've created macro routines to trig and calculate shifts for rotary's and still i only need to pick up one work shift , the machine calculates the g52 shift for any rotational position with the use of the sub routine , which is to say that I've saved myself from possibly manually picking up or calculating 100's of work shifts on a complicated rotary part
    its not always simple but with macro variables to use in a calculative sub routine and a g52 , then a guy can let his imagination run fairly wild

    eg

    %
    O1212
    #101=0
    t1m6
    m98p1000 / or m97p1000(depending upon control)
    m98p1100L20
    g91g28z0
    m30

    O1100/or n1100 (depending upon control)
    g52 x#101+2(2 was random add whatever is necessary for the shift )
    O1000/or n1000
    g0g90xy
    g43 z2.
    blah blah
    blah blah
    ;
    ;
    g52x0(cancels shift)
    g0z2.
    m99
    %
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........

  4. #4
    Join Date
    Jun 2005
    Posts
    1436
    Thanks both.

    Bit puzzled at the reference to the G52 and G55 as they didn't seem familiar.

    Checked out my printed copy of EMC User Manual - it's dated November 2009, so I think it's time to update and do some serious reading !
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  5. #5
    g55 is a simple work shift which is same as g54
    typically most people use g54 g55 g56 g57 for work shift positions

    hopefully i can explain g52 so that it makes sense .
    lets say that your qualifying your part as usual and you pick up the g54 position , and your g54 values are x-10 y-10 .
    when you call g0g90g54x0y0 in your program your tool will go to that point that you've just picked up as x0 y0 ,
    now lets throw in a g52 shift
    g0g90g54
    g52 x-2.
    x0y0
    now the tool will move an increment of -2 inches from the point that you've picked up , which is to say that the g54 shift is no longer x-10 but it is now x-12. , the machine will calculate the g52 shift of -2. inches .
    g52 will not physically change the g54 value but simply adds to it , until you use g52 x0 which will cancel that value and you've original position will be restored

    so say we've got a fixture that has 6 parts which are 3" apart . we can program for one part at g54 then use a sub routine and a g52 shift for the rest of the parts
    so we'll qualify g54 x0 y0 z0 from part # 1
    now the program will look sort of like this


    t1m6
    g0g90 g54
    m97p1000
    g52x3.(shift for part 2)
    m97p1000(sub call)
    g52x6.(shift for part 3)
    m97p1000)
    g52x9.(shift for part 4)
    m97p1000
    g52x12.(shift for part 5)
    m97p1000
    g52x14.(shift for part 6)
    m97p1000
    g0g91g28z0
    g90
    m30

    N1000(sub routine)
    x @$# y%$
    g43 h
    blah
    blah
    g52x0
    m99
    %
    now we can also take the same parts and program with the addition of macro variables which can make things a bit cleaner
    %
    O0001
    #101=0 (important to reset back to zero for next batch of parts)
    t1m6
    g0g90 g54
    m97p1000
    m97p1100 L5 (loops 5 times)
    g91g28z0
    g90
    m30

    n1100
    g52 x(#101+3.) (need brackets for calculations)
    N1000(sub routine)
    x @$# y%$
    g43 h
    blah
    blah
    g52x0(cancels the g52 shift)
    m99

    g52 can be used on all axis , I've only gave x as an example , I use this stuff on a daily basis but I'm not the best guys for explaining crap and don't like too much typing so if I've forgotten something or my explanation isn't that great then I'm sure someone else will speak up and help




    .
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........

  6. #6
    ok so after that winded explanation I checked out the emc codes and g52 isn't implimented yet :

    so another way is with the use of a g10
    g10 will physically change the work shift values permanently
    g90 g10 L2 P1 x10 y10 z-6. will change the work shift values in the control to x10 y10 z-6 .
    l2 is the change work shift call , P is the shift to change , P1 changes g54 P2 changes g55 and so on
    now if you use a g91 instead of a g90 then the workshift will change incrementally , which is to say that if your g54 work shift is x10 y10
    and you put in the program g91g10 L2 P1 x2 y5 , then your workshift will now be changed to x12 y15
    so we'll go back to the example i showed previously but modified to use a g10

    first qualify your g54 position for x y z , now add those values to the g10 below
    %
    O1212
    g90 g10 l2 p1 x10 y10 z-2.( the original workshift needs to be recalled and this will do it )
    t1m6
    g0g90 g54
    m97p1000
    g91g10L2P1x3 (shift for part 2)
    g90( back to absolute)
    m97p1000(sub call)
    g91g10L2P1x3
    g90
    m97p1000
    g91g10L2P1x3(shift for part 4)
    g90
    m97p1000
    g91g10L2P1x3(shift for part 5)
    g90
    m97p1000
    g91g10L2P1x3(shift for part 6)
    g90
    m97p1000
    g0g91g28z0
    g90
    m30

    N1000(sub routine)
    x @$# y%$
    g43 h
    blah
    blah
    m99
    %

    or back to using loops


    O0001
    t1m6
    g0g90 g54
    m97p1000
    m97p1100 L5 (loops 5 times)
    g91g28z0
    g90
    m30

    n1100
    g91 g10 l2 p1 x3. (sub routine)
    g90
    n1000
    x @$# y%$
    g43 h
    blah
    blah
    m99
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........

  7. #7
    Join Date
    Jun 2005
    Posts
    1436
    Dertsap, many many thanks for your efforts.
    The beauty of Axis(from my point of view, anyway) is that I can enter your code along with my modifications, and see what the tool paths look like.
    For me, this is the quickest way to understand, learn, and use.
    Regards
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

  8. #8
    Join Date
    Jun 2005
    Posts
    1436
    Hi dertsap.
    I had a bit of a problem getting my head round it all, but managed to work my way through OK.
    However, as I thought that I would need to cut more than 10 units per line,
    I had a go at using G92 to reset the tool position to a new zero, and enclosed it all in an O-code repeat.
    Here's the result -

    (Code for cutting the end/start of a series of complete links)

    G17 G21 G40 G49 G54 G80 G90 G94
    #3= 500
    #4= 300
    (Tool is 3mm diameter straight bit)
    G0 x[0.000] y[0.000] z[10.000] F#3(machine start)

    O101 repeat [15]

    G1 z[-4.000] F#4
    G1 x[4.757] y[4.757]
    G2 x[10.500] y[14.809] I[4.243] J[4.243] F#4
    G1 x[10.500] y[21.000]
    G1 x[16.500]
    G1 y[16.500]
    G0 z[10.000] F#3
    G0 x[18.000] y[9.000] F#3
    G1 z[-4.000] F#4 (Drill pivot hole)
    G0 z[10.000] F#3
    G0 x[17.890] y[0.000] F#3
    G1 z[-4.000] F#4
    G2 x[16.500] y[17.890] I[0.000] J[9.000] F#4
    G0 z[10.000] F#3

    G0 x[35] y[0] (step to next start position)
    G92 x0 y0 z10 (set new position as start)
    O101 endrepeat
    (I've yet to add the "next line" bit of coding to get a repeated line.)

    The concept is to cut a set of identical pieces which, when glued together in pairs, back to back, you get a 3D link from a 2D cut.
    Two sets of these form the sides of the chain, and they are glued either side of short lengths of rectangular plastic conduit(trunking).

    By separating the function of the chain into two parts - 1. pivoting 2. constraining, I can make my e-chain very cheaply and to whatever size fits the available material.
    Regards
    John
    It's like doing jigsaw puzzles in the dark.
    Enjoy today's problems, for tomorrow's may be worse.

Similar Threads

  1. Replies: 268
    Last Post: 06-03-2012, 11:33 PM
  2. "Repeat" event
    By Fighter in forum Dynapath
    Replies: 3
    Last Post: 09-10-2011, 09:30 PM
  3. "Flip" DSTV coding
    By pikamonk in forum Uncategorised MetalWorking Machines
    Replies: 1
    Last Post: 01-20-2011, 07:08 PM
  4. Can someone explain "Full step", "Half step", "Quater step", etc. ???
    By danmst3k in forum DIY CNC Router Table Machines
    Replies: 4
    Last Post: 12-04-2008, 06:13 PM
  5. Help finding information on Sanyo Denki "Step Syn" IBM stepper motor
    By Oracle_9 in forum Stepper Motors / Drives
    Replies: 12
    Last Post: 06-08-2007, 06:55 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
  •