Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: ranchak on May 20, 2010, 11:21:45 PM

Title: External Button for Auto Tool Zero
Post by: ranchak on May 20, 2010, 11:21:45 PM
I finally got my Auto tool zero function for the z axis working. I used the file posted by Hoss machine, which works great. What I would like to do is have a push button installed on the head of my mill that I can push that would trigger the Auto tool zero function. Can this be done?
Title: Re: External Button for Auto Tool Zero
Post by: Hood on May 21, 2010, 02:25:58 AM
Yes but at this point in time you will really need to use the MachMad plugin from ScottSchaefer, in Rev 4 of Mach it will hopefully  be natively supported.
Hood
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 21, 2010, 02:34:46 AM
I did this for someone who wanted the Z zero macro triggered by an external switch.

It was a while ago and there may be easier ways to do it by now.

I used a combination of a macro pump and a brain.

The macro pump polled the switch to see when it was pressed.

The brain did some safety interlocks and a time delay to avoid accidental activation.

Greg

EDIT:  Sorry I was going by memory and got it wrong.  (it was a couple of years ago)

The brain polls the input (switch) and does the safety interlocks and delay.  Then sets a user LED.

The macro pump just calls the macro when the user LED is active. Because a brain can not directly call the macro.
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on May 24, 2010, 12:35:13 AM
Thanks for the replies. Hood, why should I use the plugin from Scott Shaefer? I guess I'll wait until someone else figures out a better way to do this.
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 24, 2010, 12:52:00 AM
Have a look at these two files if interested.

One is a brain that is triggered by making input 4 active (press a momentary switch)

If, the switch is held for two seconds and the spindle is inactive and no axis movement is happening, then a user LED is activated.

Have a look at the brain in the brain editor.

The other is a macropump.  This will call your auto tool zero script from the macro folder when the user LED is activated.

You can check this macropump script out in any text editor.

The reason there are the two parts to make this work is,

The brain takes care of the two second safety delay and the other interlocks but can not call a macro.

So the macropump is used to monitor the user LED and call the macro.

As I said there may be more elegant ways to do this but it works.   Having a look at it may give you some ideas.

Greg
Title: Re: External Button for Auto Tool Zero
Post by: Hood on May 24, 2010, 07:43:09 AM
Hood, why should I use the plugin from Scott Shaefer?

Not saying you should, it is the route I have taken and it works very well and for $10 its well worth it in my opinion. You can however do it the way Greg has said which is very similar to using the plugin in its method,  or wait until Rev 4 comes out as hopefully it will support a less clunky method of doing this.

Hood
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on May 25, 2010, 11:02:31 AM
Hi Greg, I tried to open your files, but the Quicktime file will not open. I did open the BRN file, but I couldn't make anything of it. This is exactly what I would like to be able to do with my machine. How do I go about setting this up? Do I install your file in my Mach 3 folder? What does "LED" stand for? Thanks, Ron
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 25, 2010, 04:47:54 PM
I hunted down an old post and it is copied below,

Greg


There are two components in the attached zip folder.

Macropump.m1s and ZeroSwitch.brn

For an external switch to trigger the zero routine, I also place the "Macropump.m1s" in the macro folder, and the "ZeroSwitch.brn" goes in the brain folder.

The zero script also needs to be in the macro folder.  I called it M615

Macropump is then enabled on the "General Config" page. Brain is enabled via Operator / Brain Control. A Mach restart is needed for both of these to work.

Then you can open, Operator / Brain Control / View Brain, and see the brain operate.

My external switch is connected to a spare input pin and assigned to "Input#4" in "Ports and Pins". Set to become active when switch is pressed.

The brain contains a switch delay as a safety feature. I have it set so the switch must be pressed for two seconds before it triggers.

For this reason I have removed a delay that was previously coded into the zero routine. Two delays built in was confusing for an operator.

Also the brain locks out if the spindle is running or machine is moving.

