Go Down

Topic: Using the ENC28J60 with an Arduino Mega 2560 (Read 4 times) previous topic - next topic

Jolls

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.  =(

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

PaulS

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.

moon06

#2
Nov 27, 2012, 03:09 pm Last Edit: Nov 27, 2012, 03:13 pm by moon06 Reason: 1
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)

Jolls

#3
Nov 27, 2012, 06:45 pm Last Edit: Nov 27, 2012, 09:02 pm by Jolls Reason: 1

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?  :~


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.

moon06

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: [Select]
#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 ;))

tochinet

#5
Dec 04, 2012, 02:41 pm Last Edit: Dec 04, 2012, 02:47 pm by tochinet Reason: 1
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: [Select]
 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.

Go Up