Introduction: Arduino Mega+Ethernet Shield+Lcd Display+AdvancedHMI
I recently got an Arduino Mega board in oder to more I/O than an Arduino UNO or a clone based on an atmega328p/644p/1284p. This board is going to be used on a further automation project which needs an ethernet scada to control a special process (soon on Instructable).
So this little Instructable will give you the skills to connect a cheap Ethernet Shield and a Lcd Display on the Mega 2560 board with special pins you need to know to work the project without communication break down.
Step 1: 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.
Step 2: 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
Step 3: 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
Step 4: Conclusion:
It works with no communication problems and after several connection test.
Thanks to all interesting tutorial all over the net.