Discussion:
Gerber Export Generates Abitrary Drill Tool Numbers
(too old to reply)
Geoffrey Yerem - HEAT, LLC
2014-07-15 17:29:59 UTC
Permalink
Hello,
I'm having a small problem with the Gerber export in PCB. When it
generates the cnc drill file, it starts the tool numbers at an arbitrary
count. For example,

...
T648C0.016
T647C0.167
...

This normally isn't a problem when I'm viewing the gerbers in gerbv,
but my fab house is complaining that they can't handle tool numbers
greater than 255.

While I imagine that they can fix things on their end, is there any
reason to start the tool numbers so high? Why can't they simply start
at 001? Is there a workaround where I can fool PCB into starting at a
lower number, so I don't have to manually edit the file and risk making
a mistake?

Thanks for your help!

Geoffrey
Gabriel Paubert
2014-07-16 08:02:41 UTC
Permalink
Post by Geoffrey Yerem - HEAT, LLC
Hello,
I'm having a small problem with the Gerber export in PCB. When it
generates the cnc drill file, it starts the tool numbers at an
arbitrary count.
Not exactly an aribtrary count, it uses the same number space for Gerber
apertures and drill numbers.

I believe I submitted a patch for this and it was not included because
it was thought that it could break something. I have appended the patch
to this mail, but I don't know whether you compile from sources or use
a version packaged in the distribution.
Post by Geoffrey Yerem - HEAT, LLC
For example,
...
T648C0.016
T647C0.167
...
This normally isn't a problem when I'm viewing the gerbers in
gerbv, but my fab house is complaining that they can't handle tool
numbers greater than 255.
So the current PCB system breaks your fab process.
Post by Geoffrey Yerem - HEAT, LLC
While I imagine that they can fix things on their end, is there any
reason to start the tool numbers so high? Why can't they simply
start at 001? Is there a workaround where I can fool PCB into
starting at a lower number, so I don't have to manually edit the
file and risk making a mistake?
Apply the following patch and recompile:


diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index 6d7c7c1..d02d35d 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -106,7 +106,8 @@ enum ApertureShape
SQUARE, /* Shaped like a square */
ROUNDCLEAR, /* clearance in negatives */
SQUARECLEAR,
- THERMAL /* negative thermal relief */
+ THERMAL, /* negative thermal relief */
+ DRILL
};
typedef enum ApertureShape ApertureShape;

@@ -174,7 +175,7 @@ deinitApertureList (ApertureList *list)
initApertureList (list);
}

-static int aperture_count;
+static int aperture_count, drill_count;

static void resetApertures()
{
@@ -187,6 +188,7 @@ static void resetApertures()
layer_list_max = 0;
layer_list_idx = 0;
aperture_count = 0;
+ drill_count = 0;
}

/* Create and add a new aperture to the list */
@@ -200,7 +202,8 @@ addAperture (ApertureList *list, Coord width, ApertureShape shape)

app->width = width;
app->shape = shape;
- app->dCode = DCODE_BASE + aperture_count++;
+ if (shape == DRILL) app->dCode = ++drill_count;
+ else app->dCode = DCODE_BASE + aperture_count++;
app->next = list->data;

