The General Schematic
The Mega 2560 board will be connected to a switch via the Ethernet Shield and you computer too. The communication is based on a famous protocol: the Modbus TCP (see one of my former Instructables).
So on the Arduino 1.6.5 IDE you need to add the “mudbus” library (not modbus!) that you can download.
To control via ethernet with a free Scada, I used the project: AdvancedHMI (thank you Archie). A catchy Scada wich need Visual Studio 2013 to be launched.
To use the Lcd Display you need the embbedded library LcdCrystal.
The Mega 2560 Board Schematic With All the Connections
The ethernet shield:
If you connect directly the ethernet shield on the board there will several communication problems break down. So you need to follow the schematic: disconnect all the pins of the ethernet shield except pin 4, pin 10 and the ICSP1. Thankx to the web site below:
The LCD dicplay:
If you connect directly the Lcd display on the ethernet shield or if you don’t use the pins recommanded on the schematic, there will be communication and displaying problems. Here I used a shield but you can use a simple display as shown on the following web site:
To avoid interraction beetween the shields I connected:
Mega board pins Lcd Display pins
pin 44 D4
pin 45 D5
pin 46 D6
pin 47 D7
pin 48 RS
pin 49 EN
Programs and Source Code:
I drawn quickly a very simple Scada to test a bidirectional communication with the modbus TCP protocol.
A pushbutton to light a led connected on the reachable outputs of the Mega board, a lcd display which displays the value 12345 send by the Mega board and a pilot light also controlled by the Mega board (red: off, green : on). Source code given.
The arduino program:
A very simple program to test each I/O. I just used the Mega board pins as outputs but you can turn it in input with a push button added on the board. Program given