Writing Your Own GCode?


Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Writing Your Own GCode?

  1. #1
    Registered
    Join Date
    Jul 2011
    Location
    USA
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default Writing Your Own GCode?

    I'd like to ask a few "survey" questions:

    1. How many people write their own GCode on a regular basis?

    2. Is it pretty simple stuff, or does it involve many lines of code?

    3. What editor do you use?

    4. What is your reason for doing it manually?

    Thanks

    Similar Threads:


  2. #2
    Member Don Clement's Avatar
    Join Date
    Jan 2007
    Location
    Running Springs, California USA
    Posts
    1332
    Downloads
    0
    Uploads
    0

    Default

    It would be more effectual to ask who doesn't write their own G-code.



  3. #3
    Member
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    12177
    Downloads
    0
    Uploads
    0

    Default

    'Survey' answers.

    1. I do.

    2. What do you call simple? The longest program has twelve tools, machines sixteen parts in four positions on a rotating fixture and uses thirty two work zeros. I don't know exactly how many lines of code but it was around 2000.

    3. Write them in Notepad and edit them on a Haas Simulator.

    4. Two reasons: I never learned how to do CAD/CAM and when I introduced CNC machines to my business CAM programs were nearly always slower running than hand coded programs when hand coding was possible. This becomes important when doing thousands of parts because even a difference of a minute in runtime can justify an extra 16 hours coding time per thousand parts machined.

    An open mind is a virtue...so long as all the common sense has not leaked out.


  4. #4
    Registered RogerHq's Avatar
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    10
    Downloads
    0
    Uploads
    0

    Arrow G-codes sucks.

    Yes I do bc my teatcher forces me to do it.
    The problem with G-coding is that it's a lousy way to create SW.
    As a former professional C-programmer I find the language incredibly primitive.
    Man is not supposed to remember what G00, G01, G02, M30 etc means because that is a job for a computer.
    So where is the assembler language?
    There is a macro language in the Fanuc Oi- controller but I haven't tried it yet.
    That gives you the opportunity to create loops and using symbolic variables, but that is also implemented in a very primitive way it seems.
    Maybe it's a topic here for that too?

    / Roger



  5. #5
    Member
    Join Date
    Aug 2010
    Location
    US
    Posts
    130
    Downloads
    0
    Uploads
    0

    Default

    1. I write some from complete scratch. Most programs I do some form of editing between CAM and actual machining. Sometimes that is changing just a couple of things, others it is a lot. It is something you should be prepared to do.

    2. None of my programs developed from complete scratch have been very complicated and I would guess are less than 200 lines.

    3. Notepad or Wordpad.

    4. I do manually programming when the work seems fairly simple and I want to machine it a certain way. I am not a CAM Master, so I do what it takes to get it done. For instance, I needed to remove material from a round piece held horizontally in the rotary table. I use Sprutcam and at the time, didn't know how to do the indexing in Sprutcam to machine the four sides with each one being different. I knew how I wanted to do it, so I wrote it by hand for each side and added the 4th axis moves to index to each side. It didn't take long at all. It would have been a long time in Sprutcam, with editing needed anyway.



  6. #6
    Registered
    Join Date
    Jul 2011
    Location
    USA
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default

    Geof - You're definitely in the advanced class of hand coding! I would say a simple program is less than 100 lines of actual GCode.

    RogerHq:
    My thoughts exactly. It is a crude language. The numbered codes are not descriptive, so they're hard to remember. A macro language would be nice. The problem with that is, it would have to kick out GCode to be run, and then you would still need to know the language when verifying/debugging the tool path. One more comment. I'd like to kick the clown that decided that parenthesis should be used for comments, and square brackets for operator precedence. Square brackets? Give me a break. The entire world uses parenthesis for operator precedence. At least they allowed the typical programming language double slash “//” for comments.

    Tbkahuna:
    I haven't gotten going with a CAM program, mainly because I'm just starting out. Everything I've done so far is simple 2.5D stuff. After researching CAM programs, I can see it might often be easier to hand code the simple stuff. Of course 3D is an entirely different story. I tried some of the wizards included with Mach3, but I find them very user unfriendly. I spent about 4 hours trying to figure out what some of the more obscure parameters do. I finally gave up, and wrote my own code in about 30 minutes.


    So far, 4 responses out of 45 views, which is about 10 percent. I suppose some number of those who "viewed" do write their own, but just didn't take the time to respond.



  7. #7
    Registered
    Join Date
    Jun 2007
    Location
    usa
    Posts
    143
    Downloads
    0
    Uploads
    0

    Default

    I am a model-maker or prototyper.

    I, generally, do NOT write G code. I can read, understand and modify it if necessary.
    Unlike the gent above that must conserve every minute of machine time, I rarely make more that 5 of anything. The 5 extra minutes of machine time is more than compensated by the efficiency of the CAM program producing the G code in minutes.

    As a matter of comment, G code was invented before C code. G code was implemented on very primitive controllers; think paper tape, teletypes and controllers with clock speeds less than 1 MHz (about 3000 times slower than the typical PC of today). I can understand your dislike for it RogerHg, but it is the foundation of CNC machines, you had better accept, understand and know it if you hope to be successful in your trade. You don't know the G codes? Keep a chart at your desk, one sheet of paper ought to do it. It takes a whole book for the C language. If you have that in your head, you ought to get the page of G codes memorized in no time :>}



  8. #8
    Member Don Clement's Avatar
    Join Date
    Jan 2007
    Location
    Running Springs, California USA
    Posts
    1332
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by flyinchips View Post
    I am a model-maker or prototyper.

    I, generally, do NOT write G code. I can read, understand and modify it if necessary.
    Unlike the gent above that must conserve every minute of machine time, I rarely make more that 5 of anything. The 5 extra minutes of machine time is more than compensated by the efficiency of the CAM program producing the G code in minutes.

    As a matter of comment, G code was invented before C code. G code was implemented on very primitive controllers; think paper tape, teletypes and controllers with clock speeds less than 1 MHz (about 3000 times slower than the typical PC of today). I can understand your dislike for it RogerHg, but it is the foundation of CNC machines, you had better accept, understand and know it if you hope to be successful in your trade. You don't know the G codes? Keep a chart at your desk, one sheet of paper ought to do it. It takes a whole book for the C language. If you have that in your head, you ought to get the page of G codes memorized in no time :>}
    Hello world! I also programmed in C and think that G-code is primitive. I started programming with Blat IV Fortran back in 1972 on 80 column punch cards before C was widely used. Fortran on punch cards is more sophisticated than G-code but still primitive, not as primitive as writing assembly code for an 8008 microprocessor though. Remember the Adam Osborne books?

    I agree that a good CAM program (i.e. SprutCAM) is the way to go however one really does need to know G-code even when using CAM. It's like using NI LabView vs programming in C. One does not have to know C to program in LabView but it sure helps to program better.

    Don



  9. #9
    Member
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    12177
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by flyinchips View Post
    ...As a matter of comment, G code was invented before C code. G code was implemented on very primitive controllers; think paper tape, teletypes and controllers with clock speeds less than 1 MHz (about 3000 times slower than the typical PC of today)......
    This is what a lot of you young guys either overlook or are not aware off. NC machines predated personal computers and the G and M codes have been 'etched in stone' for a long time. It is somewhat analogous to the Qwerty/Dvorak keyboard situation. Dvorak is more efficient but how many people use them? Qwerty hangs on simply because it is the most common.

    An open mind is a virtue...so long as all the common sense has not leaked out.


  10. #10
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    816
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by Money Pit View Post
    I'd like to ask a few "survey" questions:

    1. How many people write their own GCode on a regular basis?

    2. Is it pretty simple stuff, or does it involve many lines of code?

    3. What editor do you use?

    4. What is your reason for doing it manually?

    Thanks
    I don't. Mainly because I have been using CAD for almost 30 years and very comfortable drawing something in CAD and using to create the Gcode.


    That being said recently I have been doing tasks that I realize can benefit from writing my own Gcode. Just made 20 parts with a secondary opt that was simply two holes drilled on each side. A simple Gcode would have been quicker than manually moving the axis.. But I learned more about the MDI commands



  11. #11
    Registered
    Join Date
    Jul 2011
    Location
    USA
    Posts
    20
    Downloads
    0
    Uploads
    0

    Default

    For those of you using regular Windows Notepad, you should check out Notepad++. It's free, and you can find it at Notepad++ Home

    One of the really nice features is that you can create a User Defined Language, which is a way to highlight syntax. I've attached a sample GCode file that is highlighted by a UDL.

    Attached Thumbnails Attached Thumbnails Writing Your Own GCode?-notepad-gif  


  12. #12
    Registered
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    228
    Downloads
    0
    Uploads
    0

    Default

    1. I very, very rarely write gcode.

    2. When I do write manual gcode it is usually to test something. The blocks might be complex, but there are very few of them.

    3. If I use an editor I use Textpad. It doesn't have any gcode specific features, I just like it.

    4. Like I said, my reason is to test something, or to learn something.

    I use Vectric's VCarve for 99.99% of my work. It does the gcode for me.



  13. #13
    Registered
    Join Date
    Nov 2006
    Location
    usa
    Posts
    134
    Downloads
    0
    Uploads
    0

    Default

    I frequently write my own gcode.
    Mostly I use fairly simple stuff, such as for facing and squaring blanks, but some part programs grow rather complex. I don't often go over 1,000 hand-written lines because I use a lot of structured programming techniques, with conditional control flow, data structures and subroutines, etc. I have used hand-coding to implement multi-part fixtures that seem like they would be a PITA using CAM. I can call CAM-generated operations for complex geometries from my fixturing control loops, in addition to calling hand-written operations for simple stuff.

    If I'm coding huge amounts of part geometry by hand there is probably a more efficient way to do it in CAM, but if the geometry is simple enough then hand coding is often way more efficient to go from art to part.
    I use gvim on my main engineering workstation and notepad++ at the machine controller.

    Many parts are faster for me to program in CAM than by hand, but there are often particular operations, such as thread milling operations, that are faster to code by hand than to wrestle with SprutCAM.

    A few days ago I wrote a program that allowed me to use a spindle-mounted abrasive wheel and a verticle 4th axis to finish-grind a couple of bores into the tenths. Within a few minutes of coding time I had cycles for dressing the wheel automatically, in-feeding and cross-feeding the cut to specific but easily-adjusted finish locations and then retracting for in-process bore measurements and adjustments, etc. I can't imagine trying to accomplish all of this using general-purpose CAM - it would probably all be a big ugly hack, instead of what I actually wanted.



  14. #14
    Member
    Join Date
    Aug 2011
    Location
    UK
    Posts
    617
    Downloads
    0
    Uploads
    0

    Default

    I used to work in the PCB industry. PLotting , drilling , and routing.

    I used to write programs in pascal that wrote the code for me !
    much less time (and less boring) than coding yourself :-)



  15. #15
    Registered RogerHq's Avatar
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    10
    Downloads
    0
    Uploads
    0

    Default G-code assembler?

    Quote Originally Posted by Tricky! View Post
    I used to work in the PCB industry. PLotting , drilling , and routing.

    I used to write programs in pascal that wrote the code for me !
    much less time (and less boring) than coding yourself :-)
    Well, that sounds like some sort of G-code assembler!
    You are invited to go into details!

    / Roger



  16. #16
    Member
    Join Date
    Aug 2011
    Location
    UK
    Posts
    617
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by RogerHq View Post
    Well, that sounds like some sort of G-code assembler!
    You are invited to go into details!

    / Roger
    It was actualy Gerber code, but for the proccess of writing the program it is identical.

    Basically we would take the customer data for the PCB. My program would read through the gerber data, find the size of the board. Offset it and step and repeat , rotate etc it to fill our standard size panels. Then it would generate the code for the panel test holes, tracks, add alignment holes and targets to the artwork. Router paths with tabs for the board cutouts etc etc.

    It's really simple stuff. Just move to a coordinate (X,Y) and then do something (cutter up / down / peck / etc.)

    For simple stuff like just cutting a rectangle, it's quite simple to just type the actual code using a text editor.



  17. #17
    Registered
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    340
    Downloads
    0
    Uploads
    0

    Default Notepad++ Gcode UDL

    Quote Originally Posted by Money Pit View Post
    For those of you using regular Windows Notepad, you should check out Notepad++. It's free, and you can find it at Notepad++ Home

    One of the really nice features is that you can create a User Defined Language, which is a way to highlight syntax. I've attached a sample GCode file that is highlighted by a UDL.
    Hi MoneyPit,
    Did you write the Gcode UDL that you use or did you download it from somewhere?

    I use Notepad++ as well and until reading your post I was not aware of the UDL capibility. Having examined the Hlep file, producing a UDL seems straightforward, but just a little tedious to enter all the key words, etc. The one you use looks well done.

    Any info would be appreciated.
    Bevin



  18. #18
    Registered
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    340
    Downloads
    0
    Uploads
    0

    Default

    Looking at your thumbnail I can see that entering the keywords and the rest will be easy. So I will write the UDL tomorrow.

    Another question... does that code in your thumbnail run on the Tormach Mach3 controller? When I tried to use // for a comment, Tormach M3 would report an error at those characters.



  19. #19
    Registered RogerHq's Avatar
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    10
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by Tricky! View Post
    It was actualy Gerber code, but for the proccess of writing the program it is identical.

    Basically we would take the customer data for the PCB. My program would read through the gerber data, find the size of the board. Offset it and step and repeat , rotate etc it to fill our standard size panels. Then it would generate the code for the panel test holes, tracks, add alignment holes and targets to the artwork. Router paths with tabs for the board cutouts etc etc.

    It's really simple stuff. Just move to a coordinate (X,Y) and then do something (cutter up / down / peck / etc.)

    For simple stuff like just cutting a rectangle, it's quite simple to just type the actual code using a text editor.
    Well, I have learnt that simple things have a tendency to become complicated at the time of implementation...

    Anyway, taking on the task of creating an assembler/compiler for G-code seem to be a real challenge considering the lack of standard.
    I guess I have to leave it for a while but maybe there is some willing in the zone? ;-)

    / Roger

    Last edited by RogerHq; 08-15-2011 at 10:57 AM. Reason: Too many smileys (2) ;-)


  20. #20
    Registered
    Join Date
    Dec 2010
    Location
    USA
    Posts
    201
    Downloads
    0
    Uploads
    0

    Default

    My boss freakin' DREAMS in Allen-Bradley 8400MP G code.

    And he is pretty good with optimizing the stuff, because, well, it isn't like that thing has enough memory to deal with the kind of stuff I write... er... have exported...

    G code reminds me of some fairly primitive printer driver stuff - I wrote some printer drivers back in the 1980s, and it seems fairly similar.



Page 1 of 2 12 LastLast

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Writing Your Own GCode?

Writing Your Own GCode?