The macropump simply sets the M615.m1s going. It has a lock out thingy built in to stop Mach trying to run the script multiple times.

Now you will ask "Why both a brain and a macropump?"... "Either one or the other should do it"

A brain can not trigger a macro, so a brain alone won't do what I need.

Mach does not like delays coded into a macropump because of timing issues. It can be done but is much more complex.

The brain makes the switch delay a no brainer. Pun intended.

Also the other safety lock outs are really easy to do in a brain.
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on May 25, 2010, 09:02:17 PM
I got my push button wired to input pin #11 on my BOB.

I assigned Input #4 to pin #11.

 I copied the file Macropump.m1s in the macro folder.

I enabled "macropump" in the General Config screen.

I installed the ZeroSwitch.brn file in the brain folder.

I enabled  the loaded brains.

I also copied this file to the macro folder.

I renamed it M615.m1s.

I restarted Mach3.

My problem is when I push the external button I get an error message "Scripter Compile Error. In:M615.mis. Where did I go wrong?
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 25, 2010, 10:10:07 PM

I also copied this file to the macro folder.

I renamed it M615.m1s.


I presume you mean your zero script. That is what is now in the macro folder and named M615.  Right?   Must be a problem with it.

Post it and I will take a look.

Greg
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 26, 2010, 02:13:54 AM
Greolt -
thx for information.very good

i think "ranchak" copy macropump to macro folder and rename it.
this is wrong.
in fact macropump call M615 and These two are different
I say wrong?

But one question:
i assigned a macro to a button, why sometimes i press button see this error: "Scripter Compile Error. In" ?
At this time, in "operator/Edit Button Script"   i see my code and press run  and all things is ok and Macro runs.
why?
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 26, 2010, 05:08:10 AM
i test your Method:
i design button +LED  in Mach3Screen. i set OEMled =1200
then create macropump.m1s :
A = GetOEMled (1200)

 If A Then
 Code "M113"
 End If

and create brain that i attach it.
but mach3 shows behavior strange and error.
Where I got wrong?
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on May 26, 2010, 11:03:41 AM
No I meant ZeroSwitch, but this is where the mistake is. I used the "ZeroSwitch" file and renamed it. I guess I didn't read the directions! I'll delete it and then rename my zeroing program, that should work. Thanks, Ron
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 26, 2010, 04:10:51 PM
i test your Method:
i design button +LED  in Mach3Screen. i set OEMled =1200
then create macropump.m1s :
A = GetOEMled (1200)

 If A Then
 Code "M113"
 End If

and create brain that i attach it.
but mach3 shows behavior strange and error.
Where I got wrong?

Try this instead

A = GetOEMled (1200)
B = GetUserDRO (1200)

If A And (B = 0) Then
Code "M113"
SetUserDRO(1200,1)
End If

If Not A And (B > 0) Then
SetUserDRO(1200,0)
End If 
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 27, 2010, 02:41:59 AM
thx Greolt
macropump problem solved , but brain problem
dont work
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 27, 2010, 10:57:46 AM
i have two button(user button) and two VB code.i have modbus pendant with 32 key.
and them should after pressing the button be activated immediately.
please guide .
i try but not work.
http://www.machsupport.com/forum/index.php/topic,14964.0.html (http://www.machsupport.com/forum/index.php/topic,14964.0.html)
Title: Re: External Button for Auto Tool Zero
Post by: BobWarfield on May 27, 2010, 12:14:52 PM
I love this idea of a button!

Would look great in a little panel on the head next to the powered drawbar "In" and "Out" switches:

In
Out
Zero

I'll have to give that some thought.  Definiitely worth waiting for Mach 4 as the new functionality for tool tables would likely support it better.

Cheers,

