Page 1 of 2 12 LastLast
Results 1 to 12 of 16

Thread: Ok, how do I do write a simple program in gcode?

  1. #1
    Registered Apples's Avatar
    Join Date
    Feb 2004
    Location
    Australia, Queensland
    Posts
    417
    Downloads
    0
    Uploads
    0

    Ok, how do I do write a simple program in gcode?

    Ok, how do I do write a simple program in gcode?

    I want to make the mill go from say 0 to 100, then back to 50 then up to 200 and back to 150 then up to 250 etc.

    So far I know G0y100 will move me from home, to y100mm position at full speed.

    There is an F200 command for feed speed, but where abouts in that line would that F code go?

    And can I add in a dwell too.
    And do I have to then number the lines as N1, N2, N3 with each seperate command on each line etc.

    Peter
    My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/


  2. #2
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    2,923
    Downloads
    0
    Uploads
    0
    Apples

    G0 is for rapid moves, G1Y100F50. G1 is what you want to use for a feed move

    G1Y100F50.
    G1Y-50F50.

    A Dwell is G04P500 The 500=0.5 second dwell (place this on a line by its self were ever you want it to stop/Dwell)

    Try this to start to see how it will work for you, You can ajust the numbers to suit
    Mactec54


  3. #3
    Registered Apples's Avatar
    Join Date
    Feb 2004
    Location
    Australia, Queensland
    Posts
    417
    Downloads
    0
    Uploads
    0
    Cool thanks for that, I will give it a shot tomorrow and see how I go.

    yes G01 makes sense now..

    In this code G04P500 What does the 4 mean? Or is it G04 together which means dwell, it looks like that.
    My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/


  4. #4
    Registered
    Join Date
    May 2007
    Location
    US
    Posts
    779
    Downloads
    0
    Uploads
    0
    Here is a run down on G-Code, standards are not strictly adhered to so things do change from machine to machine.
    G-code - Wikipedia, the free encyclopedia

    One of the better books I have found on CNC programming.
    CNCProgramming Handbook: Acomprehensive Guide to Practical Cnc Programming by Peter Smid - ISBN 9780831133474

    And yes the dwell command is G04 or most machines will also take G4


  • #5
    Registered
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    1,271
    Downloads
    0
    Uploads
    0
    Apples, whitespace within a block and leading zeros aren't significant in G-Code so G04P500 is the same as:

    G04 P500
    G4 P500
    G4P500

    I suggest you download http://www.machsupport.com/docs/Mach3Mill_1.84.pdf and read chapter 10. It gives a good introduction to g-code and will answer a lot of your questions.

    bob


  • #6
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    2,923
    Downloads
    0
    Uploads
    0
    Apples

    G04 is the code P500 is the time for the Dwell
    Mactec54


  • #7
    Registered Apples's Avatar
    Join Date
    Feb 2004
    Location
    Australia, Queensland
    Posts
    417
    Downloads
    0
    Uploads
    0
    Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

    Here is a similar code

    o0001 (program name)
    N10 G00 Y100
    N20 G4 P500
    N30 G00 Y0

    Do I need to add a start/go code after the dwell command?
    My little site on MIG welding http://www.learn-how-to-weld.com/mig-welding/


  • #8
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    2,923
    Downloads
    0
    Uploads
    0
    Apples

    Try this G0Y0.

    You need a ./ period after the zero
    Mactec54


  • #9
    Registered
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    987
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by Apples View Post
    Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

    Here is a similar code

    o0001 (program name)
    N10 G00 Y100
    N20 G4 P500
    N30 G00 Y0

    Do I need to add a start/go code after the dwell command?
    What controller is on the machine you're using?

    Posted by mactec54

    Try this G0Y0.
    You need a ./ period after the zero

    If its a Fanuc Control a period (decimal point) makes not difference for a zero value, Y0, Y0., Y0.0 are treated all the same by the Fanuc control. If a period is omitted in a coordinate value, the control will count 3 or 4 places to the left, depending on whether the control is in imperial or metric mode. In metric mode G21, Y100000 is read as Y100., similarly, Y100 is read as Y0.100

    With a Fanuc control, G04 can be specified as Revs of the spindle by specifying G95 before the G04 dwell call, either on the same line of prior to the call. If your machine is in G95 (feed per revolution) mode and the spindle is not running, the program will stop at the dwell line waiting for the required number of rotations to be completed. You only show the move lines in your program snippet, so I don't know if you have the spindle running or not. If the spindle is not running, that may be the reason for the program dwelling for an indefinite period.

    The fact that the move lines are in rapid traverse will allow those moves to occur irrespective of the control being in G95 (feed per revolution), or G94 (feed per minute) mode as rapid positioning does not rely on the spindle rotating. Put G94 in your program prior to the G04 command and that should fix the problem if the spindle is not running.

    That's about the only thing that I can see in your program that would make it stop indefinitely once the G04 command has been launched.

    Again depending on the control, an X value will work with a G04 and is my preference. G04 X0.5 will initiate a dwell of 0.5 seconds in G94 mode and 0.5 spindle revs in G95 mode. With a Fanuc control, there is a parameter that can be set that will cause the G04 to be treated as a dwell in seconds for both G94 and G95 mode.

    Regards,

    Bill


  • #10
    Registered BobWarfield's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    2,498
    Downloads
    0
    Uploads
    0
    Yes indeed, welcome to the wonderful world of different controls which have slightly different g-code dialects.

    Some controls want that trailing decimal point even if there is no fraction, so we have to write "X1.". Some don't care and we can write "X1".

    RE your G4 (and there are controls that make you write G04) Dwell, the P500 may be interpreted as 500 milliseconds = 1/2 second on some controls or 500 seconds = over 8 minutes on others. That may be one reason why your Dwell just went on and on. As was pointed out, Dwell may also be expressed as revolutions (handy for some operations like making sure the bottom of the hole has seen a rev or two before you withdraw the twist drill).

    So, your first task is to lay hands on the programming book for your controller. Otherwise all these little idiosyncracies will make no sense as each person gives you advice from the context of their controller.

    You might find my G-Wizard G-Code Editor a helpful tool for learning:

    GWizardE: A Machinist's CNC G-Code Editor

    It lets you setup the g-code to match your controller's preferences. BTW, CAM programs call that a "post" informally. GWE has a "post" capability.

    In addition it has "Wizards" to help you get the syntax right entering the g-codes and "Hints" that tell you what the g-code does in plain English.

    Since it's in Beta test, it's free to play around with.

    Cheers,

    Bob Warfield
    Try G-Wizard Machinist's Calculator for free:
    http://www.cnccookbook.com/CCGWizard.html


  • #11
    Registered
    Join Date
    Jan 2009
    Location
    US
    Posts
    24
    Downloads
    0
    Uploads
    0

    G code programming

    For Fanuc style controls, always use a decimal point in your moves. Example
    X5 means move .0005, X5. means move 5 inches. Big difference. Use your G0 to X, Y, rapid to where you want to do your work. You have to use height offset to rapid to where you want to start. Example G43H1Z.1 would use the value in height offset register 1 to move your Z axis to .10 above the top of your part. Use a G1 with a feedrate of say F5. for 5 inches per minute to feed to the depth required, since the G1 is modal, that means it is in a feed rate mode until you give it a different G0 code, you can just write the coordinates that you want to machine too. Example G1 Z-.25 F5.; X-1.Y1.;
    Y-1.;X1.;Y1.;X-1.;X0.Y0.;G0Z1.;M30; If you were using a .50 mill, the above program would cut you a 1.5 square pocket .25 deep, go back to the center and rapid the Z up 1.0 from the top of your part. Hope this helps from an old timer.


  • #12
    Registered Torsten's Avatar
    Join Date
    Nov 2004
    Location
    U.S.A.
    Posts
    260
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by Apples View Post
    Hey, I could get it to dwell. But then it just kept on dwelling, like chilling out and not moving at all.

    Here is a similar code

    o0001 (program name)
    N10 G00 Y100
    N20 G4 P500
    N30 G00 Y0

    Do I need to add a start/go code after the dwell command?
    May need to make sure the Controller is in G90 absolute mode.
    Else if a G91 incremental mode is active the N30 G00 Y0 line will not move anywhere.


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Simple GCode Reference / Commands?
      By WarrenW in forum G-Code Programing
      Replies: 14
      Last Post: 11-30-2010, 04:03 AM
    2. Need A Quote- Write knife grinding program
      By tr4252 in forum Employment Opportunity
      Replies: 17
      Last Post: 03-10-2010, 08:57 PM
    3. How to write a code program to cut threads
      By jjenks in forum NCPlot G-Code editor / backplotter
      Replies: 7
      Last Post: 04-21-2008, 10:18 PM
    4. Possible to write variables to a program?
      By Heavy D in forum G-Code Programing
      Replies: 2
      Last Post: 08-22-2006, 12:08 AM
    5. someone wanna write a program?
      By ljoe1969 in forum DIY CNC Router Table Machines
      Replies: 2
      Last Post: 06-06-2004, 08:47 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.