Ethernet
Ethernet is a widely used communication protocol for local area networks (LANs), providing high-speed data transfer and reliable connectivity over longer distances compared to other serial communication methods. Ethernet uses a more complex communication model than serial protocols like TTL, employing packet-based transmission that includes error detection mechanisms. This makes it highly reliable, even in environments with significant electrical noise or over long distances, making Ethernet a preferred choice for networked devices in both consumer and industrial applications.
In industrial settings, Ethernet is increasingly used to connect programmable logic controllers (PLCs), sensors, actuators, and other automation equipment in a robust, scalable network. Its high-speed data transfer capability allows for real-time monitoring and control of complex processes. Ethernet’s versatility also extends to its ability to support multiple communication protocols, such as Modbus TCP/IP, making it a flexible solution for integrating diverse systems within a single network.
Only the M-Duino PLC family feature Ethernet connectivity. The Ardbox family PLCs do not.
Hardware
The M-Duino Family PLCs feature one Ethernet port, located on top of the PLC. The Ethernet connectivity is provided by the embedded W5500 chip, a hardwired TCP/IP Ethernet controller chip.
The only requirement for using the Ethernet is having an Ethernet cable. The link speed of the W5500 is100 Mbps, so a CAT 5 cable is enough for the PLC.
The Ethernet chip off the PLC does not support auto MDI-X (aka "auto crossover"), which means that when you connect to another device of the same type which does not support either, you will need to use a crossover cable. This is not necessary when using switches or PCs, but it is in some cases such as connecting two M-Duinos directly.
Remember to properly power the PLC with a 12-24V power supply.
Software
The Industrial Shields boards package includes an "Ethernet" library, intended to facilitate the use of this protocol. Various examples are included with the library, you can check them out going to File > Examples > Ethernet inside the Arduino IDE.
Also, take a look at the following program. This code
serves as a diagnostic tool to ensure the proper functioning of the
Ethernet port. It establishes a connection to "www.google.com" through the W5500 controller using DHCP IP configuration.
#include#define REMOTE "www.google.com" const uint16_t port = 80; uint8_t mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x01}; EthernetClient c; //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(9600L); Serial.println("ethernet started"); test(); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { if (!c.connected()) { Serial.println("Disconnected"); test(); } delay(1000); } //////////////////////////////////////////////////////////////////////////////////////////////////// void test() { //if you need a DHCP IP use this configuration: Ethernet.begin(mac); switch (Ethernet.hardwareStatus()) { case EthernetW5100: Serial.println("W5100 found"); break; case EthernetW5200: Serial.println("W5200 found"); break; case EthernetW5500: Serial.println("W5500 found"); break; default: Serial.println("Unknown hardware"); break; } uint8_t MAC[6]; Ethernet.MACAddress(MAC); for (int i = 0; i < 6; ++i) { if (i > 0) { Serial.print(':'); } Serial.print(MAC[i], HEX); } Serial.println(); //use this block with DHCP IP: Serial.println(Ethernet.localIP()); if (Ethernet.localIP() == IPAddress({0,0,0,0})) { Serial.println("Local IP FAIL"); } else { Serial.println("Local IP OK"); if (c.connect(REMOTE, port)) { Serial.println("Remote connection OK"); } else { Serial.println("Remote connection FAIL"); } } }
#include#define REMOTE "www.google.com" const uint16_t port = 80; uint8_t mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x01}; EthernetClient c; //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(9600L); Serial.println("ethernet started"); test(); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { if (!c.connected()) { Serial.println("Disconnected"); test(); } delay(1000); } //////////////////////////////////////////////////////////////////////////////////////////////////// void test() { //if you need a DHCP IP use this configuration: Ethernet.begin(mac); switch (Ethernet.hardwareStatus()) { case EthernetW5100: Serial.println("W5100 found"); break; case EthernetW5200: Serial.println("W5200 found"); break; case EthernetW5500: Serial.println("W5500 found"); break; default: Serial.println("Unknown hardware"); break; } uint8_t MAC[6]; Ethernet.MACAddress(MAC); for (int i = 0; i < 6; ++i) { if (i > 0) { Serial.print(':'); } Serial.print(MAC[i], HEX); } Serial.println(); //use this block with DHCP IP: Serial.println(Ethernet.localIP()); if (Ethernet.localIP() == IPAddress({0,0,0,0})) { Serial.println("Local IP FAIL"); } else { Serial.println("Local IP OK"); if (c.connect(REMOTE, port)) { Serial.println("Remote connection OK"); } else { Serial.println("Remote connection FAIL"); } } }
For more information about the Ethernet library, check out Ethernet | Arduino Reference.
There are no comments for now.