What is a good microcontroller for doing Ethernet applications? Or do I just need a good Ethernet library to connect with an Ethernet MAC/PHY?
-
\$\begingroup\$ Can you tell us what solution you went with and your experience with it? \$\endgroup\$– thom_nicCommented Feb 2, 2015 at 13:57
-
1\$\begingroup\$ I am currently using the PIC18F97J60 series and PIC32 with an ENCxxx. It works OK. The biggest gotcha is it only has up to SSLv3.0, which Firefox and Chrome just dropped. Microchip does have support for many other protocols that I use: FTP, TFTP, SNTP, SNMP. \$\endgroup\$– Robert DemlCommented Feb 2, 2015 at 16:34
-
\$\begingroup\$ Good to hear - also the SSL limitation is good to know but it seems like all of the "robust" TLS implementations are non-free in general. Thanks for sharing! \$\endgroup\$– thom_nicCommented Feb 3, 2015 at 18:09
20 Answers
Microchip's PIC18s with built-in ethernet are excellent for this, just add a magjack (or other connector with built in magnetics) and download their TCP/IP stack. You'll be pinging things in no time. For more grunt, the PIC24 and PIC32 also have TCP/IP stacks designed to run with one of the SPI Ethernet MAC/PHY parts they offer (ENC624J600 or ENC628J60).
ST also recently enhanced their ARM Cortex based STM32 line to include on-chip ethernet, but you'll need an external PHY and magnetics. It's an option if you're already looking at the PIC32.
-
17\$\begingroup\$ I've had problems with the Microchip network stack, so I wrote my own and make it available for free with source code at embedinc.com/pic/dload.htm in the PIC Development Tools release. You do have to embrace the concept of our PIC development environment (also free), but that's a good idea anyway. After installation, look for files with "net" in their names in the SOURCE > PIC directory. \$\endgroup\$ Commented Jul 14, 2011 at 11:25
Regarding having a TCP/IP stack, there are three projects you should look at:
- The Contiki Operating System
Contiki is an open source, highly portable, multi-tasking operating system for memory-efficient networked embedded systems and wireless sensor networks. Contiki has been used is a variety of projects, such as road tunnel fire monitoring, intrusion detection, water monitoring in the Baltic Sea, and in surveillance networks.
Contiki is designed for microcontrollers with small amounts of memory. A typical Contiki configuration is 2 kilobytes of RAM and 40 kilobytes of ROM.
- The uIP TCP/IP Stack:
The open-source uIP TCP/IP stack provides TCP/IP connectivity to tiny embedded 8-bit microcontrollers, with maintained interoperability and RFC standards compliance.
- The lwIP TCP/IP Stack:
Much faster than uIP but harder to get started with
Generally Ethernet is not built into microcontrollers. First you need a jack which can convert Ethernet signals into signals read by a microcontroller (this is generally called 'magnetics'). Then you need a TCP/IP stack, and then on top of that you need DHCP, DNS and whatever other protocols you want to use. So the actual microcontroller you use doesn't matter a whole lot. If you get something very powerful like an ARM with Linux running on it, then developing for it would be very simple, almost the same as writing a network application running on a desktop PC running Linux. Or you could go with something less powerful & cheaper like an AVR or PIC.
Ethernet and TCP/IP can be quite complex if you want to implement an entire TCP/IP stack in software. One common solution is to use something like Wiznet's W5100 chip, which handles all the low level TCP/IP stuff for you. You can buy it in a pre-made module that includes the ethernet connector and everything for pretty cheap, around $20 for the WIZ812MJ module. You can communicate with it using only SPI, so it won't take a lot of I/O pins on your microcontroller.
Lantronix also provides some more powerful modules that look even simpler to use, but they are a bit more pricey ($50-$100 depending on the model). See their XPort for example.
-
1\$\begingroup\$ I'd love to see a reputable reference for the term "magnetics", as I've never heard of it. \$\endgroup\$– AndrewCommented Oct 25, 2010 at 3:20
-
\$\begingroup\$ @Andrew I dunno any technical dictionary that has it. Googling it will find various references. That's just what I've seen it referred to. Basically the point of them is to isolate your circuit from the other devices connected to it via ethernet. Similar to how MIDI uses optical isolation. \$\endgroup\$– davrCommented Oct 26, 2010 at 5:16
-
\$\begingroup\$ I get about half a million more results for "ethernet isolator" than "ethernet magnetics", but I understand what you mean now. \$\endgroup\$– AndrewCommented Oct 26, 2010 at 6:29
-
\$\begingroup\$ There's a discussion on the origin and use of the term on this Hack A Day post on capacitive coupling. \$\endgroup\$– AndrewCommented Oct 27, 2010 at 12:42
-
\$\begingroup\$ I was just looking at an Ethernet transceiver datasheet (LAN8720A from Microchip), and that section is variously referred to as 'Mag' and 'Transformer'. \$\endgroup\$– IsvaraCommented Nov 13, 2013 at 13:54
ARMs are the microcontrollers of the day, and NXP has a wide offering of them. This web page lists literally too many Ethernet controllers to mention all here, as of this date (2011-07-13):
17 ARM7 devices
2 ARM9 devices
16 Cortex-M3 devices
edit
I moved the ARM advantages discussion to this answer.
-
\$\begingroup\$ what advantages do the arm line give. I see many other answers that need more detail, the important part is that you give a reason why the line more then just a link to the line of controllers. I only give you this feedback because you are too prolific of a user to not be giving the best answers possible! \$\endgroup\$– KortukCommented Jul 14, 2011 at 9:52
-
6\$\begingroup\$ @Kortuk - Oh, that's just great! Not only want they many answers, now they have to be the best as well! ;-) \$\endgroup\$– stevenvhCommented Jul 14, 2011 at 12:06
The XMOS XC-2 kit is an interesting way to do it. Everything is done in software, apart from the PHY. The software should run on the $7.50 XS1-L1 chip.
-
\$\begingroup\$ man you are getting me interested in XMOS products. I'm going to have to try really hard to resist picking up that development kit. Do you know if there is an RTOS available for it? \$\endgroup\$– DaveCommented Apr 15, 2011 at 6:47
-
\$\begingroup\$ It doesn't really need an RTOS, because of the hardware threads. That said, one or two people are working on one. \$\endgroup\$ Commented Apr 15, 2011 at 7:47
-
\$\begingroup\$ XMOS also make a version with two ethernet jacks. It's intended for bit LED signs, but I don't see why you couldn't do other things. Roll your own Router! xmos.com/products/development-kits/xc-3-led-tile-kit \$\endgroup\$ Commented Jul 14, 2011 at 8:28
Microchip have a number of Pic microcontrollers with inbuilt ethernet capabilities, there's a list here. They also have a series of pages concerning design solutions for ethernet and their products here, which also includes details of their full TCP/IP stack (with integrated MAC and PHY).
Hope this helps.
Lots of the TI Luminary microcontrollers (ARM Cortex-M3) have an onboard ethernet MAC. It needs an external crystal and ethernet PHY (connector + magnetics).
GCC and openOCD (JTAG flashing/debugging) support them well and they're pretty cheap in quantity.
They have cheap hardware devkits too...
http://uk.farnell.com/luminary-micro/ekt-lm3s811/kit-eval-lm3s811-code-red/dp/1712254
Netduino plus is a good 60$ microcontroller for ethernet applications. It can also accept most Arduino shields if needed.
Depending on just how easy you want to make your life I would recommend using an MBED and purchasing a magjack and ethernet breakout board (see sparkfun) for connecting up the cable and dealing with the signal conditioning. The supporting model is the mbed NXP LPC1768.
I managed to get an mbed sending data to my remote server (ie. over the internet) in about 2 hours from a standing start.
It depends what you want to do with it. The main thing to look out for is the amount of RAM (can limit individual message size) and if you want to serve web pages then the amount of storage available for that. I use an Arduino Duemilanova http://www.arduino.cc/ - ATMega328 micro controller, 2Kbytes RAM. You can connect up a SD card if you want significant storage. The ethernet shield will support upto 4 concurrent sessions. Don't expect to be able to serve up complex pages but works fine uploading to Pachube, twitter etc.
For a more powerful solution look at Marvell Plug
I would suggest using the ENC28J60 together with one of the pic 18 micro-controllers because microchip offers a TCP/IP stack for this combination and there should be plenty of information available through google on implementing this.
-
4\$\begingroup\$ Using an AVR micro with a Microchip MAC/PHY? What's next? Cats and dogs living together? :) \$\endgroup\$ Commented Nov 12, 2009 at 15:08
-
\$\begingroup\$ I have one of these - it works well. Comes as a kit with all the surface mount parts pre-soldered. uIP sources and ethernet driver come with it. \$\endgroup\$ Commented Mar 27, 2010 at 0:23
There are many projects using the ENC28J60 and ATMEL Cips. The most of them are well documented and using C or BASCOM. You could also buy complete kits to start with. I by myself own such a kit and learned much about the programming from the forums.
The nanode is open source and only £22 / $40 shipped. I've just bought two for home energy/environmental monitoring via pachube.
30 second pitch from the site:
Nanode is an open source Arduino-like board that has in-built web connectivity. It connects to a range of wireless, wired and ethernet interfaces. It allows you to develop web based sensor and control systems - giving you web access to six analogue sensor lines and six digital I/O lines. It is an easy build it yourself kit. Nanode was designed with Hacking in mind.
I've tried the microchip stack using the picdem.net 2 develpment card and i was not satisfied at all, it's not optimised and not well documented.
I think that the best solution in market now is Wiznet that have the first Ethernet based TCP/IP hardware chip that save a lot of time and give you more efficiency
This link gives all the solutions available and compare them:
-
-
1\$\begingroup\$ I have also had bad experiences with the Microchip network stack, so I wrote my own. It's included in the PIC Development Tools release at [url]embedinc.com/pic/dload.htm[/url]. It runs on a PIC 18, can drive the external ENC28J60 or the internal MAC/PHY, is well commented, easily configurable, and was designed for low footprint. \$\endgroup\$ Commented Jul 14, 2011 at 11:22
I'm late to the party here but I recommend the TI Stellaris EK-LM3S6965. It's an ARM Cortex M3 part with built-in Ethernet controller including PHY. For prototyping I used their evaluation kit, which has an Ethernet jack, small OLED display (great for debugging and barebones UI), SD card slot, speaker, buttons, LEDs and breakouts for wiring stuff up to the micro's peripherals. You didn't describe your application (i.e., looking to produce tens of thousands of something or a one-off hobby project), but pricing is reasonable (~$70 for the dev board, $12-15 in small quantities for just the chips), they come with an OK set of development libraries if you want to do your own firmware or it can run FreeRTOS (required a tiny bit of porting due to minor hardware revs between my board revision and the stuff in the FreeRTOS distro) and eLua. You can use either uIP or lwIP for TCP/IP.
Compared to popular hobbyist offerings like AVR/Arduino and PIC the Cortex M3 is a 32-bit part, runs at 50MHz, the 6965 has a lot of I/O features, IMO for the money it is just amazing how much computing power and how many features you can get out of something so tiny and cheap. It is pretty raw on the development side, however, and you must know C (well, unless you run eLua). I'm a software developer by trade and do my ARM development on a Mac, so I'm not afraid of scary/inconvenient toolchain setups and used Make + arm-eabi-gcc + OpenOCD for debugging, but if you are a Windows guy maybe the Code Composer Studio bundle would be a good bet. I used TI's Code Composer IDE for a fun MSP430 experimental project and it was fine by me and had an easier workflow than my OSX/ARM setup. They have about a half-dozen board bundles with different development tools, so you can pick your poison.
Full-disclosure, I haven't actually designed a PCB around this chip that used the Ethernet controller, but I did a board that didn't use the Ethernet and had a good experience with that, and I have built Ethernet-enabled projects using the evaluation board.
Check out the evaluation board/tool bundles here
UPDATE Sep 2013
These parts seem to be no longer recommended for new designs. There don't seem to be any obvious replacements.
UPDATE Nov 2013
There's now a TM4C129XNCZAD which is nominally a replacement for the above part - it has onboard MAC + PHY, albeit not pin compatible - however a lot of people are reluctant to use it after the issues/confusion over the LM3S early life discontinuation / availability.
It may not be 100% what this question is asking, but for projects where the production runs are fairly small I've started to see people embedding pre-built boards like the raspberry pi. This has a lot of advantages:
- The price isn't too much more than one of the higher end CPUs with ethernet (at least for low-volumes), and you skip a whole load of design/test/bring up issues.
- The raspberry PI is already CE/EMC tested, so that cuts out a whole load of uncertainty (otherwise ethernet & fast clocks can throw up a bunch of EMC issues). You still have to test your final product, but at least there's a whole area that really shouldn't cause a failure.
- You get a lot more grunt and a proper, server grade TCP/IP stack if you use linux etc - none of these "only one active connection allowed" type things!
As I say, it's not for everyone, but for some projects it can be a good fit.
There's a few options in terms of the exact board used around:
- Raspberry PI
- Beaglebone black - has onboard flash
- STM32F4DISCOVERY with expansion boards
You can use almost any MCU with Wiznet W5500 embedded MAC + PHY controller, it is driven by SPI. The advantages are: it has built-in network stack, Tx/Rx buffers, requires minimum MCU pins, simplified programming.
I just found another interesting option - AX88796C from ASIX, it also has both MAC + PHY, 10\100Mbps Ethernet and up to 40MHz SPI interface option, so looks nice fit for any ARM based MCU.
UPDATE: Netduino 3 is already using this chip, here are interesting details:
If you have any experience with firmware I would recommend the STM32F4Discovery board with the STM32F4DIS-EXT board. I recently used this to create a configuration webpage for my device and it was fairly easy. There is a lwIP example project available online and if you google "makefsdata" you will find a lot of information about how to generate the necessary files for your own HTML files. Message me if you need more info.
I like the (25 EUR) Openpicus FlyportPro ethernet module for that purpose. Just add an ethernet jack with magnetics and create your firmware using their TCP/IP stack. They have a TLS implementation as well:
http://blog.openpicus.com/2014/12/idepro-2-9-0-bye-ssl-welcome-tls.html
I did a project using the 'classic' Flyport ethernet and it's been rock solid so far.