Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Duc748 on October 22, 2010, 01:58:37 PM

Title: Manual button for auto zero
Post by: Duc748 on October 22, 2010, 01:58:37 PM
Hi All,

Is it possible to have a manual button on the gantry to do a z auto zero, instead of using mach3 zero button??
When doing tool change I think it would be better to have button on the gantry rather than going back to pc to do it.

If its possible is their anyone prepared to give me advice and directions on how to implement this?

Rick
Title: Re: Manual button for auto zero
Post by: Hood on October 22, 2010, 02:22:29 PM
I do a similar kind of thing, in as much as I run macros via external buttons. Scott Scheafers MachMad plugin allows you to assign a User LED to a macro and when the LED is seen the plugin will run the macro that you have designated.
So what you would do is have your autozero named as a macro ( eg m1234.m1s) and placed in your profiles macro folder. You would then set up the plugin to look out for your LED and tell it the macro to run.

You could also likely do this via a macropump, just have the macropump look for a LED and then do the macro when its seen.
Hood
Title: Re: Manual button for auto zero
Post by: Duc748 on October 22, 2010, 02:34:30 PM
Thanks Hood,

Do you have a simple macro for this you like to share?
I read so many posts with different operations like is the probe conneted.. although they seem good ideas all I want is something very simple to get the job done.

Rick
Title: Re: Manual button for auto zero
Post by: Hood on October 22, 2010, 02:38:08 PM
Afraid I dont use auto zero so dont have a macro but a search of the forum will bring up plenty I am sure.

I use external buttons to activate other things such as Cycle Start, Ref All etc.

Hood
Title: Re: Manual button for auto zero
Post by: Greolt on October 23, 2010, 07:00:20 PM
Hood's advice to use MachMad is good.  It only costs $10.  Then you can have all sorts of remote triggers.

However if you want to do it this way, here is a copy of an old post of mine regarding having a manual button for a macro.

====================================================================

A brain can not trigger a macro on it's own.  So the macropump does that.

However brains are a no brainer to implement safety timers and lockouts.  (pun intended)   ;D

The auto tool zero macro needs to be placed in the macro folder with the name of your profile.  Eg.  Mach3Mill.    Call it  M615.m1s

The macropump calls the relevant macro when a user LED goes active.

It basically is one which Poppabear wrote for me a while ago.  Much the same as posted above.

The brain sets the LED when the switch is pushed and held for 1.5 seconds but only if there is no motion,  the spindle is not running and reset is not active.

Being an external momentary switch I think the 1.5 second delay is a good safety measure.  

This means you must push and hold the switch for 1.5 seconds before anything will happen.

You do not want unintentional activation of the macro.

So the addition of the brain is just to allow for easy implementation of the safety lockouts.

====================================================================

Have the momentary switch activate OEMTRIGGER#5

Remove any initial delay in the auto tool zero script.  The brain now handles that.

Try it if you wish,

Greg
Title: Re: Manual button for auto zero
Post by: Duc748 on April 13, 2011, 06:52:09 PM
Hi Greg,

I am running a twin Z axis machine (Z and A axis) with external zero buttons for both axis, can you please advise on what additional code I need to add to the macropump? I have 2 separate Macros M615 and M616 one for each axis in the macro folder but unsure regarding the macro pump.

Rick
Title: Re: Manual button for auto zero
Post by: Greolt on April 14, 2011, 06:23:43 AM
Rick

Just duplicate what is in the macropump  as follows. (duplicated section in blue).  This time using DRO and LED 1141  and M616


A = GetOEMled (1140)
B = GetUserDRO (1140)

If A And (B = 0) Then
Code "M615"
SetUserDRO(1140,1)
End If

If Not A And (B > 0) Then
SetUserDRO(1140,0)
End If 

C = GetOEMled (1141)
D = GetUserDRO (1141)

If C And (D = 0) Then
Code "M616"
SetUserDRO(1141,1)
End If

If Not C And (D > 0) Then
SetUserDRO(1141,0)
End If 

Then edit the trigger brain to duplicate what is already in the brain.   Make the first input of the duplicated section,  OEMTRIGGER#6  and terminate with OEMLED: 1141

So M615 will be for Axis Z,   and M616 will be for Axis A.

That should work.............I think.  ;D

Greg
Title: Re: Manual button for auto zero
Post by: stirling on April 14, 2011, 08:23:18 AM
I'm probably missing something here, but isn't it easier just to use triggers? i.e. with no macropump, macros, brains or plugins needed.

Ian
Title: Re: Manual button for auto zero
Post by: ger21 on April 14, 2011, 11:58:46 AM
That's what I was thinking. As long as you have a button for it, just use an OEM Trigger.
Title: Re: Manual button for auto zero
Post by: Greolt on April 14, 2011, 05:13:07 PM
No doubt there are lots of ways you can do this.   Using MachMad would be easy.

As I understand it you cannot activate a macro with an OEMtrigger.  With the exception of the one "Trigger Macro" which first must be set in the init string.

I guess with some clever macro writing you could run a tool zero routine for the appropriate Z or A axis, all contained within the trigger macro.

Why I use a brain is because the safety lockouts and time delay can be done very easily.

Greg

Title: Re: Manual button for auto zero
Post by: ger21 on April 14, 2011, 05:14:40 PM
But can't you activate an onscreen button that calls a macro? Or that doesn't work?
Title: Re: Manual button for auto zero
Post by: Greolt on April 14, 2011, 05:33:25 PM
I don't believe that you can.  Could be wrong.

It was a long time ago that I looked into this.

