PDA

View Full Version : Circular interpolation?



SJorgensen
08-05-2003, 01:55 AM
Can someone explain the syntax of circular interpolation? I've tried a couple of times to input a G2 command on a BOSS 5 but I don't get the results that I am expecting. On the BOSS 5 as I understand it, if you put a second X and value and second Y and value in a block it will be interpretted as an "I" and "J" value. I have tried this method and I have tried sending the command block from the PC where I can input "I" and "J" values directly but I'm still missing something. For the time being I am wittling away at some pieces of wood with a 3/8" bit. My proceedure is to enter my GCode, send it, then zero my axis and set my TLO and then run the code. I want to get a feel for GCode before I dig into automated GCode authoring tools.
Thank you in advance,
Spence

ibewgypsie
08-05-2003, 02:21 AM
Download Craigs trial version of Qstep. It has a teach mode for people unfamilar with gcode.
It draws on screen, instead of cutting wood, you could be drawing with 3d your commands.

books are on the way Spence.

SJorgensen
08-05-2003, 02:44 AM
Thanks Ibew,
I'll take a look at that program. Still there is a certain thrill in the discovery method. It certainly impresses upon you the reality of the machine. Hitting the emergency stop button becomes a natural reflex just as nature intended. I don't expect to be writing the code for all the complex work that I want to do, but I do want to be familiar with the code a little. I don't think it will be a wasted adventure.
I'll keep you informed on the progress on this and the other project.

Thanks,

Spence

C. Tate
08-05-2003, 08:52 AM
Try entering the code using two x values and two y values as you described. The control may be very syntax sensitive. If that does not work start checking your math and check to see if you have to turn on tool comp.

CT

Techtchr
08-05-2003, 09:39 AM
I work with the small machines (toys to many of you), but the code should be the same or very similar. G02 (clockwise circular interpolation)For example: If working in absolute coordinates (G90)and Inches (G20) And the current position of the tool is 1,1 a command like G02X3Y1I2J1 will swing a 1" radius clockwise arc that starts at 1,1 with a center point at 2,1 and ends at 3,1. The XandY coordinates are the ending point of the arc and the I and J are the centerpoint. If you used the G03 (CCW circular Interpolation) with the same numbers, you should complete the circle.

Graph paper and a pencil are helpful when hand writing code, and a bit of math skill can't hurt.

By the way, on my machines, if you pick an ending point in your coordinates that doesn't fall on the radius you've defined by your starting point and center point, the machine will spit back an error code. In other words, the starting and ending points have to be on the arc defined by the centerpoint you chose. Hope this helps.

regards, Matt

DR
08-05-2003, 10:48 AM
Spence,

You need to know how the machine wants the I,J to be specified. Generally, machines either want the values to be the relative distance from the arc start to the arc center OR the absolute coordinates of the arc center.

Example:

Tool at X0, Y1. To cut a CW arc of 1" radius ending at X1,Y0.

G02 X1 Y0 I0 J0, (this method uses absolute center corrdinates)

G02 X1 Y0 I0 J-1, (this uses relative center coordinates, the values are relative to arc start)

You don't have a choice between the two methods, you can only use the method that the control will accept and that's what your control manual should tell you. If you don't have a manual try both methods to see which one works.

C. Tate
08-05-2003, 11:14 PM
I think FANUC will accept an absolute ending point followed with a r value to produce an arc. This is not as accurate as the x,y,i,j syntax but will work.

DR
08-05-2003, 11:52 PM
C. Tate,

I wonder why an R value for arc radius would not be as accurate? Whether it's R, or I,J the control still has to do the same basic calculations.

Different controls do have different tolerances with respect to allowable deviation off the arc of the specified end point coordinates. Is that what you're referring to?

ChipWright
08-06-2003, 01:01 AM
> Whether it's R, or I,J the control still
> has to do the same basic calculations.

I,J method removes the abiguity of two potential centerpoints under R method. Consider the draftsman's process for determining the centerpoint knowing two endpoints and the radius:

