Hello Guest it is December 10, 2019, 02:14:38 AM

Author Topic: Reference all home help.  (Read 4784 times)

0 Members and 1 Guest are viewing this topic.

Re: Reference all home help.
« Reply #10 on: November 29, 2017, 03:53:39 AM »
Hi,
this code seems to work...haven't really tested it fully

Code: [Select]
function GoCenter();
local inst=mc.mcGetInstance();
local Xhand=mc.mcRegGetHandle(inst,'iRegs0/Xcenter');
local Xcenter=mc.mcRegGetValue(Xhand);
local Yhand=mc.mcRegGetHandle(inst,'iRegs0/Ycenter');
local Ycenter=mc.mcRegGetValue(Yhand);
local Zhand=mc.mcRegGetHandle(inst,'iRegs0/Zcenter');
local Zcenter=mc.mcRegGetValue(Zhand);
local homed=0;
local enabled=0;
if (mc.mcAxisIsEnabled(inst,mc.X_AXIS)==1) then enabled=enabled+1 end;
if (mc.mcAxisIsEnabled(inst,mc.Y_AXIS)==1) then enabled=enabled+1 end;
if (mc.mcAxisIsEnabled(inst,mc.Z_AXIS)==1) then enabled=enabled+1 end;
local Xhomed,rc=mc.mcAxisIsHomed(inst,mc.X_AXIS);
local Yhomed,rc=mc.mcAxisIsHomed(inst,mc.Y_AXIS);
local Zhomed,rc=mc.mcAxisIsHomed(inst,mc.Z_AXIS);
if Xhomed==1 then homed=homed+1 end;
if Yhomed==1 then homed=homed+1 end;
if Zhomed==1 then homed=homed+1 end;
if (homed+enabled)==6 then
    mc.mcCntlGcodeExecuteWait(inst,"g53 g0 z"..Zcenter.."\n g53 g0 x"..Xcenter.."y"..Ycenter)
end
end
if (mc.mcInEditor() == 1) then
    GoCenter()
end

Craig
My wife left with my best friend...
     and I miss him!
Re: Reference all home help.
« Reply #11 on: November 29, 2017, 03:57:01 AM »
Hi,
I suggest putting this in your profile/macro folder. Allows you to debug and work on it. Once you get it polished then we'll put it in the screen load script
and attach it to the button.

Craig
My wife left with my best friend...
     and I miss him!
Re: Reference all home help.
« Reply #12 on: November 29, 2017, 03:46:29 PM »
Hi,
realised this morning that if the machine axes are not enabled and homed then a message should pop up to tell
you why the function didn't proceed.

Craig
My wife left with my best friend...
     and I miss him!
Re: Reference all home help.
« Reply #13 on: November 29, 2017, 11:29:01 PM »
WOW! thanks Craig! I super appreciate it. I will put the code in the macro folder.. in the mach4/hobby folder? I have yet to mess with or research anything about macros as of yet. Once the code is in the macro folder, is the next step tying the code to a button to test it out? This is getting exciting now! - Nick
Re: Reference all home help.
« Reply #14 on: November 29, 2017, 11:31:26 PM »
I just went back a page and read the post i missed about registers! I will create the 3 registers like you show tomorrow and we can proceed with testing code. Thanks Craig.

- Nick
Re: Reference all home help.
« Reply #15 on: November 30, 2017, 12:42:54 AM »
Hi Nick,
for the moment put it in the Macro folder of your current profile.

This is in fact a modification and extension of your screen set wx4.set  In a few months time when you download and install the latest build of Mach4
it will be overwritten by a new copy of wx4.set and your work, this and other tweaks will be lost.

For this reason I recommend that you make a copy of wx4.set and call it something distinct like Nickswx4.set and use that as your screen set. Then any tweaks
you make will not be overwritten. Create a copy of wx4.set in Mach4Hobby\Screens and rename. Run Mach4 Loader and copy your current profile, you can give
it a new name, and also select your newly created screen set.

The function code should be put in Mach4Hobby\Profiles\NicksProfile\Macros

Craig
My wife left with my best friend...
     and I miss him!
Re: Reference all home help.
« Reply #16 on: November 30, 2017, 01:14:26 AM »
Craig. I created a screen set with a custom name, it no longer says wx4 when i open and run mach. I read about about the importance of saving your profile right! I hope i did it the right way. I will copy the function code to the macros profiles and go from there! 

- Nick
Re: Reference all home help.
« Reply #17 on: November 30, 2017, 01:22:50 AM »
Hi Nick,
I learnt the hard way...blithely editing my screenset for a few months (Mach4 was new to me) only to find that I had inadvertently overwritten it all when I got
a later build. It did cause me to re-read and more importantly UNDERSTAND the recommendations about having not only your own profile but screenset as well.

Craig
My wife left with my best friend...
     and I miss him!
Re: Reference all home help.
« Reply #18 on: November 30, 2017, 01:40:19 AM »
The thought of that pains me! =)  ... So, Am i correct in thinking after the function code is in the  macros folder... then I will need something to link the button to the function? possibly  something like GoCenter() in the left up on a custom button?
Re: Reference all home help.
« Reply #19 on: November 30, 2017, 01:51:13 AM »
Hi,
yes that is the idea. Tempted to strip it out of the macros folder and put it in the screen load script. It would then be possible to call the function from
the left-up script of a screen button but also from the signal script if you wanted it to be accessible from a physical button.

Craig
My wife left with my best friend...
     and I miss him!