Greg
Title: Re: Manual button for auto zero
Post by: stirling on April 15, 2011, 04:18:33 AM
I guess I was just making the point that as far as Duc748's particular requirement here, there's no need for any macros (or macropump) at all in the first place, so how to fire one is not really an issue.

However, if you DID want to use a trigger macro that handled multiple triggers, then it just requires a "select" statement so is not really that comlex.

Anyway - JMHO

Cheers

Ian
Title: Re: Manual button for auto zero
Post by: Greolt on April 15, 2011, 05:56:58 AM
I guess I was just making the point that as far as Duc748's particular requirement here, there's no need for any macros

I think the question was about triggering an auto tool zero routine, which is a macro.

Hi Greg,
I am running a twin Z axis machine (Z and A axis) with external zero buttons for both axis, can you please advise on what additional code I need to add to the macropump?
I have 2 separate Macros M615 and M616 one for each axis in the macro folder but unsure regarding the macro pump.

And yes I am sure with a bit of clever macro writing it could all be handled in the trigger macro.

However Rick has been using this macropump/brain combination method for a while and asked how he could extend it to cover dual Z axis.  Hence my reply.

Greg
Title: Re: Manual button for auto zero
Post by: Duc748 on April 16, 2011, 03:21:22 AM
Well thanks for all the input,
I have implemented this as Gregs method based on the fact that the Brain has the safety feature of holding the button for 2 seconds for activation..I think this is important as people do push buttons..ah whats this for..you get my meaning.
The trigger macro does interest me too..is it possible to have the safety feature built into this method?

thanks again
Rick
Title: Re: Manual button for auto zero
Post by: stirling on April 16, 2011, 06:26:08 AM
Hi Rick - can you clarify whether you're talking about an "auto tool zero" or just about zeroing the axis as per the standard Z and A zero buttons please?

Cheers

Ian
Title: Re: Manual button for auto zero
Post by: Duc748 on April 16, 2011, 01:59:52 PM
Hi Ian,

The machine is configured as auto zero tool buttons with touch off plate.

Rick
Title: Re: Manual button for auto zero
Post by: stirling on April 17, 2011, 01:24:44 PM
OK Rick and Greg - I misunderstood the requirement - Mea culpa.

However Rick if you do want to have a go via a trigger macro then yes you should be able to code in any safety features you like. See http://www.machsupport.com/forum/index.php/topic,15120.msg101160.html#msg101160 (http://www.machsupport.com/forum/index.php/topic,15120.msg101160.html#msg101160) where if for example you put a "sleep 1000" as the first line of the example code, it would test whether you held the button that fired the trigger for more than a second before doing whatever.

Ian
Title: Re: Manual button for auto zero
Post by: Greolt on April 17, 2011, 05:44:58 PM
Ian

The advantage of using a brain is the timer safety.   If the switch/button is held for less than the specified time (2 sec) then nothing happens.

Can you give us an example of how to do this in the trigger macro.  It would be very handy to know how this is done.

Would it be an if/then with a pause and recheck input?

Greg
Title: Re: Manual button for auto zero
Post by: Duc748 on April 17, 2011, 05:50:31 PM
Greg,

Ive been testing my setup today, I noticed that nothing happens for 2 seconds as my input into the Brain, but if I try the auto zero again it starts as soon as the button is pressed and no 2 second delay.

You have any idea what ive done wrong?

Rick
Title: Re: Manual button for auto zero
Post by: Greolt on April 17, 2011, 06:50:56 PM
No I don't Rick.  Have not had anyone else report that.  Does it happen for both Z and A auto tool zero buttons?

Perhaps if it is the second section of the brain that you added, it may be that the timer module is set differently.  Not set as one shot maybe.

It might be worth waiting on Ian to show how this can all be done in a trigger macro.  It would be more elegant.

Greg
Title: Re: Manual button for auto zero
Post by: Greolt on April 17, 2011, 07:16:17 PM
Rick

Here is the brain as described earlier.  Using OEMtrigger # 6 and OEMLED 1141

Try this and see if the result is the same.

Greg
Title: Re: Manual button for auto zero
Post by: stirling on April 18, 2011, 06:43:12 AM
Ian

The advantage of using a brain is the timer safety.   If the switch/button is held for less than the specified time (2 sec) then nothing happens.

Can you give us an example of how to do this in the trigger macro.  It would be very handy to know how this is done.

Would it be an if/then with a pause and recheck input?

Greg

Hi Greg - see my suggested example in my previous post. FWIW using the macro method I don't think there's a need for checking IsMoving and Enable like in your Brian because Mach ignores macro generated movement whilst already in motion and doesn't execute macros whilst in reset. That would just leave your spindle check which could be done the macro equivalent way as the Brian i.e. by checking LED 116.

So my example macro 666.m1s above might look something like this: (change trigger #s to suit)

Code: [Select]
'wait before doing checks so that a trigger must still be active after 2 secs for the following to succeed
sleep 2000

'if T1 is still active i.e. button is still pressed after 2 secs and spindle is off
If isActive(OEMTRIG1) and not getOEMLED(116) Then
  'paste your Z axis tool setting code here
End If

'if T2 is still active  i.e. button is still pressed after 2 secs and spindle is off
If isActive(OEMTRIG2) and not getOEMLED(116) Then
  'paste your A axis tool setting code here
End If

Let me know how you get on.

Cheers

Ian
Title: Re: Manual button for auto zero
Post by: Greolt on April 18, 2011, 08:34:12 AM
Thanks Ian.  I get the general idea.  Gives me something to work on.

You can't call a macro from a macro....can you?

Greg
Title: Re: Manual button for auto zero
Post by: stirling on April 18, 2011, 09:56:11 AM
You can't call a macro from a macro....can you?

Well.... you can, but there be dragons. Best avoided.

Ian