gerbview does not handle arcs correctly

Bug #611907 reported by AmenophisIII
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

or more precisely gerbview's output with arcs is not the same as gerbv's (gerbv is independent of kicad).
the gerber file was produced by pcb, not kicad, but this should not matter (as long as there are no two nullifying bugs in pcb and gerbv :)
kicad itself seems to not be able to plot (real) arcs. the arc i drew on a silk layer was converted to a number of short lines (which were displayed correctly in gerbview btw).

the attached gerber should be a single arc from north 90° clockwise to east, instead it's something like a small counterclockwise arc from about 6 o'clock to 5 o'clock.

i used the version of gerbview included in lucid, which is 20090216-final.

Tags: gerbview
Revision history for this message
AmenophisIII (amenophisiii) wrote :
Revision history for this message
Johansen (johansense) wrote :

I think i have the same issue (at work so i can't view your gbr file.)

I solved a similar issue (tracks being printed out as rectangles with triangles missing where they touch at an angle, or a square missing where two tracks meet at a 90 degree bend) by downloading the latest stable release. (i'm running lucid as well)

However they are back again, but only on the second layer of a two layer board.

fwiw i havn't figured out how to make arcs yet, and it took me a while to find the option to route tracks at any angle (which should be enabled by default, or the check box have the verbage changed to "route tracks at any angle, rather than what it is now, but that's another story.)

Revision history for this message
Johansen (johansense) wrote :

I can't duplicate it on Build 2010-05-05 BZR 2356 stable.

Revision history for this message
Brian Bidulock (bidulock) wrote :

Technically the block is a single quadrant arc drawn with a multiple-quadrant circular interpolation command. Why not fix gEDA's pcb to not generate such nonsense? Have it remove the G75 and make J the absolute value of the center offset and remove the final G01*. That is, a proper single quadrant block would look like:

 G54D11*X96000Y361000D02*G02X152000Y306000I0J56000*

instead of what pcb generated which was:

 G54D11*X96000Y361000D02*G75*G02X152000Y305000I0J-56000D01*G01*

There is simply no point to using a multiple quadrant circular interpolation command to plot a single quadrant when the single quadrant circular interpolation command will suffice.

Revision history for this message
AmenophisIII (amenophisiii) wrote :

from the POV of the exporter it makes sense to only use a single format, that is able to represent all possible "subgeometries" for simplicity, as long as it is valid (which seems to have happened here, as far as i understand your post).
an importer/viewer on the other hand should be able to read any valid command.

"Be liberal in what you accept, and conservative in what you send."

Revision history for this message
Brian Bidulock (bidulock) wrote :

In this case RS274X says G75 is a "multiple" quadrant command. pcb uses it to draw a "single" quadrant. Therefore, it is invalid.

Revision history for this message
AmenophisIII (amenophisiii) wrote :

rs274x - as crappy as it is - states "Multiquadrant interpolation *can* produce arcs that are larger than 90° and also
circles." (my emphasis). nowhere (in revision f) is stated, that g75 can't be used for arcs <=90°. it may imply, that it should though. anyway, it's your choice, i'm out of this discussion.

Revision history for this message
DJ Delorie (djdelorie) wrote :

I'm willing to "fix" pcb to be more robust (we've worked around limitations in other tools before), but let me ask a few questions first...

1) How do gerbers indicate the difference between a 135 degree arc and a 225 degree arc? The start/end/center points are the same for both. What about 45 vs 315 degrees?

2) How do you do a 10 degree arc that happens to cross into a different quadrant?

3) If you can support the above, why is a 45 degree arc that happens to start and end in the same quadrant a special case?

Revision history for this message
Brian Bidulock (bidulock) wrote : Re: [Bug 611907] Re: gerbview does not handle arcs correctly
Download full text (5.6 KiB)

DJ,

On Tue, 31 Aug 2010, DJ Delorie wrote:

> 1) How do gerbers indicate the difference between a 135 degree
> arc and a 225 degree arc? The start/end/center points are
> the same for both.

Direction of rotation determines the difference: G02 code for CW
about the pivot (centre), G03 code for CCW about the pivot.

> What about 45 vs 315 degrees?

Well, that's part of the issue...

45 has two arcs for the same start/end/centre using a G74
(one-quadrant interpolation): one is a G02 CW arc (convex to the
left when looking at "end" from "start"), the other is a G03 CCW
arc (convex to the right when looking at "end" from "start").

315 has one arc for a given start/end/centre and is either a G75
(multiple-quadrant interpolation): CW G02 or CCW G03. The
questionable point is whether the complementary G75 command (G03
and G02 respectively) represents a 45 degree are or is simply
invalid. The OP felt that the command was valid and this is the
behaviour you would need to accommodate.

> 2) How do you do a 10 degree arc that happens to cross into a
> different quadrant?

The term quadrant is a poor choice. It bears no relation to the
x-y axis of the plot (true Cartesian coordinate system
quadrants), but is basically internal angles from zero to pi/2
or interior angles from pi/2+ to 2pi. It does not matter in
which Cartesian quadrant the arc starts or finishes but whether
the included angle would span one or multiple quadrants if the
centre was placed at the origin and the start on an axis.

> 3) If you can support the above, why is a 45 degree arc that
> happens to start and end in the same quadrant a special case?

I think you will see in the answer to (2) why question (3) does
not apply.

Handling abnormal values in these commands becomes an exercise
in how to treat invalid data.

Consider that G74 (single-quadrant) G02 and G03 commands are
part of RS274D. G75 (multiple-quadrant) G02 and G03 commands
are not part of RS274D, and were only added for RS274X.

