Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Experimental Drivers for Wiznet-based Ethernet Shields


  • Please log in to reply
89 replies to this topic

#1 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 September 2010 - 06:44 AM

Netduino community members are building some pretty terrific projects. But they've been missing something...the ability to connect their standard Netduino to the Internet.

While a Wiznet add-on solution cannot provide the performance and capabilities of the Netduino Plus's native networking, it provides a networking option for standard Netduino users.

I have attached some very early, unfinished, experimental drivers that have been tested with the following Ethernet shields:
* Arduino Ethernet Shield (original)
* Arduino Ethernet Shield (new design) requires soldering of optional 3x2 'ICSP' connector
* DFRobot Ethernet Shield

To use this driver in your solution, include its project in your solution and add a reference to it from your project's "Add Reference..." dialog. I'll post a sample project below this post.

What you can do with this driver:
1. Send/receive data to devices/servers on the Internet (using System.Net.Sockets.Socket)
2. Request web pages
3. Act as a TCP server (web, web services, sockets, etc.)
3. Use web services
4. Stream data

Disclaimer: these drivers are not complete and have not passed our QA standards for release code. If we are not comfortable with the performance of the drivers and/or the supported hardware, this software may be released as a community contribution instead of as an official driver.

This driver is released under the Apache 2.0 license. It is an open source driver.

The attached driver has the following limitations (and maybe more):
1. Static IP only: the Wiznet chip does not support DHCP natively.
2. DNS is not yet supported. You must connect to servers via IP address
3. No support for HttpWebRequests, at least yet.
4. We may tweak the object model in future releases.
5. Wiznet limit: maximum of 4 simultaneous socket connections
6. Wiznet limit: server ports may only serve one client at a time

While this software is experimental, it is safe to use on production-firmware Netduinos. If you're interested in building Internet-connected devices with Netduino, please help us test this code. If you find any bugs or have bugfixes or recommendations, please post in this thread. We'd love your participation!

Chris

EDIT: updated drivers posted on 25-Nov-2010

Attached Files



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 September 2010 - 06:46 AM

Here is a quick test app I put together for the experimental drivers. It will request and download the www.secretlabs.com homepage.

You can change the server and webpage to download. Please note that the following two caveats apply:
1. DNS is not yet implemented--so set the "proxy" string to the IP address of the server in the "url" string.
2. This sample is derived from the SocketSample which ships with the .NET Micro Framework SDK. That sample uses lots of memory when downloading big web pages. This sample would need to be altered to output the contents of large web pages (i.e. work with sections of a webpage--don't concatenate it all into a big string).

Notes on how to set up your app and use this early experimental firmware follow.

---

The experimental Wiznet drivers include an implementation of a few .NET Micro Framework namespaces to help ensure, among other things, that your code will work on the desktop and potentially in Windows Phone apps.

To add the drivers to your solution, add the SecretLabs.NETMF.Net.Wiznet5100 project to your solution. Then add a reference in your Netduino App to the Wiznet5100 project.

After you have attached a Wiznet-based shield on top of your Netduino, you'll need to write a few lines of code to set it up.

First, create an instance of the Wiznet5100 class. Pass it the SPI module to use (SPI1 is the SPI module on the Netduino's digital pins) as well as the desired chip select line.

// configure our wiznet chip
SecretLabs.NETMF.Net.Wiznet5100 wiznet = new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);

Next, configure your network settings (MAC address, IP settings).

// configure our IP settings
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
networkInterface.PhysicalAddress = new byte[] { 0x5C, 0x86, 0x4A, 0x00, 0x00, 0x00 }; // test MAC address
networkInterface.EnableStaticIP("10.0.1.12", "255.255.255.0", "10.0.1.1");

Finally, create an instance of the System.Net.Sockets.Socket object. Connect to servers, send data, receive data, etc. Please note that NetworkStreams are not yet supported.

Chris

Attached Files



#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 September 2010 - 07:02 AM

There's an alternate, more efficient way to use the Wiznet chip on the supported Ethernet shields. If you look at the top of your 3rd-party Ethernet shield, you'll see a "solder jumper" labeled INT. By melting this solder (and/or adding a bit of solder to bridge it), pin D2 will then become the Wiznet's "interrupt" pin.

In interrupt mode, network communication is much more efficient. You'll be able to use more of the MCU's processor time to do things within your app--and less time polling the Wiznet chip (i.e. "any data? no. any data? no. any data?...").

Connecting the solder bridge will not remove your ability to use the Ethernet shield in non-interrupt mode, but it will remove the ability to use pin D2 for other purposes in your Netduino app.

If you bridge the INT solder jumper, you can populate the third parameter to the Wiznet5100 constructor as follows:

SecretLabs.NETMF.Net.Wiznet5100 wiznet = new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10, 
    Pins.GPIO_PIN_D2);

