GCODE macro language

Here is a new gcode macro language but of it is not for the faint of heart.
It is called G# and found here https://github.com/NRSoft/GSharp

Here is the info from the author

I was surprised that GRBL controllers do not support standard macro-programming language similar to LinuxCNC. I heard that bCNC introduced Python-like programming, but because it is rather non-standard this limits application area and user acceptance.

I absolutely understand that it is impossible to add this functionality to GRBL itself. GRBL code is ingenious enough to fit G-code interpreter, route planner and CNC controller into 32KB of Arduino memory. But I cannot see why it cannot be done in the external software controllers.

So to fix this discrepancy I wrote a software library which converts macro-programming commands (highly compatible with LinuxCNC, differences are minimal) into a stream of corresponding plain G-code lines. I called it G# language for simplicity, but in effect it has the same syntax, described in G Code Overview and O Codes. Variables, conditions, loops, subroutines, active comments - all included.

The library has quite a simple interface to be incorporated into existing controllers. The code is in github and is under permissive BSD license. You can get it from here: https://github.com/NRSoft/GSharp. I’m happy to support and enhance the library if there is any interest. Currently it’s been tested under Ubuntu Linux only, but it’s generic enough to be used in other OS platforms.

In addition to the library there is an example of how to use it. After simple compilation it can work as a stand-alone converter from G# program into plain G-code file. (It is command-line application, doesn’t have any GUI).

I would be happy to get any comments, bug reports and suggestions on how to improve the library.

2 Likes