EmbeddedRelated.com
Forums

Ethernet: How/where to start? (Microchip)

Started by Rodo November 21, 2008
Hi all,

I want to be able to use Ethernet in my projects but I'm so overwhelmed by 
its complexity that I don't know where to go. I've read and watch most of 
the information at microchip.com. I'm aware of the new PICs that have a MAC 
built-in and the ENC28J60. I'm also aware of the TCP/IP stack and the rest 
of the ... stuff (DHCP, ARP, etc.). The reason I say "I'm aware" is because 
I don't really understand the details of each. I'm aware of the TCP and IP 
packets. But I don't understand how to use them to connect a PIC from a PC 
running a custom application. I've seen their demos on the vending machine , 
Ethernet radio, etc. But I didn't see a demo on a custom application like 
they have for USB. I do want to be able to make the PC application as well. 
I have Visual Studio 2005. I'm not thinking that this is going to be quick 
and easy in fact I think it is going to be painfully slow, which I don't 
mind as long as I learn the stuff. I don't have a project right now that 
requires it so I have all the time in the world.

I'm looking for info that would tie all the info together. Like...

How does the PC application find the PIC? How can I TX data from the PIC to 
the PC? Will DHCP take care of all "handshake" (for lack of a better word) ? 
if so how does the PIC know where to send the data? etc, etc, etc.

Any books, web sites that can tie all that info would be great.

Thanks a bunch 


On Nov 20, 11:20=A0pm, "Rodo" <no...@youwish.com> wrote:
> Hi all, > > I want to be able to use Ethernet in my projects but I'm so overwhelmed b=
y
> its complexity that I don't know where to go. I've read and watch most of > the information at microchip.com. I'm aware of the new PICs that have a M=
AC
> built-in and the ENC28J60. I'm also aware of the TCP/IP stack and the res=
t
> of the ... stuff (DHCP, ARP, etc.). The reason I say "I'm aware" is becau=
se
> I don't really understand the details of each. I'm aware of the TCP and I=
P
> packets. But I don't understand how to use them to connect a PIC from a P=
C
> running a custom application. I've seen their demos on the vending machin=
e ,
> Ethernet radio, etc. But I didn't see a demo on a custom application like > they have for USB. I do want to be able to make the PC application as wel=
l.
> I have Visual Studio 2005. I'm not thinking that this is going to be quic=
k
> and easy in fact I think it is going to be painfully slow, which I don't > mind as long as I learn the stuff. I don't have a project right now that > requires it so I have all the time in the world. > > I'm looking for info that would tie all the info together. Like... > > How does the PC application find the PIC? How can I TX data from the PIC =
to
> the PC? Will DHCP take care of all "handshake" (for lack of a better word=
) ?
> if so how does the PIC know where to send the data? etc, etc, etc. > > Any books, web sites that can tie all that info would be great. > > Thanks a bunch
My suggestion is to take using Ethernet is small steps. For get about TCP/IP and concentrate on something simple like just getting/sending Ethernet frames. Work up to using IP using Ping (use fixed IP addresses). Start adding/testing other protocols after that. A good book is TCP/IP Illustrated Volume 1. It doesn't cover Ethernet but it does cover a lot of the important protocols from IP on up.
On Nov 21, 12:20 pm, "Rodo" <no...@youwish.com> wrote:
> Hi all, > > I want to be able to use Ethernet in my projects but I'm so overwhelmed by > its complexity that I don't know where to go.
Don't get overwhelmed. It is not that difficult. First thing, you have to come out of the 'microcontroller' mindset of doing everything (all coding) yourself. You do not need to know any of the TCP/IP internals to make this project going. This project is more about integration difficulties. That assured let's see what we can do about your situation !
> I've read and watch most of > the information at microchip.com. I'm aware of the new PICs that have a MAC > built-in and the ENC28J60. I'm also aware of the TCP/IP stack and the rest > of the ... stuff (DHCP, ARP, etc.).
Do you have hardware ready? If not, that is a different project on its own ! First thing you need to use an operating system. Even if is as simple as FreeRTOS or full blown like Linux. This is essential because the TCP/IP stacks need to work in a separate thread of their own. Hence normally you will get TCP/IP stacks made for particular OSes. See: http://www.freertos.org/portrowleylpc2124.html For more examples: http://www.freertos.org/embeddedtcp.html Second thing, you need to know a little about the Ethernet hardware. No need to worry about TCP/IP issues here. Again you will most probably get a ready made driver for you Ethernet chip which you will need to integrate into your OS. Once you are done with this that's all on the kernel side. You need to do some trivial configurations of your own IP address, subnet mask, gateway address, etc. Thats all ... You have for yourself a LAN enabled board. No need to write any application for now. All TCP/IP stacks support ICMP. So you can ping the board from your PC. No application need to be created on the PC as yet. Once this task is over you can then learn some socket programming. That's 100 times simpler than above. You do not need to think anything about routing, packet fragmentation, flow control, ARP, DHCP... that magic is the prerogative of the TCP/IP stack. -Kaustubh
On Fri, 21 Nov 2008 07:20:12 GMT, "Rodo" <noway@youwish.com> wrote:


