I can't take credit for the modIO interface but I can make it a bit simpler for you. Here is a link to the library I found.
https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slaveYou need the modbus slave library linked at the bottom. It's tar compressed so you will need a program to uncompress it. Drop the folder in your Libraries Folder in your arduino software. Here is all you need to make a sketch that will talk to Mach3. It shows the registers I setup. They are in an array called regs[]. I included a sample if statement to show how to reference them.
#include <ModbusSlave.h>
ModbusSlave mbs;
enum {
MB_REGS=6 //Number of Slave Registers
};
int regs[MB_REGS]; //regs[0] = Ignore this register
//regs[1] = M3 CW spindle Direction (Active High)
//regs[2] = M4 CCW spindle Direction (Active High)
//regs[3] = Spindle Speed
//regs[4] = Active Spindle 0 = Z Axis, 1 = A Axis
//regs[5] = Estop
void setup()
{
mbs.configure(1,9600,'n',0); //Init ModBus Slave
}
void loop()
{
mbs.update(regs, MB_REGS); // Update ModBus
if(regs[5]==0) { // EStop
digitalWrite(2,LOW); //Set Servo1 to Mach3
}
}
I'll get a screen shot of the setup for Mach3 and post it shortly.