Устройство "Контрольная точка" для оределения доступности учаска сети
Here you find some information to understand the picnic project a bit more. This documentation includes neither summaries of datasheets nor of RFCs (go to the link page and get them yourself) but circuit layouts, software descriptions and general notes. So don't expect me to hold an IP introductory course here.
Table of Contents
PICs and NICs
The list of components you need to get a "picnic compatible" board isn't that long. Summarized in one sentence: take a PIC, connect it to an ISA ethernet card (hosting a network interface controller, short NIC) and plug in the network cable.
A PIC is a member of Microchip's popular PICmicro (TM) line of microcontrollers. I decided to work with a PIC 16F877. Most important, the 16F877 series has a large number of I/O ports. So it is possible to connect the microcontroller's inputs without any sophisticated interface logic one by one to the ISA slot. Also, build-in USART support (RS 232), 8 KB of Flash EEPROM and an A/D converter are big advantages. Two disadvantages of this PIC are on the one hand its 8 bit architecture, which causes some nice overhead when parsing 16-bit based network protocols, and on the other hand the limited RAM (368 bytes). But I didn't want to miss my experience with PICs in this project.
At the beginning of the project I looked for an ISA ethernet card with a well documented onboard chip. In order to make things not worse as they are anyway the card had to be a 8 bit ISA card. The ISA bus protocol is easy to implement and the 8-bit mode of the card reduces comlpexity of the PIC (also 8 bit logic) - NIC interface.
The first (and probably not the worst) card I could get was a ISA NE-2000 compatible card with a Realtek 8019AS chip. Working with this card turned out to be really fine (though the lack of direct memory access makes reading/writing data slow as well as expensive). Documentation is available at Realtek (poor infos on basic operations) and at National Semiconductor (really good NE-2000 description).
I set up a FAQ page to explain in detail which cards are "picnic compatible".
This card has an onboard EEPROM - an ATMEL AT93C46 - where configuration values and PnP information are stored[top]
the curcuit layout
The PIC with power supply, reset circuit and clock source has to be seen as the main unit of the curcuit layout. If you want to keep it simple you only have to add the 36 pin ISA slot for the ethernet card. This configuration is sufficient to run picnic successfully. I added two more components to this basic setup (green in graphics below): First, I connected the PIC to a serial port of my computer, to realize some kind of a debug information port (MAX 232). Second, five programming lines enable in-circuit-programming of the PIC.
Detailed schematics can be found here
Schematics and board were made using Eagle, an Eletronic CAD Software that runs under Windows and Linux. We used the Free version of it, that allows schematics design, has a powerfull auto router for the board layout, and allows boards up to 100 x 80 mm. Thanks to Peter Target who made the board layout and corrected some errors in the schematics.
Eagle Schematics: picnic.sch
Step by step assembly can be done following some steps:
As you can see in the detailed version of the circuit layout, I left as many PORTA I/O pins unconnected as possible. These pins are on the one hand ordinary digital I/O pins and on the other hand input sources for the integrated A/D converter. I didn't connect them in the basic layout to be able to use them in a maybe future project (A/D + ethernet). One of NIC's interrupt line is linked to RB0/INT. A rising edge on this pin causes an interrupt so that PIC can take full advantage of the interrupt capability of the ethernet card.
Attention when connecting this interrupt line! You have to connect the interrupt line your card will use for interrupts![top]
This section will be added as soon as possible. Meanwhile, this page gives you an idea what remote is able to do (see the screenshot - shows an example working session). A full list of all remote commands is given when help or ? is entered in the command line.[top]
PIC software in general
All the PIC software is written in assembler. I have to admit I never had a look at a PIC compiler, but I think the complexity of the picnic project justifies the use of pure assembler. My PIC assembler of choice is the GNU PIC assembler (gpasm), an intended open source replacement for Microchip's MPASM assembler (btw, the picnic sources also compile well with MPASM).
In order to have a chance to understand my own programs, the sources are very well documentated (at least from my point of view). So if the following documentation of the PIC programs looks poor, go on and read the comments in the source.[top]
nicshell was the first PIC software I wrote within the scope of the picnic project. It is based on serial communication between a PC and the PIC; that's why you have to connect the picnic board somehow to a serial port of your workstation (see chapter the circuit layout for details) if you want to use nicshell (this is developing software. if you just want a webserver, you won't need a serial line). If you are looking for a computer program doing the job described below, give remote a try (or any other terminal program).
nicshell offers all important I/O methods to work with an ethernet card:
*) The on board EEPROM is accessed in words!
After you powered the picnic board, you should receive 0xAA over the serial line to indicate, that the PIC is initialized and ready for operation.[top]
I don't want to discuss here every line of code that has been written for the PIC web server. The source code is commented very well - so this is the first address to start learning all about picnic. In the following, I simply want to outline the main design ideas.
After reset, the PIC initializes itself and the ethernet card. These routines are mainly the same as in nicshell. After initialization, PIC does nothing till it catches a NIC interrupt. The interrupt service routine (ISR) reads the ethernet card's interrupt status register and determines, what kind of interrupt occured. Correspending to the result of this test an interrupt handler will be called. The most common (and only supported) case is a "received packet" interrupt.
So the PIC jumps into the reading subroutine and reads the ethernet packet header. From this point the PIC makes the same thing again and again: determine the type of (included) packet/protocol and call the right parser. The last parser will eventually send an answer. In the meaning of modularity every protocol has its own subroutine.
E.g. if we received an ICMP echo request (commonly known as ping request), the basic receiving routine will see an IP packet and call therefore the IP parser. This one will read the IP header and recognize, that the protocol type of the header is set to ICMP. The ICMP parser will process the ICMP header, prepare an eventually answer on the fly and if everything goes well, transmit the answer.
If a parser finds something the PIC software can't handle the processing of the packet will be aborted. If debugging is activated the PIC will send some debug information (one byte in size) over the serial line to the PC. To return to the above example, the PIC would tell the serial port: "got a packet", "good IP packet", "good ICMP packet" and "send ping reply". To resolve the debug byte values, have a look at the software source.
The maximum size of all network packets is limited to the MTU (maximum transmission unit). The current version of webpic doesn't support fragmented IP packets. So if your HTTP request request gets fragmented somewhere, the PIC won't reply. Keep this limit in mind when making your own web pages for the PIC. The MTU is 1500 bytes in common, so a e.g. "ping -s 1472 picnic" (1472 + headers = 1500) would be the longest possible ping request.
The files of the webserver are stored in the program memory of the PIC; a simple "file-system" manages file requests. Files are stored as a series of retlw incstruction. To put your own HTML page in picnic's program memory, you have to create this page, merge it with the HTTP Header and convert it with html2picnic to PIC assembler. At last you have to include the output in files.asm. Once again I want to recommend the source code of files.asm and the documentation of html2picnic for further details.[top]
Before you give the PIC web server a try, you have to configure the source code for your network environment. This sounds horrible but isn't difficult at all. You anly have to change two values in webpic.asm: somewhere at the top of webpic.asm there is a section called Configuration. These lines define six constants:
If you want to replace the web pages included in the picnic code, you have to modify files.asm. You have to insert a record generated by html2picnic.
If reading this documentation resulted in more new questions than in answers to old ones, have a look at the FAQs or contact me:
Программы и прошивки (137 Кб)
Pic Nic (NetPing)
Doc Просмотров: 5387