Forskningsavdelningen have been working on a new vectorization algorithm specifically designed for tracing PCB layouts, keeping CNC routing restrictions in mind to produce G-code that executes with minimal dwelling-requirements. This is a preview of stage-1 (vectorization) output of a sample input containing a large variety of potentially problematic designs:

Bitmap PCB to G-code conversion, stage 1
(Click to enlarge)

The algorithm is complete, and now begins the work of writing stage-2 (tool-size correction) and stage-3 (g-code generation). The finished solution will allow autonomous conversion of any PCB bitmap image to G-code for tracing, drilling and outline milling. Output options will be one program per operation and drill-size, or a single program with tool-change operations.


16 Responses to Bitmap PCB to G-code for CNC

  1. Hi Guys!
    I have done limited coding for PCB2GCode, and as you probably know, whats going on there is that the gerber files are rendered to black/white pixel graphics. Each seperated black object get a different color. Then some offsetting is going on, which is basically like a flood fill of a couple of pixels, either to compensate for the width of the isolation-milling tool, or to grow a voronoi shaped PCB (visolate style). Then there comes something like your step, but the outputed path still contains the pixel shape, and hence leads to very large gcodes, that are smoothed by the gcode G64 in the mill software:,-G61.1,-G64:
    Also, each islands surrounding is traced separately. This sometimes leads to some lines that are are done twice, or if voronoi is performed, all lines are done twice.
    It would be nice if your algorithms were useable as a C/C++ library, because then PCB2Gcode could benefit from that.
    Having continous pahts rather than “pixelated” paths should increase milling speed, and also quality, because I experimented with V shaped “gravierstichel” and the best results I got for low rotational speed and fast sidwards movement, with the only limit being the breaking of the tip at too low rotational speeds.
    Do you have some more info on what you do? If you want to discuss, please mail me, kubicek gmx at,

  2. [...] of [Forskningsavdelningen], a Swedish hackerspace, are working on software that will allow users to vectorize bitmap images in order to convert them to G-code files for CNC [...]

  3. JimmyG says:

    Can’t wait. Need a beta tester?

  4. Ray says:

    This sounds awesome. Can’t wait to use it :)

  5. James says:

    Looking forward to it! Especially when other people ask you to mill something, I seem to always get it as a bitmap and I have to manually convert to DXF.

  6. Kevin says:

    Please keep us in the loop.

  7. btomasz says:

    It looks great! I hope that it will be Open Source. What language you’re using?

  8. dude says:

    @spe: pcb2gcode (at the time this code was written) produces a pixel trace – ie arcs are NOT arcs, rather tons of short horizontal or vertical lines.

    This increases g-code size and the time required to mill the boards due to (de)acceleration required on sharp bends.

    Since all bends are 90 degrees the files produced matches the worst-case scenario for this type of work.

    A “dumb” machine with no (de)acceleration management will work better than a professional machine in this case, unless the professional machine also has smoothing (there is a G-code for that) but even with smoothing enabled, a properly designed file will still cut faster.

    This was what this project intended to address.

    Development was stopped, for no reason other than lack of interest. The code was not complex and basically consisted of a pixel tracer, just like pcb2gcode followed by an arc and line detection routine, followed by a routine to calculate the optimum curve/line parameters to match the input data.

  9. dude says:

    Ah yes, and a drill hole detector was in there somewhere to generate tap drilling g-code. It was basically designed to find inner traced areas of roughly circular shapes.

    These shapes were removed from the trace data, rounded off to the nearest available tool diameter and output to a separate file for each tool.

  10. Gus says:

    Hi “dude”.
    I’m interested in your project. Is the source code available?

  11. dude says:

    @Gus: no sorry, or… well I guess it’s somewhere on some compuler in some folder that I’ve forgotten about – but I really have no clue. Like I said though, the parts that worked perfectly were very simple (see above). The arc/line detection never reached a stable state. The whole code up to the point you can see on the screenshot took less than half a work day to complete and I’m pretty sure someone else could do a much better job.

  12. [...] an image which you would like to mill with CNC? Most likely it is not in vector format. This software takes care of it – it simply takes bitmap image and converts it to vectorized G-code that is [...]

  13. melhem says:

    i really need this nice program

  14. Nicola Lunghi says:

    I really need this!!! also if it’s incomplete! please share some code on github!!!!

  15. jarmo says:


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.
Creeper MediaCreeper