Machsupport Forum

Mach Discussion => Brains Development => Topic started by: poppabear on June 25, 2008, 09:18:05 PM

Title: How to run a Brain triggered Macro.........
Post by: poppabear on June 25, 2008, 09:18:05 PM
ok, this is a little convoluted but bear with me.

Make the Macro you want to run with some trigger in Brians.

i.e. 
'M1001.m1s
my code here that the brian triggers to run

Then
Make another Macro file that will set your default Macro trigger file.
i.e.

'M1000.m1s
SetTriggerMacro(1001) 'that is all that is in this one.

Now under config>general in the "Init box", put a M1000
As Mach3 boots up, (or on a reset if you have that ticked)
It will run the M1000 that sets the Default Brain run macro.

Then in Brians:

set up a rung that is some input, nop, Terminate "Push User Button"
i.e.

INPUT1>NOP>Push User Button

When ever that input goes HOT in the brian, it will then trigger the running of the M1001 and what ever code is in it.

Scott
Title: Re: How to run a Brain triggered Macro.........
Post by: fer_mayrl on August 20, 2008, 07:02:18 PM
Hello Scott,

Can this be done with multiple macros?

What about running multiple macros simultaneously, is this possible?
Regards
Fernando
Title: Re: How to run a Brain triggered Macro.........
Post by: jordie1944 on January 20, 2010, 08:13:21 PM
Scott

Could you please explain the User Button in the Brain a bit more. I could not find any terminators for User Button.

Also how does the User Button associate with the macro? I would like to run a Zero tool macro from a brain triggered from a modbus or pokeys switch.

Mike
Title: Re: How to run a Brain triggered Macro.........
Post by: scottn on February 06, 2012, 11:51:07 PM
I'm helping somebody who wants to do the same thing.  I could not find any valid termination that had anything to do with a User Button, either, but here is a solution that seems to work with my test setup (your mileage may vary):

Brain:

Input X -> No Op -> OEMTrigger X


OEMTrigger X (Config -> Ports/Pins, Input Signals) was Enabled and Emulated, no actual port/pin or hotkey information configured.  The action for OEMTrigger X (Config > System Hotkeys) was configured to be OEM Code 301, which runs the current trigger macro.  The trigger macro was setup as Scott said, using a macro in the Init String (ie. M1000 in his example) to SetTriggerMacro() the "working" macro (ie. M1001 in his example)...

I hope that helps,

scott
Title: Re: How to run a Brain triggered Macro.........
Post by: poppabear on February 07, 2012, 10:57:50 PM
Hey Guys the is a "Button" called "Execute Button Script" (1034), this is the way that the Brains pushes (fires off), a "Button" that has a macro in it......
see my first post above and follow those directions, when you build the brain, use the above "Button" Terminator called "Execute Button Script"

Scott
Title: Re: How to run a Brain triggered Macro.........
Post by: stirling on February 08, 2012, 07:28:53 AM
Just a couple of thoughts guys but why would we want to run a macro as a result of an input using a brian? That's what OEM triggers do i.e. input goes active, macro runs - no brainer ;D. Or was that just an example?

Also - what's to stop a brain running a macro whilst another (or the same) macro is already running - we know that's uber bad for Mach's health.

Sorry - just being devil's advocate.  >:D

Ian
Title: Re: How to run a Brain triggered Macro.........
Post by: poppabear on February 08, 2012, 09:24:37 PM
mostly, it was an exercise in how to do it, from a user who wanted to know how to do it using a brain......... so, there it is......
Title: Re: How to run a Brain triggered Macro.........
Post by: darlly01 on October 17, 2012, 10:22:41 PM
I came to this post to find a solution to my problem, anyone could help me?
I need to use a modbus signal to activate a macro which will load a gcode. I did the modbus signal and its working I have 2 different Gcode tha I want choose and load it with a command from modbus signal. I make the brain input works and even I could create a button on mach 3 screen to load the Gcode. But I couldn't make it works with modbus. Please let me know if the example I have seen like yours can control just one macro, or can it be done to 2 different macros?
Or is there anyway to make my modbus signal activate the button I add on my screen, which is openning the macro to load the Gcode?
 
Any help will be very appreciated.

thanks
Darli
Title: Re: How to run a Brain triggered Macro.........
Post by: darlly01 on November 13, 2012, 07:51:49 PM
Hi, Poppabear,
I follow your example, I'm just confused because I am already using the first string to execute another macro. Is there anyway I can use brain to activate a different macro using my Modbus control?
thanks for your attention.
Darli
Title: Re: How to run a Brain triggered Macro.........
Post by: darlly01 on November 13, 2012, 08:24:40 PM
I did everything as Scottn said, and it works perfect, but I want to control another macro, how do you associated the 1001 macro with code 301? How can I associate another macro with another number to execute the OEM?
thanks a lot for all your attention.

darli
Title: Re: How to run a Brain triggered Macro.........
Post by: Tony Bullard on November 27, 2012, 04:40:06 PM

I beleive you can only have one OEM code 301 at a time.

SetTriggerMacro 35    'Macro M35.m1s

This sets Macro M35.m1s to OEM code 301.

If you want to use another you have to use another SetTriggerMacro statment
SetTriggerMacro 36 sets M36.m1s to OEM code 301.

Tony
Title: Re: How to run a Brain triggered Macro.........
Post by: darlly01 on November 27, 2012, 10:30:02 PM
thank you Tony, I solved my problem to activate several macros with the plugin Mad Mach. I thank everybody that gave me attention and tried to help.
Title: Re: How to run a Brain triggered Macro.........
Post by: Cbyrdtopper on September 02, 2014, 04:48:41 PM
I've done everything in this to run a via the brain.  It still is not working for me.  I've checked the syntax in my macro to set the trigger macro to make sure it wasn't spelled wrong.  I even went through the OEMTriggers in the hotkeys and set them to 301 which runs the triggered macro.  I'm using a switch to change my jog % to a UserDRO # fast or slow.  My switch, left or right, is set to OEMTrigger 1 & 2.  I've got it in my brain set as follows.  OEMTrigger1 --> NOP --> Terminate 1034 (Execute button script).  Just like it says to do in the post.  Still Nothing.  ANY SUGGESTIONS!!??
Title: Re: How to run a Brain triggered Macro.........
Post by: simpson36 on January 08, 2015, 01:06:38 PM
The forum software suggested starting a new thread as this one is old.

I did that, but wanted to stick something in here to tickle anyone who might still be subscribed.