Go Down

Topic: Enc28j60 arduino023 VS arduino1.0.4 (Read 766 times) previous topic - next topic

kimjessen

Hi I have built a ATmega2560 kit.
with ENC28J60 as Ethernet communication.
I made it according to this document--> http://www.fut-electronics.com/wp-content/plugins/fe_downloads/Uploads/Ethernet-Module-ENC28J60-Arduino.pdf

The problem is that it works perfectly under arduino023 but not in version1.0.4
Is there anyone who can help me.
There is mentioned something about having to change in the libraries.?

I have done this in 023 and it worked perfectly.
Now I have some projects written in 1.0.4 which does not work on my kit. (It works on orginal Arduino kit Atmega 2560)
I have made the same changes as the 023 but it does not work.?

PaulS

You have some code that we can not see. It does something when you run it that we can not see.

How can we help you?

kimjessen

#2
Jun 17, 2013, 04:10 pm Last Edit: Jun 17, 2013, 04:28 pm by kimjessen Reason: 1
ok I trying in a different way.
I have a atmega 2560 kit original from arduino without ethernet. ( http://arduino.cc/en/Main/arduinoBoardMega2560 )
I have an ethernet shield ENC28J60. ( http://www.fasttech.com/product/1169600-pcb-arduino-microchip-enc28j60-ethernet-shield-mod )

I connect the ethernet shield to atmega kit so.

ENC28J60          Atmega kit

CS           ->         D53

SI           ->          D51

SO           ->         D50

SCK           ->       D52

RESET       ->        RESET

INT           ->        INT

VCC           ->       3V3

GND           ->      GND


if I then install Arduino IDE Version 023 and follow the procedure described in this report.
works the example of the Web client:
Code: [Select]
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 10, 95 };

Server server(80);

void setup() {
 Ethernet.begin(mac, ip);
 server.begin();
}

void loop() {
 Client client = server.available();
 if (client) {
   boolean current_line_is_blank = true;
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();
       if (c == '\n' && current_line_is_blank) {
         client.println("HTTP/1.1 200 OK");
         client.println("Content-Type: text/html");
         client.println();
         
         client.print("Analog input 0 = <b>");
         client.print(analogRead(0));
         client.println("</b><br>");
         client.print("millis() = <b>");
         client.println(millis());
         client.println("</b><br>");
         break;
       }
       if (c == '\n') {
         current_line_is_blank = true;
       } else if (c != '\r') {
         current_line_is_blank = false;
       }
     }
   }
   delay(1);
   client.stop();
 }
}


But if I install IDE 1.0.4 and trying to run the code server so it does not work.
Should I use an particular library for IDE 1.0.4.

Code: [Select]
/*
 Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

*/

#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[] = {
 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,10, 95);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
 Serial.begin(9600);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 }


 // start the Ethernet connection and the server:
 Ethernet.begin(mac, ip);
 server.begin();
 Serial.print("server is at ");
 Serial.println(Ethernet.localIP());
}


void loop() {
 // listen for incoming clients
 EthernetClient client = server.available();
 if (client) {
   Serial.println("new client");
   // an http request ends with a blank line
   boolean currentLineIsBlank = true;
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();
       Serial.write(c);
       // if you've gotten to the end of the line (received a newline
       // character) and the line is blank, the http request has ended,
       // so you can send a reply
       if (c == '\n' && currentLineIsBlank) {
         // send a standard http response header
         client.println("HTTP/1.1 200 OK");
         client.println("Content-Type: text/html");
         client.println("Connection: close");
         client.println();
         client.println("<!DOCTYPE HTML>");
         client.println("<html>");
                   // add a meta refresh tag, so the browser pulls again every 5 seconds:
         client.println("<meta http-equiv=\"refresh\" content=\"5\">");
         // output the value of each analog input pin
         for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
           int sensorReading = analogRead(analogChannel);
           client.print("analog input ");
           client.print(analogChannel);
           client.print(" is ");
           client.print(sensorReading);
           client.println("<br />");      
         }
         client.println("</html>");
         break;
       }
       if (c == '\n') {
         // you're starting a new line
         currentLineIsBlank = true;
       }
       else if (c != '\r') {
         // you've gotten a character on the current line
         currentLineIsBlank = false;
       }
     }
   }
   // give the web browser time to receive the data
   delay(1);
   // close the connection:
   client.stop();
   Serial.println("client disonnected");
 }
}


why does it work in the IDE 0023 and not in IDE 104

zoomx

I know that the ethernet library support only Wiz5100 Ethernet shields and not ENC28J60 shields.

But you was able to run the first example! Amazing! Maybe the library is compatible?

kimjessen

thanks for the roses.
But I do not think I get on with IDE 1.0. + +, It just is not working.

Someone who knows how to write a new library.
Is it difficult.?

PaulS

Quote
if I then install Arduino IDE Version 023 and follow the procedure described in this report.

In which report? There is no way that the code you posted will work with an Enc28j60, regardless of which version of the IDE you are using.

kimjessen

http://www.fut-electronics.com/wp-content/plugins/fe_downloads/Uploads/Ethernet-Module-ENC28J60-Arduino.pdf

these

Erdin

If you want to stay out of trouble, you should use the Arduino Ethernet Shield with the W5100.

However, it is possible to use the ENC28J60, if you know a few things about it.

Your wiring is okay.
The ENC28J60 needs 3.3V and requires 200mA or 300mA (just a guess, I forgot how much). A small voltage regulator could get too hot.

There are compatible libraries for the ENC28J60, so they can use the same sketch as the normal sketches for the W5100. Those libraries have issues and as far as I know they are no longer maintained.

I started to use the Ethercard library for the ENC28J60. I think it is the only good library. I'm not going back to other libraries. That library is not compatible with the Arduino Ethernet library, so the sketches look a lot different.
https://github.com/jcw/ethercard

You seem to have installed a library that is compatible with the Arduino Ethernet library. From where did you download it ?

Please use the newest Arduino version 1.0.5.
There are bug fixes in every version.
If you are willing to move to the Ethercard library, you have to use a third parameter for the chip select with Ethernet.begin().

Go Up