Hello Guest it is March 29, 2024, 04:59:50 AM

Author Topic: Auto run a program after clicking RESET  (Read 5399 times)

0 Members and 1 Guest are viewing this topic.

Auto run a program after clicking RESET
« on: March 26, 2012, 12:32:31 AM »
Is there a way to automatically run a VB script after the RESET button enables Mach3? I need to home an axis and initialize some things. I can't get a VB script to run when Mach3 is in RESET mode. Might Brains or the macro pump do it? If so, I would be appreciate a code fragment or two to get me started. Thanks in advance.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Auto run a program after clicking RESET
« Reply #1 on: March 26, 2012, 12:54:05 AM »
Create a macro to do the functions you want save it as an Mcode M1000 for example.

Next put the Mcode into the initialization string in on the gen config page. Next check the box that says Use intialization string on all resets.

Now when ever you come OUT of reset it runs the initialization string WITH your Mcode call .

(;-) TP
Re: Auto run a program after clicking RESET
« Reply #2 on: March 26, 2012, 10:17:25 AM »
Thanks! Your trick worked perfectly the first time I tried it.
Re: Auto run a program after clicking RESET
« Reply #3 on: November 18, 2014, 05:06:19 PM »
Will this method work for all M-codes?
I need to run a script after the G-code is done, i.e. M30.

I've been looking for some method like IsMoving to be able to tell if the file execution is still under way, like IsFileRunning(), but haven't been able to find any. If there where I could do run my scrip in the macropump. IsMoving seems dangerous to use since there could be situation where the axis doesn't move but the g-code file isn't finished yet.

Basically i need to make sure that the work piece doesn't get released while the CNC is still working on it, even if the operator flips the hardware switch that does exactly that.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Auto run a program after clicking RESET
« Reply #4 on: November 18, 2014, 09:09:04 PM »
To run a script after the Gcode file has completed create a macro named M1030 and place the functions you need in that macro. At program end the M30 will CALL the M1030 macro.

It can be VERY dangerous to depend on Mixed functions that use CB and Gcode together. It can be very unpredictable.

(;-) TP
Re: Auto run a program after clicking RESET
« Reply #5 on: November 21, 2014, 09:27:19 AM »
Yes I did notice, Some small errors and my router got a mind of it's own. Did manage to behave as planned eventually though.
Thanks for the help!