586,609 active members*
3,529 visitors online*
Register for free
Login
Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2012
    Posts
    113

    Need help with simple code

    I want to cut a square pc out of a thin pc of aluminum and am trying to learn how to use the gcode repeat command. This is the code I have:

    S1500 M3 S500
    M98P1 L5
    M30
    O1
    G1 Z-1
    G1 Y-25
    G1 X25
    G1 Y0
    G1 X0
    M99

    I need to go down 5 steps total, each repeat I want to go down Z-1, but it will only go down on the first run since it will make the machine/dro at Z-1. I need to trick the machine into thinking it is back at Z0 and then go down another 1 step during the repeats. What am I missing in this code ?

  2. #2
    Join Date
    Jul 2005
    Posts
    12177
    You make your Z motion an incremental (G91) move then go back to G90 for going around the square. Something like this:

    S1500 M3 S500
    G00 X0. Y0. Z1.
    Z0.0
    M98P1 L5
    G00 Z1.
    M30
    O1
    G91 G1 Z-1
    G90 G1 Y-25
    G1 X25
    G1 Y0
    G1 X0
    M99

    This positions the tool at the starting corner, moves it down to the top of the workpiece, increments down and does the square 5 times then retracts back to the clearance position and stops.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  3. #3
    Join Date
    Jan 2012
    Posts
    113
    thanks so much, ill give that a try

  4. #4
    Join Date
    Jan 2012
    Posts
    113
    I got the code working for the square but I am still a bit confused on how to do it for other code. This is my code:

    N10 G90 G41 D1 F5 S1500 T01 M03 Z0.100;
    N20 G54; (X 1.5 Y1)
    N30 G00 X0 Y0
    N40 Z-.05
    N50 G01 Y0.1396384774068
    N60 X0.0848076923076923
    N70 X0.161240625 Y0
    N80 X0.0848076923076923 Y-.1396384774068
    N90 X-0.0848076923076923 Y-.1396384774068
    N100 x-0.161240625 Y0
    N110 X-0.0848076923076923 Y0.1396384774068
    N120 X0 Y0 (go back to center of hole to avoid plunging)
    N130 Z.1
    N140 Z-.1
    N150 Y0.1396384774068
    N160 X0.0848076923076923
    N170 X0.161240625 Y0
    N180 X0.0848076923076923 Y-.1396384774068
    N190 X-0.0848076923076923 Y-.1396384774068
    N200 x-0.161240625 Y0
    N210 X-0.0848076923076923 Y0.1396384774068
    N220 X0 Y0 (go back to center of hole to avoid plunging)
    N230 Z.1
    N240 Z-.125
    N250 Y0.1396384774068
    N260 X0.0848076923076923
    N270 X0.161240625 Y0
    N280 X0.0848076923076923 Y-.1396384774068
    N290 X-0.0848076923076923 Y-.1396384774068
    N300 x-0.161240625 Y0
    N310 X-0.0848076923076923 Y0.1396384774068
    N320 X0 Y0 (go back to center of hole to avoid plunging)
    N330 Z5 F500 (get tool out of way)

    and this is what I want to do:

    Run the code at 0,0,0 and then add +1 to Y and run the code 5 more times and then add +1 to X and repeat from the beginning 6 times.

    I could do it manually but I'd have hundreds of lines of code and rather learn how to do it the neat way.

    So there is no simple way to reset the zero's via gcode? If there was I could simply move to Y1 at the end of the code, reset everything to 0 and let it repeat itself. I would be suprised if mach3 doesn't have it. I mean I could probably program a macro to control my mouse and click the "zero Y" button in mach 3 and cycle start button everytime as well.

    If mach3 doesn't allow a reset axis gcode, does it allow a code to increment lets say Y by 1 instead of going to Y1, so if your already at Y3, you can use a code to increment by Y1 and it will go to Y4 instead of having to type G01 Y4

    Sorry if I confused anyone, still learning gcode. Got the handbook but I use it more as a sleeping pill than a book. Maybe I should start reading it in the morning

  5. #5
    Join Date
    May 2004
    Posts
    4519
    It seems what you would rather do and what you should do are two different things. Crawl before you walk. Walk before you run. When learning manual G-code programming, the more times you practice now in the beginning, the better you will be later. Take too many short cuts now and you will pay for it later.

  6. #6
    Join Date
    Jul 2005
    Posts
    12177
    "I got the code working for the square"

    Did you? In other words my contribution was of no assistance.



    "Maybe I should start reading it in the morning"

    Yes you should, before coming back here and wasting bytes asking trivial questions. I suggest you find out what G10 and G52 are for.
    An open mind is a virtue...so long as all the common sense has not leaked out.

  7. #7
    Join Date
    May 2012
    Posts
    0
    Quote Originally Posted by txcncman View Post
    It seems what you would rather do and what you should do are two different things. Crawl before you walk. Walk before you run. When learning manual G-code programming, the more times you practice now in the beginning, the better you will be later. Take too many short cuts now and you will pay for it later.
    Do you ever comment with the intention of helping others, or are all your comments negative with the intention of boosting your ego?
    It seems what you should comment and what you do comment are two different things! I have a feeling your an intelligent individual, please leave comments like this for high school kids!

  8. #8
    Join Date
    Apr 2002
    Posts
    5003
    With all incremental programming, you mustcome back to the same point, from where you starting. If not, the machine shifts your zeropoint to the difference.
    On a machine with a windows or similiar OS I prefer simply copying the contour and only insert the stepdepth.

  9. #9
    Join Date
    Jul 2011
    Posts
    0
    As my German Bavarian colleague already mentioned the program pattern should be copied and pasted 5 times using an offset code G55, 56 and the pattern will repeat in the new offset location. See CNC G54 Zero Offset 1 Mill Milling Fanuc 0M G Codes
    Out of curiosity, what programming tools are you using, which puts out numbers like yours with 13 digits?
    Else, I recommend using some CAM software CamBam CNC Software which helps particular beginners, generating G-codes with much less effort.

  10. #10
    Join Date
    Apr 2012
    Posts
    43
    Quote Originally Posted by uli12us View Post
    With all incremental programming, you mustcome back to the same point, from where you starting. If not, the machine shifts your zeropoint to the difference.
    On a machine with a windows or similiar OS I prefer simply copying the contour and only insert the stepdepth.
    Not necessarily true. I have several programs where I don't bother to do this and have no adverse effects.

    As always it's best to know your machine(s).

  11. #11
    Join Date
    May 2009
    Posts
    104
    On a machine with a windows or similiar OS I prefer simply copying the contour and only insert the stepdepth.
    I do that quite a bit.

    It seems what you would rather do and what you should do are two different things. Crawl before you walk. Walk before you run. When learning manual G-code programming, the more times you practice now in the beginning, the better you will be later. Take too many short cuts now and you will pay for it later.
    Words to live by IMHO.
    A good start would be an editor with backplot function along with
    the G&M code book for your CNC.
    You type code and it backplots the path as you edit.
    Play with that offline until you get the path right and there may be a cutter left after you try to run it in the mill.

    Good luck,

    Maz

Similar Threads

  1. simple G code help
    By Deltabox in forum G-Code Programing
    Replies: 22
    Last Post: 06-11-2012, 04:46 PM
  2. 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
  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 G-Code program?
    By N4NV in forum G-Code Programing
    Replies: 10
    Last Post: 03-25-2006, 01:35 AM
  5. Perhaps a bug in simple one line code??
    By thuffner3 in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 3
    Last Post: 02-03-2004, 03:21 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
  •