Posts Tagged ‘hardware’

Web server on a 8051 microcontroller

Monday, December 26th, 2011

A couple of years ago it was rather fashionable to create a web server in a microcontroller, most often in a Microchip PIC 16F84. The latter has been chosen because of easy programmability, I surmise.

But each implementation had at least one thing about it I disliked: One used a preprocessor to translate web page contents to TCP/IP packet payloads, which required one additional step before compiling, another one used an external EEPROM for storage of the said contents; a third one did not have an external EEPROM, but had much less than 1 kb for web page data storage. Besides, almost all of them had been written in assembler. These implementations impressed me, but they did not have enough appeal for being rebuilt.

All of a sudden, seeing easily programmable 8051 clones from Atmel, which had between 16 and 64 kb flash memory and (as all 8051-based microcontrollers have) a hardware UART, I decided to implement a minimal web server by myself, choosing C as the appropriate programming language. This can be seen as an experiment in compatiblity, both in hardware, because the resulting web server runs on any 8051 clone with enough program memory and in software, because it might be ported to any architecture, for which a C compiler exists.

The first of the mentioned implementations, Miniweb, appeared to be a good starting point before the discovery that fixed TCP/IP packets made it somewhat inflexible. Another implementation, phpstack, by the same author, came as the main inspiration instead.

The results are packed into the file httppong.zip. Much information about the development, as well as the BSD license, under which this web server implementation is published, reside in the file Readme.txt.

Working with the 8051 architecture meant to stick with SDCC. The development was conducted under Windows; instead of using a building utility such as make, two DOS batch files were used, c.bat for compilation and conversion of the resulting file to the programmable Intel HEX format and c-clean.bat for cleaning the directory. The server communicates over a SLIP connexion (therefore you will need a serial port), using the address 192.168.3.2, communicating with 2400 bps at tact frequency of 12 MHz, or 4800 bps at 24 MHz. Internally, the server uses the standard 8051 UART and Timer1 to generate correct timings for the UART. The most basic, characters only, connexion, resides in the file pingpong.c. It answers the input ping with pong (it just translates an i to o, echoing all other characters back), hence the naming of all source files, as all implementations are expected to answer reactively to the input. Next higher implementation, SLIP only, is implemented in the file slippong.c. An implementation using IP is in the file ippong.c. It also implements ICMP, so from this implementation on, you may ping the server and receive answers. TCP is added in the file tcppong.c. The final implementation is in the file httppong.c. The file httppong.hex contains ready-to-flash firmware, working at the aforementioned IP address with the aforementioned parameters.

The implementation uses 76 bytes of RAM and (with current HTML data) 2950 bytes of ROM. To reduce usage of RAM, banking techniques of the 8051 were employed. Useful data is in the array welcomepage, which was placed in ROM. Update this array with new data. Recompile. Flash. Use.

Contiki port for ez430 RF2500 board

Wednesday, April 28th, 2010

The ez430 RF2500 port of the Contiki OS was created as the entry to the MSP430 Design Contest. Currently the port allows to use one RF2500 board as a terminal and another RF2500 board as a sensor node. For further development your may check out the source code from the repository of Contikiprojects (look for the directory with the same name as the server this blog is hosted on). Both the documentation and the source code archive can be found at its software page in this blog.

Touch Demo Drum Board

Sunday, February 28th, 2010


Have you seen this video already? No? Then it is time to do so.

This music instrument was created a while ago. Recently I was asked whether I would like to put it online. I would.

The video tells (almost) everything. If you want to get the firmware sources or need further explanations, go to this projects software page.

One Bit Groovebox for AVR Butterfly

Sunday, November 15th, 2009

This time it is a hardware device. One Bit Groovebox is a synthesizer which produces one bit sound waves. It was created by Noah Vawter (original page at http://web.media.mit.edu/~nvawter/projects/1bit/). The code from the original device was ported to run on AVR Butterfly (with a minor hardware addition), which is a very nice application board from Atmel. Look it up at http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146.

The source code resides in the file OBG-BF.zip. Both hardware addition and the installation process are described in the ReadMe.txt file (in the archive too). The sounds are the same as in the original One Bit Groovebox device.

If you would like to know somewhat more, go to the software page of the project.