Swing a compass, set to radius R, from both endpoints. The resulting two circles intersect at two points. Ambiguity... R Method therefore requires some additional parameter to specify a concave or convex arc... This is why I,J is more desirable.

At least it makes some sense me and I'm a mathemagician on microprocessors. http://bbs.homeshopmachinist.net//smile.gif

DR
08-06-2003, 02:04 AM
I understand what you're saying, but am not buying the argument. The parameter to remove the ambiguity of two centers would be the G02,03 wouldn't it?

Now that I think about it, from an accuracy standpoint, the "R" method will always produce an arc going through the current position and the target position.

The I,J method may not always yield an arc going exactly through the end point if that end point is specified slightly off, but still within the controls's tolerance of the true arc.

So I'd say that the R method will be generally more accurate in terms of putting an arc through two points.

SJorgensen
08-06-2003, 02:35 AM
I think another aspect of the I,J method that isn't present in the radius method is in the interpolation of the arc to the end point. That is, if the end point does not exist on the path of the perfect arc then the control must interpolate a curve to the point. I haven't done enough experimenting to fully understand yet, but that is my best guess.

Spence

ChipWright
08-06-2003, 02:45 AM
> the "R" method will always produce an
> arc going through the current position
> and the target position.

If it were a draftsman. Its likely that the algorthm used requires the midpoint. While its simple to derive the center point as a draftsman, the microcontroller (8 bit or PDP11 in the old days) has to use a math library to get higher precision (lazy programmers use math libraries).

So in this scenario, given endpoints and R it mathematically deduces the centerpoint. As microprocessors of the G-Code generation seldom had multiply commands, a bunch of additions and trigonometric lookup tables were likely used. Compromises are made against binary accuracy and resolution versus human world decimal numbers. Accumulating errors build up in computing the center point from which a tainted arc is now struck.

Microprocessor math is seldom like what we expect from spreadsheets. By the rules of minimized chained calculations, you'd not want to derive the centerpoint and then calculate the arc from there.

As I've already pointed out, the R method suffers from ambiguity that requires an additional parameter. Simplifying the human interface by requesting the centerpoint coordinate simplifies the job for the programming AND the machinist. After all the machinists designs the arc curve using a compass and therefore has a defined centerpoint. Seldom does one take to endpoints and through in a connecting radius without using a centerpoint. Draftsmen would do this with a circle template but even that has markings to locating the center.

What is gained by R method? Nothing. It has three strikes against it: Ambiguity, Accumulating error, and Complication to the designer.

> I,J method may not always yield an arc
> going exactly through the end point if
> that end point is specified slightly off

I assume the GCode calculates a table of stepper movements before it runs the arc. Sinces its digital its going to run minute increments of X, Y and XY (if its good). Going through the generation of the table its able to confirm that given all resolution issues, the arc stepping arrived at the endpoint as intended.

From a mathematical viewpoint, R method appears more elegant and I think we engineers and scientists would be drawn to requiring the R method. I,J appears clumsy and low tech in contrast.

But in putting G-Code into practice it appears that practicality won out over beauty. http://bbs.homeshopmachinist.net//smile.gif

> R method will be generally more accurate
> in terms of putting an arc through two
> points.

Only for a draftsman. Not for a microprocessor control system (my forte).

> The parameter to remove the ambiguity of
> two centers would be the G02,03?

I don't know the G-Code specification. Someone mentioned CW and CCW and that would not remove the ambiguity. Either feasible circle could still be drawn CW or CCW - the ambiguity remains.

> additional parameter to specify a concave
> or convex arc

Between two endpoints the definition of concave and convex is even ambiguous. Say that you are simply routing a straight vertical line in a piece of wood. half way up the vertical you are to insert an arc between two endpoints and then proceed with the vertical line as before.

So which is concave and which is convex? Its not relative to a material fill so its has no meaning in line art of an open structure.

