Writing Your Own GCode? - Page 2


Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: Writing Your Own GCode?

  1. #21
    Registered
    Join Date
    May 2007
    Location
    US
    Posts
    781
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by RogerHq View Post
    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
    There are/have been higher level CNC programming languages.
    APT was one, What is Apt

    Before reinventing the wheel it would be a good idea to do a bit of research.



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

    Default

    Quote Originally Posted by bevinp View Post
    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

    I wrote it, and it's very simple. I've attached a UDL file that you can import. Before you import, you will need to change the extension from ".txt" to ".xml". Seems the system wouldn't let me upload an XML file. To import:

    Select "View", "User-Defined Dialogue..."
    Click the "Import..." button
    Select the file "GCode_UDL.xml"


    When you see it, you won't believe how simple it is. That UDL file specifies that all files with the extension ".tap" are considered GCode files, and the formatting will be applied when they are opened in the editor.

    Attached Files Attached Files


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

    Default

    Quote Originally Posted by bevinp View Post
    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.
    Oops, that could be a problem. I haven't tried to run it yet, but in section 7.5.5 of the Tormach manual, it says "//" is valid for a comment. So much for accuracy in documentation.

    Take another look at that thumbnail again. There's some other "weird stuff" going on in there...



  4. #24
    Gold Member BobWarfield's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    2502
    Downloads
    0
    Uploads
    0

    Default

    Ah, the ever popular "Do you write your own g-code?" question. Always an interesting discussion. We surveyed the readers of CNCCookbook on this and I was shocked at how many professed a fairly high proficiency with it.

    I attached the survey results to the front of our g-code tutorial:

    CNCCookbook's G-Code Tutorial and Course

    Upon reflection, I became a little less shocked. Several of you mention being C coders. Really great C coders are very familiar with assembly and what the C code will produce. Heck, as a language and compiler, C isn't much more than a fancy macro assembler for the PDP-11. It has arcana too that are peculiar to the 11's old assembly language, LOL. All that pre and post decrementing, for example.

    So it is with g-code. Whether you want to write it from scratch or use CAM, having good proficiency with g-code will make you a better CNC machinist.

    Here's the thing: sooner or later your CAM program will have a bug, your post will be not quite right, you'll wish you could optimize the post to save yourself some time, or you'll have a case where you want a program to do something slightly different that's very hard to accomplish with the CAM program.

    I'm not talking about optimizing a few seconds out of a part program that will make hundreds or thousands of parts--these things come up even just for very short programs. Whose of you who have spent time with C will recognize that being able to see what's really going on down in the guts can give you a lot of insight into how to write better C. In this case, you'll get insight out of how to get better results with your CAM program.

    The other thing is that a little bit of proficiency will mean you can make little tweaks without having to run it all back through the CAM program. That's one more thing that can save you a lot of shop time.

    Here's the other thing--as a lifetime software engineer, it's rare that I don't see some new language and immediately wish it did some things differently. G-code is no different. Yes, it seems arcane, but what you'll discover is it actually works pretty well for what it does. We're not writing operating systems or iPhone apps in it, we're moving cutters around in precise and consistent ways. There are relatively few g-codes to memorize, and it isn't hard to get used to them reading the g-code your machine's execute. At worst you may have a hard time remembering exactly how a canned cycle works. Easy to look up, or if you have a tool like my G-Wizard Editor you can let it worry about it.

    So go ahead, give the g-code a try. You'll be surprised at how easy it is with even a little practice.

    Cheers,

    BW

    PS The other thing you'll discover about g-code is that like any "standard" the wonderful thing about it is there are so many versions to choose from. Lots of arcana in the specific g-code dialects for various controllers. You can get an idea looking at the "post" options for the G-Wizard Editor.

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


  5. #25
    Registered
    Join Date
    May 2011
    Location
    Carnation, WA - USA
    Posts
    180
    Downloads
    0
    Uploads
    0

    Default

    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.
    Thanks for sharing the UDL file.



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

    Default

    Quote Originally Posted by BobWarfield View Post
    Upon reflection, I became a little less shocked. Several of you mention being C coders. Really great C coders are very familiar with assembly and what the C code will produce. Heck, as a language and compiler, C isn't much more than a fancy macro assembler for the PDP-11. It has arcana too that are peculiar to the 11's old assembly language, LOL. All that pre and post decrementing, for example.

    For me the desire to move to CNC as a hobby/part time job, was to get away from the computer more and actually stop writing code (Dr's orders). I don't mind using Gcode some, but you have to remember any language, if you do not write with it everyday, you will soon forget it or not be as proficient. A few lines would be no problem. A few hundred/thousand.. No way.



Page 2 of 2 FirstFirst 12

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?