Go Down

Topic: Arduino SPI Ethernet interfacing problems (Read 4200 times) previous topic - next topic

LoScuby

Hello Everybody,

This is my first post after some days of readings on this usefull forum;
I need help to interface my arduino 2009 and an external SPI module that I bought on ebay based on the chip ENC28J60.
This is a simple item description:
1. On-board ENC28J60  SSOP28 Mini Chip with Latest V2.0 PCB Layout version( Gain better EMC& Higher Speed)
2. On-board 25MHz Crystal
3. On-board HR911105A Ethernet DC converter(embedded status LED)
4. 3.3V input Pin for power supply
5. PCB Size: 44.5mm x 21mm



It offer an SPI standard communication,but after many days of trying I'm not been able to have a communication between arduino and this module.
The specific module is this: http://cgi.ebay.it/Mini-ENC28J60-V2-Ethernet-Module-AVR-PIC-ARM-MCU-/190534845895?pt=LH_DefaultDomain_0&hash=item2c5cc305c7#ht_2682wt_905  instead here http://www.megaupload.com/?d=L61RMUTW there's all material about this component (schematic,datasheet of ENC28J60,and some code example,i don't know how it work...)

I have read many material about SPI communication and the standard ethernet module of arduino,but I've not understood a lot...
Can someone help me to do a simple web server with this component?
I don't know if i can use the standard ethernet library or i should incapsulate readings and writes on web server with SPI shiftout function like this:

void spiWrite(byte data){
  shiftOut(MOSI, SCK, MSBFIRST, data); // send to spi output
}

byte spiRead(){
  byte value=0;
  for(int i = 0; i<8; i++){
    digitalWrite(SCK,LOW);
    value = value << 1; // shift up for next byte read
    value |= ( digitalRead(MISO) & 0x1); // add the next bit to the value
    digitalWrite(SCK,HIGH);
  }
   digitalWrite(SCK,LOW);  // put clock low at the end
  return value;
}

Thank you in advance.


PaulS

Quote
I don't know if i can use the standard ethernet library

Did you try it? It didn't work, did it?

Did you try googling Arduino + ENC28J60? There is a guy working on a library that will work with that chip, such that it looks a lot like the standard ethernet library.

You have said nothing about how YOU connected that device to your Arduino or if any of the LEDs on it light up or what issues you are having. Hard to help without a clue what you need help with.

LoScuby

Thank you to answer me Pauls;

You've right,i've omitted many details about my connection attempts (thanks to my inexperience).

I'm been able to give the power supply to the module (there's a led correctly lighted on the ethernet module when i link the GND arduino to the pin 8 of the module and the 3.3v output pin of arduino to module pin 1).
I've not linked to nothing the pin 2 of the ethernet module (the RST pin,coz I don't use it now),and the pin 7 too (ETH0-INT) coz I don't know what is it.
Instead I've linked the pin 3 (of the module,SPI-NSS)to the arduino pin 10,pin 4 (SPI-SCK) to arduino pin 13,pin 5(MOSI)to arduino pin 11,pin 6 (MISO) to arduino pin 12 as in the SPI library reference.
While I'm writing,it come in my mind a question:"Should i link the MISO module's pin to MOSI arduino's pin and vice-versa?" Now I've not done this,but I've directly linked MISO module to MISO arduino.
Obviously I tried to search on google,but what i found is material for standard arduino ethernet shield,that i don't know how it work,and how it's linked to arduino.

About the ethernet connection,I linked with ethernet cable my pc with ethernet module ,and I also tried directly my home router and ethernet module,but without communication results.
My principal problem is to have a simple communication between arduino and the module after some ethernet stimulus,like a ping or a tcp-ip packet from my pc to ethernet module address;It don't answer to the ping. The IP address i use is in the range of my local net,192.168.0.10 i.e. , and I'm sure is not used.As mac address,I've always used mac addresses found on the various examples on internet,coz I do not know the specific MAC address of my enc28j60 (is there a way to find my unic idenfier?).

I hope to have added more details to be well understood,in case please noted me if I can add more details that I escaped.

LoScuby

#3
Aug 23, 2011, 05:28 pm Last Edit: Aug 23, 2011, 05:30 pm by LoScuby Reason: 1
To be more clear I report a simple schematic connection of my actual situation:



PC or HOME ROUTER  <----------------------------------------------->Ethernet module<---------------------------------->Arduino 2009
                                               Ethernet cable
                                                                                                   1 (3V)                                                              3.3V
                                                                                                   2 (RST)                                                             NO CONNECTION
                                                                                                   3 (SPI-NSS)                                                        10
                                                                                                   4 (SPI-SCK)                                                        13
                                                                                                   5 (SPI-MOSI)                                                       11
                                                                                                   6 (SPI-MISO)                                                       12
                                                                                                   7 (ETH0-INT)                                                     NO CONNECTION
                                                                                                   8 (GND)                                                            GND                                                                

alvarojusten


Hello Everybody,

This is my first post after some days of readings on this usefull forum;
I need help to interface my arduino 2009 and an external SPI module that I bought on ebay based on the chip ENC28J60.
This is a simple item description:
1. On-board ENC28J60  SSOP28 Mini Chip with Latest V2.0 PCB Layout version( Gain better EMC& Higher Speed)
2. On-board 25MHz Crystal
3. On-board HR911105A Ethernet DC converter(embedded status LED)
4. 3.3V input Pin for power supply
5. PCB Size: 44.5mm x 21mm



It offer an SPI standard communication,but after many days of trying I'm not been able to have a communication between arduino and this module.
The specific module is this: http://cgi.ebay.it/Mini-ENC28J60-V2-Ethernet-Module-AVR-PIC-ARM-MCU-/190534845895?pt=LH_DefaultDomain_0&hash=item2c5cc305c7#ht_2682wt_905  instead here http://www.megaupload.com/?d=L61RMUTW there's all material about this component (schematic,datasheet of ENC28J60,and some code example,i don't know how it work...)

I have read many material about SPI communication and the standard ethernet module of arduino,but I've not understood a lot...
Can someone help me to do a simple web server with this component?
I don't know if i can use the standard ethernet library or i should incapsulate readings and writes on web server with SPI shiftout function like this:

void spiWrite(byte data){
  shiftOut(MOSI, SCK, MSBFIRST, data); // send to spi output
}

byte spiRead(){
  byte value=0;
  for(int i = 0; i<8; i++){
    digitalWrite(SCK,LOW);
    value = value << 1; // shift up for next byte read
    value |= ( digitalRead(MISO) & 0x1); // add the next bit to the value
    digitalWrite(SCK,HIGH);
  }
   digitalWrite(SCK,LOW);  // put clock low at the end
  return value;
}

Thank you in advance.




There are libraries, such etherShield, that does the SPI communication to you, so you need just to develop your HTTP application, for example. These libraries are not the easiest to use (like the standard Arduino Ethernet library -- that is not compatible with ENC28J60). I'm developing a library that does the job: with the simple code you write using the standard Arduino Ethernet library, my library will 'talk' with ENC28J60, so you can use it in the easiest way.
It has some limitations now, but you can create a Web server. More information at: https://github.com/turicas/Ethernet_ENC28J60/
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

alvarojusten

About the pin connections, please see this message: http://arduino.cc/forum/index.php/topic,68569.msg505946.html#msg505946
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

LoScuby

Thanks a lot Alvaro...

I will try immediately your library.

Thank you for your work(I hope to be able to use it...:D).

LoScuby

#7
Aug 24, 2011, 12:09 pm Last Edit: Aug 24, 2011, 12:14 pm by LoScuby Reason: 1
I tried your library Alvaro but it continue to do not work...
To be more clear on what i do during my attempts,I made a video,so you can see my real situation.
http://www.youtube.com/watch?v=2lSVTyJWP0Y


The connections i do are the same I wrote here:

PC or HOME ROUTER  <----------------------------------------------->Ethernet module<---------------------------------->Arduino 2009
                                              Ethernet cable
                                                                                                   1 (3V)                                                              3.3V
                                                                                                   2 (RST)                                                             NO CONNECTION
                                                                                                   3 (SPI-NSS)                                                        10
                                                                                                   4 (SPI-SCK)                                                        13
                                                                                                   5 (SPI-MOSI)                                                       11
                                                                                                   6 (SPI-MISO)                                                       12
                                                                                                   7 (ETH0-INT)                                                     NO CONNECTION
                                                                                                   8 (GND)                                                            GND        


And the schematic description of the ethernet module is here:

http://www.megaupload.com/?d=C1HJH3MG          

I don't know  where I wrong...

Thanks

PaulS

The ethernet port on your computer is an input port. The Ethernet shield needs to be connected to an output port, on a router, not an input port on a PC.

LoScuby