As you report bugs or recommend improvements to the drivers, please let us know which mode you're using--standard polling or interrupt.

Thanks, and enjoy!

Chris

#4 adi

adi

    New Member

  • Members
  • Pip
  • 4 posts

Posted 13 September 2010 - 07:24 AM

Excellent, time to shop again. :D This project is moving so fast! Does the DFRobot Ethernet Shield always come with an SD card holder or perhaps none?... some pictures show one, others don’t, but I can’t see any information. Thanks, Adi

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 September 2010 - 07:33 AM

Does the DFRobot Ethernet Shield always come with an SD card holder or perhaps none?... some pictures show one, others don’t, but I can’t see any information.


Hi Adi, thanks for your post and welcome to the community!

The DFRobot shields in our lab have pads/space for the SD card holder--but no actual SD card slot on them. It looks like the new (updated) Arduino Ethernet Shield has MicroSD on board. The caveat is that they used the 6-pin "ICSP" header for its digital communication--so you may need to solder the optional 2x3-pin header onto your Netduino. Not sure yet, but we have one of the new shields on order for testing...

Chris

#6 adi

adi

    New Member

  • Members
  • Pip
  • 4 posts

Posted 13 September 2010 - 12:56 PM

The caveat is that they used the 6-pin "ICSP" header for its digital communication--so you may need to solder the optional 2x3-pin header onto your Netduino. Not sure yet,
Chris


I had to lookup what the "ICSP" header is (its all new to me) and found that in one of your other postings that you explain that they duplicate existing pins, so maybe they are not required , If anyone has one of these shields, maybe they could tell us whether there is a socket under there in the middle which would match up with the ICSP header.

#7 ThreadAbort

ThreadAbort

    New Member

  • Members
  • Pip
  • 4 posts
  • LocationChesapeake, VA

Posted 14 September 2010 - 07:31 PM

Chris, why wouldn't you just put the driver in the actual firmware? I like the code, it definately gives me a direction on coding my device. Thanks.

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 September 2010 - 07:38 PM

Hi ThreadAbort, Good idea. If the hardware/software combo passes all our gates for production, perhaps we can integrate it in (or at least provide firmware you can flash onto your Netduino with Wiznet support integrated). Chris

#9 phantomtypist

phantomtypist

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationNew York, NY

Posted 15 September 2010 - 04:01 AM

If you make it included in the firmware, won't it add 22KB to the payload size? As a result, wouldn't the usable code storage space shrink from 128KB to about 106KB? If this were true, then I can't see adding this to the firmware as we are already constrained and not every project will need Ethernet support. Please correct me if I'm wrong. If that is the case, I'd ask that it not be included in the firmware and instead be in a separate assembly that can be added as a reference such as SecretLabs.NETMF.Net.

Edited by phantomtypist, 15 September 2010 - 04:58 AM.


#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 15 September 2010 - 04:29 AM

phatomtypist, Yes and no. I think we can get the best of both worlds, but it might have to wait for v4.1.2 or so. In the meantime, we'll make it available as an add-on and if there's enough demand for it we might make a special firwmare release available which has it built in (so that deployment is a big quicker). Chris

#11 hari

hari

    Advanced Member

  • Members
  • PipPipPip
  • 131 posts

Posted 16 September 2010 - 06:23 AM

I have this NKC Ethernet Shield. I have confirmed that it works on the Arduino.
http://www.nkcelectr...la-diy-kit.html

But using the shield on the Netduino, it is stuck waiting for bytes to appear. I never got further than Init() in the Wiznet5100 constructor.

private byte ReadRegister(UInt16 address)
        {
            m_readCommand[1] = (byte)((address & 0xFF00) >> 8);
            m_readCommand[2] = (byte)(address & 0xFF);

            byte[] dummyResponse = new byte[1];

            m_spi.WriteRead(m_readCommand, dummyResponse); // dummy read -- WHY IS THIS NECESSARY?
            m_spi.WriteRead(m_readCommand, m_readResponse);

            //m_spi.WriteRead(m_readCommand, m_readResponse);

            return m_readResponse[0];
        }


m_readResponse[0] is always 255.

A comment in Arduino code says this: Ethernet shield attached to pins 10, 11, 12, 13
In the Netduino code, we do this: new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
What about pins 11,12,13 ?!

