I was reading an older thread User defined variables for custom macro and so, It made me curious. I have never written any CNC macros, but I do have a bit of a programming background.
Wow! talk about cryptic and difficult to use with everything using M and G codes and variable names that are just numbers like #100 and programming in a text editor like Notepad ++ or Sublime. I thought there must be a better way so, I started digging deeper. I found a few interesting things.
I use Visual Studio to code in Python and C#, and it is a great free development tool with lots of extensions and a built-in Ai programming assistant called Co-pilot.
The first thing I did was look for an extension that could do code highlighting. that can turn code that looks like this:
The extension is called G-Code Syntax by Applied Engineering and Design
As far as the AI tools go, Co-Pilot does include some free AI tools, but for a small monthly fee, you can add on some very powerful options. I generally use Anthropic’s Claude-Sonnet Ai to help me code. It seems to be the best overall.
Just to give you a taste, I set my Co-Pilot to use Claude in Agent mode and presented this prompt:
”Generate a Centroid M6 macro for an ISO30 ATC”
This is what I got back: (You might want to click the image then zoom in)
I don’t have my Ex controller or CNC12 yet, so I have no idea if this is valid or not. You would of course, have to change the I/O assignments. But this is a great starting point at least.
This was just a made-up scenario, but I thought it was pretty cool. I did not know Claude-Sonnet could generate Centriod CNC macros. Anyway, I thought I would share in case anyone finds this useful.
I have almost zero coding background but I have also be using AI to start messing with some basic Macros. I know you need to be very careful implementing what it spits out but it seams like this has the potential to turn coding into a simple conversation were you are only limited by what you can think of and describe.
For development here I use VS code and that same plugin you referenced for color and syntax highlighting.
I took a brief glance at your AI generated M6 and… it’s exactly what I expected: Unworkable.
These AI tools are pretty fantastic at modern languages, especially for stuff that involves the web and web apps. They absolutely cannot figure out macro code. It makes sense… it’s an esoteric mix of G code, BASIC, and DOS.
As someone who is very pro AI tools in software development, I would strongly advise against using them for Centroid macros… it just doesn’t work for them, and without a massive body of work they likely won’t learn.
He also mentioned in the previous thread that there is a new update in the works that might make building or modifying macros a little more accessible…
Macros are all plain text, and anyone can get at them and mod them. In this new update they are WAY more modular than they are now. Each “function” has it’s own macro, and then there are larger macros that orchestrate the smaller ones.
In theory this makes them much easier to mod. Let’s say there a particular function you want to tweak you could find that macro and tweak it. If you want to make fundamental changes to the orhestration of things, that might get harder just because it could take a bit of research to see how everything works together.
However! The hope is that you won’t need to actually do that. We’ve tried to think of every use case and hopefully there’s a setting in our menus that you can change to get what you need so you don’t have to resort to editing code