WWWpic2 - A web server in a PIC
WWWpic2 is a web server in a
Microchip PIC 16F84 .
The current release is 0.2 See
the Changelog for what's changed since the last
- I recently discovered some non commercial
linux 24Cxxx programming code
which will shortly mean I can provide external 24C256 eeprom support for page
- WWWpic2 is based upon the work of
Denis Petrov and is released under
the GPL by myself after seeking permission from
- I use Debian Linux to build my hex files and connect my PIC to so thats the only "supported" platform for now.
- This code differs from the original wwwPic in that it doesn't
require Borland TASM 4.1. Versions prioor to 0.2 were converted to the free
picasm assembler syntax.
Version 0.2 and later have been changed to use the GPASM assembler which is
compatible with Microchips own MPASM.
- If you cannot or do not wish to build your own hex file I have assembled a hex file for you. This uses teh settings as found in the source ie 19200 baud and 10Mhz crystal.
- This version can also be changed at compile time to account for
any crystal frequency or baud rate (4MHz and 10MHz at 9600-38400baud have
- The comments that were Cyrillic text in the original source,
have been removed and replaced with a (rus) tag in this version. I am
in the process of re-commenting the source so I can understand it
better to modify it!
- The Makefile assumes you will be using
pic programmer to burn your pic - change this as necessary.
- I have provided a circuit schematic
which is somewhat clearer and more reliable than the one in the
original wwwPic project, it was created using XCircuit on a Linux
system , it is a postscript file (which XCircuit uses to save its
files) and as such can be printed readily.
- The aforementioned circuit design was created by
off the top of his head one Tuesday afternoon, as usual for
Dave's ideas it worked flawlessly first time - cheers Dave :-)
- My schematic is correct for the supplied asm code! The original
schematic in the wwwpic project is incorrect! It has RA2 and RA3
- The page was
on slashdot. Just for interest
here is the usage graphs during the 2 day
period of the posting.
- firstname.lastname@example.org reports
that the 16C84 cannot be used with the current code as it uses 3 too
- Install any necessary tools.
- Unpack the source tar.
- Change the SPORT line in the makefile to your serial port
- Type make
- Attach the hardware to a serial port
- Modify the connect.sh script
with your systems parameters.
- Try a "telnet 192.168.2.2 80" type "GET /" and you should get a reply of the index page.
Just a quick disclaimer, you fry something (especially yourself)
even if my design is wrong it is your problem! I have tried to make
these details as accurate as possible but I accept no responsibility
for any errors or omissions.
- Currently the hardware part of this project has been built on
breadboard twice and
strip-board, I plan to create a PCB layout
as soon as the circuit design is more stable (see future expansion for
- Although I do not currently have access to the equipment necessary to
fabricate SMC designs, I intend to create a SMC layout.
- If constructing from the current schematic please pay attention to
the notes! Especially that the two crystal caps have been omitted for
clarity and the notes on component tolerances (there are none ;-)
- If your cable run is long, you have a serial port that won't
source enough current on its DCD line or your additions require a lot
of current (you were going to do something with those port B
inputs/outputs weren't you?). You will need an additional power source,
a 9V PP3 battery is totally sufficient for this. Attach its -ve to
anywhere on the ground rail and the +ve between the diode and the
input to the power regulator.
Parts list and guide prices
This is a quick list of parts, it doesn't include the strip-board
or PCB nor does it include any cable. Aside from that it should be
complete to build the current design. You may wish to add a IC socket
if you don't want to solder your pic directly (recommended).
||Farnell order code
|5V Power Regulator4||LM2931AT-50||1||1.09||300-4685|
|NPN silicon transistor5
|10µF Electrolytic Capacitors6|| ||2||0.08||286-527|
|33pF Ceramic Capacitors|| ||2||0.03||896-421|
|10K Resistor6|| ||2||0.044||514-263|
|4K7 Resistor6|| ||1||0.044||514-184|
|2K2 Resistor6|| ||1||0.044||514-100|
|Female 9Pin D type6
1 Guide prices are all in pounds sterling and taken
from October 99 catalogue of Farnell Electronics my current
favorite supplier in the UK. Note smallest multiple on transistors and
9pin sockets is 5. For the diodes, capacitors and resistors it is 10.
2 Not used in the current design.
3 Any above 4MHz will do (I tested above 4MHz, below
that higher baud rates simply don't have enough cycles to process
4 Any 5V regulator with greater than 30mA supply is
adequate, I used this one as it has self protection and can source
100mA with very low internal power loss. This part turns out to be
very awkward to get the pinouts of.
5 Any NPN small signal transistor with HFE>50 will do.
6 None of these are particularly critical (esp. the
caps) anything reasonably close will do, note the quoted Farnell codes
are their "best value" lines and not necessarily what I used
exactly in the prototype.
Please see the package section for the package download of everything you need. Links to files in this section are for ilustrating the code only.
The software for the pic is provided as a single file of assembly code
(wwwpic2.asm) and an include file
The basic structure of the code can be broken down into the following sections
- Serial byte recieve
- Serial byte send
- SLIP decode
- SLIP encode
- IP recieve
- IP send
- TCP recieve
- TCP send
- Revived TCP data processing (HTTP server)
I have split the code up in this way because each of these sections
in isolation isn't too difficult to understand. This should give you a
fairly good understanding as how the whole works and hopefuly how to
do the modifications you want for your real world applications.
- I am currently adding support for simple UDP and possibly some
ICMP echo reply stuff - problem with that is I'm meant to return all
the data I get intact... I thought lots of file registers would be
required, however Tom Davies
has come up with a possible solution to this one.
- I have some 24C256 serial eeprom chips which I'm going to
integrate so web page text can be stored externally to the pic itself
freeing the ROM space for code. Update! I recently found some
24Cxxx programming code.
- I plan to add support for some serial ADCs I have.
- There is the posibility of interfacing some serial temperature
monitoring devices I have. These are Philips semiconductors part NE1617 but could
just as easily be Maxim's MAX1617 or Analog Devices ADM1021.
- General improvements to the documentation.
- Possibly change to GPASM as an alternative assembler.
- Suggestion from
Lars Segerlund to
attach an ethernet controller perhaps similar to the
Embeded Ethernet project.
- Suggestions! (sensible please - there is only 500 or so
spare instructions even with the text of the pages on external eeprom)
It is GPL! what other licence is there? ;-)
Felix Gallo and others mailed me
to disagree with this. I have decided not to change it, so please
don't try to start a debate on differing licences thank you.
This isn't an exhaustive list by any means but they appear to be the ones based on PIC controllers. Note the IPic does not have any source code and it appears it may become a commercial project.
Any problems with this web page mail Vincent Sanders
There's lots more to the site! A good place to start is the Main Page.
100% hand typed HTML
© Vincent Sanders
$Id: index.html,v 1.1 2002/12/14 21:14:04 vince Exp $