587,255 active members*
2,934 visitors online*
Register for free
Login
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2011
    Posts
    0

    Exclamation Simple G code loop needed!

    Hello everyone! I am an undergraduate student who just got into a research laboratory with a professor. My task is to program our laser (which functions with G code) to make fairly simple designs, but a lot of them. I need to find a way to run a simple loop where I can designate the start point (probably absolute coordinates), allow it to run maybe 20-30 times, making a simple design (in a horizontal x direction) and then return to the start position, only an increased y amount upwards, so I may begin another row. I think I have the other parts down, I just need a way to run the loop a specified number of times without having to program the same code 100000 times and I am not very familiar with G code.

    Thank you all very much!

  2. #2
    Join Date
    Jul 2011
    Posts
    0
    https://docs.google.com/viewer?a=v&p...Z3RMN&hl=en_US

    This is the manual for controlling the stage. I am afraid there might be limiting factor because of what G codes it allows. Please let me know. Thank you very much.

  3. #3
    Join Date
    Dec 2003
    Posts
    24223
    You need something called Nesting S/W, this takes a single part/shape and nests it efficiently on a certain material sheet size, it will also rotate parts in order to reduce waste.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  4. #4
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by gcodehelp View Post
    Hello everyone! I am an undergraduate student who just got into a research laboratory with a professor. My task is to program our laser (which functions with G code) to make fairly simple designs, but a lot of them. I need to find a way to run a simple loop where I can designate the start point (probably absolute coordinates), allow it to run maybe 20-30 times, making a simple design (in a horizontal x direction) and then return to the start position, only an increased y amount upwards, so I may begin another row. I think I have the other parts down, I just need a way to run the loop a specified number of times without having to program the same code 100000 times and I am not very familiar with G code.

    Thank you all very much!
    The example uses the code for a Fanuc control, but most controls have Sub Program, and repeat of Sub Program functionality.

    1. Write the code for your simple design in Incremental
    2. Main program has the call of the ROW logic
    Go to the Absolute position of the starts of the first component offset in X and Y by the X and Y pitch of the individual parts

    Lets say that the pitch of the start of each part in X and Y is 50mm and 100mm respectively, and that the start point of the first part is X0.0 Y0.0, then:
    G90 G00 X-50.0 Y-100.0 (G90 is Absolute Mode G code)
    M98 P1000 L10
    where:
    M98 is the Sub program call command
    P1000 is the Sub program number
    L is the number of ROW repeats of your design

    Sub program 1000 logic follows
    O1000
    G90 X-50.0 (Absolute start position of the first column of each row, minus the pitch of the columns)
    G91 G00 Y100.0 (incremental pitch of rows)
    M98 P2000 L50
    M99
    where:
    M98 is the Sub program call command
    P2000 is the Sub program number
    L is the number of COLUMN repeats of your design

    Sub program 2000 logic follows
    O2000
    G91 G00 X50.0 (incremental pitch of columns)
    code for design goes here, all written in incremental moves.
    ........
    ........
    ........
    ........
    ........
    ........
    M99

    3. The program works by the head of the machine starting at a position offset by the pitch of the part in X and Y in the main program.
    4. A Sub Program is called from the main program to repeat a number of times equal to the number of rows to be cut.
    5. Program control is transferred to the Sub called in the main program (O1000) and repeats it L times (number of Rows)
    6. The first line of Sub O1000 will make no move when control is first transferred from the main program because the head has already been positioned there in the main program.
    7. The second line will move incrementally in Y the pitch of the Rows and will now be in the correct Y start position for the design.
    8. The NESTED program O2000 is called and repeated L times (number of columns of parts). Control stays with O2000 until it has completed L number of repeats.
    9. The first line of O2000 moves incrementally in X the pitch of Columns and will be in the correct X start position of the design.
    10. O2000 will repeat the process of moving X pitch of the design and then running the shape of the design L number of times.
    11. Control then returns to O1000, where the head of the machine is returned to the Absolute X start position for the next Row and calls O2000 again. This process repeats until O1000 has repeated its L number of times.
    12. After O1000 has repeated L number of times, control is passed back to the main program.

    The above logic works if the Start and End point of each design component is the same Absolute point. You will have to manipulate the Absolute coordinates and the Row/Column pitch moves if the the Start and End point of each design component is not the same Absolute point; but the general logic will work.

    The above is not as difficult as it may appear in written form. It results in the code for the shape of the design only being written once and its start position being changed and controlled by two Sub programs.

    There are other ways of achieving what you want by using User Macro techniques, or using work coordinate shifts. However, not knowing the type of control you have, the above method will work on just about any control.

    You will have to look in your programming manual of your machine's control to get the correct syntax for Subs and nesting Subs.

    Regards,

    Bill

  5. #5
    Join Date
    Jul 2011
    Posts
    0

    Exclamation Another Question-thanks so far

    Thank you very much for the replies, I've researched the nesting/G98/99 and I think I understand it. Unfortunately we are having a more fundamental problem with controlling the stage. I am going to call the programmer tomorrow but I thought I'd ask on here first because it might be a simple problem solvable by someone with a little experience.

    So we are trying to operate in relative coordinates (G91) while also using linear motion (G01) instead of (G00). For some reason, even if I include the G91 code, once I also include G01, the entire code changes to absolute coordinates, even if everything is help constant and this is the only change in the entire code. Its my understanding that you can program G01 and G91 at the same time. If I do not include G01 then it will move in G00 mode with relative coordinates but the diagonal motions will come out in a hockey stick looking manner. Please advise if you have any advice. I am afraid there is something wrong with the program.

  6. #6
    Join Date
    Jun 2008
    Posts
    1511
    You should be able to program them in the same line but you could try programming the G91 before your G1 line. These codes should stay modal until you change them.

    Stevo

  7. #7
    Join Date
    Dec 2003
    Posts
    24223
    Quote Originally Posted by gcodehelp View Post
    If I do not include G01 then it will move in G00 mode with relative coordinates but the diagonal motions will come out in a hockey stick looking manner. Please advise if you have any advice. I am afraid there is something wrong with the program.
    G01 is interpolated motion under feedrate command, G00 is a non-interpolated move in rapid motion.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  8. #8
    Join Date
    Aug 2011
    Posts
    10

    Absolute and relative coordinates...

    Ok, your last post is as mentioned in conflict with Standard ISO G-codes

    G90 and G91 is NOT related to G00, G01

    If G01 takes your machine out of relative coordinate mode then there is a break of standard.
    Only G90 is intended to switch the controller to absolute coordinate mode.
    G01 is as mentioned used in linear work mode and G00 is NOT used for anything else than rapid movements WITH NO machining of any sort taking place.
    That i I believe, the standard.
    OF course anyone can create an G-code interpreter who treats the G-codes differently and they do...
    If that is true in your case only You can tell us.
    Check it up again!

    / Roger

Similar Threads

  1. Need (hopefully simple)G code Help
    By inventor30 in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 2
    Last Post: 11-12-2010, 12:32 PM
  2. Is it possible to loop a g-code program?
    By sul1 in forum G-Code Programing
    Replies: 4
    Last Post: 04-03-2009, 08:49 PM
  3. Need help with simple G code
    By Step by Step in forum Coding
    Replies: 2
    Last Post: 10-25-2008, 02:49 AM
  4. Simple loop program for mazak
    By katsbobo in forum Mazak, Mitsubishi, Mazatrol
    Replies: 3
    Last Post: 04-08-2008, 12:11 AM
  5. simple start up code needed
    By jrick in forum Community Club House
    Replies: 0
    Last Post: 02-08-2007, 07:05 AM

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
  •