Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Llaves on September 13, 2020, 06:06:56 PM

Title: Using G54-G59 in macro?
Post by: Llaves on September 13, 2020, 06:06:56 PM
I have a very simple macro to position my router above the touchplate  that relies on offsets saved in fixture 6 (G59):
Code: [Select]
code ("G59")
code (G0 x0 y0 z0)
code ("G54")
If I type this code manually it works fine. But in the macro the change of fixture offset doesn't seem to get recognized and the machine moves to the origin of the current fixture offset (usually G54). How do I make this work?

Bonus credit - how to a read the save and restore fixture current when the macro starts instead of relying on it's being G54?

Thanks
Title: Re: Using G54-G59 in macro?
Post by: Llaves on September 13, 2020, 06:43:43 PM
Answered half of my question -
I forgot that the motion code call would return before the move completed, so the offset is reset to G54 before the move completes.
The correct code is
Code: [Select]
code ("G59")
code (G0 x0 y0 z0)
while (IsMoving())
    sleep(100)
wend
code ("G54")

I'd still be interested in learning how to save and restore the current fixture setting.
Title: Re: Using G54-G59 in macro?
Post by: TPS on September 14, 2020, 01:01:38 AM
with:

Code: [Select]
actwo = GetOEMDro(46)

you can read the actual selected workoffset.

and with:
Code: [Select]
SetOEMDro(46,actwo)

you can restore it.
Title: Re: Using G54-G59 in macro?
Post by: Llaves on September 14, 2020, 09:09:50 AM
thanks - that's the info I needed.