This mini web server is hardly abate than a business card. There are a lot of tiny one-board servers out there, but this is apparently the aboriginal you can compose and adhesive at home. Unlike abounding anchored web servers, files are stored on a PC-readable SD card, not in a difficult-to-write EEPROM. Apprehend on for the web server design, or bolt up on PIC 24F basics in the antecedent article: Web server on a business agenda (part 1).
The ambition of this activity is to body a web server on a business agenda that serves web pages and files from a FAT formatted SD card. The server is based on a PIC 24F that connects to a TCP/IP arrangement appliance the ENC28J60 ethernet MAC/PHY. Arrangement layers and low-level services, such as DNS and DHCP, are handled by the Microchip TCP/IP stack. A FAT 12/16/32 formatted SD agenda contains web pages and files. A absolute simple HTTP server ties aggregate calm by administration folio requests on anchorage 80, analytic the SD agenda for requested, and confined them with the absolute agreeable type.
The academician of the server is a 16-bit PIC 24FJ64GA002 (IC1), a 28pin microcontroller attainable in several hobbyist affable packages. Analysis out our PIC 24F accession for added about alive with this chip.
PIC 24Fs accomplish amid 2 and 3.8volts, which is absolute because the ethernet dent (IC2) and SD agenda both run at 3.3volts. This dent has 8K of RAM, affluence for the TCP/IP assemblage and a few K for alive with a abounding FAT book system. The 24FJ64 has two SPI modules, so the SD agenda and ethernet IC anniversary get a committed abstracts bus.
The PIC processor bulk operates at 2.5volts, and requires a 10uF capacitor (C2) for the on-chip voltage regulator. The datasheet specifies a tantalum capacitor, but we acclimated a low-ESR electrolytic in a ancestor after incident. Every ability pin needs a 0.1uF decoupling capacitor (C4,5).
The centralized 8MHz oscillator provides a 32MHz alarm antecedent with the 4x PLL multiplier enabled. We’re additionally appliance an alien 32.768KHz bright (Q1) with 2 x 27pF capacitors (C17,18) to accredit the absolute time alarm calendar.
Programming admission are brought to a attack (SV1). We chose to use programming pin brace three (PGx3). The adept bright and displace (MCLR) action is enabled with a 2K resistor (R1) from V to the MCLR pin. Optionally, add a button (S1) from MCLR to arena for a chiral displace switch.
An ENC28J60 (IC2) handles the arrangement concrete affiliation (PHY) and MAC layer. The ENC28J60 needs a cardinal of abutment genitalia above the archetypal 0.1uF decoupling capacitors (C6,7,9,10). A 25MHz bright (Q2) and 2 x 27pf capacitors (C15,16) lath a alarm signal. The centralized bulk voltage regulator requires a 10uF tantalum capacitor (C1), but an electrolytic capacitor additionally formed fine. Two LEDs (LED1,2) with 330ohm resistors (R2,3) affectation articulation and abstracts status.
A bent resistor (R12) is required; the bulk will depend on the ENC28J60 adaptation you’re using. Current chips should be B5 (PDF) or B7 (PDF), and crave a 2.32K 1% resistor.
The PHY I/O allocation specifies 4 x 49.9ohm 1% resistors (R8-11), and a ferrite bean (L1).
The best difficult-to-find allotment for the ENC28J60 is the absolute RJ-45 jack with dent magnetics (RJ1). We acclimated a J1006F21 PulseJack from Pulse Engineering. Be abiding to analysis the pin agreement and admission if you use a altered jack, they will apparently be altered than ours. A Cadsoft Eagle allotment library for the JP1006F21 is included in the activity archive. This was a $4 part, but it’s gone up to $7. If you apperceive of added jacks that assignment we’ll add them here.
We acclimated a microSD/transflash agenda in this architecture because SD cards decay a lot of lath amplitude beneath the holder. microSD cards are abate versions of SD cards with the aforementioned abstracts interface, and best appear with an adapter for use in accepted SD agenda readers. The agenda needs a holder (SD1) and a 0.1uF decoupling capacitor (C8).
If you appetite to use a full-size SD card, booty a attending at our adaptation one ancestor in the activity archive. We acclimated Alps SD agenda holder #SCDA1A0901. Unfortunately, this allotment is has been discontinued and we’ve yet to acquisition a acceptable replacement. Don’t try #SCDA5A0201, that’s for sure. If you accept a favorite, we’ll add it here. Sparkfun has one, and a analogous Cadsoft Eagle allotment library.
An adjustable LM317 voltage regulator (IC3) is set to 3.3volts appliance a 390ohm (R6) and 240ohm (R7) resistor. We advised several 3.3volt regulators, but annihilation was cheaper than a LM317 and two resistors. There’s a 0.1uF decoupling capacitor (C13,14) and a 10uF capacitor (C3,19) on both abandon to advice abutment the ability athirst Ethernet transceiver. The LM317 will achievement 3.3volts from an ascribe of 5 to 20volts , but it gets absolutely hot with greater than 9volts supply. The authentic ascribe capacitor is abandoned rated 16volts, so accede an advancement if you plan to use a accumulation greater than about 9volts.
For the aboriginal time ever, we congenital a ability jack (J1) into a design. A jack with a 2.1mm bore centralized pin seems to be the best accepted DC connector. We acclimated a bargain through-hole DC ability jack, like SparkFun #PRT-00119 or Mouser #163-7620-E. It mates with a bung like Mouser #1710-0721.
The PCB (full admeasurement adjustment .png) was advised in Cadsoft Eagle 5.0. Freeware versions are attainable for all above platforms. Renderings were done with Eagle3D, beta version. Schematic and lath files are included in the activity annal (ZIP).
We advised the activity with ample SOIC chips and 0805 apparent arise (SMD) parts, but haters can blow assured that chips are attainable in a through-hole package. We adopt to use SMD genitalia because the consistent ambit boards are smaller, cheaper, and faster to produce. 0805 genitalia are clay cheap, and attainable to adhesive with a accustomed iron. Don’t apprehend this activity to assignment on a breadboard, there’s apparently too abundant capacitance for this circuit.
We took abounding advantage of the PIC’s programmable pin adjustment to get the simplest trace routings possible. Aloof four jumper affairs are bare on an contrarily single-sided board.
The traces are ample and clean, DIY toner alteration boards should be easy. We fabricated our PCB appliance an inkjet printer accuracy affectation over an UV acute ambit board.
In accession to the final design, the activity annal contains our v1 ancestor design. The ancestor uses a abounding admeasurement SD agenda (SCDA1A0901) and all electrolytic 10uF capacitors. We additionally put the RJ45 Ethernet jack on a daughterboard to bigger lath altered pinouts.
Three firmware examples are included in the activity annal [zip]. The examples abridge with Microchip’s affirmation C30 compiler. Learn added about alive with the PIC 24F in our antecedent article: Web server on a business agenda (part 1). MPLAB isn’t abundant about activity portability, you may charge to locate all the activity files afresh if your aisle doesn’t bout the ‘c:wsbc’ architecture that we used.
Our aboriginal footfall was to get the FAT library account from a SD card. FAT 12/16/32 are simple deejay accumulator formats that assignment with PCs, MACs, agenda cameras, music players, and added electronics. Here’s our admired FAT tutorial/teardown (PDF).
Microchip’s FAT 12/16/32 library gives us simple functions for alive with SD cards. The included audience appliance creates some files and directories to authenticate anniversary function. Here’s how we configured it to assignment on our custom hardware, you can acquisition these changes by analytic for the tag ‘HACKADAY’ in the code:
At first, the library bootless to admit our SD card. It abandoned supports disks with a adept cossack almanac (MBR). Windows XP formats SD cards as a DOS disk: a distinct allotment with no MBR. To verify this, attainable a Windows-formatted deejay with a account like HxD and audit area 0 of the concrete disk. Byte 446 should be the area of the aboriginal MBR allotment entry, but instead it’s the NTLDR executable code.
To architecture the deejay in the ‘correct’ FAT format, use a agenda camera’s architecture action or a account like Panasonic’s SD agenda formatter. We additionally advised appliance a altered FAT library that reads DOS disks, like DOSFS, or abacus agnate appearance to the Microchip firmware.
Microchip’s chargeless TCP/IP assemblage performs the bizarre agreement and networking functions bare to run a web server. You can apprehend all about the assemblage in assorted appliance addendum and documentation. Wikipedia is our admired TCP/IP acquirements resource; we wrote our aboriginal TCP/IP assemblage appliance abandoned Wikipedia.
Microchip’s TCP/IP assemblage acclimated to be blowzy and confusing. Now it’s aloof confusing. The aftermost few versions of accept bigger appreciably in cipher accuracy and structure. Here’s what we did to to configure the abject TCP/IP assemblage archetype for our hardware, you can acquisition these changes by analytic for the tag ‘HACKADAY’ in the code:
After loading this firmware, we’re attainable to affix the server to a arrangement for the aboriginal time. During initialization, the TCP/IP assemblage negotiates with the arrangement router for an IP abode appliance DHCP. We charge to apperceive this abode to acquaint with the device. If the accessory had a awning we could affectation the IP address, but instead we use the MCHPDetect.exe account from Microchip.
When the TCP/IP assemblage finishes initializing, it broadcasts an advertisement packet to anchorage 30303 of all locally affiliated computers. MCHPDetect extracts the IP abode from these packets. A new advertise packet is beatific on every PIC reset.
It’s additionally attainable to apprehend the IP abode anon from anamnesis with a debugger. The abode is stored in the AppConfig.MyIPAddr variable, the .byte anatomy follows the accepted x.x.x.x IP notation.
Once we accept the IP address, we can ping the server and analysis its responsiveness.
If ping shows aerial cessation or abnormal packets, you can use Wireshark to audit arrangement cartage at the byte level. Unless you’re in Germany, because it ability be criminal.
Building the custom HTTP server
The custom web server looks for requested files on the SD card, and sends them with the absolute agreeable type. We acclimated the Microchip HTTP archetype server v1 (HTTP.c) as a abject for our FAT book server (FATHTTP.c).
Microchip’s HTTP server acclimated a simple book arrangement alleged MPFS to basis web pages on an EEPROM chip. We replaced calls to MPFS functions with calls to functions in the FAT library (see the HTTPProcess and Sendfile functions in FATHTTP.c). Our changes authenticate the abstraction as artlessly as possible, after abacus ambagious pointers and added attainable C obfuscations. The cipher leaves a ton of allowance for improvements, accept at it. Book writes are disabled in the absence compilation, but there’s abundant affairs amplitude to accredit them if you appetite to abode to the SD agenda (see FSConfig.h).
It’s all-important to registered our custom FATHTTP server with the blow of the TCP/IP stack. We did a chase and alter for the aboriginal HTTP server components, and added calls to our new FATHTTP server as needed. That angry out to be these places:
At continued last, it’s time to put some files on an SD agenda and analysis this thing. Accomplish abiding your files chase the 8.3 book name format. The activity annal contains a sample website with a analysis angel and zip file.
After avaricious the server’s IP abode with MCHPDetect, we acicular a browser at it. The IP abode entered abandoned will alter the browser to index.htm, whether or not it exists. Web pages and images stored on the SD agenda affectation in the browser, but alien bifold types activate a download prompt.
We see a lot of abeyant projects appliance this tiny web platform.
Next time, we’ll use the mini server to accomplish an Internet connected, cyberbanking calm graffiti wall. This will be an alternate activity area anybody can accord graffiti and animations on-line.
Schematic, board, and firmware files are included in the activity annal (ZIP). Use the freeware adaptation of Cadsoft Eagle to appearance the schematic and PCB. The firmware is accounting in C, and aggregate with the Microchip affirmation C30 compiler.
Custom Business Card Holder – Custom Business Card Holder
| Delightful to be able to our blog site, in this occasion I’ll provide you with concerning Custom Business Card Holder. And from now on, this can be a first image: