Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Videos => Topic started by: DazTheGas on September 17, 2015, 09:54:14 AM

Title: Mach4 and ESS Homing Offset Script UPDATED
Post by: DazTheGas on September 17, 2015, 09:54:14 AM
Heres an update to the homing script I wrote a while back that somewhere during the version updates broke and I never noticed..  Was trying so hard to figure out the mcAxisSetMachinePos  to do this until I saw the post by Ya-Nvr-No in regards to using    mcMotorSetHomePos, which in substitution done the trick.

https://youtu.be/HhcCGt0Lywo

New PLC Script all the restis the same

Code: [Select]
if (x_enable_offset == "true" and y_enable_offset == "true" and z_enable_offset == "true") then
    if (offset_applied == "false") then
        xoffset = mc.mcAxisGetHomeOffset(inst, 0);
        yoffset = mc.mcAxisGetHomeOffset(inst, 1);
        zoffset = mc.mcAxisGetHomeOffset(inst, 2);
        mc.mcAxisSetPos(inst, 0, 0.00);
        mc.mcAxisSetPos(inst, 1, 0.00);
        mc.mcAxisSetPos(inst, 2, 0.00);
        mc.mcCntlGcodeExecuteWait(inst, "G00 X"..xoffset.." Y"..yoffset.." Z"..zoffset);
        mc.mcMotorSetHomePos(inst, 0, xoffset * mc.mcProfileGetDouble(inst, 'Motor0','CountsPerUnit',0)) --X
        mc.mcMotorSetHomePos(inst, 1, yoffset * mc.mcProfileGetDouble(inst, 'Motor1','CountsPerUnit',0)) --Y
        mc.mcMotorSetHomePos(inst, 2, zoffset * mc.mcProfileGetDouble(inst, 'Motor2','CountsPerUnit',0)) --Z
        mc.mcMotorSetHomePos(inst, 3, yoffset * mc.mcProfileGetDouble(inst, 'Motor3','CountsPerUnit',0)) --Y Slave
        mc.mcAxisSetPos(inst, 0, xoffset);
        mc.mcAxisSetPos(inst, 1, yoffset);
        mc.mcAxisSetPos(inst, 2, zoffset);
        offset_applied = "true";
end
end

P.S Does mcAxisSetMachinePos actually work cause I cant do anything with it??

DazTheGas
Title: Re: Mach4 and ESS Homing Offset Script UPDATED
Post by: Chaoticone on September 17, 2015, 05:18:09 PM
Quote
P.S Does mcAxisSetMachinePos actually work cause I cant do anything with it??

I had it working a while back but haven't tried it lately. I will have to give it a play and let you know what I find.
Title: Re: Mach4 and ESS Homing Offset Script UPDATED
Post by: gudre on April 01, 2016, 09:20:44 AM
Thanks for the lessons DazTheGas.
When SoftLimits Off, everything works OK.
Question: why when SoftLimits On - HommeOffset wrong.
Title: Re: Mach4 and ESS Homing Offset Script UPDATED
Post by: DazTheGas on April 01, 2016, 10:25:54 AM
I will check on this as I dont use softlimits myself but will have a look over the weekend.

one thing that possibly could help is setting the OSIG_SOFTLIMITS_ON to off at beginning of script then again to turn on after the offsets have been applied.

DazTheGas