/Mach4ModbusTCPArduinoWithENCJ28J60

Inputs from Arduino to Mach4 using Modbus IP

Primary LanguageC++

Mach4 Modbus TCP using Arduino and ENCJ28J60

Inputs from Arduino to Mach4 using Modbus over Ethernet

Hardware

Using Arduino UNO with ENC28J60 ethernet shield. Pins 13, 12, 11, and 10 are reserved for the ethernet shield and are connected to the Arduino UNO at the same pins.

Software

Arduino

TCP_KEEP_ALIVE should be uncommented in the ModbusIP_ENC28J60.h header file in this Arduino Modbus library:

https://github.com/andresarmento/modbus-arduino

Download the repo as zip and import as a library in arduino.

The Mach4Modbus.ino file in this repository should be edited for the inputs you want to use and the IP address you want for your device. Pins 13, 12, 11, and 10 are reserved for the ethernet shield and cannot be used as inputs.

Mach4

The latest version of Mach4 comes with the Modbus plugin by default. The following images show the setup for reading 10 input states. The registers at every (n + 8) register do not "register" for inputs in Mach4 Modbus Read Coils function.

Mach4 file menu goto Configure->Plugins..->Modbus

Configure IP address and TCP port:

Mach4 file menu goto Diagnostic->Modbus to test inputs: