Pages: [1] 2   Go Down
Author Topic: Problems with Arduino DUE and ENC28J60.  (Read 4081 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi people

 smiley

First to say sorry about my English.

I need some help, I want to begin using Arduino, I was working with Microchip, but I need more speed and I/O Ports, so I just bougth an Arduino DUE. CortexM3 ARM based board.

The question is that I have a few Enc28j60 Modules and I wish to use it with my new Arduino due, So I was searching in the web And I can´t find any working example.

I just tried with a few examples but having problems.

Please help me, I don´t want to go back to Microchip.

A big hug from Colombia.

Luis.
Logged

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Poke through https://github.com/jcw/ethercard

The library includes examples.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Many thanks,


I already was tried these one,but when I try to compile examples I have problems with AVR files, then when I try to show to the compiler, where de files are,

It shows another kind of error.


 smiley-cry smiley-cry
Logged

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to tell us what the error is.
Logged

Napoli
Offline Offline
Sr. Member
****
Karma: 7
Posts: 356
Post fata resurgo
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Basically only official sketches that runs over Arduino UNO can run directly (or with few effort) on Arduino DUE, this because the Arduino core (the libraries) was migrated for the ARM CPU used in the DUE. Every other Arduino sketch won't run without a porting.

Some non-official Arduino sketches that runs UNO may run also on DUE, it depends if they are based on custom libraries or if are based only on the Arduino core, in the latter case it should run. The EtherCard library has an its own SPI driver (doesn't use the Arduino ones) and this is creating your problems.

I've never been in detail with ARM, so I don't know if there are others to be considered. As minimum you need to review all pins assignment and all direct access to register and interrupts, it should be not so hard, because the library doesn't use a lot of those.

I can try to help if you want.

Regards,
Dario.
Logged

Souliss - Open-source Distributed Home Automation with Arduino and Android

http://www.souliss.net
Follow at @soulissteam

@veseotech

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thanks Dario.

You are so nice trying to explain the problem.

And exactly if I try to compile the code built in Arduino examples, it compiles well, but when I change to my Arduino DUE. it crash.

I have downloaded a lot of examples (there are many of them), but I can´t find any for the DUE.

If you want to help me, I really would appreciate it.

So, what is the next step?

Best regards.

Luis.

P.D: Spanish is my language, so my apologies.
Logged

Napoli
Offline Offline
Sr. Member
****
Karma: 7
Posts: 356
Post fata resurgo
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

English isn't mine smiley

First step is to have a look to the official SPI drivers and port your code using that drivers instead of the one included in Ethercard (or any other that you are using), then look if you have still compilation errors and move forward.

Regards,
Dario.
Logged

Souliss - Open-source Distributed Home Automation with Arduino and Android

http://www.souliss.net
Follow at @soulissteam

@veseotech

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 147
Posts: 6038
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This will probably cause problems with SPI devices connected to a Due.
http://arduino.cc/en/Reference/SPITransfer
The Due needs an additional parameter to continue sending additional bytes over the SPI. Otherwise, it deactivates the SPI slave select after each call to SPI.transfer().
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hello.

Sorry I was working and I have not time to test your teory.

I think this weekend I will.

Thanks a lot.


Luis.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 smiley-eek

Ok I can´t wait,

I go to this page, http://tecnotinker.blogspot.com/2012/07/uso-del-modulo-ethernet-enc28j60-con.html , he says it works with Arduino UNO, I try to compile it with my Arduino DUE, and again error.

The next image shows that the picture are like´s an attachment.


Thanks a lot.

Luis.



* error.png (54.62 KB, 501x607 - viewed 151 times.)
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 181
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

just got ENC28J60 running with Arduino DUE with UIPEthernet-library.
Not release or merged in branch master yet, code resides in branch 'due'. (You can download complete branch as zip-file).
To install first unzip, then add the library by going to 'sketch'->'import library'->'add library', then navigate to the directory you have unzipped the library to and select directory 'UIPEthernet', then click 'open'. Afterwards you will find new examples (AdvancedChatServer, EchoServer, TcpClient, TcpServer, UdpClient and UdpServer) for UIPEthernet in 'file'->'examples'->'UIPEthernet'

I use Arduino 1.5.5, the ENC28J60 is connected to SPI on ICSP-header, CS is connected to pin 10.

Examples from UIPEthernet run without modifications, WebServer-example from Ethernet-lib runs by replacing include 'Ethernet.h' by 'UIPEthernet.h' (not removing the SPI.h, as this is required on DUE).

Have fun!

- Norbert

« Last Edit: January 09, 2014, 12:55:25 pm by ntruchsess » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Norbert

First I wish to thank you for your library.

I'm trying to use it with Arduino DUE, but I have a problem:
I only can make it work if I connect the ENC28j60 CS to pin 52 , but I wish to use pin 10 for CS.

To make it work on pin 52 I also have to change line 30 in Enc28J60Network.h from #define ENC28J60_CONTROL_CS   SS
to #define ENC28J60_CONTROL_CS  52. In this line I have tried change 52 to 10, but if I do that it stops working.

What I'm doing wrong, or for now it only works on a DUE with CS connected to pin 52?

I have connect ENC28j60 on Arduino Due SPI header.

Thanks
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ntruchsess could you help me getting your library work for the arduino send e-mail sketch? When I upload the sketch with your library it says connected and then prints an endless line of ÿÿÿ... I don't know what I am doing wrong.
I also use a ENC28J60.
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 181
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When I upload the sketch with your library it says connected and then prints an endless line of ÿÿÿ... I don't know what I am doing wrong.

I don't know either. And without seeing the sketch you upload this ain't change.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2
//
////

#include <SPI.h>
#include <UIPEthernet.h>

  /////////////////
 // MODIFY HERE //
/////////////////
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };   // Be sure this address is unique in your network
IPAddress ip(192,168,1, 20);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255,255, 0);

//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want
char DEVID1[] = "PushBoxCode ";        //Scenario : "The mailbox is open"

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3

// Debug mode
boolean DEBUG = true;
  //////////////
 //   End    //
//////////////


char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;                // Save the last state of the Pin for DEVID1
boolean lastConnected = false;                 // State of the connection last time through the main loop


// 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):
EthernetClient client;

void setup() {
  Serial.begin(9600);
  pinMode(pinDevid1, INPUT);
  
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
}

void loop()
{
      ////
      // Listening for the pinDevid1 state
      ////
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
        //Sending request to PushingBox when the pin is HIGHT
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
        //Sending request to PushingBox when the pin is LOW
        //sendToPushingBox(DEVID1);    //Here you can run an other scenario by creating a DEVID2 variable
      }
      
      
      //DEBUG part
      // this write the respons from PushingBox Server.
      // You should see a "200 OK"
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
      
      // if there's no net connection, but there was one last time
      // through the loop, then stop the client:
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}
This is my current output:

I could get to connecting by changing something in the UIPClient.cpp file. I changed in the available function the return -1 to return 0. This got me to connecting...

Edit: I found that in the file Dns.cpp the progam get stuck. Trough the function Client.connect the program get to ProcessResponse in the Dns.cpp file. Here it gets stuck in the while loop on line 325. I have no idea why but that's why it never connects.
« Last Edit: August 16, 2014, 06:41:05 am by cpu20 » Logged

Pages: [1] 2   Go Up
Jump to: