Gcode Laser Engraving Software

25,453

46

22

About: hacker working as hacker

I made this instructable because I couldn't find software for engraving images with G-code controlled laser. I tried inkscape with extenstions, but this isn't what I expected. I want to engrave photos like attached one, make PCBs etc.

@edit: I wont support nor provide old version any longer New one was written in python, can be used on any platform and is opensource! There is precompiled Windows executable in my github repo (link's below).

@not longer true: So I wrote app in Matlab, which I use commonly on my university. I call it imGcode I want you to give it a try. It is standalone executable, with all libraries attached, so you will only need to install one file and it should work.

You will need laser with grbl or other Gcode controller. It have to have laser PWM controlled by S code.

App is here:

https://github.com/vidmo91/imgcode

Step 1: Imgcode

App is very simple. You'll have write parameters in command line after app name:

python imgcode.py image_path output_file_path x_offset_mm y_offset_mm output_image_horizontal_size_mm pixel_size_mm feedrate max_power number_of_colours

e.g. python .\imgcode.py lena.png test.nc 0 0 10 0.2 100 255 5

e.g. python .\imgcode.py "C:\Documents\laser files\lena.png" "C:\laser files\out files\output_gcode.nc" 0 0 10 0.2 220 1000 5

image_path - path to image file relative or absolute (most file formats should work, if something fails convert it with MS Paint to bmp or png). Image can be bw or rgb.

output_file_path - path to gcode file (any extension can be provided .nc is quite standard on)

x_offset_mm y_offset_mm - origin offset it is point where lower left corner of image will be according to machines' coordinate system.

output_image_horizontal_size_mm - size of eatchet image - pretty obvious, I hope

pixel_size_mm - size of one pixel of image You can set it as you like, but I think that the best value is 0.1mm or 0.2mm.

feedrate - speed of laser head in mm/min

max_power - maximal laser power 255 or 1000 in most machines

number_of_colours - number of colours / power steps in output image 1 means B/W etc.

For better results use some graphic program that will allow you to change image to B/W, make higher contrast and set brightens to appropriate level.

Step 2: Additional Info

imgcode is quite slow when working as standalone executable compared to python script, so please be patient or use script instead.

If you have inverted Y axis in opposite direction to my drawing in previous step, it will work, but image will be upside down and origin offset will show upper left corner.

Let me know if any bug appears or you need any changes.

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Sensors Contest

      Sensors Contest
    • Backyard Contest

      Backyard Contest

    22 Discussions

    0
    None
    VadimF3

    4 months ago

    Greetings,
    would you consider open sourcing your code? I would be quite interested in studying from it, and perhaps, porting it to python, to make it easier to deploy.

    3 replies
    0
    None
    VidmoVadimF3

    Reply 4 months ago

    I lost it with HDD malfunction. I was dumb enough to not upload it to cloud or email.
    Anyway algorithm was like that:
    Resize image so 1px is minimal CNC step.
    Set colours to desired levels eg. 16 colors for 16 laser power steps, or binary for BW only.
    Now zig zag through picture when it's white than M5 G0 to first next black
    When it's back than M3 G1 to first next white or line ending. And x,y pos in pixels have to be multiplied by CNC minimal step size to get real position. Eg. Minimal step is 0.01mm that picture 10x10mm have to be 1000x1000px and (100,100) position on picture is in reality (1,1)mm which is X1 Y1 in gcode.

    0
    None
    VidmoVidmo

    Reply 4 months ago

    I forgot you have to set laser power with code Sxxx for every colour value and you should scale maximum value to something like 255 or 1000 or user input preferably (it is machine dependent).

    0
    None
    tejadacoll

    1 year ago

    Hi, maybe I did not understand the instructions well, but it does not work on Windows 7

    0
    None
    webberen

    Question 1 year ago on Step 2

    Splash screen comes up, then it disappears ? It is still running in the background tho'

    0
    None
    webberen

    1 year ago

    Hey there, downloading as I write. Will it use M106 S commands and can you save in .gcode format. I use it a ramps arduino setup.

    0
    None
    ed_d

    1 year ago

    Thank you for this. I bought a DIY laser like yours a month of so ago and the software that came with it is very basic and limited. What I want is photos like your example but no luck so far. When I set up a file using Photoshop the laser software takes liberties with it and it turns out most black and white with little to no shading in between. I am getting closer by using "lasergrbl", which is a lot nicer for photos but still tweaking. This laser was so inexpensive so I do not want to buy software that at best will cost $40 or one third the cost of the machine. I tested "T2Laser" and think this might just be the premium photo engraving software but they are cheap with their demo. It only runs for 30 minutes and allows a limit on how many lines it will burn down while testing so not enough time to see results. In a passion, after thinking I was getting good results, I tried to buy the full version of this software but they only accept PayPal, which I have no luck using from where I work near Hong Kong so I was stopped cold. I already could write a book with what I have learned but none of it has yet yielded acceptable results. Now I am starting to consider upgrading to a small Chinese Co2 laser with 40 or 50 watts as they are more versatile in terms of photo burning, especially on acrylic, which our diode lasers will not work very well. It was photos and acrylic that got me interested and these are not working so well with a 6.5 watt diode. I will try your software and let you know how it comopares to what I have tried so far.

    0
    None
    surfer8

    1 year ago

    Nice work!

    Back in the late 80’s I worked in a laser application lab in
    Massachusetts. At Christmas time I set up a moving table CO2 laser system to do
    a raster scan of black and white artwork.
    I set up a bar code reader parallel to the laser head.

    I would do a step and repeat raster scan with the table.
    When the barcode reader saw dark it would fire the laser. The laser head was
    positioned above a piece of birch plywood. It did a very nice job reproducing
    the artwork.

    0
    None
    PaulS615

    2 years ago

    Hi, I installed it on my windows 10 desktop and everything went well but when I tried to run the program I got the splash screen and it closed and the another window popped up and immediately closed. So fast I could not see what it was, but it looked like the main window.

    0
    None
    Vidmo

    2 years ago

    You may try using lasergrbl.com instead of my software. It seems to be good equivalent.

    0
    None
    erniehattPicengraverToo

    Reply 2 years ago

    I can assure you they do not work on all systems.

    I thank the op for giving us the use of this, it works for me though I am having problems getting small details in faces, any tips for preparing the image first. thanks

    0
    None
    Vidmoerniehatt

    Reply 2 years ago

    You should edit photo first in Lightroom or other developing software. Make it W/B, change contrast to maximum possible, also try using highest values for whites and lowest for blacks, reduce colors to number closest to one you want to achieve (MS paint can save bmps with reduced colors).

    0
    None
    erniehattVidmo

    Reply 2 years ago

    Thankyou for that.

    With a lot of files I get the message.

    MAP must be a mx3array

    Error in -> img2gcode02.m at line 12

    Can anyone please explain this.

    thanks

    0
    None
    Vidmoerniehatt

    Reply 2 years ago

    That is some issue with file format. Color map is not recognizable by program. Maybe it shouldn't be BW. I lost code and I don't remember exactly what was there... Try saving it in different format.

    0
    None
    VidmoPicengraverToo

    Reply 3 years ago

    It is too expensive for me. I would have to work longer to earn $40 than I coded my application.

    0
    None
    adibiut

    2 years ago

    Hi. Do you have version for 32bit cpu?

    This doesn't run on my laptop

    2 replies
    0
    None
    Vidmoadibiut

    Reply 2 years ago

    I'll see what I can do.

    0
    None
    VidmoVidmo

    Reply 2 years ago

    I'm sorry, I can't find code anywhere, I think it's on my old PC in myparents' house. Unfortunetly it might be corrupted, because I had very unplesant virus on that pc. I'll let you know as soon as I visit my parents.