>Any books, web sites that can tie all that info would be great.
Try "Networking and Internetworking with Microcontrollers" by Fred Eady. The first half of the book covers async serial and I2C; the latter half builds example code to get ARP, UDP, and TCP up and running over IP. -- Rich Webb Norfolk, VA
Rodo wrote:

> Hi all, > > I want to be able to use Ethernet in my projects but I'm so overwhelmed by > its complexity that I don't know where to go. I've read and watch most of > the information at microchip.com. I'm aware of the new PICs that have a > MAC built-in and the ENC28J60. I'm also aware of the TCP/IP stack and the > rest of the ... stuff (DHCP, ARP, etc.). The reason I say "I'm aware" is > because I don't really understand the details of each. I'm aware of the > TCP and IP packets. But I don't understand how to use them to connect a > PIC from a PC running a custom application.
You can avoid most of Ethernet and TCP/IP, if such is your taste, by using chips like the W5100 or W5300 from Wiznet <http://wiznet.co.kr/>. These effectively package 4 IP sockets into hardware, controllable through an SPI or a memory interface. Mel.
> First thing you need to use an operating system. Even if is as simple > as FreeRTOS or full blown like Linux. This is essential because the > TCP/IP stacks need to work in a separate thread of their own. Hence > normally you will get TCP/IP stacks made for particular OSes. > See: > http://www.freertos.org/portrowleylpc2124.html > For more examples: > http://www.freertos.org/embeddedtcp.html
There was somebody on the FreeRTOS.org forum just today talking about getting lwIP running on a PIC32 - maybe you could try contacting them? http://sourceforge.net/forum/forum.php?thread_id=2591366&forum_id=382005 uIP is a nice small and easy place to start, but its interface is a bit non-standard. Regards, Richard. + http://www.FreeRTOS.org & http://www.FreeRTOS.org/shop 17 official architecture ports, more than 6000 downloads per month. + http://www.SafeRTOS.com Certified by T&#4294967295;V as meeting the requirements for safety related systems.
Rodo wrote:
> Will DHCP take care of all "handshake" (for lack of a better word) ?
Only part of it. DHCP is a way for your device to be assigned an IP address, and told what its default gateway and DNS servers should be. In the simplest case, the DHCP server simply assigns an IP address out of a pool. For example, if you have a typical SOHO router/gateway product, that's how they are configured by default. Your device will get an IP address, but your PC won't really know how to find it. On the other hand, it's possible to configure a DHCP server (usually running on a PC rather than a SOHO router/gateway) to give a specific IP address to your device based on recognizing the Ethernet MAC address of the device. If you do that, software running on the PC can more easily find your device to communicate with it (if the PC is going to initiate the communication).
> if so how does the PIC know where to send the data? etc, etc, etc.
If the PIC is going to initiate the communication, it probably needs to be configured somehow to know a host name or IP address it is intended to communicate with. It is also possible for a device to get its configuration information through DHCP/BOOTP, but as stated above, this requires the DHCP server to be configured specifically for the device. There are also fancier discovery mechanism such as UPnP, but they are quite complex.
> Any books, web sites that can tie all that info would be great.
The "Internetworking with TCP/IP" series by Comer are excellent for the IP layer and up.
On Nov 21, 3:23=A0pm, Eric Smith <e...@brouhaha.com> wrote:
> Rodo wrote: > > Will DHCP take care of all "handshake" (for lack of a better word) ? > > Only part of it. =A0DHCP is a way for your device to be assigned an IP ad=
dress,
> and told what its default gateway and DNS servers should be. > > In the simplest case, the DHCP server simply assigns an IP address out of > a pool. =A0For example, if you have a typical SOHO router/gateway product=
,
> that's how they are configured by default. =A0Your device will get an IP > address, but your PC won't really know how to find it. > > On the other hand, it's possible to configure a DHCP server (usually > running on a PC rather than a SOHO router/gateway) to give a specific > IP address to your device based on recognizing the Ethernet MAC address > of the device. =A0If you do that, software running on the PC can more > easily find your device to communicate with it (if the PC is going to > initiate the communication). > > > if so how does the PIC know where to send the data? etc, etc, etc. > > If the PIC is going to initiate the communication, it probably needs to > be configured somehow to know a host name or IP address it is intended > to communicate with. =A0It is also possible for a device to get its > configuration information through DHCP/BOOTP, but as stated above, this > requires the DHCP server to be configured specifically for the device. > > There are also fancier discovery mechanism such as UPnP, but they are > quite complex. > > > Any books, web sites that can tie all that info would be great. > > The "Internetworking with TCP/IP" series by Comer are excellent for the > IP layer and up.
DHCP can also be used to provide a name for the device. Most (?) low-end routers include a DNS server, so the device can immediately be accessed by name. That's how I access the devices in my office LAN - no need for hardwired IP addresses ! This is an option in both DHCP and the router, so not *always* available... Hope that helps, Best Regards, Dave