Is there a way to prevent Relay 2 from being turned off at the end of a program?

I use VCarve Desktop to generate MCode and Mach4 to control my 24x24 standard desktop machine using the Avid post processer. I recently purchased some vacuum pods to hold down work pieces. It works great, but I found that the end of the program turns off relay 2, which I used to turn on the vacuum pump. I made a custom processer removing the M09 code that turns off the relays. However it still turns off and I found the M30 at the end does the same thing. Is it possible to replace M30 with other gcodes to end the program to avoid turning off relay 2? I certainly can not use it for the vacuum pump, but it seemed convenient to use it for this purpose.

Just to be clear, you just want a Mach4 button on the screen then to control the vacuum, not have Gcode to turn it on or off?

I was using the Relay 2 button to turn on and off the vacuum pump and I don’t want the program to turn it off when it’s done so I can change bits and run another program without moving the piece. If it can’t be done I’ll just turn the pump on and off manually, but I thought this way was convenient.

Interesting, I never realized the M30 would turn off the relays, but it sure does. So the spare outputs on the ESS can be used (controlled with the M64/M65 codes) to run the relay instead, but I don’t know if those will also be affected by the M30. Are you interested in rewiring one of the relays and creating a button in your screen that uses the M64/65 commands? If so I can go do an experiment to see if that will work or not. I just want to make sure thats not beyond your threshold for work on this before I do the experiment :slight_smile:

Well it wouldn’t be beyond my threshold to do that, but I was hoping that there might be a setting I missed somewhere that might control this, or if I could avoid using M30 altogether. I’m going to experiment with that today.

I was just reading on the M30. It is a program end and reset. Its supposed to reset everything that was set in the program. There is an M02 that is just end without the reset. So try replacing the M30 with an M02 and see if that leaves your relay on. You will have to make sure that you have all the Gcode to turn off everything that you turned on since the M30 will no longer do cleanup.

You can create your own m30 and do what you want with it. See this forum for more info; Can i edit or add to a Predefined Macro?

Find smurph’s response.

I would avoid using anything other than m30 at the end. The reason is Mach4 has two “included for free” functions that you MUST execute at the end. Not doing so leaves Mach4 in a bad state.

Ok, “MUST” might be a bit strong but “cycle stop” is pretty important.

After a bit further research I came upon this well done page describing the Program Stop functions: PROGRAM STOP AND PROGRAM END (M00, M01, M02, AND M30)

Based on what it said I replaced the M30 with this code:


…it doesn’t rewind to the start of the program, but I can just hit the rewind button for that.

Even though I seldom run the same program twice in a row I ran one using this code several times with no problems. And it never turned off my vacuum pump.

1 Like


A lot of folks never realize just how much you can configure. I am sure if you keep playing with it you can figure out why it doesn’t rewind though. But, that is a nice to have and not required.