Pages: [1]   Go Down
Author Topic: Using the ENC28J60 with an Arduino Mega 2560  (Read 3907 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I've just started learing more about electronics (Other than the regular soldering and diagram reading from school.) and I'm trying to use an ENC28J60 ethernet module from dealextreme, together with an Arduino Mega 2560 drom dealextreme as well. What my project is all about, is controlling an robot over WiFi using my Android phone (Having the arduino hooked up by cable to a router, and my phone to the router over WiFi.). But I've already gotten my head into the deep end of the pool.

The first problem is that I can't find any updated guides on how to connect the ethernet module to the Arduino itself. Pin configuration, libraries to use etc. One of the setups that I tried is from (http://www.geeetech.com/wiki/index.php/Arduino_ENC28J60_Ethernet_Module), but that one doeasn't seem to work as of v1.0. The only thing that happens, is that the DI diod light up red on the ethernet module.
Other than that I've tried the deafult examples from the Arduino soeftware, but no luck there eather.

What do I do? I'm desperate for a solution, as I've done a mere 1% of this project during the last two months.  smiley-cry

(Yes, I've tried to search the forum for a solution to this. But I've found none.)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What do I do? I'm desperate for a solution, as I've done a mere 1% of this project during the last two months.  smiley-cry

(Yes, I've tried to search the forum for a solution to this. But I've found none.)
Sure there is a solution. Spend the money on a W5100 based shield, instead.
Logged

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

Hi Jolls,

I guess I bought the same module from DX, and I finally managed to get it working with my Arduino Uno.

I explained here (in French) how you can do : http://michael.bouvy.net/blog/2012/09/21/arduino-ethernet-enc28j60/

Hope it will help ;-) Do not hesitate to ask if you need any further informations, I'll do my best to help.

Edit : you might easily find the mapping between the pin numbers of an Uno and your Mega2560 (also check the library's source for pin numbers)
« Last Edit: November 27, 2012, 09:13:17 am by moon06 » Logged

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

Quote
What do I do? I'm desperate for a solution, as I've done a mere 1% of this project during the last two months.  smiley-cry

(Yes, I've tried to search the forum for a solution to this. But I've found none.)
Sure there is a solution. Spend the money on a W5100 based shield, instead.

Unfortunately I have already used up my whole budget thus far. If I could, I would buy something less troublesome.

Hi Jolls,

I guess I bought the same module from DX, and I finally managed to get it working with my Arduino Uno.

I explained here (in French) how you can do : http://michael.bouvy.net/blog/2012/09/21/arduino-ethernet-enc28j60/

Hope it will help ;-) Do not hesitate to ask if you need any further informations, I'll do my best to help.

Edit : you might easily find the mapping between the pin numbers of an Uno and your Mega2560 (also check the library's source for pin numbers)

This sounds really promising! I will try it out as soon as possible. But there was one thing on the blog that I didn't quite understand.
What did you mean by "* = CS should be logically connected to a D10 or Arduino Uno pin 16 on a ATMega328 (Slave Select), but the library uses the following D8 / pin 14 by default."? Which pin do I connect the CS to, and how?  smiley-confuse


Update: I tried what the blog sugested. And it did not work. I tried switching the pings around, using DCHP and static address, but to no avail.
« Last Edit: November 27, 2012, 03:02:26 pm by Jolls » Logged

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

I just gave a quick look to the source code of the EtherCard library (especially enc28j60.cpp) and figured that it should be compatible with Arduino Mega 2560 out of the box.

Here's the portion of code that defines the pin numbers :

Code:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    const byte SPI_SS   = 53;
    const byte SPI_MOSI = 51;
    const byte SPI_MISO = 50;
    const byte SPI_SCK  = 52;
#else

This english translation : "CS should be logically connected to a D10 or Arduino Uno pin 16" is not correct. I mean to say that Slave Select on the ATMega328 is pin 16 (D10 on Arduino Uno, D53 on Arduino Mega 2560), but I read somewhere pin 8 on Uno should be used, and it worked like this for me.

However, it looks strange as D10 is actually defined as SS pin in the library's source code ... you should try both to figure which one is correct (and do not hesitate to keep me posted smiley-wink)
Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Just Do it (with Arduino of course)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Basic stuff : you need to add ",_cspin" in the begin() call in the example sketches for them to work. For some obscure reason, there is a "default cs=8" in several places, that already lead dozens of people into confusion.

Consistently writing it
Code:
 if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)  
and replacing the 10 by 8 if you're using a Nanode, 53 for MEGA, etc. would have helped may people a lot.

The trouble comes from the fact that you have three "levels" of library here : the spi.h, the enc28j60.h and the ethercard.h

Then depending on the versions, your server etc, you may or may not have DHCP working.
« Last Edit: December 04, 2012, 08:47:45 am by tochinet » Logged

Pages: [1]   Go Up
Jump to: