Hello Guest it is April 17, 2021, 08:00:01 AM

Author Topic: Configuration of Mach4 for homing with reference contacts  (Read 3947 times)

0 Members and 1 Guest are viewing this topic.

Re: Configuration of Mach4 for homing with reference contacts
« Reply #10 on: May 14, 2017, 12:21:30 AM »
Hi MaBoeck,
I have been experimenting at my machine and believe I've got a workable solution.

Mach4 core has a container for the 'home in place' flag. With the container variable false when the 'ref<axis>' or 'ref all' button
is pressed the machine will home to the switches in the order, direction and speed you specify as normal. The motion plugin/controller
actually does the work.

If however the 'home in place' flag is true for a given axis it will not drive anywhere but reset its machine co-ord to zero and home
in its current location.

Machs API has some instructions you can use to manipulate the 'home in place' flag programmatically.
The first is:
homeInPlace, rc = mc.mcAxisGetHomeInPlace(
      number mInst,
      number axisId)
which allows you to inspect the status of the flag for a given axis and:
rc = mc.mcAxisSetHomeInPlace(
      number mInst,
      number axisId,
      number homeInPlace)

which allows you to set the flag as you require. Presumably the flag will eventually be written to your profile and would become permanent
if you left it.
My suggestion for the 'ref all' button script would be:

1) Ref All---drive to home switches per normal
2)MDI---or programmed move to your desired machine home...something like
       mc.mcCntlGcodeExecuteWait(inst,'G53 G0 x500 y500 z-100')   this will hopefully put you at your desired machine home
3)mc.mcAxisSetHomeInPlace(inst,0,1)---sets 'home in place' flag for X axis as true
4) RefX--- given the 'home in place' flag the current X axis location will become X 0.
5)mc.mc.SetHomeInPlace(inst,0,0)---sets x axis 'home in place' flag back to normal
6) Repeat for Y and Zaxes as required.

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