PIC16F84 Simple PICmicro Web Server

| July 16, 2023 Updated
PIC16F84  Simple PICmicro Web Server

There is a project that I am curious about and want to try, there are two projects with web server 16f84. The circuits are serial and parallel port connected and 24c256 eeprom is used in the circuits, pic and epprom communication can be an example.

PIC Web Server (PIC16F84 )

HTTP 1.0 web server
miniature TCP/IP application
RS232 level SLIP interface
32kB file storage for up to 99 files

Inspired by the ongoing ‘world’s smallest web server’ thread, but certainly not a competitor, this tiny HTTP server uses a PIC16F84 microcontroller to serve files stored in a serial EEPROM over an RS-232 Serial Line IP (SLIP) connection.

The project hardware includes 3 main components: a Maxim MAX233 RS232 transmitter/receiver to provide a true RS232-level serial interface, a 10 MHz 16F84 PIC microcontroller that provides the operational heart of the server, and a 256kb serial (I2C bus) EEPROM server’s file system. LEDs report incoming and outgoing data.

I have socketed the microcontroller and EEPROM to allow them to be removed for reprogramming, but you may want to add some provisions for in-circuit programming of these parts, especially if surface mount construction is used.

border-bolme

PIC16F84 Web Server Schematic

web-server-pic16f84 www-server-in-a-pic16f84-24c256-eeprom

pic16f84-eeprom-basit-web-server

Features:

Soft UART baud rate : up to 38400
HTTP port : 1..255
Maximum TCP window size :128 (up to 255)
Program ROM use :about 400×14
RAM use : 32×8
Internal storage for www-pages :1K
External storage for www-pages : up to 8M

Software

The PIC code is written in C using the PCM compiler from Special Computer Services.

The server code implements a minimal subset of TCP/IP standards that are sufficient to provide basic functionality but rely on the SLIP server and client implementation to fill in the gaps. A stateless TCP/IP model is used; The only information kept between requests is the server IP packet ID number, which increases each time a packet is served, and the first server TCP sequence number, which increases by 64000 each time a new connection is requested.

When a packet arrives at the server, the incoming bytes are decoded by SLIP and the fields required to reply to the packet are retained. A 20-byte IP header is assumed and all TCP options are ignored – a standard 576 MTU if used. Connection attempts to TCP ports other than the defined HTTP port (usually 80) generate a TCP ReSeT response, while received non-TCP packets are silently discarded.

Server files have 2-digit identifiers in the range 01 to 99. The file system used in the external EEPROM is detailed below. A default ‘/’ request is served to file 01, while requests for non-existent files or invalid filenames will receive a ‘404 error’ page with the correct title. Files of multiple MTU lengths can be served, but stateless TCP/IP requires that each requested file be served in full so that more packets can be answered. Therefore, larger files should be avoided if the server does not appear to be responding.

The server does not retransmit lost packets and client ACKs are ignored – if no response is received, the client is assumed to retransmit its request. Client FINs are not processed; in normal operation, these are not expected, as the server closes the connection after the requested file is served, and an acknowledgment-free RST is received if the client cancels the connection (for example, when the browser is closed).

Network connection

The server hex file in the download package is configured as HTTP port 80 and IP local address 192.168.2.3 – these values are defined at the top of the C list.

The PIC server relies on a host SLIP server (typically running Linux or some form of BSD) to provide network connectivity. The exact commands for installing the SLIP server on the host will depend on the operating system you are using. These work for FreeBSD 3.3:

lath -h -l -n -s 19200 /dev/cuaa3
ifconfig sl0 192.168.2.2 192.168.2.3 up

(The first IP number identifies the server-side address of the SLIP connection). To make the PIC server accessible to other machines on the network, routing must also be set and an ARP entry added on the SLIP server.

A freely downloadable BSD/Linux utility that decodes tcpdump output, tcpshow is very helpful when observing packets traveling through a SLIP link – on FreeBSD with tcpshow installed, this command gives a live, human-readable view of the data exchanged between tcpdump. PIC and SLIP server:

tcpdump -s 1518 -lenx -i sl0 -S | tcpshow -pp -cooked -track

EEPROM File System

The first 400 bytes of the EEPROM contain the File Allocation Table. Each file has a 4-byte entry: the first two bytes hold the start byte of the file and the second two bytes hold the length of the file.

The first four bytes (i.e. 0h-3h) should point to the ‘File not found’ page.
The second four bytes (ie 4h-7h) point to index page 01.
Byte 8h-18Fh reference files 02 – 99
Unused file entries should point to the ‘File not found’ page

Each file starts with its own HTTP header followed by two CR/LFs.

source sxlist.com

PIC16F84 Web Server project files alternative link:

PIC16F84 Simple PICmicro Web Server

Password: 320volt.com

Published: 2009/01/26 Tags: , , ,



1 Comment “PIC16F84 Simple PICmicro Web Server

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Comment moderation is enabled. Your comment may take some time to appear.