Machsupport Forum
Mach Discussion => Mach4 General Discussion => Mach4 Videos => Topic started 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
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
-
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.
-
Thanks for the lessons DazTheGas.
When SoftLimits Off, everything works OK.
Question: why when SoftLimits On - HommeOffset wrong.
-
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