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.