Good Evening Tom,
Looking at the time on your post, if it came straight through, you are about 9 hours east of me. I'm in Melbourne, Australia, where are you?
Interesting about the toggle/momentary thing. I have my small Hercus mill with an ANCA control that I am slowly converting to Mach4 as well as kind of helping a good friend convert his old Bridgeport with a Bandit control to Mach4. He was fortunate enough to get a retired friend of his to step in and take over all the electrics, freeing me to go on with life, but every now and then Mike, the chap helping my friend, phones to see if I can help with the software and Lua side of things. Kind of the blind leading the blind. AND, one of the latest hurdles, is how to get the spindle toggle button on the screen to emulate a real momentary switch. Not exactly the same as your issue, but similar.
The Bridgeport has a system of latching relays to simply turn the spindle on, off and reverse. The speed is set using the pulleys. So when issuing an M3 or M4 from G code or the Mach screen, he has it all working, but of course it’s a constant ON condition either CW or CCW. So if you push the momentary OFF button on the machine it certainly cuts the latch circuit and stops the machine, but as soon as you take your finger off the stop button the circuit re-latches and the spindle restarts because Mach still has it powered on.
Just as a side, we are both using the ESS with a CNCRoom MB2 beak out board. And I also have the Pokeys 57E for more IO and the analog inputs.
My friend wants to keep the machine switches the way they are. So yes, how to get a momentary/toggle signal. I asked this of Rob Gaudette through the Mach support page way back in January. I think I was asking for the purposes of having external jog buttons. My question wasn’t actually on the response email, so I can’t remember. It wasn’t long after that I had to pull the pin and get into house renovations, so I never actually did anything with it YET! I will post his email to me and the two files he sent. It still doesn’t make sense to me, but if I just follow what he says to do, maybe the penny will drop.
And yes, your last though about how it feels with learning Lua and Mach4 is correct. However there have been some really helpful guys come to my aid, but I still struggle to understand when they explain.
Below is the email from Rob.
Regards,
Craig.
Craig,
I have attached an emulated toggle button in a screen for your configuration purposes. I know you will be using a physical toggle, but this will be how you could set this up. Look at the button in screen edit. I have it triggered and mapped to output #3. So when you are ready you would wire up your switch to an output, then take a look at the attached code example, I know it is written for inputs, but you can change these. You will have the code in the in the screen load script, and when the output is active, then you will run the ButtonJogModeToggle() function