The ambiguity remains. The only valid additional parameter would be a third point on the curve. I,J this or I,J that... reductionism leads againt to I,J centerpoint method.


[This message has been edited by ChipWright (edited 08-06-2003).]

SJorgensen
08-06-2003, 03:14 AM
In what I have learned so far about the arc direction using the "R" method is that the direction is determined by the positive or negative value of "R" and that different controls behave differently.
I found out that the GCode required to describe things like lettering in complex fonts or objects with lots of complex curves will quickly exceed the machines memory. I wonder what improvements can be made. Does any one know if memory expansion beyond the "80 feet of paper tape" is possible with these machines? Is this where DNC becomes the advantage over CNC?

Spence

DR
08-06-2003, 11:27 AM
chipwright,

You wrote:"So in this scenario, given endpoints and R it mathematically deduces the centerpoint. As microprocessors of the G-Code generation seldom had multiply commands, a bunch of additions and trigonometric lookup tables were likely used. Compromises are made against binary accuracy and resolution versus human world decimal numbers. Accumulating errors build up in computing the center point from which a tainted arc is now struck."


You're a little off base here when you say microprocessors of the "G-code generation". G-code is still a viable language supported on virtually all modern controls and we aren't talking microprocessors, we're talking calculations done in assembly language or C or Basic or other high level language in CPU's with a complete set of mathematical operations. Calculations to 4 decimal places are not a problem.

And no, a third arc point is never needed. In your example of a straight line then an arc then continue the straight line, there's no problem. The G02 or 03 determines which way the arc goes.

You mentioned steppers, yes, they can have some limitations in arc cutting based on their angular resolution. Because of the resolution it may not be possible to exactly reach a specified end point. This usually is not an issue anymore because very few modern machines use steppers.

I see no difference whatsoever between the R or I,J methods other than the I,J method allows an error factor tolerance in the specification of end point. The amount of calculating required between the two methods may be vastly different, but that's not apparent to the operator or programmer. Some controls support both arc methods as a convenience to the programmer, not because one is better than the other.

spope14
08-06-2003, 12:14 PM
OK, I could go into a three page lesson on this, for teaching CNC (10 years industrial), this is about lesson "four" in programming. The foundations of it all are the Absolute and Incremental coordinate systems, which I hope you have down.

The keys to arc programming are as follows:

1. does the arc cut clockwise or CCW from the last end point of cut and in relation to the direction of cut.
If you are cutting "up" in the Y axis from the operator, do you swing in a convex arc, or concave arc. The convex CW arc would be like swinging fom 9:00 (clock reading) to 12:00. The concave (CCW) would be like swinging from 6:00 to 3:00.

2. What is the "radius" of the cut.

3. What is the "relative / incremental" center point (incremental) of the center of the arc. I use the example of the old drafting table drawing, using a compass to draw an arc. Where do you plant the sharp point of the compass to draw the arc. This is the arc center point.

4. What is your desired "end point" of the arc from the start point.

5. In most controls, "R" vs "I" and "J" do not mix. You use either "R", or I and J method, but not both in the same line, though many controls accept both in a total program setting(some controls will not accept "R").

6. G02 is CW (clockwise). Two letters, thus "2" is a good memory standard. G03 is CCW (counterclockwise), three letters, thus "3" is a good memory standard.

