Go Down

Topic: Arduino MEGA 2560 + Official Ethernet Shield (MEGA Compatible) (Read 4191 times) previous topic - next topic

fafabio

Jun 21, 2011, 10:24 pm Last Edit: Jun 22, 2011, 01:44 pm by fafabio Reason: 1
Hello all,


first let me congrat all that contribute to an amazing thing that Arduino is. I simply love it. This is my first post of this kind, normally I always find someone with my problem and the solution and it works for me too. this time is different:

Platform: MAC
Software: Arduino IDE 0022
Hardware: MEGA 2560 + Ethernet Shield
Problem: webserver sketch or webclient does not work.

Extra:Powered with an 9v external PS only with USB sometimes gave me the avrdude verification error, content mismatch when downloading. now its ok.

I got my mac serve a page with "it works!" only. Got an network cable between arduino and Mac.
I seem to find only this problem related to 0018 or below. and none of the solution worked.

Evolution:

without remaping the 10,11,12,13 pins, respond to pings
remaping 11,12,13 responds to pings
remaping 10,11,12,13 does not respond to pings

if I download the webclient sketch (Serial Dependent) and press to open the Serial Port, it stops responding to pings for 3 or 4 seconds.

the file pins_arduino.h have an if to choose between 10,11,12,13 and 50,51,52,53 that I dont understand if I need to change or not.

I tryed too put the pin 10 in OUTPUT mode and HIGH to activate the ethernet part...nothing...

I try the shield on a duemilenueve and works normally.but with MEGA no...

I reset the shield countless times.. after, during(not really) and before the download, the opening of the serial monitor, had a ping to the Arduino during some period also...I simply don't understand.

the strange thing is that one time only worked for 3/4 sketches that I download.. during 10 minutes. i was able to get the page from my mac on the serial monitor, change the page and execute it again... it worked fine... and with the webserver example i got the analog values and with a pulldown resistor, i checked if it was showing live values and it was. More... It worked with no remaping of the 10,11,12,13... but after it worked, I disconnected it for 8 hours and when I turn back... never worked again...

desesperation:
please help me.. i'm driving slightly mad with this.what could it be???

the code I used:

Code: [Select]

/*
 Web client

This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13

created 18 Dec 2009
by David A. Mellis

*/

#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:
byte mac[] = {  0xFA, 0xFA, 0xB10, 0xDE, 0xAD, 0x11 };
byte ip[] = { 192,168,1,177 };
byte server[] = { 192,168,1,67 }; // my mac with the websharing and a "it works!" page

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);

void setup() {
 // start the Ethernet connection:
 Ethernet.begin(mac, ip);
 // start the serial library:
 Serial.begin(9600);
 // give the Ethernet shield a second to initialize:
 delay(1000);
 Serial.println("connecting...");

 // if you get a connection, report back via serial:
 if (client.connect()) {
   Serial.println("connected");
   // Make a HTTP request:
   client.println("GET /index.html HTTP/1.0");
   client.println();
 }
 else {
   // kf you didn't get a connection to the server:
   Serial.println("connection failed");
 }
}

void loop()
{
 // if there are incoming bytes available
 // from the server, read them and print them:
 if (client.available()) {
   char c = client.read();
   Serial.print(c);
 }

 // if the server's disconnected, stop the client:
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();

   // do nothing forevermore:
   for(;;)
     ;
 }
}

johnwasser

Three of the ATmega SPI pins (10-13 on the regular Arduino and 50-53 on the Mega) are also connected to the ICSP port.  The 4th "SlaveSelect" pin (10 on the Arduino and 53 on the Mega) is a software controlled pin when the Arduino is the SPI Master.  Since it's under software control the Megan can use Pin 10, just like the regular Arduino.  By using Pin 10 plus three ICSP pins you can get a full SPI interface that works on both machines.

I suspect the local IP address assigned to your Mac might have changed in the eight hours you had the board offline.  Check that.  If you have administrator access to your router you might be able to assign the Mac a permanent local address.  That would keep it from changing in the future.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

fafabio

Hello John,

thanks for the reply. As I understand, i must move the 3 pins to 11-13 to 50-52 in order go work. the strange is that I saw it working without the remapping.

Regarding the router, I thought of that and to avoid problems I used a direct cable and static ip(192.168.1.67).

yesterday i tried again with an arduino uno and was all good. just connect the shield, the cables (9v,usb and rj45) download the same sketch and pow!! it works.

what else could it be?  what is so obvious ( or not ) that I am doing all wrong?



I got my mac serve a page with "it works!" only. Got an network cable between arduino and Mac.




Go Up