Hello Guest it is April 19, 2024, 01:52:13 AM

Author Topic: G-code oddities..  (Read 6406 times)

0 Members and 1 Guest are viewing this topic.

G-code oddities..
« on: October 28, 2010, 01:18:46 PM »
Hi,

I'm using the Mach3 to study G-code and to test a corner case I wrote:

G1 X0 Y0
X0 Y2 G42 P0.2
X1 G2 I2 J2
Y4 G1


This produced something like this:
(screen cap from Mach3)

http://www.sparetimelabs.com/gplot.png


Two things strike me as odd.

1) According to Mach3 manual 1.84 when using G2 with arc center format:

"It is an error if when the arc is projected on the selected plane, the distance from the current point to the center differs from the distance from the end point to the center by more than 0.0002 inch (if inches are being used) or 0.002 millimetre (if millimetres are being used)."

Now clearly I've violated this in my code but I get no error message, how come?

The path is show as a spiral (which kind of makes sense), is that normal?

How do other software handle this?

The compensated tool path does not follow the spiral at all, rather
produces something strange, is that correct?

Can anyone shed any light on this?

All comments welcome..

br Kusti

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-code oddities..
« Reply #1 on: October 28, 2010, 06:54:18 PM »
Try this instead. When using offsets you MUST provide a leadin AND leadout so the machine has room to compensate the offset.

Also if you are cutting an inside cut you have to start inside the profile you plan to cut.

F500
G1 X2 Y4
G42 P0.2
G1 X0 Y2
G2  I2 J2
G40
G1 X2 Y4


IF you wanted a spiral then try this

F500
G1 X2 Y4
G42 P0.2
G1 X0 Y2
G2  I2 J2 Z-.5
G40
G1 X2 Y4

Just a thought, (;-) TP
Re: G-code oddities..
« Reply #2 on: October 29, 2010, 10:07:37 AM »
Thanks BR549/TP,

for answering, but my question was slightly different.

I was interested why the G-code I presented resulted in a spiral when according to the manual it should have resulted in an error (or so I gathered)?

The other oddity was that while the uncompensated path looks like a spiral the compensated path looks totally different, how come?

I know about lead in and lead out, in fact I was just investigating those when I came up with this issue and question.

My sample was just an artificial code fragment to illustrate my point which can come up for example if your lead in/out is not a straight segment but an arc, or if the tool (raidus/compensation) changes between two arcs. I'm curious how that is handled by Mach3 and was hoping for some insight into this.

br Kusti

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-code oddities..
« Reply #3 on: October 29, 2010, 10:33:06 AM »


Here using MACH the code "generated" properly in realation to HOW you wrote it, . I suspect certain things as far as IJ modes, Inc or abs may have been set incorrectly???.

(;-) TP
« Last Edit: October 29, 2010, 10:36:04 AM by BR549 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-code oddities..
« Reply #4 on: October 29, 2010, 10:57:04 AM »
OK looking at your example Picture I assume that it is just a segment that has been blown up to see the spiral effect???  That looks like machs attempt to get the leadin you specified to work. The results is the spiral shape of the supposed straight line.

You also may want to study up on the structure of the block coding. Certain things come before others or unexpected results can occurs.

Just a thought, (;-) TP

« Last Edit: October 29, 2010, 11:01:01 AM by BR549 »
Re: G-code oddities..
« Reply #5 on: October 31, 2010, 12:54:43 PM »
Thanks again for looking at this.

We seem to be getting nowhere fast ;-) but if you look at my picture:

http://www.sparetimelabs.com/gplot.png

the white line is the compensated toolpath.

Starting from the origin at 0,0 the first two lines:

G1 X0 Y0
X0 Y2 G42 P0.2

produce the slightly slanted lead in move, correctly.

Then the next G-code line is (thats absolute IJ mode):

X1 G2 I2 J2

Now in my view this should produce an error message because
there is no arc that can be drawn from 0,2 to 1,2 with arc center at 2,2.

But it produced the white horizontal segment in the compensated toolpath,
or a sprial (the purple line) for the uncompensated path. Both seem to be wrong,
in that Mach3 manual mentions nothing about spirals and OTOH if spirals are
valid resulst for G2/G3 moves, why is the compensated spiral suddenly a
horizontal move?

You also wrote:

"You also may want to study up on the structure of the block coding.
Certain things come before others or unexpected results can occurs."

According to Mach3 manual:

"The first group (the words) may be reordered in any way without changing the meaning of the line."

"If the second group (the parameter settings) is reordered, there will be no change in the meaning
of the line unless the same parameter is set more than once. "

So I do not see how that would apply here.

br Kusti



Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: G-code oddities..
« Reply #6 on: October 31, 2010, 01:10:07 PM »

But it produced the white horizontal segment in the compensated toolpath,
or a spiral (the purple line) for the uncompensated path. Both seem to be wrong,
in that Mach3 manual mentions nothing about spirals and OTOH if spirals are
valid result for G2/G3 moves, why is the compensated spiral suddenly a
horizontal move?

Spirals are an undocumented feature. I don't have the info handy, but the endpoint of a circle is allowed to deviate by up to 1/2".

I think what you're seeing is that G41/G42 will not work correctly with a spiral move.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-code oddities..
« Reply #7 on: October 31, 2010, 02:10:22 PM »
Here is what your code looks like on a running machine. Notice the change of code required to "make" it run. The original code as you posted it is an error with the 3rd line. Also note that the G42 has NOT been cancelled.

(;-) TP

« Last Edit: October 31, 2010, 02:22:44 PM by BR549 »
Re: G-code oddities..
« Reply #8 on: November 01, 2010, 05:23:12 AM »
Spirals are an undocumented feature. I don't have the info handy, but the endpoint of a circle is allowed to deviate by up to 1/2".

I think what you're seeing is that G41/G42 will not work correctly with a spiral move.

Ok, thanks that [confirmation that it was undocumented feature] was the kind of info I was looking for.

br Kusti
Re: G-code oddities..
« Reply #9 on: November 01, 2010, 05:26:04 AM »
Here is what your code looks like on a running machine. Notice the change of code required to "make" it run. The original code as you posted it is an error with the 3rd line. Also note that the G42 has NOT been cancelled.

Thanks TP for your trouble, yes you are right that there was an error in line 3, but it was deliberate: I was trying to see what happens. Did you get an error message on line 3 or what...?


br Kusti