I am building a website right now , and am trying to automatically calculate the number of PCB pads that are there given only a gerber file. One way is to manually review this. Is there any other way to determine how many pads a gerber file has? From a BOM one can easily find it. However, from the gerber is there anyway to find it?
-
\$\begingroup\$ Write a program that parses the Gerber and applies a heuristic on what looks like a pad and count them. \$\endgroup\$– PlasmaHHCommented Apr 1, 2016 at 7:40
-
\$\begingroup\$ @PlasmaHH, that is going to be really hard to do. ANy other options? \$\endgroup\$– user2578666Commented Apr 1, 2016 at 8:07
-
\$\begingroup\$ You say "given only a gerber file". Does that mean you have a single gerber data file or a zip file with like 10 gerbers in it? If it is one individual file then which layer does it represent? If it is a zip file then I suggest you use the top and bottom solder stencil files if available, or else the top and bottom solder mask files. These should mainly contain only rectangles, just count the rectangles after you've grouped the lines together. \$\endgroup\$– user98663Commented Apr 1, 2016 at 9:15
3 Answers
A Gerber artwork is mostly rendered by three "D-code" commands. D01 means move with exposure on. D02 means move with exposure off. D03 means flash. Open a Gerber file with a text editor and you can see the D-code commands at the end of the lines with the coordinates in front.
Typically, almost all the pads should be flashes on the soldermask layers. So counting the flashes on the soldermask layers would give you an estimate. But I don't think there is a sure way of knowing what is a pad from the Gerber file alone.
Pretty much all pads are not covered by the soldermask - leaving the pad exposed for soldering.
There is generally one soldermask layer (top) for single layer boards and two soldermask layers (top & bottom) for single layer boards. The gerber file(s) for these layers indicate the regions where soldermask should not be.
So count the number of regions there are in the top & bottom soldermask layers. This would give you the number of SMD pads + through hole pads (+ untented vias).
If you are only interested in SMD pads, you could subtract any region that has a hole within that region.
Untented vias may inflate the number pads you detect. You can rectify this by ignoring regions below a certain size. Eg 60 mil^2
A gerber viewer such as GC_Preview can tell you how many pads there are on each layer. I don't know if GC_Preview has a batch mode or API so it can be done automatically. Have alook on their website: GC_Preview
-
\$\begingroup\$ It can - import all the Gerbers into a project and assign them layers, and then do "Tools->Layer Info..." selecting all layers when prompted. It gives a pad count for each layer. \$\endgroup\$ Commented Apr 1, 2016 at 7:57
-
\$\begingroup\$ I was looking for something online, without a quote the customer may not place an order \$\endgroup\$ Commented Apr 1, 2016 at 8:06