Hey guys,
I have been working on upgrading a CNC plasma cutter with a PC running Mach3, and an arduino as a torch height controller. Everything was going very well using the code below that I pieced together from bits around the web to suite my needs (am by no means the original brain behind most of this code). That is until I went to run it for the first time and found that RF interference was causing major issues with the relay board I was triggering with the parallel port from the PC to turn the arc on/off. I farted around for a while with earth grounding everything and shielding and so on before finally giving up. It would seem that particular pin on my parallel port just cannot compete with the RF from the plasma. That being said, the stepper motors work just fine.
So my solution is to move the relay board out of the CNC enclosure and out to the PC where the arduino lies and trigger it with said arduino. As you can see from my code, it is designed to connect to Mach3 via modbus and send command inputs to Mach3. I can easily send bits back to the arduino, however I actually do not understand the modbus language well enough to do anything with said bits. Please ignore any erroneous comments, they were meant for my future self mucking around with updates. Attached is also the modbus options menu that clearly allows for output values.
So in summary, what I want to add to this code (which works great for what it does) is read a bit from Mach3, and turn a pin on. Sounds simple, but I do not know how to read that bit from Mach3 (or exactly configure mach3 to send it, beyond tieing it to the output command.)
Turns out I exceeded the maximum allowed length with the code in the post, therefore I have attached it in a txt file.
Please advise
THCR2.txt (7.7 KB)