We use cookies to personalize content, interact with our analytics companies, advertising networks and cooperatives, and demographic companies, provide social media features, and to analyze our traffic. Our social media, advertising and analytics partners may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services. Learn more.
So I was reading the cnccookbook site and found out that gcode can use macros. Huge revelation to me but probably not to many others.
My main interest in using macros is to do simple operation such as facing and possibly milling wood to size. I tried googling grbl macros and wasn’t able to find much.
I did find a nice facing macro which I’ll post a link to below. Anyone else use macros/snippets like this? feel free to post your macros and share what you can.
Link to macro Facing Macro
I tried pasting it here but it doesnt work well converted to html.
UGS has a macro tab that you can store and run gcode from. I have one that will probe the x y and z axis all in one go. I can do this because I cut aluminum exclusively and can hook up the probe directly to the aluminum plate. Check out this post:
You can just write a small program that does nothing but the face operation then just load that into UGS and run it whenever you need to face something.
@AllenMassey if you follow that link it shows a macro for a facing operation. You can plug in your variables and the rest of the macro finishes the operation for you.
The way I understand that particular macro, it will take into account the width of your bit diveded by the material width and adjust the number of passes needed.
So rather than make a new cad/cam for every piece, you can plug in your height/width feed spped and bit and it takes care of the reset for you.
I understand what the macros are (and they are very nice). I just did not think that Grbl supported the type of gcode macros referenced.
The Macro commands tab on UGS is very useful but the Gcode entered into the Macro tab commands is just normal gcode snippets not the programming macros that support variables and goto commands like the facing example shows.
The gcode that @CharleyThomas provided for edge finding is super useful and works perfectly in the UGS macro slots.
I do not know of anyway to make that facing operation macro work in UGS/Grbl. I have a feeling that Grbl would throw a rod if you sent it a “goto” command.
I am just now finding the macro stuff so I’m not sure if they would work or not. I’m hoping someone more knowledgable can chime in and say what will and what wont work.
Even if the goto command wont work, I think the # variable could be used to accomplish the same thing.
No variables, no tool databases, no functions, no canned cycles, no arithmetic and no control structures. Just the basic machine operations and capabilities.
That is the page I was using. Under heading 6 List of all G-codes[30] it has the # variable as well as the O subroutine listed. I’m going to head to the shop and see what happens when you try using some of these.
FYI. Grbl doesn’t support macro programming. There was some thought at some point to include it, but modern high-level programming languages(i.e. Python) can do a much better job at generating variable-based g-code programs than traditional g-code macros. Also, macros are based on very ancient programming concepts and is very limited in what it can do.
That said, bCNC does have a “macro” programming language. It was just released a few weeks ago. It uses Python and uses the basic ideas around macro programming. It should be able to do everything macros can do and more, since you’ll have all of Python’s tools available to you.
Features
g-code sender
workspace configuration (dialog for G54…G59 commands)
auto leveling, Z-probing and auto leveling by altering the g-code during sending
basic CAM features (profiling, drilling)
user configurable database of materials, endmills, stock
graphically moving and arranging objects
g-code editor web pendant to be used via smart phones
graphical display of the g-code, and workspace
Goodies:
finger joint box generator
Don’t take any of this wrong. I’m not trying to say that it has macros, i just thought it did. From the evidence here i’m definitely wrong and thats ok. I just got excited over the possibility. Programming has never been a strong point for me. the only python I have ever used is ugs and thats idiot proof. I’ll have to look into a different way of doing what I want.
Yep. And it runs GREAT locally on a RaspberryPi 2. I’ve been using this a lot recently, but it’s still under development. Vasilis (a CERN researcher and lead developer) is working hard to add tool changes. Let him know of any issues you run across. He’s very prompt and good at fixing problems.
Any chance you can recommend a free python gcode Generator? I found intuwiz which has alot of options but paid software. Wife has me on a “no paid software” limit right now. . . sad days a my house right now.
One that can generate gcode from traditional g-code macros? Sorry no I don’t know of one.
If you know how to write g-code and any programming language, it should be relatively easy to generate what you want. It would also likely take as much time and effort to learn the g-code macro language as it would to learn a simple programming language like Python, TCL, or even the Arduino IDE (could have the gcode output to serial port and cut and paste to a text file).
If you were to learn one language, Python is pretty easy to learn. It can be as simple as a set of print statements and commands like a script, because all you need are variables, loops, and maybe functions. Just don’t look at bCNC’s Python code, because it uses more advanced objects and constructs than what you need.