Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bill_O on March 11, 2019, 02:24:02 PM

Title: 2 simple lines
Post by: Bill_O on March 11, 2019, 02:24:02 PM
Why will the attached work as a button but not as a mcode?
Title: Re: 2 simple lines
Post by: Bill_O on March 11, 2019, 03:39:37 PM
Ignore the last 2 lines.
They are not in the one I am using.
Title: Re: 2 simple lines
Post by: SwiftyJ on March 11, 2019, 03:57:43 PM
I believe the state must be 'idle' for the axes to be homed. Therefore you will not be able to use your code in an mcode. If you use the following code in your m100 script and run it, you will most likely get a return value of -18. This is error: MERROR_NOT_NOW - The operation could not be completed at this time.

Code: [Select]
function m100()
--home material and arm
local inst = mc.mcGetInstance()
local rc = mc.mcAxisHome(inst, 0)
mc.mcCntlSetLastError(inst, tostring(rc))
end

if (mc.mcInEditor() == 1) then
m100()
end
Title: Re: 2 simple lines
Post by: Cbyrdtopper on March 12, 2019, 06:30:31 PM
Looking in the G Code Mill Manual; I see G28.1:  Home Axis.  I
I have never used this and I'm not at a machine at the moment so I can't test this, but has anyone tried this?
Title: Re: 2 simple lines
Post by: Chaoticone on March 12, 2019, 09:23:19 PM
Used it in a lathe m6 this week. Works a treat (in the last dev. version I know).
Title: Re: 2 simple lines
Post by: Bill_O on March 13, 2019, 09:43:44 AM
We did end up using G28.1 to do the homing.
Thanks for the tip.

Bill
Title: Re: 2 simple lines
Post by: Cbyrdtopper on March 13, 2019, 11:51:32 AM
Bill,
Glad to hear that.
How did you use it?  In the Macro?  Using the MDIExecute or GCodeExecute call?
Title: Re: 2 simple lines
Post by: Bill_O on March 13, 2019, 11:54:39 AM
Chad,

We used the GcodeExecute

Bill