This is a continuation of the article on an AVR microcontroller-based Ethernet device. The hardware remains unchanged (ENC28J60 + ATmega88), but the software has been updated to include a web server. Instead of using a command line application to send UDP packets to the Ethernet device, users can now simply access it via a web browser. The web server is added while retaining the existing UDP-based functionality, allowing the use of both interfaces. Although a UDP command interface suffices for many applications, an integrated web server is more universal and user-friendly.
To build a web server into an ATmega88 chip, initial prototyping indicated that UDP was manageable with ample memory available on the ATmega88, leading to confidence in the feasibility of TCP + HTTP. TCP/IP, developed over 25 years ago, provides computing capabilities comparable to standard computers of that era. The TCP protocol establishes a connection through the exchange of packets, allowing for the transmission of multiple data packets. This ensures that user data arrives in the correct order and without loss.
The application discussed in the initial article focuses on simple on/off control, which can be executed via a basic web page. Other potential applications include measuring temperature or air pressure, all of which involve minimal data transmission—less than 100 bytes, including HTML tags. The primary advantage of TCP lies in its ability to send multiple packets; however, for this application, the requirement is simplified to sending a single packet. Consequently, the TCP protocol and state management can be streamlined, allowing for immediate transmission of the FIN signal with the data, simplifying connection closure.
This approach enables the implementation of a web server on the ATmega88 while retaining over 50% of the chip's memory for additional applications. The eth_rem_dev_tcp-2.X software provides a basic switching function, secured by a simple password mechanism to prevent unauthorized access. The relevant code is included at the end of the article, along with explanations to facilitate modifications for various applications.
The Single Data Packet web server will navigate through the necessary TCP states, demonstrating a straightforward command and action sequence. The functions required for this operation are implemented in the file ip_arp_udp_tcp.c, while the main.c file contains the data reception loop with conditional statements to determine the appropriate actions. This code also distinguishes between UDP and TCP traffic on port 80 (designated for the web server). Users interested in creating their own applications, such as reading temperature or air pressure, can modify the code above the call to the function print_webpage and adjust the print_webpage function to display custom web content. The file enc28j60.c serves as the driver for the Ethernet chip, ensuring seamless integration without requiring extensive user intervention.This is a continuation of the article An AVR microcontroller based Ethernet device. The hardware is still the same (ENC28J60 + atmega88). The software is now updated to provide also a web-server. That is: instead of using a command line application and send UDP packets to the Ethernet device we can just point our web browser to it. . and even bet ter: we add only the web server and all the UDP based functionality is still there. Now you can use both! A UDP command interface is sufficient for most applications but an integrated web-server is much more universal and easier to use. How to build a web server into an atmega88 chip Before starting this Ethernet project I did of course some prototyping and then I noticed already that UDP was not a problem with lots of space left on the atmega88.
Therefore I was quite confident that TCP + HTTP will work. TCP/IP was invented more than 25 years ago. Todays microcontrollers provide almost the computing power a standard computer had at that time. No java or xml was used at that time. Things were done in smart and efficient ways. TCP is a protocol where one establishes a connection. For this a number of packets are first exchanged and both sides of the connection go through several states [see tcp state machine from rfc793]. Once the connection is established a number of data packets can be sent. More than one packet, large amounts of data can be sent. Counters and the state machine ensure that the actual user data arrives in correct order and without data loss.
Let`s take a look at the application introduced in the first article [June 2006, article060601]. In this first article we just switch on and off something. It can be done with a simple web page which might look like this: Other applications might be measurement of temperature or air pressure. Those are all small web pages with is very little data. In other words we will send less than 100 bytes including all the html tags. How many IP packets with data will be sent for such a page The whole point of using TCP is that one can send more than one packet of data but we don`t need that functionality.
We need TCP only because HTTP is based on it and we want HTTP in order to use our web browser. Under the assumption that you will never need to send more than one packet with data the whole TCP protocol and state handling can be simplified a lot. We can e. g send the FIN immediately together with the data. This makes the state handling for the closing of the connection very simple. Under this assumption it possible to implement a web-server in a atmega88 and have just under 50% of the chip`s memory still free for the actual application.
The application that the eth_rem_dev_tcp-2. X software implements is a simple switch. You can switch on or off something. A simple password mechanism provides very basic protection to avoid that unauthorized users toggle the switch. The code is available at the end of the article and I will explain it a bit. That way you will hopefully be able to modify it and adapt it also to other applications. The Single Data Packet web-server will go through the following TCP states : As you can see this is a quite simple command and action sequence.
I have implemented the needed functions for this the file ip_arp_udp_tcp. c The file main. c is where the receive loop for the data is implemented. main. c has in this loop a number of if statements in order to decide what action to take. Here you will also see that the code branches between udp and tcp with port 80 (=web-server). If you want to implement your own application (e. g read temperatures, air pressure, whatever. ) the you just need to modify the code above the call to the function print_webpage and modify the function print_webpage in order to print your own webpage. All this is in the file main. c The file enc28j60. c implements the driver to the Ethernet chip. You don`t have to worry about the enc28 🔗 External reference
Acquire all the components required for this lecture here. It is highly recommended to obtain a multimeter with a continuity setting. A quality multimeter with this feature typically costs around $60, while premium models can reach $300. The $60...
A smart card is designed using EEPROM chips, while smart card readers utilize a Renesas microcontroller. The card reader reads data from the smart card and transmits it to a computer via its serial port. Access is granted only...
A common requirement across various applications is a continuous signal source that produces a regular and definable waveform. Among these waveforms, the square wave is particularly significant. The circuit described utilizes a comparator featuring both positive and negative feedback...
The widespread application of Flash technology in microprocessors has led to significant advancements in the development and utilization of one-chip computers. Designers have transitioned from traditional in-circuit emulators (ICE) and JTAG interfaces to more cost-effective and user-friendly development methods....
This series of lectures is designed for individuals with a basic understanding of electronics, such as sophomores in Electrical and Computer Engineering, to explore the field of Embedded Electronics. It is assumed that the reader has a fundamental knowledge...
Fixed some issues with the Benito Arduino programmer and upgraded it to the latest version of the LUFA library. There was a mismatch between the INF file and the library-supplied descriptors. Apologies to the two XP users. As this...
We use cookies to enhance your experience, analyze traffic, and serve personalized ads.
By clicking "Accept", you agree to our use of cookies.
Learn more