On 5/10/2013 4:18 PM, Viesturs Lācis wrote:
> Hello!
>
> Today I was helping my client to prepare a g-code for their new machine I
> built.
> The particular code was manually optimized for faster performance and I
> thought that having a code for one part in subroutine and then creating
> another file, which just moves around material and calls subroutine in
> appropriate places would be easier than hand-optimizing one big and long
> g-code file.
>
> Since I have not had any experience with subroutines so far, I looked in
> manuals. Based on them I was able to define subroutine and call it from the
> master file.
>
> What I do not know, how to do properly, is when the subroutine has been
> called once and is finished, machine moves to next point to call the
> subroutine again. How do I move subroutine's coordinate origin to the new
> spot?
>
> I tried 2 things:
> 1) G55 is specified at the beginning of subrouting file;
> in master file I had:
>   G21
>   G54
>   G40 G90
>   G64 P0.02
>   G0 Z15
>   G0 x0 y0
>   G10 L2 P2 X0 Y0 Z15
>   o101 call
>   G54
>   G0 Z15
>   G0 X0 Y200
>   G10 L2 P2 X0 Y0 Z15
>   o101 call
> ....
>
> 2) then I tried to move G10 L2 P2 X0 Y0 Z15 to subroutine so that it is
> done in subroutine
>
> Anyway, none of these 2 approaches work properly, G55 origin is not moved
> and as soon the subroutine was called for the second time, machine started
> to move somewhere. Z axis was moving down too much, so I never allowed it
> to finish as it really seemed to be willing to crash the tool in material
> (I tested it in the air some 100 mm above material).
>
> I would appreciate, if someone could share some working example of how to
> do these things properly.
>
I usually just specify the coordinates as arguments to the subroutine. 
For example, if I have a subroutine that mills a circular pocket, I pass 
the center of the pocket as the first two arguments to the subroutine.

Ken

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to