G74 (single-quadrant) commands G02 and G03 take two points
(start and end) and a distance to a centre point. The x- and y-
distance to the centre point is described with unsigned numbers.
This means that there are as many as 4 possible centre points.
The start and end point are presumably on a circle centered
about one of these 4 possible centre points. G02 specifies a CW
rotation about the centre and G03 specifies a CCW rotation.

By definition the start point exists on a circle centered about
one of the 4 possible centre points; however, the end point can
be specified in such a way as to be located off of the circle
(i.e. an different distance from all possible centre points than
the radius defined by the start point and possible centre point,
even considering integer round-off). How does one plot this?
Invent an ellipse perhaps that transfixes both points? Perhaps
invent an obround (oval) segment? Adjust the centre point in
some way so that it is equidistant from the start and end
points? Or does one just consider the command invalid and warn
the user of this before she sends this undefined command to a
plotter?

Now, say that the end *is* on a circle defined by the ...

Read more...

Revision history for this message
William Lash (william-lash) wrote :

> The term quadrant is a poor choice. It bears no relation to the
> x-y axis of the plot (true Cartesian coordinate system
> quadrants), but is basically internal angles from zero to pi/2
> or interior angles from pi/2+ to 2pi. It does not matter in
> which Cartesian quadrant the arc starts or finishes but whether
> the included angle would span one or multiple quadrants if the
> centre was placed at the origin and the start on an axis.

A reference I have seen would seem to contradict this.

http://www.rulabinsky.com/cavd/text/chapa.html

Section A.3

In this he gives an example of drawing an arc, centered at 0,0, starting at -4,3 and going to 3,4 and states that it must be split up into 2 arcs, one going from -4,3 to 0,5 and one from 0,5 to 3,4

Also, at http://www.ams-us.com/princi.html the description of G74 versus G75 seems to imply this.

Here is a quote:

"Another important case for G codes is when determining if the arc is a quadrant (G74) or Full 360 (G75). Quadrant arcs never cross quadrant boundaries, because the center co-ordinate offsets (I,J Codes) are always unsigned (even if they are negative!). Therefore, it requires at least four G74 arcs to draw one complete circle.

center co-ordinate offsets for 360 arcs (G75) can be positive or negative, allowing for a single command to draw a complete circle.

In either case, the center co-ordinates are given relative to the start point of the arc. The most dramatic difference between Quadrant and Full 360 arcs is that a Quadrant arc with identical start and end points has a sweep of 0 degrees, whereas a similar Full 360 arc is a full circle."

Revision history for this message
Brian Bidulock (bidulock) wrote :
Download full text (7.3 KiB)

William,

On Thu, 02 Sep 2010, William Lash wrote:

> > The term quadrant is a poor choice. It bears no relation to the
> > x-y axis of the plot (true Cartesian coordinate system
> > quadrants), but is basically internal angles from zero to pi/2
> > or interior angles from pi/2+ to 2pi. It does not matter in
> > which Cartesian quadrant the arc starts or finishes but whether
> > the included angle would span one or multiple quadrants if the
> > centre was placed at the origin and the start on an axis.
>
> A reference I have seen would seem to contradict this.
>
> http://www.rulabinsky.com/cavd/text/chapa.html
>
-X-snip-X-
>
> Also, at http://www.ams-us.com/princi.html the description of G74 versus
> G75 seems to imply this.
>
-X-snip-X-

After doing a bunch of research, I think that I now understand
the difference between single-quadrant and multiple-quadrant
circular interpolation.

Yes, it appears that single-quadrant arc must be constrained to
lay within the confines of a Cartesian quadrant, but not for the
reasons stated by Steve in your reference above. Also note that
Steve was working from now long obsolete 1983 Gerber format
specifications (it includes G06 parabolic and G07 cubic
interpolations that are no longer supported, as well as G56 text
which also is long deleted from the spec). Steve says:

 "One restriction on the drawing of arcs is that they must start
  and end in the same quadrant. This is because the I and J
  parameters, which specify the arc center, are unsigned
  absolute distances relative to the starting point. Therefore
  the arc must remain in the same quadrant to prevent ambiguity
  in the center location."

This is not true: there is no ambiguity in the center location.
The reason that the arc could not cross a quadrant was because
the old CNC controllers on photo-plotters could not handle a
reversal in direction on the axis. Consider, for example, a
photo-plotter table movement controlled by a worm gear and
stepper motor. If there was any slop in the worm gear, a
reversal in direction would result in a discontinuity in the
arc. Compensation for this effect was only performed at the
beginning of travel (i.e. between part program blocks). A CNC
controller that was capable of compensating while moving or that
used a movement that did not require compensation (e.g.
recirculating ball gear) was capable of multiple-quadrant arcs
(arcs that crossed quadrant boundaries or was capable of
reversals in the movement without significant discontinuities).

Now, two ways evolved of specifying arcs with G02 and G03
commands: center location using I and J coordinates (i.e.
G02X#Y#I#J#) and another using radius (i.e. G02X#Y#R#). Some
controllers were incapable of the later (radius specification).
Some controllers specified the I and J using absolute
coordinates and some relative coordinates with sign indicating
direction. RS274-D and RS274/NG3 always use relative
coordinates with directional sign. Single quadrant arcs could
be specified with center or (positive) radius. Multiple
quadrant arcs could be specified with center or radius (positive
radius 0 to 180 degrees, negative radius 180+ to 359.999
degrees).

For ...

Read more...

Martin Errenst (imp-d)
tags: added: drc
Martin Errenst (imp-d)
tags: added: gerbview
removed: drc
Revision history for this message
Martin Errenst (imp-d) wrote :

Looks correct in current gerbview (r4719). Please reopen if the problem still exists with a recent version of KiCad.

Changed in kicad:
status: New → Fix Committed
Jon Neal (reportingsjr)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.