Unfortunately, the hardware behind macros I posted has one deficiency (that I know of), which I now have to rectify.
The selection of Mill or Lathe operation uses TWO off DPDT relays for safety reasons, instead of the original one DPDT relay. Why?
Because I had found with just one relay that an eStop while in Mill mode would drop out the Mill-select relay, which meant power was transferred to the Lathe spindle. This had been a bit too exciting for me. There are also some logic gates which should prevent both Mill and Lathe being asserted at the same time.
The reversing operation was done with a DPDT reversing relay, driven off the M4 line. That seemed fine at the time. However, if the program executed M5 while the spindle was in reverse mode, the reversing relay would drop back to FWDs, and the spindle would do an extremely fast stop as the remains of the power supply output were applied in the other direction. This seemed a bit too exciting as well.
So I have had to use the same two-off double-throw relay system for direction. M3 will activate one relay, M4 will activate the other relay, and M5 will deactivate both relays. A power resistor across the NC terminals brings the spindle to a halt, but is NOT in circuit the rest of the time.
Ah, but what if both M3 and M4 are issued? The short simple answer is a dead short across the spindle power supply, followed by a repair bill. So the macros will be expanded to check to see whether the system is in the 'other' state, and to kill that first with a short time delay to allow the mechanical world to catch up with the electric world. I will also use a logic gate lockout as was done for the Mill/Lathe selection.
But what about a wiring error? Powering both mill and lathe at once is not a calamity: one hits eStop and fixes the electronics. But the reversing section is another matter.
Instead of using a DPDT relay for each direction, I will use a 3PDT relay. The 3rd pole for the M3 relay will be in the coil circuit for the M4 relay, and vice versa. So if M3 is asserted, you can NOT assert the M4 relay as well, and vice versa.
What if you try to assert both M3 and M4 simultaneously? The system could chatter. However, the logic gates should prevent that from happening, and part of that circuit will detect a simultaneous M3+M4 assertion - and activate the eStop. Short of really gross wiring errors, that should suffice.
M5 will drop both outputs regardless of course, but it will do it in sequence. If M3 is asserted, it will first make sure M4 is NOT asserted, before it clears M3, and vice versa.
Cheers
Roger