Hello Guest it is March 28, 2024, 07:35:50 PM

Author Topic: LUA: moving out of home-switches after RefAll-Home  (Read 3030 times)

0 Members and 1 Guest are viewing this topic.

LUA: moving out of home-switches after RefAll-Home
« on: December 30, 2014, 09:35:42 AM »
Hi everbody,

i'm tryining to code my own homing-script.
After homing my axes should move out of the home-switches.
But i can't get it to work - I'm very new to LUA!!!

It seems that my axes get never homed...
so i have written this script to test if axis-x is homed.
But after pressing the button RefAll-Home the axes move to the homing-switches, but the axes are never homed!

Code: [Select]
local homed_x;
local rc;
local inst;

inst= mc.mcGetInstance();
homed_x, rc = mc.mcMotorIsHomed(inst, 0)

if (homed_x == true) then
   rc = mc.mcCntlSetLastError(inst, 'homed')
else
   rc = mc.mcCntlSetLastError(inst, 'not homed')
end


Sorry for my bad english!
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #1 on: January 02, 2015, 05:47:12 AM »
for me it seems that some LUA calls are not working.
I tried a different button script to ask wether x-axis is movin or not.

but the output is always the same: axis-x is moving (even if the axis stands still!!!).

Code: [Select]
local still;
local rc;

local inst = mc.mcGetInstance();
still,rc = mc.mcAxisIsStill(inst, 0);

if (still == true) then
    rc = mc.mcCntlSetLastError(inst, 'axis-x is still')
else
    rc = mc.mcCntlSetLastError(inst, 'axis-x is moving')
end

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #2 on: January 02, 2015, 08:40:42 AM »
Hello Student,
The first thing to do is make sure you are running the latest Mach4 and Darwin.
Second, use the diagnostics page to make sure you have your home switches configured correctly.
Third, make sure homing works with the default ref. all home button script.
Forth, have a play with the home offset values in homing and limits to see how that effects your axis position when homing.
When you are at this point you can then alter your homing script if you still need to. If it does not work, you will know it is your script.

Code: [Select]
--Default ref. all home script
local inst = mc.mcGetInstance();
mc.mcAxisHomeAll(inst);

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #3 on: January 02, 2015, 10:13:03 AM »
Thanks for your reply.

I have the latest Mach4 and Darwin installed (V1.2157).

The home switches are configured correctly - I think...
Homing with the default ref. all home button works.
Also the home offset values work -> after homing the actual machine position is set to the value I have configured as home offset.

maybe my script is wrong...
but i can't find an error.

Maybe someone else can try...

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #4 on: January 02, 2015, 11:29:23 AM »
You could give this a try if you want. It has not been tested so try at your own risk.

Code: [Select]
local inst = mc.mcGetInstance();
mc.mcAxisHomeAll(inst);
wx.wxMilliSleep(10);
mcState = mc.mcCntlGetState(inst);
while (mcState ~= mc.MC_STATE_IDLE) do
mcState = mc.mcCntlGetState(inst);
wx.wxMilliSleep(10);
end
mc.mcCntlGcodeExecuteWait (inst, "G53 G90 G0 Z0.0000 X0.0000 Y0.0000");


Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #5 on: January 04, 2015, 07:13:04 AM »
Thanks a lot.
Your Script works and does exactly what i wanted!

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: LUA: moving out of home-switches after RefAll-Home
« Reply #6 on: January 04, 2015, 12:32:28 PM »
 :)
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!