EDIT:
Like some of the Arduino Ethernet Shield, the NKC also require the ICSP header. Keep reading this thread for more info.

#12 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 September 2010 - 06:58 AM

m_readResponse[0] is always 255.

A comment in Arduino code says this: Ethernet shield attached to pins 10, 11, 12, 13
In the Netduino code, we do this: new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
What about pins 11,12,13 ?!


If m_readResponse[0] is always 255, then the MISO line is always logic-high. Perhaps there's something else that needs to be in place to get the device to read/write data...

Pins 11, 12, and 13 are the SPI data/clock lines. Those are selected when you specify the first parameter: SPI.SPI_module.SPI1. The SPI chip select line is selected with Pins.GPIO_PIN_D10.

We're still trying to track down this Ethernet shield. According to the manufacturer, it has been discontinued... If you find one available for sale somewhere, please let us know Hari.

Now I wonder what's different between the Arduino/DFRobot shields and this one...

Chris

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 September 2010 - 04:46 AM

Quick update: We have tested the new Arduino Ethernet shield. It works with the experimental Wiznet drivers--but it does require use of the optional 6-pin 'ICSP' connector. If you pick up the new Arduino Ethernet Shield (the one with the MicroSD card onboard), you'll need to solder the 6-pin connector manually. Very few Arduino shields require use of the 'ICSP' header pins--but a few do (which is why the Netduino has the unpopulated header holes on the end--just in case you need them). Chris P.S. Based on preliminary tests with the v4.1.1 alpha firmware (and a temporary jumper wire between D4 and D10), you can use the MicroSD card slot on the new Arduino Ethernet shield as well.

#14 stacyh3

stacyh3

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 19 September 2010 - 05:20 PM

P.S. Based on preliminary tests with the v4.1.1 alpha firmware (and a temporary jumper wire between D4 and D10), you can use the MicroSD card slot on the new Arduino Ethernet shield as well.


That seems cool. A two-for-one shield. Too bad, I already ordered the shield with no SD. Oh well. Maybe for a future project.

#15 dm3281

dm3281

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 20 September 2010 - 05:57 PM

Can I have a link to the Ethernet shield with SD card that would work with my netduino? Also, can I have some instructions on soldering the 6-pin? I never done this before? If I get the ethernet shield with the SD card, can I also use the SD card to save files and server them up via a web server hosted on the netduino?

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 20 September 2010 - 06:45 PM

Can I have a link to the Ethernet shield with SD card that would work with my netduino?

Also, can I have some instructions on soldering the 6-pin? I never done this before?

If I get the ethernet shield with the SD card, can I also use the SD card to save files and server them up via a web server hosted on the netduino?


NKC/Amazon and Adafruit have them in stock; other resellers may have them as well.
http://www.amazon.com/dp/B0022TWQ22
http://www.adafruit....products_id=201

Here is the 6-pin "ICSP"-style header that you can solder onto the board:
http://search.digike...ds=67996-206HLF

You could certainly create a web server on the Netduino, but you'll need to wait for a newer set of Wiznet drivers...the "Listen" feature isn't built into the sockets quite yet. It will be soon. Also, you'll currently need to put a jumper wire between D10 and D4 to get the SD card to work--although that will not be necessary with the production v4.1.1 firwmare (which will let you specify the SD card's chip select line).

[You'll also need to write a bit of code to read HTTP requests and send back HTTP responses. There will be some samples available that you will be able to use as a starting point. More on that soon.]

As far as soldering goes...can anyone recommend a good primer?

Chris

#17 segu

segu

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationLima - Peru

Posted 20 September 2010 - 10:55 PM

As far as soldering goes...can anyone recommend a good primer?


I solder many years ago, but I found this a good explanation



Take it only as one opinion :)

#18 RvBCrS

RvBCrS

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationZutphen, Netherlands

Posted 26 September 2010 - 04:12 PM

Hi Chris and others! I was trying this code with my DFRobot shield, but everytime I run the code I get this error:

SocketException when connecting to http://www.nu.nl/.
If your network uses IPSec, you may need enable the port manually
Socket Error Code: 10060


I have turned of my firewall just to be sure, but I can't seem to get it to work.. anyone any suggestions?

Thanks,

Ramon
Blog: Morrison Blog
Twitter: @rvbcrs

#19 klotz

klotz

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts

Posted 29 September 2010 - 01:22 AM

I am having the same results. 10060 when running the wiznet test app from here. I am sure we are missing something basic but have no clue what it could be. :(

#20 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 29 September 2010 - 01:56 AM

klotz, Can you ping the shield from your PC or another device on your network (using the same static IP address you set in your code)? Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.