Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Propeller Chip > TCP/IP Stack (Includes Beta Code - Responds to Pings / ARP)  Forum Quick Jump
 
New Topic Post Reply Printable Version
30 posts in this thread.
Viewing Page :
 1  2 
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/20/2006 4:49 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
I have started working on a tcp /ip stack for the Propeller (since no one answered my last question pertaining to if anyone was working on their own implementation). So far I have implemented ARP and PING. These are simple protocols and are useful for testing. I have tested the ping code with 20+ ping windows open with no dropped packets. The only issue is the response times are > 44ms due to the slowness of the sloppy spin code.

You could use this code to control stuff (send variable length pings to signal different things). This would be very useful since you would get direct feedback if your command was successful via a ping reply. Kind of a simple idea, but hey, its cheap and simple network communication.

I am working on implementing a simple HTTP server. I am having some difficulty with checksums so it may take a while...

Attached is my working PING code and some pictures. The code is 'copyrighted' just in case. You are free to use this in any non-commercial product. (It's highly beta so no one in their right mind would use it in a commercial product anyways).

Edit: I forgot to mention that you must use the ENC28J60 B5 silicon revision. The code checks for this and will not run if an incorrect revision is detected. You may be able to use B2 and B3 if you change the required version constant. B4 is out of the question since it requires > 8mhz spi clock, which I don't think is possible with the prop.

Edit 2: Updated driver. There was a problem with the send_frame where it ended up sending one extra random byte which could lead to the packet being dropped due to bad checksum.

Edit 3: Driver removed temporarily while I put in licensing information and post it on it's own site.

Edit 4: Complete project moved to code.google.com/p/proptcp/. All code is now released under Open Source GPL v3.

Harrison

Post Edited (Harrison.) : 8/29/2007 9:20:01 PM GMT


Image Attachment :
Image Preview
ScreenShot005.jpg
  119KB (image/jpeg)
This image has been viewed 603 time(s).
Image Attachment :
Image Preview
ScreenShot006.jpg
  174KB (image/jpeg)
This image has been viewed 742 time(s).
Image Attachment :
Image Preview
ScreenShot007.jpg
  108KB (image/jpeg)
This image has been viewed 685 time(s).
Back to Top
 

GdSis
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2006
Total Posts : 12
 
   Posted 12/20/2006 9:14 PM (GMT -8)    Quote This PostAlert An Admin About This Post.

Harrison,

This is great, thanks! 

Any success on those checksums? Some old Scenix app notes and source code showed

a clever routine to do that, in few bytes of code.

Having udp/tcp on prop would be great.

GdS

Harrison. said...
I have started working on a tcp /ip stack for the Propeller (since no one answered my last question pertaining to if anyone was working on their own implementation). So far I have implemented ARP and PING. These are simple protocols and are useful for testing. I have tested the ping code with 20+ ping windows open with no dropped packets. The only issue is the response times are > 44ms due to the slowness of the sloppy spin code.

You could use this code to control stuff (send variable length pings to signal different things). This would be very useful since you would get direct feedback if your command was successful via a ping reply. Kind of a simple idea, but hey, its cheap and simple network communication.

I am working on implementing a simple HTTP server. I am having some difficulty with checksums so it may take a while...

Attached is my working PING code and some pictures. The code is 'copyrighted' just in case. You are free to use this in any non-commercial product. (It's highly beta so no one in their right mind would use it in a commercial product anyways).

Edit: I forgot to mention that you must use the ENC28J60 B5 silicon revision. The code checks for this and will not run if an incorrect revision is detected. You may be able to use B2 and B3 if you change the required version constant. B4 is out of the question since it requires > 8mhz spi clock, which I don't think is possible with the prop.

Edit 2: Updated driver. There was a problem with the send_frame where it ended up sending one extra random byte which could lead to the packet being dropped due to bad checksum.

Harrison
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/20/2006 9:26 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
I think my checksum problem was related to me sending an incorrect number of bytes in a packet. I am going to try udp first since tcp is so dang long with its annoying syn, ack, fin, etc flags. I am hoping to eventually hook this up to some christmas lights and controlling it via network.
Back to Top
 

Ym2413a
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined May 2006
Total Posts : 477
 
   Posted 12/21/2006 4:28 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Oh, this is cool.
A propeller based web server. *grins*

HEY!! why not write a propeller based browser in its 4-color glory?
I have seen a browser for the C64 before, it was pretty neat to say the least.
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/21/2006 10:48 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
A web browser would be pretty cool. It would take some work making a much more robust tcp stack to be able to run connect to other servers.

So far I have managed to slap together a really really bad implementation of a tcp server. UDP is working well (it echos udp packets). At this stage, it would be very easy to add simple I/O, but doing stuff like hosting images and files is out of the question since the stack only supports one frame (1500 bytes).

You can try my test setup at wx.fwdweb.com:88/ . Note that it may not be up all the time since I work on it throughout the day when I have time.

Harrison

Post Edited (Harrison.) : 12/22/2006 6:52:13 AM GMT

Back to Top
 

william chan
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 850
 
   Posted 12/22/2006 12:26 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
How did you manage to wire it to a PCI card?
What's the IC in the breadboard?
Can you interface to a Wifi module?


www.fd.com.my
www.mercedes.com.my

Back to Top
 

ciw1973
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2006
Total Posts : 64
 
   Posted 12/22/2006 1:24 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Ym2413a said...
HEY!! why not write a propeller based browser in its 4-color glory?
I have seen a browser for the C64 before, it was pretty neat to say the least.


Or just go for a text based one along the lines of Lynx (but the site seems to be down), better still Links (but this hasn't been updated since 2003) or ELinks, which is still actively being developed. They actually offer a very effective browing experience, and are open source, so you could grab the code to help you along the way.
Back to Top
 

Dave Paton
I program with solder.



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Sep 2004
Total Posts : 286
 
   Posted 12/22/2006 6:11 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
william chan said...
How did you manage to wire it to a PCI card?
What's the IC in the breadboard?
Can you interface to a Wifi module?

I'm not the OP, but a little close examination netted me these tentative answers:

The PCI card is wired to the chip on the breadboard, the PCI circuitry isn't active.
The IC on the breadboard is a Microchip ENC28J60 (rev B5 or better). It's a purpose built 10bT Ethernet interface chip for 8 bit micros.
The possibility of a WiFi interface is a longshot I think.

-dave


This is not a sig. This is a duck. Quack.

Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/22/2006 8:52 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Dave is correct, I am not using the PCI interface on the computer NIC. I am only using the ethernet magnetics (the rectangle on the PCB labeled FB2022) and the ethernet jack (the silver box with the RJ45 cable plugged in).

I would recommend a prebuilt module from edtp.com or sparkfun.com . I used the schematic from http://www.edtp.com/download/ft/framethrower_package.pdf to wire up my test bench.

Harrison
Back to Top
 

Catweazle
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2006
Total Posts : 17
 
   Posted 12/22/2006 12:09 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Very exciting!

two little questions:

1. I heared there are some bugs in the ENC28... (Microchip Errata), did you haven't any?
2. are the the transformer values (filter,ratio ...) critical?
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/22/2006 12:35 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
The only problems I ran into with the current B5 rev were:
- RX Buffer should start at 0x0000 since crossing the 8kb circular buffer end would corrupt the buffers
- Buffer pointers should only contain odd values
- Auto half duplex detection via LED polarity errors

I worked around all these issues in software. The driver now sets most, if not all the parameters so the chip doesn't have to infer any major settings. I haven't run into any odd bugs after fixing the ones listed above.

--

I am not sure how critical the ethernet magnetic ratio / discrete components are. I just hooked the magnetics straight into the ENC chip and used the recommended 47 ohm resistors. I completely omitted the inductor / ferrite bead recommended by Microchip. My setup worked perfectly with my dlink router / switch
Back to Top
 

acantostega
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2006
Total Posts : 105
 
   Posted 12/22/2006 5:25 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Dave Paton said...
william chan said...
How did you manage to wire it to a PCI card?
What's the IC in the breadboard?
Can you interface to a Wifi module?

I'm not the OP, but a little close examination netted me these tentative answers:

The PCI card is wired to the chip on the breadboard, the PCI circuitry isn't active.
The IC on the breadboard is a Microchip ENC28J60 (rev B5 or better). It's a purpose built 10bT Ethernet interface chip for 8 bit micros.
The possibility of a WiFi interface is a longshot I think.

-dave


If you're willing to spend some money, it isn't hard to interface to Wi-Fi from a micro:

www.lantronix.com/device-networking/embedded-device-servers/wiport.html
www.edtp.com/ (scroll down a bit)
www.dpactech.com/wireless_products/embedded-802.11-wireless-module.asp
Back to Top
 

Benoit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2006
Total Posts : 48
 
   Posted 12/22/2006 9:18 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Really cool project.

The reference to the C64 browser reminded me of the contiki uIP TCP stack. Maybe you can use parts of it for your own stack.

www.sics.se/~adam/uip/

-Ben

Post Edited (couch-pilot) : 12/23/2006 5:25:23 AM GMT

Back to Top
 

Catweazle
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2006
Total Posts : 17
 
   Posted 12/24/2006 4:21 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hello,

You've done a great work with the Ethernet Stack!!
I have created a little adapter PCB for the ENC28J60 (www.microchip.com -> Samples ;)
It's for the DIL version of the chip and a LF1S022 RJ45 connector with integrated transformer and filters (+2 LEDs)

Here's the schematic and the EAGLE files (schematic and PCB-layout)

gtz
Eric
Image Attachment :
Image Preview
ENC28J60-Adapter.jpg
  122KB (image/jpeg)
This image has been viewed 662 time(s).

File Attachment :
ENC28J60_Adapter.zip   57KB (application/x-zip-compressed)
This file has been downloaded 274 time(s).
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/24/2006 8:25 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Very nice. I might eventually make a breakout board for the chip so I don't have to bother with the mess I have right now.

Also, if you don't have a 25mhz crystal on hand then you can use the Propeller to generate the 25mhz clock. That's what I did because I couldn't find a 25mhz crystal.

Harrison
Back to Top
 

william chan
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 850
 
   Posted 12/25/2006 6:20 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Catweazle said...
Hello,

You've done a great work with the Ethernet Stack!!
I have created a little adapter PCB for the ENC28J60 (www.microchip.com -> Samples ;)
It's for the DIL version of the chip and a LF1S022 RJ45 connector with integrated transformer and filters (+2 LEDs)

Here's the schematic and the EAGLE files (schematic and PCB-layout)

gtz
Eric


Where are the connections to the Propeller?
I can't find it.....


www.fd.com.my
www.mercedes.com.my

Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/25/2006 8:37 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
This is highly beta code so you will have to look around in the source to see how to configure the mac address, ip address, and i/o.

Here are some pointers:
In driver_enc28j60.spin, there is a start method with the paramters start(i_cs, i_sck, i_si, i_so, i_int, clkout) . These are the pins that are used to communicate with the enc28j60 chip. In driver_tcpstack.spin, you will see that the start method calls the enc28j60 driver's start method with pin numbers that correspond with those hooked up to the enc28j60 chip.

The above may be confusing so heres some more info:
start(i_cs, i_sck, i_si, i_so, i_int, clkout)
cs = hook to enc28j60's cs pin (CS)
sck = hook to enc28j60's sck pin (SCK)
si = hook to enc28j60's spi in pin (SI)
so = hook to enc28j60's spi out pin (SO)
clkout = hook to enc28j60's xtal1 in (XTAL1) if you are not using a 25mhz crystal, otherwise leave this pin disconnected

You will need to use your own judgment on how to get this to work. Read the datasheets to make sure you hooked up stuff correctly.

Harrison
Back to Top
 

Gavin
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2006
Total Posts : 134
 
   Posted 12/25/2006 11:26 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
 
Harrison,
 
Well done, you are making it easier for the rest of us to follow in your footsteps.
 
I have some premade modules.
Will need to check if they are B5 silicon.
Date code is 05 27, how do I know if it is B5?
From the errata data I need to get it working first to read address 0312 ?
Hmm just read your last post re versions, guess I should just plug it in and test it.
 
 
Gavin
Back to Top
 

Catweazle
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2006
Total Posts : 17
 
   Posted 12/26/2006 6:59 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
William,
on the schematic the connections to the prop is on the left side, it's a 8pin connector labeled JP1.
(CS,SCK,SI,SO,RESET,INT,WOL,CLKOUT)

It's mainly copied from the Olimex schematic.

In the Eagle PCB (.brd) file the connector is on the right upper side.

The www.microchip.com Erratas sais that you should use a 2k7 bias resistor (ENC28J60 pin 14) for revision B1 and B4,
and 2k34 for revision 5

- Eric
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/26/2006 12:58 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
About revision compatibility: The NIC driver start() method has a few lines of code which read the revision register and compares it to the required revision number (B5 in this case). If you find out the driver isn't loading then try commenting out those lines and seeing if it works.

Also, in theory B4 revisions may work if you are using the propeller to clock the enc28j60 chip. The reason why there was a 8mhz spi clock requirement was due to a clocking synchronization between the 25mhz enc28j60 clock and the spi clock. Using the propeller to provide the 25mhz using the counter modules would in theory mean that the clocks are somewhat in sync so it may work. Then again I could be entirely wrong, but you could always try.

Also, the code posted in the original post only does ping responses. The current revision I am working on isn't ready for release yet.

Harrison
Back to Top
 

william chan
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 850
 
   Posted 12/29/2006 5:59 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
CatWeazle,

Can you make another schematic and PCB based on ExpressPCB that is easily plugged on as a daughter board
on top of the Propeller Demo board?
I think a lot of people will buy the board from you.

Thanks.


www.fd.com.my
www.mercedes.com.my

Back to Top
 

BEEP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2006
Total Posts : 32
 
   Posted 12/30/2006 5:24 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
An AVR microcontroller based Ethernet device
HTTP/TCP with an atmega88 microcontroller (AVR web server)
Back to Top
 

Harrison.
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 441
 
   Posted 12/30/2006 9:38 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Interesting links. I used http://www.edtp.com/download/enc28j60/enc28j60_driver.zip while working on this since I am much more familiar with the PIC line of micros and C compilers. In any case, I resorted to using a tcp scheme thats extremely simliar to the one described in the http/tcp with the atmega micro link you posted.

Harrison
Back to Top
 

TransistorToaster
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2006
Total Posts : 149
 
   Posted 1/11/2007 3:46 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
What documents should one read to become more familiar with embedded ethernet. Do you know these by Fred Eady and if so, which one is better:

http://www.edtp.com/netbook_page.htm
http://www.edtp.com/airdropbook_page.htm

Or could you recommend some other reading?
Frank
Back to Top
 

Kloss
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 43
 
   Posted 1/12/2007 2:24 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Take a look at this:
http://mikrocontroller.cco-ev.de/de/avr_webserver.php

They're using an ISA ethernet card (NE2000 or 3COM) as an interface.
Not a bad idea, as you can get this type of cards for free or less
than a buck.

cu
Karl
Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
30 posts in this thread.
Viewing Page :
 1  2 
 
Forum Information
Currently it is Friday, November 20, 2009 11:14 PM (GMT -8)
There are a total of 393,738 posts in 55,521 threads.
In the last 3 days there were 82 new threads and 702 reply posts. View Active Threads
Who's Online
This forum has 17687 registered members. Please welcome our newest member, mark09.
48 Guest(s), 1 Registered Member(s) are currently online.  Details
SRLM