list->data = app;
@@ -694,7 +697,7 @@ gerber_set_layer (const char *name, int group, int empty)
{
if (i == 0 || pending_drills[i].diam != pending_drills[i - 1].diam)
{
- Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, ROUND);
+ Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, DRILL);
fprintf (f, "T%02d\r\n", ap->dCode);
}
pcb_fprintf (f, metric ? "X%06.0muY%06.0mu\r\n" : "X%06.0mtY%06.0mt\r\n",
@@ -762,7 +765,7 @@ gerber_set_layer (const char *name, int group, int empty)
if (is_drill)
{
/* We omit the ,TZ here because we are not omitting trailing zeros. Our format is
- always six-digit 0.1 mil or µm resolution (i.e. 001100 = 0.11" or 1.1mm)*/
+ always six-digit 0.1 mil or um resolution (i.e. 001100 = 0.11" or 1.1mm)*/
fprintf (f, "M48\r\n");
fprintf (f, metric ? "METRIC,000.000\r\n" : "INCH\r\n");
for (search = aptr_list->data; search; search = search->next)
@@ -947,7 +950,8 @@ use_gc (hidGC gc, int radius)
radius *= 2;
if (radius != linewidth || lastcap != Round_Cap)
{
- Aperture *aptr = findAperture (curr_aptr_list, radius, ROUND);
+ Aperture *aptr = findAperture (curr_aptr_list, radius,
+ is_drill ? DRILL : ROUND);
if (aptr == NULL)
pcb_fprintf (stderr, "error: aperture for radius %$mS type ROUND is null\n", radius);
else if (f && !is_drill)
Post by Geoffrey Yerem - HEAT, LLC
Thanks for your help!
Geoffrey
Regards,
Gabriel
Peter C.J. Clifton
2014-07-16 10:05:51 UTC
Permalink
Post by Gabriel Paubert
Post by Geoffrey Yerem - HEAT, LLC
Hello,
I'm having a small problem with the Gerber export in PCB. When it
generates the cnc drill file, it starts the tool numbers at an
arbitrary count.
Not exactly an aribtrary count, it uses the same number space for Gerber
apertures and drill numbers.
I think we deliberately don't re-use numbers between the various files
we export. This allows people to copy+paste outline / random notes layer
content in the output file into the files for other layers - without any
apperture clashes / conflicts.


I'd suggest you change your board house. If their CAM software is so
broken in one respect, I would suspect there could be other issues
lurking. It also speaks to a certain lack of investment in their
process, so who knows where else they will be using sub-standard
workflows.

For our ammusement, you might find out which vendor supplied their
BROKEN CAM software, which version it is / which centuary they purchased
it.

Sorry not to be more helpful.. As Gabriel said, you may be able to patch
the source-code to achieve what you want. Just be SURE to check the
Gerber files that result actually preview correctly in a gerber viewer
(like "gerbv") before sending them for manufacture.

Regards,

Peter Clifton
Gabriel Paubert
2014-07-16 10:52:53 UTC
Permalink
Post by Peter C.J. Clifton
Post by Gabriel Paubert
Post by Geoffrey Yerem - HEAT, LLC
Hello,
I'm having a small problem with the Gerber export in PCB. When it
generates the cnc drill file, it starts the tool numbers at an
arbitrary count.
Not exactly an aribtrary count, it uses the same number space for Gerber
apertures and drill numbers.
I think we deliberately don't re-use numbers between the various
files we export. This allows people to copy+paste outline / random
notes layer content in the output file into the files for other
layers - without any apperture clashes / conflicts.
I have to disagree for __drill__ numbers. I can understand it for
aperture which go into Gerber files (since I sometimes edit them
by hand myself). But drill numbers are not even in the same file
format as apertures and are not processed by the same machine, so
having independent number spaces does not hurt (and you obviously
can't play copy/paste games between Excellon and Gerber files).

Besides that, aperture numbers start at 11 in PCB (actually you
are allowed to start at 10 from the Gerber specification), drill
numbers with my patch start at 1. The first 10 (or at least 9)
drill diameters can't even overlap with valid aperture numbers.

I've never need more than 6 drill size on a given board, how often
have you made a board with 10 or more different drill sizes?
Post by Peter C.J. Clifton
I'd suggest you change your board house. If their CAM software is so
broken in one respect, I would suspect there could be other issues
lurking. It also speaks to a certain lack of investment in their
process, so who knows where else they will be using sub-standard
workflows.
For our ammusement, you might find out which vendor supplied their
BROKEN CAM software, which version it is / which centuary they
purchased it.
Sorry not to be more helpful.. As Gabriel said, you may be able to
patch the source-code to achieve what you want. Just be SURE to
check the Gerber files that result actually preview correctly in a
gerber viewer (like "gerbv") before sending them for manufacture.
My patch does not affect in the slightest the photoplotter Gerber files
(well some aperture numbers might change because the drill numbers
no more affect their allocation, but that's a minor side effect).

Regards,
Gabriel
DJ Delorie
2014-07-16 18:29:03 UTC
Permalink
Post by Gabriel Paubert
I've never need more than 6 drill size on a given board, how often
have you made a board with 10 or more different drill sizes?
Er, about half of my designs have 10 or more different drill sizes.
Lilith Bryant
2014-07-16 21:12:26 UTC
Permalink
Post by Gabriel Paubert
I've never need more than 6 drill size on a given board, how often
have you made a board with 10 or more different drill sizes?
My last board had 12. The one before that had 13.

And both of those were after rounding to the nearest 0.1mm

If you have a lot of different connectors, you get a lot of different
sizes.
Gabriel Paubert
2014-07-17 07:10:04 UTC
Permalink
Post by Lilith Bryant
Post by Gabriel Paubert
I've never need more than 6 drill size on a given board, how often
have you made a board with 10 or more different drill sizes?
My last board had 12. The one before that had 13.
And both of those were after rounding to the nearest 0.1mm
If you have a lot of different connectors, you get a lot of different
sizes.
Ok, you have a point, most of my connectors are now SMD and I try to limit
the variety of connectors in a single design.

This said, it was also probably the weakest of my arguments. You simply
can't mixup Gerber photoplotter files and Excellon drill files, therefore
independent number spaces should never cause a problem.

A limit of 255 drill sizes for a single project is probably more than
sufficient: on a metric setup drills are typically produced by steps
of 0.05mm (and I'm not sure that 0.05mm is available), so this gives
you all sizes by steps of 0.05mm up to 12.7mm.

The fab I currently use does not allow drills above 6mm (larger ones
are milled and cannot be plated, so they should be specified by the
outline layer). Smallest holes are 0.2mm (0.1mm with surcharge).

There are ~120 drill sizes between 0.1 and 6mm, so the limit of 255
should never be reached in practice.

Gabriel
Geoffrey Yerem - HEAT, LLC
2014-07-22 15:32:22 UTC
Permalink
Hi,
Post by Gabriel Paubert
This said, it was also probably the weakest of my arguments. You simply
can't mixup Gerber photoplotter files and Excellon drill files, therefore
independent number spaces should never cause a problem.
I imagine that in the worst case that you could add a check box to the
gerber dialog that enables an independent number space ("start Excellon
drill count from one") for the Excellon files.

Geoffrey
Gabriel Paubert
2014-07-22 17:21:24 UTC
Permalink
Post by Geoffrey Yerem - HEAT, LLC
Hi,
Post by Gabriel Paubert
This said, it was also probably the weakest of my arguments. You simply
can't mixup Gerber photoplotter files and Excellon drill files, therefore
independent number spaces should never cause a problem.
I imagine that in the worst case that you could add a check box to
the gerber dialog that enables an independent number space ("start
Excellon drill count from one") for the Excellon files.
This is really overkill, this unified number space was introduced
with a rewrite of the Gerber exporter around 2008 (from looking at
the archives of the drill files I produced) and I consider that it
was a mistake to unify drill and apertures number spaces (that's
why I submitted the patch to separate them, I use it on all
my boards right now).

A long time ago, Gerber exporter used overlapping number spaces
for all Gerber files (a given aperture had the same number on all
layers), while now the Gerber files use disjoint aperture spaces.
Actually I already suggested that we should give the option of
3 possible aperture allocation policies:
1) start at D10 (or D11) on each layer
2) use a global aperture space (like old PCB versions)
3) use disjoints aperture spaces (like now)

I think that 2 should be the default, especially if we switch
to flashed apertures. The problem with 3 is that it can create
an enormous number of apertures for no real good reason. Current
limit of the Gerber specification is ~2^31 but it was 999 until
recently. Option 1 could be used if you really overflow the
999 limit with option 2, and option 2 is a reasonable compromise.

Gabriel

Geoffrey Yerem - HEAT, LLC
2014-07-16 14:35:11 UTC
Permalink
Hello,
Post by Gabriel Paubert
Post by Geoffrey Yerem - HEAT, LLC
I'm having a small problem with the Gerber export in PCB. When it
generates the cnc drill file, it starts the tool numbers at an
arbitrary count.
Not exactly an aribtrary count, it uses the same number space for Gerber
apertures and drill numbers.
That's what I suspected. I have little knowledge of the Gerber format.
Post by Gabriel Paubert
Post by Geoffrey Yerem - HEAT, LLC
This normally isn't a problem when I'm viewing the gerbers in
gerbv, but my fab house is complaining that they can't handle tool
numbers greater than 255.
So the current PCB system breaks your fab process.
Here's a quote from them:

"The NC Drill file that was sent in for this order contained tool sizes
labeled over 255, although only 7 sizes were used. Upon loading the
drill file into the software all the tool sizes were ignored."

This only happens on my more complicated designs. This particular
design was a four-layer board, but it only had 7 drill sizes.
I've been compiling PCB from source on Cygwin, but support for GTK+
broke recently and I'm relying on the ElektronIQ builds now.
Post by Gabriel Paubert
Post by Geoffrey Yerem - HEAT, LLC
I think we deliberately don't re-use numbers between the various
files we export. This allows people to copy+paste outline / random
notes layer content in the output file into the files for other
layers - without any apperture clashes / conflicts.
I have to disagree for __drill__ numbers. I can understand it for
aperture which go into Gerber files (since I sometimes edit them
by hand myself). But drill numbers are not even in the same file
format as apertures and are not processed by the same machine, so
having independent number spaces does not hurt (and you obviously
can't play copy/paste games between Excellon and Gerber files).
If you're going to use the same number space for everything, would it
make sense to prioritize the drill numbers so they start at 1 and
everything else follows? Sometimes a little defensive programming pays off.

I guess it would help to know how other layout tools handle this issue.
Again, I'm not an expert here, just a user.

Speaking as a user, let me mention that I've been using geda for over
five years now and I really love the quality of boards I can make with it!

Geoffrey
Loading...