Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: abdulasis on November 04, 2020, 12:01:32 AM

Title: macro for Home Axis
Post by: abdulasis on November 04, 2020, 12:01:32 AM
Hi
I have create macro for Home Axis
but when  I type in MDI and click Start cycle  Click 5 time it's do 1 time or nothing anything.
why ?

Code: [Select]
function m108()

local inst = mc.mcGetInstance()
local rc = 0

rc = mc.mcAxisHome(inst, 5)
end

if (mc.mcInEditor() == 1) then
m108()
end
Title: Re: macro for Home Axis
Post by: joeaverage on November 04, 2020, 03:04:54 AM
Hi,
do you have a motor assigned as number 5?

If you have no home switch assigned to an axis which is being homed it will 'home in place', ie not move. An axis will
move only when it is logically connected to a motor number and a home signal for that motor is enabled.

Craig
Title: Re: macro for Home Axis
Post by: abdulasis on November 04, 2020, 11:19:14 AM
Hi,
do you have a motor assigned as number 5?

If you have no home switch assigned to an axis which is being homed it will 'home in place', ie not move. An axis will
move only when it is logically connected to a motor number and a home signal for that motor is enabled.

Craig

Hi MR. Craig
This my action

configure --> control --> active motor5 and set motor mapping motor5 on C axis
configure --> Plugins --> ESS V.260 --> Input Signals --> Motor 5 Home  set correct pin

I create new button on screen by copy from button Reffecrence Z  and change config and rename to C axis

Then
I try on screen click button Refference C   . Result  = Good, worked.

Then I try to create script macro ::::

Code: [Select]
function m108()

local inst = mc.mcGetInstance()
local rc = 0

rc = mc.mcAxisHome(inst, 5)
end

if (mc.mcInEditor() == 1) then
m108()
end

I try type in MDI  and click cycle Start Gcode
Result = nothing
When I spam click cycle Start Gcode  some time it's running for home!!! . I don't know script for check state , set state , before run it's ?
have any Idea for this my problem ?
Title: Re: macro for Home Axis
Post by: SwiftyJ on November 04, 2020, 11:44:20 AM
I don't think you can use the API to home an axis in a macro. If you want to home an axis via gcode try 'G28.1  C1' in the MDI
Title: Re: macro for Home Axis
Post by: abdulasis on November 04, 2020, 10:03:24 PM
I don't think you can use the API to home an axis in a macro. If you want to home an axis via gcode try 'G28.1  C1' in the MDI
Thank you bro.
I have question , How to script for click button on screen ? have ? or not have ?
Title: Re: macro for Home Axis
Post by: smurph on November 14, 2020, 02:06:00 AM
Why do you need a script?  Just place a button on the screen, click on it, then find the event button on the properties window (it has a little lightening bolt) then select the "Home C" action on the left up action.  The button will only work when the machine is NOT in automatic mode (meaning idle and not in a cycle).  So be sure to set the "Enable With Machine" and the proper "Enabled States".

Steve