Machsupport Forum
G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: Bodini on May 29, 2007, 05:49:45 PM
-
Noob alert. ::)
I had a look here.http://www.artsoftcontrols.com/forum/index.php?topic=2540.0
OK, i got it, that works.
Now what if you want to run that sub in different locations in the coordinate system?
So take this one... <stolen from that link above>
G20 G40
G00 g90 g43 X-1. Y-1.
z1.
M98 (SUBTEST.TAP)
M30
%
and then add another position, so it looks like this:
G20 G40
G00 g90 g43 X-1. Y-1.
z1.
M98 (SUBTEST.TAP)
X5 Y5
M98 (SUBTEST.TAP)
M30
%
You see that I'm trying to run the sub again at x5 y5... but it doesnt turn out like i'd expect (another box at x5,y5).
What remedies this?
Thanks much.
-Nick
-
In other words, it's like the coordinate system needs to be temporarily reset (or something along those lines) at the insertion point of the sub. I dont know enough about g-code yet to know what path to take.
thanks,
Nick
-
Hi Nick,
You need to offset the datum using G52, like this :-
G20 G40
G00 g90 g43 X-1. Y-1.
z1.
M98 (SUBTEST.TAP)
G52 x5. y5. (datum shift)
M98 (SUBTEST.TAP)
G52 x0 y0 (datum shift cancel)
M30
%
If you run this in Mach it will not show the 2 paths offset, it will draw them on top of each other. The machine will do it right though.
Graham.
-
Thanks Graham.
One more quiestion... and i only ask instead of doing it because Mach wont display it and I cant get to a machine to see it go right now...
What about adding another random position in the code like:
X13 Y2
would it look like this?
G20 G40
G00 g90 g43 X-1. Y-1.
z1.
M98 (SUBTEST.TAP)
G52 x5. y5. (datum shift)
M98 (SUBTEST.TAP)
G52 x0 y0 (datum shift cancel)
G52 x13. y2. (second datum shift)
M98 (SUBTEST.TAP)
G52 x0 y0 (second datum shift cancel)
M30
%
Thanks,
Nick
-
Yes, you can do it as many times as you want.
Graham.
-
Thanks Graham, just 1 more detail needed (until the next one :D)
What I meant to ask in that last one, but forgot to...
If you go to many locations, does the g52 need to be cancelled between each one?
-Nick
-
It is always safer to put the G52 x0 y0 in the code and less confusing when looking for the end of a block.
There are other rules attached to G52 too.
You can not change datum e.g. G54,G55 etc.
G52 must be cancelled before a tool change.
G40,G41,G42 must be within the G52 block.
(This is very bad code)
G52 X100 Y100
G41 X25 P2
Y..
X..
G52 X0 Y0
X10. Y10.
X15.
G40
Graham.