I switched to Linux over ten years ago, and never looked back - I love the freedom, stability and security that it provides. There are great equivalents for almost all Windows apps, but I found nothing for generating laser engraver gcode files.
So I either had to install Windows on an old laptop, or write my own cross-platform app. Guess which I did?Most laser engravers, 3D printers and other low-end CNC machines use an Arduino-based controller running an excellent open-source package called Grbl. It's ironic that the laser engraver vendors exploit the open-source movement by using Grbl, but provide only closed-source software to drive it.
Grbl expects to receive gcode instructions via a USB port. Gcode instructions for laser engravers are are fairly simple - they tell the laser to move to given coordinates at a given speed with the laser at a given power. To engrave something, you need a way to create the gcode instructions and a way to send those instructions to the controller. The sending part is easy - there are several solutions like Universal Gcode Sender that work on Linux (and other platforms). But how do we generate the gcode in the first place?
Vector and Raster Graphics
Your engraver is a vector device. That means it is good at drawing lines (vectors) from one position to another, and those positions can be anywhere on the work surface - you can draw a line directly from the bottom left to the top right, for instance. This is ideal for drawing vector graphics like SVG (Scalable Vector Graphic) images.You could make it behave like a raster device, too. By making it draw a series of horizontal lines very close together down the work surface, and varying the laser power as you do it, you could engrave a pixellated image. This mode is good for reproducing images contained in PNG or JPEG files.
Introducing Lasergcode
Given that the engraver is a vector device, it makes sense to use a vector graphics app to create the gcode. The most popular open-source vector graphics app is Inkscape, a very capable program which runs on all operating systems (Windows, MacOS and Linux). And it has a brilliantly simple way to extend it's capabilities.Inkscape already has an extension to generate gcode, called Gcodetools, but I was very disappointed with it. Its horrible user interface makes it very difficult to use, and the way it works is far from ideal. I thought I could do better, so I wrote lasergcode.
Lasergcode is designed purely for laser engravers. It's simple to install, and simple to use:
- Open your Inkscape document.
- Set the document width and height to your engraver's dimensions (File/Document Properties).
- Convert all objects (including text) to paths (Path/Object to Path).
- Choose File/Save a Copy..., select Laser gcode file (*.gcode) and click Save.
- Set the burn speed and repeat number, and click OK.
Lasergcode uses the path's opacity (alpha channel) to set the laser power. So if you want to burn a line at half power, set the stroke colour alpha to 128 (half of the maximum 256). The included intensity_chart.gcode file is useful for working out what opacity (power level) you need to use for a new material. Here is the result on chipboard:
Lasergcode also ignores any points outside the document boundary, so if you set the document width and height as suggested, it will never try to move outside those limits. This is an important safety measure, preventing damage from driving against the frame and fires from the laser burning one spot while trapped against the frame.
You can download lasergcode here. Enjoy!
What About Raster?
I haven't found a cross-platform solution for laser engraving raster images. It wouldn't be too difficult to write a python app that uses the PIL image library to resize an image and generates the Grbl 1.1 gcode to burn it, but I don't have the time to do this right now. If you know of something that does this, let me know in the comments below.
Hi Greg, stumbled across your blog whilst looking for a way to run the A3 pro on my mac. Still waiting for it to arrive, but I was wondering whether you are familiar with Axidraw? They have an extension for inkscape called “hatch fill” that enables filling of spaces.
ReplyDeleteI’m not very technical when it comes to software, so forgive my naivety if this is completely wrong. My understanding of lasergcode is that it will only engrave the outline of an image. If I were to fill a drawing with hatch fill and then generate a gcode using lasergcode, could that work to engrave a solid image?
Hi Mac - as long as the hatch fill is a path, it'll get rendered. I'll have to check it out - if you can make it draw lines close together, it should solve the fill problem very nicely.
DeleteSorry for the delayed response, I've been in Nepal doing the Everest Base Camp trek.
Doh! I've updated the post with a link to the download and install instructions.
ReplyDeleteThanks for pointing out my stupidity.
This is a good post. Thanks for sharing with us for Hp Latex 335 Price | Caldrongraphics.com.np , Excellent work and I really appreciate your work.
ReplyDeleteHi great readiing your post
ReplyDelete