Troubleshooting of Ethernet, available only for M-Duino family, step by step:
Ensure that the controller is powered between 12-24 Vdc. Just with USB is insufficient to power to power up the Ethernet communication.Â
For the Ethernet communication protocol there isn't any switch that affects it. So it does not matter the configuration of the switches to implement Ethernet communication.Â
For Ethernet communication protocol, the defined Arduino Mega pin is pin 10, which is connected and already assembled to the WX5500 Ethernet controller. W5500 IC communicates to the Mega board via SPI bus already assebmled too. You can access easly to Ethernet port in our Ethernet PLCs, it is located at the top of the communications layer.Â
IMPORTANT: Make sure to download the Arduino based PLC boards for Arduino IDE.Â
Software Configuration
Once the hardware configuration is done, it is possible to proceed with the software configuration and also its usage. Firstly it is necessary to include the Ethernet2.h library provided by Industrial Shields (has the same functionality as Ethernet.h and also the same usage).
*Attention do not use old libraries like MDuino.h or Ardbox.h, these libraries are deprecated and can cause mapping issues to your controller.
For versions V7 or earlier you must use the <Ethernet.h> library.Â
Software ExampleÂ
To see that Ethernet works correctly, in this example we define an M-Duino as a client and connect to an operating server, Google. If the connection was successful, "Connected to server" is printed, otherwise "Connection failed!".Â
// use Ethernet.h if you have a M-Duino V7 version or +
#include <Ethernet2.h>
byte mac[] = {0xBE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // mac address for M-Duino
byte server[] = {8, 8, 8, 8}; // Google
int tcp_port = 53; // DNS port
char character;
bool ping = false;
int start_time;
EthernetClient client;
void setup(){
Serial.begin(9600);
Ethernet.begin(mac); // IP given by DHCP
Serial.println(Ethernet.localIP()); // print M-Duino ip
Serial.println("Connecting...");
if (client.connect(server, tcp_port)){ // Connection to server
Serial.println("Connected to server");
}
else Serial.println("Connection failed!");
}
void loop(){
}
Be sure about...
Define an IP for the M-Duino.Â
That the server you want to connect is active.Â
Connect to the right port.Â
Ethernet Troubleshooting