Some time ago I started playing with a small CNC milling machine controlled by GRBL. It was fun until I realised that for more or less complex tasks I would need some sort of macro-programming language, similar to LinuxCNC. Unfortunately LinuxCNC has the language interpreter deeply integrated with the machine control and it would be virtually impossible to extract it for using with GRBL.

So I decided to write my own interpreter and happy to say that the first version is ready. I called the language G# for simplicity, but in effect it follows (mostly) the syntax described in http://linuxcnc.org/docs/html/gcode/overview.html and http://linuxcnc.org/docs/html/gcode/o-code.html. Inconsistencies are minimal and mostly related to the specific new LinuxCNC features (like named parameters). It supports numbered parameters, conditions, loops, subroutines and active comments (e.g. debug messages) in the same way that LinuxCNC does. The output is a stream of plain G-code lines produced by interpreting G# macro lines.

I decided to build it as a software library, this way it may be used by various G-code senders. The API allows going step by step, getting a single consecutive G-code line at a time. The code is in github and has permissive BSD license: https://github.com/nrsoft/gsharp.

There is an example of how to use the library, which itself can serve as a stand-alone converter from G# program into plain G-code file. It doesn't have GUI, just command-line interface, but I guess this should be sufficient for an example.

I already mentioned the library on Shapeoko forum (there are quite a few people using GRBL), but CNCzone seems to have much bigger community, so I hope more people may find it useful.

I'm happy to support and enhance the library if there is any interest, so please let me know of any issues, incompatibilities or suggestions of improvement.

Similar Threads: