[Scilab-users] Reading Gerber files and exporting g-code for cnc

Tim Wescott tim at wescottdesign.com
Fri Jul 31 04:13:38 CEST 2015


On Thu, 2015-07-30 at 16:30 -0700, PabloF wrote:
> Hi:
> I want to read a gerber file with scilab, process it and export a gcode file
> for using with a custom cnc we build in our university, for manufacturing
> PCB's with isolation method.. But i'm looking for advice.
> 
> By now, i've meade a script to read each line from a gerber file, and i use
> select-case to parse them... i can handle basic appertures (circles and
> rectangles) and do linnear interpolations by the momment..
> The main idea is to draw a binary image with the information of the gerber
> file and then do some image processing to get the edges of the image (with a
> sobel's filter or something).
> 
> The gerber specifications states that for tracks, i need to stroke or paint
> the arc or line with the selected apperture.. so i made a function that
> "paints" the shape of the apperture with center in a given coordinate of a
> matrix. For stroking a line for example, i should call this function for
> each coordinate of the interpolated line... I've done this but the process
> is too slow... Is there any simpler aproach?
> 
> Then, once i have the edges of the image, i don't know how to select the
> coonvinient coordinates of the detected edges so that i can export a g-code
> with them... for example, if i have to do a circle, i should give many
> points of the circle and form lots of tiny lines as an approximation, but if
> i have to do a line, i should only use 2 points.. I think this points can be
> detected with a corner filter, and then i should reorder them... any ideas
> of this? I want to do the circles with little lines so i get a simpler
> g-code for our custom cnc
> 
> Any ideas would be welcome! thanks

Before I did anything else, I'd look around to see if there were a board
aggregator in my economic zone from whom I could buy boards.  In the US
there's OshPark who'll sell you three N-square inch boards for N*$5, and
there's a number of shops in China that do this, possibly for less.

If I were bound and determined to route out boards, rather than trying
to make an image and then do image processing on that, I'd make an
algorithm that can tell if your router bit is in some copper, in the
clear, or on the boundary of some copper.  Then I'd either make it
follow that boundary (without, of course, cutting into any other bits of
copper), or I'd just scan the bit across the board, only cutting when
I'm free of copper.  The first way will be prettier, the second way will
be easier.

Finally, in spite of the fact that this is a Scilab group -- don't do it
in Scilab.  Scilab is great for things that use it's built-in matrix
handling capabilities, but when you step outside of that you'll be much
better off programming in C or some such.

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432





More information about the users mailing list