Controllino Mega Ethernet

Hi,

I recently obtained a Controllino Mega which is based on the Arduino. As far as I see it comes with a WS5100 Ethernet chip. I tried all the sample Ethernet applications that come with the Arduino IDE however the device never assigns an ip address. The advanced Chat Server example always returns 255.255.255.255 as the local ip address. Could someone please let me know what am I doing wrong.

The code is below:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);

// telnet defaults to port 23
EthernetServer server(23);

EthernetClient clients[4];

void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
//while (!Serial) {
//; // wait for serial port to connect. Needed for Leonardo only
//}

Serial.print(“Chat server address:”);
Serial.println(Ethernet.localIP());
}

while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

One of the most important skills a programmer can have is the ability to read everything very closely. If you didn't bother to read this comment, what are the chances you have closely read any of the documentation on that board or the ethernet examples?

Hi Delta,

That was just a copy and paste error. If you read more clearly you will notice that I said it does return the local ip address but the ip address that it returns 255.255.255.255 which is not correct. So I urge you to read before just jumping to conclusions.

Thanks

Try using DHCP. It worked better for me when using the same code.

hussein1612: Hi Delta,

That was just a copy and paste error. If you read more clearly you will notice that I said it does return the local ip address but the ip address that it returns 255.255.255.255 which is not correct. So I urge you to read before just jumping to conclusions.

Thanks

So you are saying that you read the documentation with that board and that library much more closely? Or you just copied and pasted code and wonder why it doesn't work right?

Please don't jump to the conclusion that I didn't read your whole post. I did. I get that you are getting a bad ip back. Maybe a big clue as to why in the documentation.

Delta, have you had a look at controllino documentation? They don't have anything there with regards to the ethernet port. I am not interesting in getting into a debate with you, the code that I copied there was from the sample, I did comment out the wait for serial when I uploaded it. Any ways if you do have some experience with the Controllino I would appreciate your comments and direction.

Thanks

hussein1612: Delta, have you had a look at controllino documentation

Gotcha. Have you looked here?

https://www.arduino.cc/en/Reference/Ethernet https://www.arduino.cc/en/Reference/EthernetBegin

Hi Aarg,

The problem I have is the final product won't have a DHCP server. We using fixed ips to link multiple of these devices to send information.

Thanks for your advise.

Regards,

Thanks for the response Delta, I tried the sample there but still returns 255.255.255.255. I am wondering if it has something to do with the pin allocation, unfortunately the datasheet does not mention anything as to which pins the ethernet chip is connected to and even opening the device it is impossible for me to see which pins they have connected the chip to. I possibly need to change the pin allocations. I am no expert at this, first time doing an ethernet application with the arduino/controllino.

Since the WS5100 uses SPI for communication, I would assume it uses the hardware SPI pins.

Pinouts close to the bottom of page. It would appear it uses the hardware SPI pins.

http://controllino.cc/

Would be nice if they included the pin outs in the datasheets that they have for download. So basically it should work without any modifications. This is mind blowing as I tried the simple samples and it just wont assign an ip address.

Just out of interest I found a post on youtube that states

"+Edward Febiar Thank's for Your reply. I'm using the ethernet shield from Aukru. It works fine, but it ssems that the Arduino IDE 1.6.6 does not work with Controllino. Now I downgraded to Arduino IDE 1.0.5 and everything is fine. So I'm happy now, thanks!"

You might try the below test code to see if the assigned ip is retained.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Hi Zoomkat, thanks for your input. The response is the exact same:

Starting w5100 255.255.255.255

Regards,

hussein1612: IPAddress gateway(192,168,1, 1); IPAddress subnet(255, 255, 0, 0);

In a 192.168.x.y network the subnet mask has to be:

IPAddress subnet(255, 255, 255, 0);

So if you want to use:

 Ethernet.begin(mac, ip, gateway, subnet);

also the subnet mask has to be set correctly before calling Ethernet.begin().

Otherwise do the Ethernet-begin() initialization like suggested by zoomkat.

And in case you did it wrong: - Upload the fixed sketch - remove network cable - power-cycle the board - plug in the network cable - push reset button on the board (or power-cycle again or upload the fixed sketch again)

Hi Jurs, thank you for taking time to reply. I tried everything you said but still no success.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(192,168,1,102);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  //Ethernet.begin(mac,ip,gateway,subnet);
  Ethernet.begin(mac,ip);
  Serial.println(Ethernet.localIP());
}

the output being returned with the network cable connected is :
Starting w5100
255.255.255.255

the output being returned with the network cable disconnected is the same. Pinging the device returns timeouts.

hussein1612: Hi Jurs, thank you for taking time to reply. I tried everything you said but still no success.

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102);

Is there any other Arduino connected to your network using possibly the same MAC address?

If there is another Arduino also using 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED, then you better completely restart the network, all routers, switches and WiFi access points.

Each Arduino using Ethernet MUST have a different MAC address (unique within your network).

Is your LAN "DHCP enabled", so that it would be possible to obtain an IP address assigned from the network instead of assigning a unique IP address in your sketch?

hussein1612: the output being returned with the network cable connected is : Starting w5100 255.255.255.255

After seeing that output message in the serial monitor: Did you try pressing the "reset" button on your MEGA? Do you see the same message again and again after pressing the reset button?

Hi Jurs,

I am going to give the DHCP option a go. I only have the one device so there shouldn't be conflict.

I did try pressing the reset button and it does return the same information.

Any other ideas, this killing me :(

Hi Jurs,

I tried the DHCPAddressPrinter sample and it returns “Failed to configure Ethernet using DHCP”. The green and the orange lights are both on and occasionally they do flash. Tried the resetting option as well with the DHCP but still get “Failed to configure Ethernet using DHCP
Failed to configure Ethernet using DHCP”

Any other ideas