BW
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 28, 2010, 02:16:52 PM
I still have not succeeded .
i read this Thread but dont understand.
http://www.machsupport.com/forum/index.php/topic,9636.0.html (http://www.machsupport.com/forum/index.php/topic,9636.0.html)
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 28, 2010, 03:16:56 PM
I realized that the process works well, But only during the run of the code does not work
why?
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 29, 2010, 11:40:47 AM
nobody guide me.
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 29, 2010, 08:30:44 PM
I realized that the process works well, But only during the run of the code does not work
why?

Perhaps you need to provide some more information so that others can help.

What is the VB macro that is failing?  Does it run from the editor?   Can you call it from the MDI?  What happens when you step through it with the editor?

Greg
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 30, 2010, 01:52:09 AM
i attach my file.
this macro should work during cut.
when trigger input#1 ,first feedhold>Torch off>stop>set position>...
i test it,macro is ok.
Quote
Can you call it from the MDI?
yes
when is stationary, input#1 work and trigger macro but in during cut dont work
please check them.
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on May 31, 2010, 10:52:48 AM
Someone faced with this problem
Title: Re: External Button for Auto Tool Zero
Post by: Greolt on May 31, 2010, 04:34:20 PM
I have no experience with plasma.

Can you trigger the macro with an onscreen button during a cut?

Is there noise swamping the input while plasma is running?

Greg
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on June 01, 2010, 01:46:54 AM
This problem is not in plasma. General case.

Quote
Can you trigger the macro with an onscreen button during a cut?
yes, i can with button and no problem even during cut

Quote
Is there noise swamping the input while plasma is running?
no, i dont test this Steps with machine. i test only with PC but when i run code ,Trigger does not cause to activate macro
If possible please test my file on the your PC.
may I get wrong step.
again thx.

Amir
Title: Re: External Button for Auto Tool Zero
Post by: poppabear on June 03, 2010, 03:34:32 AM
In your Macropump.m1s

you need to change GetOEMled(1140) to GetUserLED(1140), there is NO OEM Leds in that range.

Also in your Brain:

   You will need to INVERT your noop, for your UserLED to be ON when your Input1 is ON, you will have to use a INverted op. otherwise when the Brian says your Screen User LED is on, it will be off, and vice versa.
so you brain rung should be:

INPUT1 -> Invert signal -> UserLED

(I recommend reading the "Brains Users Guide" in the member docs section.)
BTW: make sure under Ports and Pins for the INPUT1 signal you have it enabled, AND make sure the Logic (active high, or active low), is correct for what you want the state of that signal doing when active.

scott
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on June 03, 2010, 03:37:19 AM
thx Scott
i check it

Amir
Title: Re: External Button for Auto Tool Zero
Post by: manmeran on June 03, 2010, 03:48:59 AM
i change OEMled to userled and invert signal.
result :
no change. actually it work well but only when code dont run( Axes are no moving )
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on June 06, 2010, 04:48:21 PM
I renamed my zerotool macro to M615 and now everything works fine. Thanks for everybody's help.
Title: Re: External Button for Auto Tool Zero
Post by: johnv on September 18, 2010, 05:03:12 PM
Hi All,
I would appreciate if ranchak or greg would enclose a corrected m1s & brn file. I'm been trying all different versions and am at a standstill. Thanks in advance.
Johnv
Title: Re: External Button for Auto Tool Zero
Post by: ranchak on September 20, 2010, 11:00:33 AM
Johnv, here are my files. I have to tell you that this worked great for awhile, then Mach would start to run the ATZ feature on it's own. I did have an issue with my computer and I have replaced it, but I haven't tried using this macro since then. Please let me know if you run into the same problem.
Title: Re: External Button for Auto Tool Zero
Post by: johnv on September 20, 2010, 03:09:58 PM
Hi ranchak & Greg,

The bottom line is, I got it running using ranchak's files, even though they are identical to greg's. I had another brn file running which I don't use, so I disabled it and I think thats when the ATZ started to work.  I went back to greg's files and they work as well. Greg & ranchak..... thanks loads!! :)

Johnv