Hi Nate,
OK, To set up the Legacy Modbus for a remote PLC. This is for my toolchanger.
You will need to adjust the register numbers. I also use macro 999 that is run in the Mach3 init string to initialse my toolchanger variables, etc.
The Mach3 Modbus interface should be configured. This is a config for my toolchanger (i,age below):
' ModIO Checkbox NOT checked
' First line of AutoPolling Input not checked - No inputs can go to Ports and Pins
' Second line of Inputs Checked, Slave = x, Start Regs = 1200, # Regs = 3
' First line of Autopolling Output not checked - no output Ports & Pins
' Second line of Output Slave = x, Start Regs = 1100, # Regs = 2
I set up modbus to read 3 registers starting at address 1200. I also set up twp output registers starting at address 1100
Mach3 reads and writes the modbus data from buffers. There are 2 input buffers and 2 output buffers, organised as;
0-63 Input buffer 1
64-127 Input buffer 2
0-63 Output buffer 1
64-127 Output buffer 2
I use input buffer 2 and output buffer 2. This is because Mach3 maps some of buffer 1 to it's input and outputs signals. We don't want that.
When you want to read register 1200 you do it by;
value = GetInput (64)
This is because register 1200 was read into the 2nd input buffer starting at index 64
When you want to set register 1100 you do it by;
SetModOutput 64, tool ' output requested tool number
This is because register 1100 is written from the 2nd input buffer starting at index 64
So, you need to use GetInput(r) to read your registers, and SetModOutput r, v to write outputs.
I know that the commands GetInput and SetModOutput seem inconsistant in format but thats the way it is.
I set up these constants so I can use the register names rather than the buffer index.
Const ChangerCurrPos = 64 ' Inputs 1200 Current tool
Const ChangerCountReg = 65 ' 1201 Change done indicator
Const ChangerErrCode = 66 ' 1202 Error code reply if problems
Const ChangerReqPos = 64 ' Outputs 1100
Const ChangerInitReg = 65 ' Outputs 1101
I hope this helps.
Cheers,
Peter.