I will write this simple program, done in absoulte coordinates, and using "R" in this example:
G00 x0y0 (rapid feed to start point)
g00 z.100 (rapid to safe height above part)
G01 z-.100 F1.0 (plunge cutter
G01 X0 Y1.0 F2.0 (st line move to first point)
G02 X2.0 y3.0 R2.0 (moved two inches up X, 2 inches over Y, R is 2.0 inches - This creates a 9:00 to 12:00 CW arc. Note the "end point" programmed, as it is always done in programming)
G01 X3.0 y3.0 (did not need Y in many controls, modal, also switched to straight line, a MUST, or the cut will still try to be a CW arc, or on a FANUC you will get the infamous P/S error, which means "Program stinks - because the arc info is incomplete, or previous info on center points or "R" will not "meet" the spec'ed end point)
G03 x4.0 y2.0 R1.0 (moved from 9:00 to 6:00 in direction, CCW arc, 1" radius(
G01 x4.0 y1.0 (straight line cut down to operator - remember you must "change" modes from arcs to straight lines with the "G" code.

OK, hope this helped with "R". Now the same program in I and J

I and J are "incremental" codes, the "I" being the incremental "X" direction of the arc center, "J" being the incremental "Y" direction of the arc center - INCREMENTAL TO THE START POINT OF THE ARC. "K" is the "Z" direction incremental, and used promarily on lathes, though in 3D milling I have used this.
Please remember what I said in the start about a compass, and planting the point of the compass to "strike" an arc.

G00 x0y0 (rapid feed to start point)
g00 z.100 (rapid to safe height above part)
G01 z-.100 F1.0 (plunge cutter
G01 X0 Y1.0 F2.0 (st line move to first point)
G02 X2.0 y3.0 I0.0 j2.0 - CW arc, 9:00 to 12:00. note that from the start point of the arc, the "center point", or where I put the compass point is exactly in line with the "X" axis (I), but two inches UP from the last point in the "Y" axis (J). The point would not be "3", BUT related to the start point, you would measure up if drawing the arc on paper to plant the compass point - you would measure UP (y) 2 inches
G01 X3.0 y3.0 (did not need Y in many controls, modal, also switched to straight line, a MUST, or the cut will still try to be a CW arc)
G03 x4.0 y2.0 I1.0 J0 (moved from 9:00 to 6:00 in direction, CCW arc, measuring from start point to arc center x+1.000, y0.000 to the plant point of the compass.
G01 x4.0 y1.0 (straight line cut down to operator - remember you must "change" modes from arcs to straight lines with the "G" code.
Now for fun:
G02 X3.5 y.5 I-.5 J0. Note the "negative direction of the "X / I" arc start point.

Use my link for my personal web site for a listing of general CNC Codes, feel free to print out as a reference - go to the CNC Codes page:
http://homepage.fcgnetworks.net/spope/

Feel free to e-mail me. Much of what was said above in the other links is also great knowledge about the use of "R" vs "I and J". Knowing both is also very essential, because most CAD/CAM programs use IJK as arc standards (unless you can rig the "posts" like I do, I prefer R, and CAD/CAM makes this accurate).

Scott.




[This message has been edited by spope14 (edited 08-06-2003).]

DR
08-06-2003, 12:46 PM
Scott,

You said:
"I and J are "incremental" codes, the "I" being the incremental "X" direction of the arc center, "J" being the incremental "Y" direction of the arc center - INCREMENTAL TO THE START POINT OF THE ARC. :

Let me add this to your explanation:

I,J are not only incremental codes. Some controls use (require) I,J as the absolute position of the arc center.

In G-code systems we have three basic possiblilites for describing an arc path. The R method, I,J incremental distance method and I,J absolute position method. The programming manual for the specific control will tell which method(s) are enabled on that control.

By this time we probably have the newbies thoroughly confused. But it's really simple, read the manual for your control and you'll know which method to use.

ChipWright
08-06-2003, 08:16 PM
> You're a little off base...
> the "G-code generation".

Any specification is bound by the technology available when it was written. Updates are made but the spec is retired when changes take on large fraction of the whole.

Stating that the G-Code Generation had imposed limitations doesn' deny the existance of pentiums today. http://bbs.homeshopmachinist.net//smile.gif

> and we aren't talking microprocessors,
> we're talking calculations done in
> assembly language or C or Basic or other
> high level language in CPU's with a
> complete set of mathematical operations.

The CPU *is* a microprocessor. The language of the software does not add hardware to the microprocessor. C or Basic or whatever language uses the architecture available inside the microprocessor. It just hides a lot of the hard stuff from the programmer.

> Calculations to 4 decimal places are
> not a problem.

I know a lot of microprocessor programmers that would find that a blind assumption worthy of their managers. http://bbs.homeshopmachinist.net//smile.gif

"Not a problem" is relative. Few programmers know an algorithm for computing square roots, large number divisions, trigonometric functions, statistical distributions. They rely upon the higher level language to do it. That language has to do just what I said with its microprocessor.

> And no, a third arc point is never needed.

I disagree. I've stated my case sufficiently.

> ...steppers...because of the resolution
> it may not be possible to exactly reach
> a specified end point.

I disagree. The endpoint by definition is on the workspace grid. The algorithm walks the tool to the endpoint as a series of intervals until the offset to the endpoint is zero. Therefore arrival is assured assuming the tool hasn't flown across the room. http://bbs.homeshopmachinist.net//smile.gif

> This usually is not an issue anymore
> because very few modern machines use
> steppers.

Most utilize the same basic curve generation approach regardless of what motion control they utilize. Algorithms don't necessarily advance with every CPU.

A microprocessor only approximates real-time control, the curves are still going to be granularly computed. Its the nature of von Neumann computers.

> I see no difference whatsoever between
> the R or I,J methods other than...

Well its still got that nasty ambiguity problem.

> In your example...The G02 or 03
> determines which way the arc goes.

You have to have a rule for selecting one ambiguous arc of the other for all cases. Pretending that two arcs means two commands doesn't work. You still have to have some rule even if its completely silly. Silly can be programmed.

For example, if G02 uses the arc centered closest to the workspace origin and G03 the farther, you still have to deal with the case when both arc centers fall on the same arc drawn from the workspace origin. Programmers that don't worry about these problems usually work for Microsoft where their policy is that software bugs only help sell the next version. http://bbs.homeshopmachinist.net//smile.gif

A random seletion between the two works but would likely infuriate the machinists. http://bbs.homeshopmachinist.net//smile.gif

Maybe I'm being a pain to look at this in such detail but I'm the sort of guy that designs and programs microprocessors to do such things. Part of turning out quality equipment without bugs is discovering the ambiguities before the work starts. Granted I've never messed with G-Code but that's simply not my industry.


[This message has been edited by ChipWright (edited 08-06-2003).]

ChipWright
08-06-2003, 08:19 PM
> The convex CW arc would be like swinging
> from 9:00 to 12:00. The concave (CCW)
> would be like swinging from 6:00 to 3:00.

Visualize it this way. You have a vertical line on a page with a gap in the middle. A circle much larger than the gap is positioned in from the left until that circle touches both endpoints defining the gap. As the circle didn't pass through, its diameter must be larger than the gap.

Lets say the circle is very large for clarity. Say that when positioned, 4 times the area is to the left of the line than the right of the line.

Now, cutting the vertical from the buttom up you arrive at endpoint A. The SINGLE circle defines two pathways. CW would send you to the left along the longer path enclosing the 4x area. CCW would send you to the right along the shorter path.

Neither are really convex or concave. But more importantly *** only one circle *** is navigated.

Our ambiguous R versus I,J generates TWO FEASIBLE circles because two derived centerpoints are possible - its simply mathematics. By your example, G02 and G03 only chooses how a SINGLE circle is navigated with its option of two paths, CW and CCW.

G02 and G03 therefore doesn't specify among two ambiguous centerpoints.



[This message has been edited by ChipWright (edited 08-06-2003).]

Evan
08-06-2003, 08:33 PM
Time for my $00.02. I have written machine code to control steppers that must draw circles. All floating point math is suceptible to the inherent error produced by non-representable numbers. As well, when calculating the endpoint of a circle ( or arc) you are dealing with pi, both non-representable and irrational. There will be an error, period. Also, it doesn't matter if you are using steppers or servos or hamsters in cages the determination of position will be granular. Even if the position sensing system is analog there will be an ADC digitizing it. It WILL be necessary to allow an error band and the calculation of the endpoint will have to be fitted to the best position that lies within the tool's capability.

SJorgensen
08-07-2003, 02:04 AM
Hi ChipWright,
I follow you on the issue of ambiguity. I've been experimenting with some G02 and G03 example codes from a bridgeport manual. Someone penciled in "Boss 5" but I'm beginning to believe that the internal software wasn't up to the task in my machines version. I believed before that in the G02 or G03 command, if the X and Y value didn't lay on the arc path of the circle described by the starting point and the "I" "J" center point that a curve would be calculated and run. This doesn't seem to be the case. I've found that the X and Y values must lay on an arc described between the current position and with the "I" "J" centerpoint. I have also had no luck with my controller running any examples using the radius value. The control seems to go in a straight line and then into spasms where it is logically conflicted. There may be a component failure, but I doubt it though because of the rest of the functionallity. I don't know the genesis of the controls development but I do know that Bridgeport Company was sued in later years for making software and performance claims that it couldn't produce when it went to market.

Spence

metal mite
08-07-2003, 08:56 AM
You can forget the R value.
The BOSS 5 dosen't know what you're talking about.


Format;
G2X-Y-I-J-F-: CLOCKWISE
G3X-Y-I-J-F-; CCW

In G74 (as the machine comes up) the machine
will only cut one quadrent per line of code.
Four lines are required to cut a full circle.

The i-j are unsigned valurs to the center of the arcs in this mode from the start point of the move.


In G75 the machine will cut a full circle with one line of code.

The I-J values are the absolute coordinates of the arc centers from zero in this mode.

The G75 must be in a line previous to the G2-G3 move (put this in one of the early lines of programing).

All letters must be CAPITOLS.

The second X and Y will also work for I, and J, in that order, when inputting to the machine control directly.

I know this is very, very, frustrating but keep at it.

Mite

metal mite
08-07-2003, 11:14 AM
by the way.

avoid that emergency stop.

it can blow some diodes in the control if they are weak.
emergency can be easily hit by accident where it is placed.
also, in the setup mode, 1" jog mode, they can blow if you jog it again before its motion is finished.

the feed hold is a better bet.

mite

ps;
All G2,G3,lines must have x,y,i, and j or the machine will screw up (boss5 control).
If you have the book, it's all in there (sometimes in different places).

If you need a manual, I may be able to copy one,or spare it, for you.

[This message has been edited by metal mite (edited 08-07-2003).]

ChipWright
08-07-2003, 12:43 PM
> I follow you on the issue of ambiguity.

Yeah, with two potential centerpoints, there are four potential pathways instead of the two that the classic G02 G03 problem present.

I scanned the internet a bit last night and discovered that some machines don't do the R method, some do. Obviously some rule has been agreed to for removing the ambiguity.

I suspect its an applied fillet rule. This would tend to take the last vector that ends at A and the radius endpoint B and decide by rule to turn a radius in the direction of the endpoint RELATIVE to the last vector cut.

This would make outside and inside fillets quite easy. The Rule would not work if the first operation is a R radius as not previous vector exists from which to make the ambiguity decision.

That's the nice thing about microprocessors... when an unsolvable ambiguity exists you can simple code it to act one way for the majority of situations and simply screw up or set an error for the rest. http://bbs.homeshopmachinist.net//smile.gif

spope14
08-07-2003, 02:17 PM
All mentioned after my post is correct. BOSS required IJK. Tool resolution via the steppers does count. I have a CNC 5 old EMCO lathe where all diameters must be EVEN numbers of 3 place decimal, which screws hell with my CAM system (as well as the manual programming), so I have to work this aspect into my designs, then write the programs.

Beware of the quadrant system, where an arc will only cut fom 0 to 90, 90 to 180 yah de yah. any time you cross a straight "90", you have to break the arc, and write another line of code.

learning quite a bit from this discussion.