I tried with my home router too...the result is exacltly the same...
I believe that on an ethernet communication there are not only input ports...ethernet is a protocol communication standard,so the "dialog" is a two way  dialog (as the dialog word nature suggest).
The DHCP of the router (when it's connected directly to the router) do not assign the ip to arduino,and when i try to ping arduino from my pc,ping packets are discarded by the router coz the router hasn't a correspondance in its router table routing....It's the simpliest explanation that comes to mind...
In this arduino's ethernet library the DHCP politics are not been implemented i've read...so how it can work in the other internet example?

alvarojusten


I tried your library Alvaro but it continue to do not work...
To be more clear on what i do during my attempts,I made a video,so you can see my real situation.
http://www.youtube.com/watch?v=2lSVTyJWP0Y


The connections i do are the same I wrote here:

PC or HOME ROUTER  <----------------------------------------------->Ethernet module<---------------------------------->Arduino 2009
                                               Ethernet cable
                                                                                                    1 (3V)                                                              3.3V
                                                                                                    2 (RST)                                                             NO CONNECTION
                                                                                                    3 (SPI-NSS)                                                        10
                                                                                                    4 (SPI-SCK)                                                        13
                                                                                                    5 (SPI-MOSI)                                                       11
                                                                                                    6 (SPI-MISO)                                                       12
                                                                                                    7 (ETH0-INT)                                                     NO CONNECTION
                                                                                                    8 (GND)                                                            GND         


And the schematic description of the ethernet module is here:

http://www.megaupload.com/?d=C1HJH3MG            

I don't know  where I wrong...

Thanks


Some considerations about your video:

- The RESET pin on ENC28J60 don't need to be connected to the RESET pin on Arduino. You can put it in 5V if it is activated on LOW (and on GND if it is activated on HIGH -- but I think it is activated on LOW).

- You don't need to delete the standard Ethernet library. You can just put the folder "Ethernet_ENC28J60" in your "sketchbook/libraries/" folder.

- The DHCP protocol is not implemented in my library, so you need to set the Arduino's IP and your PC's IP by hand! Put them in the same network. The IP starting with "169" is put on your machine when the operating system can't get an IP from the network. You *need* to *fix* an IP address like 192.168.0.1 for your PC and 192.168.0.2 for Arduino.

- After correcting the problems above, try to *just ping* the Arduino and then try the HTTP request.



The ethernet port on your computer is an input port. The Ethernet shield needs to be connected to an output port, on a router, not an input port on a PC.


You are wrong! Yes, we can have Ethernet peer-to-peer connections. :-) In some years ago we needed a special cable (crossover cable) that have some pins inverted, but nowadays, all modern network cards have the automatic switch between RX and TX when it detects it.
I made my tests here with either my Arduino connected directly to my PC and to my Wi-Fi access point.
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

LoScuby

I've assigned a static ip address to my pc through the properties of the lan connection (192.168.0.1) and via code also to arduino 192.168.0.2 but no communication yet....
the only thing I discovered is that my ethernet module is resetted on ground link...
I attempted to reverse the situation,so arduino is not more the server using the webclient example,and sniffing the packets of my pc,but no packets are ever arrived from the arduino's ip (in no one port by its ip address).
I'm beginning to think that my ethernet module do not work properly...

alvarojusten


I've assigned a static ip address to my pc through the properties of the lan connection (192.168.0.1) and via code also to arduino 192.168.0.2 but no communication yet....
the only thing I discovered is that my ethernet module is resetted on ground link...
I attempted to reverse the situation,so arduino is not more the server using the webclient example,and sniffing the packets of my pc,but no packets are ever arrived from the arduino's ip (in no one port by its ip address).
I'm beginning to think that my ethernet module do not work properly...


My library does not work as TCP client yet, so Web client example will not work. It only works for HTTP server example (use WebServerSimpleLED example). Can you ping Arduino?
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

LoScuby

Also this attempt to contact arduino with a ping is not gone well...nothing...no answer...

I've setted up a fixed ip to my pc in the connection properties,but i continue to do not have a signal...
Do not work WebServerSimple,and WebServerSimpleLED code.....

Ethernet module and my pc's ethernet card apparently trying to send signal in the cable,but they are not able to contact each other.

alvarojusten


Also this attempt to contact arduino with a ping is not gone well...nothing...no answer...

I've setted up a fixed ip to my pc in the connection properties,but i continue to do not have a signal...
Do not work WebServerSimple,and WebServerSimpleLED code.....

Ethernet module and my pc's ethernet card apparently trying to send signal in the cable,but they are not able to contact each other.


What Arduino/ATMega are you using?
I want to know if you are compiling the example with my library, instead of the standard Ethernet library. What is the size of compiled code for the WebServerSimpleLED example?
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

Go Up