MicroWebServer

From Wiki

(Difference between revisions)
Jump to: navigation, search
(New page: en:MicroWebServer {{ProjectFeatures}} ==Einleitung== Der MicroWebServer ist ein kleiner Webserver auf Basis eines ENC28J60 von [http://www.microchip.com Microchip] und eines ATMega168 ...)
Current revision (08:05, 13 August 2008) (edit) (undo)
(Setup)
 
(18 intermediate revisions not shown.)
Line 1: Line 1:
-
[[en:MicroWebServer]]
+
[[de:MicroWebServer]]
{{ProjectFeatures}}
{{ProjectFeatures}}
-
==Einleitung==
+
==Introduction==
-
Der MicroWebServer ist ein kleiner Webserver auf Basis eines ENC28J60 von [http://www.microchip.com Microchip] und eines ATMega168 von [http://www.atmel.com/ Atmel].
+
The MicroWebServer is a small Webserver using the popular ENC28J60 (produced by [http://www.microchip.com Microchip]) and an ATMega168 AVR ([http://www.atmel.com/ Atmel]).
-
Der MicroWebServer wurde mit dem Hintergedanken entwickelt, eine möglichst kleine Entwicklungsplattform für einen ENC28J60-Treiber zu schaffen, die auch danach noch sinnvoll eingesetzt werden kann. Dafür wurden diverse Pins des ATMega168 auf eine Pfostenleiste gelegt, sodass man eine Grundplatine erhält, die um eine externe Platine mit beispielsweise Relais erweitert werden kann. Die Möglichkeiten an dieser Stelle sind sehr vielfältig.
+
It was designed to act as a platform for developing hardware-drivers for the ENC28J60 which still should be useful afterwards. In order to be useful, the MicroWebServer extends the unused I/O-pins to a 20 pole extension header that can be connected to another circuit board with relays, just to mention one example.
==Hardware==
==Hardware==
-
===Platine===
+
===Board===
-
Wie man sieht, ist das Layout also sehr allgemein gehalten, sodass es möglich ist die Platine vielseitig zu verwenden. Trotzdem ist das Layout durch die Verwendung von SMD Bauteilen und geringen Isolate-Werten zur Massefläche kompakt geworden. Die Gesamtfläche der Platine beträgt 38x31mm². Die Platine kann einzeln oder in einem Bausatz von dem [http://www.it-wns.de/themes/kategorie/detail.php?artikelid=114&source=2 IT-WNS Shop] bezogen werden. Alternativ lassen sich die Bauteile aber auch von [http://csd-electronics.de/ CSD-Electronics] beziehen. Die Platine muss dann aber selbst hergestellt werden.
+
As you can see, the board-layout has been kept very common. Therefore it is possible to use this board in a versatile way. Still the board has become very compact by using SMD parts and small isolate values regarding the ground plane. The all-over size of the board measures 38x31mm². The board can be bought at [http://www.it-wns.de/themes/kategorie/detail.php?artikelid=114&source=2 IT-WNS Shop] (Germany) either together with the needed electrical components or PCB-only. You can also make the PCB yourself and order the components at some random shop.
-
===Spannungsregler===
+
===Voltage regulator===
-
Auf der Platine befindet sich auch ein 3,3V Spannungsregler ([http://www.national.com/mpf/LM/LM1117.html LM1117]). Bei einem durchschnittlichem Gestamtstromverbrauch von etwa 150mA und bei etwa 1,1V Dropout Spannung, die bei diesem Strom entsteht, habe ich die maximale Eingangsspannung auf 7V und die optimale Eingangsspannung auf 5V festgelegt. Die minimale Eingangsspannung wäre in diesem Falle etwa 4,4V.
+
Among the electrical components there is a 3.3V fixed voltage regulator ([http://www.national.com/mpf/LM/LM1117.html LM1117]). With an average drawn current of 150mA and with the approximately 1.1V dropout voltage, I have decided to set the mark of maximum input voltage to 7V and the minimum input voltage to 5V. The absolute minimum input voltage is 4.4V.
{{Attention
{{Attention
-
|Die 3,3V, die von dem Spannungsregler erzeugt werden, liegen auch am 20-poligen Pfostenstecker an. Über den Pfostenstecker sollte man auf der 3,3V Leitung nicht mehr als etwa 350mA bei einer Eingangsspannung von 5V fließen lassen. Die Verlustleistung des Reglers liegt hier schon bei etwa 0,6W, was angesichts der kleinen Kühlfläche hohe Temperaturen erzeugen kann. Sollte die Eingangsspannung sogar höher als 5V sein, ist dringend davon abzuraten einen Strom in dieser Höhe über den Pfostenstecker zu beziehen.
+
|The generated 3.3V are also available on the 20 pol extension header. Be sure that you dont draw more than 350mA on this line when you use an input voltage of 5V (Already about 0.6W power dissipation!). If you are even using 7V as input voltage, you shouldn't draw that much current at all.
}}
}}
-
===Ethernet-Buchse===
+
===Ethernet-Jack===
-
Der [http://www.it-wns.de/themes/kategorie/detail.php?artikelid=114&source=2 IT-WNS Shop] liefert mehrere verschiedene Versionen des Bausatzes aus, da es zeitweilig Probleme mit der Beschaffung der vorgesehenen Ethernet-Buchse gab. Da diese neue Buchse unter anderem auch ein anderes Pinout hat, sind mehrere Versionen der MicroWebServer-Platine im Umlauf.
+
The [http://www.it-wns.de/themes/kategorie/detail.php?artikelid=114&source=2 IT-WNS Shop] ships different versions of the kit, depending on what ethernet-jack is currently available. Therefore there are two different board-layouts, since the original '''MagJack SI-60024-F''' uses another pinout than the '''Halo FastJack™ HFJ11-2450E-L12RL''' or '''ERNI Modular Jack M3D01-203199'''. Moreover the pinout of the integrated LEDs isn't always the same, so either you accept that you have some swapped colors or you change the initialization word of the ENC28J60 chip, which needs a recompile of the project (See {{ProjectLinkFAQ}}).
-
Desweiteren ist die Belegung der Leuchtdioden an selbigem nicht immer gleich, sodass man entweder unterschiedliche Farben für die Sende-/Empfangsaktivität bzw. Ethernet Link hat, oder das Initialisierungswort des ENC28J60 so anpasst, dass die Funktion der Leuchtdioden getauscht wird. (Siehe {{ProjectLinkFAQ}})
+
-
Die verwendete(n) Ethernet-Buchse(n) hat/haben einen Ethernet-Übertrager integriert, was das Layout um einiges verkleinert hat. Dieser Übertrager ist nötig um das Potential des MicroWebServers von dem Potential auf den Netzwerkleitungen zu trennen. (Galvanische Trennung).
+
The mentioned ethernet-jacks integrate an isolating ethernet-transformer needed for the electrical isolation according to the ethernet specifications.
-
In der ersten Version des MicroWebServers war dies die "Magjack SI-60024-F" Buchse. In den neueren Versionen wird entweder die "Halo FastJack™ HFJ11-2450E-L12RL" oder die "ERNI Modular Jack M3D01-203199" Buchse verwendet.
+
-
===Pfostenleiste===
+
===Extension header===
-
Der MicroWebServer bietet eine 20-polige Pfostenleiste um die 14 darauf gelegten Ein-/Ausgänge sauber mit externer Peripherie zu verbinden. An diesem 20-poligen Steckverbinder befinden sich neben 2xGND, 2xEingangsspannung und 2x3,3V, wie gesagt, die 14 Pins des ATMega168.
+
The MicroWebServer offers a 20 pole extension header to connect the 14 I/Os to external periphery. The remaining 6 pins on the extension header are 2xGND, 2x3.3V and 2xVin.
-
Alle dieser 14 Pins können als normale Ein- oder Ausgänge geschaltet werden. Manche dieser Pins besitzen aber auch Spezialfunktionen, wie zum Beispiel ein integriertes I²C Modul ('''Keine Pull-Ups auf der Platine vorhanden!'''), 6 analoge Eingänge die auf den internen 10-Bit AD-Konverter gehen ('''Kondensator an AREF ist auf dem Layout vorgesehen. Typisch: 100nF. Als Referenz können die 3,3V aus dem Spannungsregler, sowie 1,1V intern gewählt werden.'''), sowie diverse Output-Compare Einheiten um Signalformen für beispielsweise PWM zu erzeugen. Jeder der 14 Pins ist zudem noch fähig einen Pin-Change-Interrupt auszulösen.
+
All of the 14 I/Os can be configured to act as an input or output. Some of the pins utilize a special function like for example an integrated I²C module ('''No integrated pull-ups on board''') or a 10-Bit A/D Converter ('''Reference decoupling capacitor present on board''') using a reference voltage of 3.3V or 1.1V integrated. Moreover there are pins having an output-compare function to produce PWM waveforms for example. Also all of the 14 I/Os can trigger a pin-change interrupt.
==Software==
==Software==
-
===Netzwerk-Stack===
+
===Network-Stack===
-
Als Netzwerk Stack kommt der [http://www.sics.se/~adam/uip/index.php uip-Stack] von Adam Dunkels zur Verwendung. Er implementiert die Netzwerkfähigkeiten der höherliegenden Schichten (insgesamt IP, ARP (Echo), ICMP, UDP, TCP).
+
The [http://www.sics.se/~adam/uip/index.php uip-Stack] is used to implement the upper network-layers (IP, ARP (Echo), ICMP, UDP and TCP).
-
===Stack-Applikation===
+
===Stack-Application===
-
Zur Demonstration ist dem Downloadpaket eine klassische Webserver-Anwendung beigelegt. Diese Applikation liegt in der obersten Schicht des OSI Modells und somit über dem uip-Stack.
+
For demonstration purposes there is a usual webserver-application added to the download-package. This application takes place on the top of the stack (according to the OSI layer model). It implements a server for webpages that can be accessed by a regular internet browser. The server currently supports GET and POST request, to configure the 14 I/Os on the extension headers or set the output value of those. (HIGH +3.3V, LOW 0V)
-
Die Anwendung implementiert einen einfachen Webserver, der über einen Browser abgefragt werden kann (GET) und über diesen auch Daten wieder empfangen kann(POST). Mit der Beispielapplikation können die 14 herausgeführten Pins an der 20-poligen Pfostenleiste auf Ein- oder Ausgang geschaltet werden, sowie in ihrem Pegel (HIGH +5V, LOW 0V) verändert werden.
+
-
==Zusammenbau==
+
==Assembly==
-
===Was wird benötigt===
+
===Necessary tools===
-
*Lötkolben (SMD tauglich)
+
*Soldering iron (SMD capable)
-
*Fortgeschrittene Löterfahrung (0805-SMD, TQFP44)
+
*Advanced soldering experience (0805-SMD, TQFP44)
-
*Atmel AVR Programmiergerät mit 6poligem Stecker und Kompatibilität für 3,3V Zielspannung
+
*Atmel AVR programmer with a 6 pin header and compability for 3.3V target voltage
-
*Spannungsquelle 5V - 7V DC mit mindestens 150mA
+
*Voltage source of 5V - 7V and at least 150mA
-
===Bestückung===
+
===Mounting===
-
#niedrige Bauelemente wie 0805 Kondensatoren/Widerstände bestücken
+
#lower parts like 0805 capacitors/resistors
-
#ATMega168, ENC28J60 und LM1117 bestücken
+
#ATMega168, ENC28J60 and LM1117
-
#Quarz und andere Kondensatoren bestücken
+
#crystal and remaining capacitors
-
#Pfostenleisten bestücken
+
#pinheaders
-
#Ethernet-Buchse bestücken
+
#ethernet jack
-
*Lötkolben nicht zu lange an das gleiche Bauteil halten
+
*Don't heat up a single part too long
-
*Vorsichtig löten um keine schwer auffindbaren Lötbrücken einzubauen
+
*Solder carefully without creating short circuits
-
*Wenn nötig mit Lupe oder Mikroskop löten
+
*If necessary, use a magnifier or microscope while soldering
-
===Inbetriebnahme===
+
===Setup===
-
#Sources herunterladen ({{ProjectLinkDownloads}})
+
#Download sources ({{ProjectLinkDownloads}})
-
#Am Netzwerk anschließen
+
#Connect to network via RJ45 connector patch cable
-
#Spannungsquelle an die 2-polige Stiftleiste anschließen (Polung beachten!)
+
#Connect voltage source to 2-pin header
-
#Programmiergerät an 6-poliger Programmierschnittstelle anschließen
+
#Connect programmer to 6-pin header
-
#Optional: Programm modifizieren und neu kompilieren (siehe [[#Konfiguration]])
+
#Optional: Modify sources and recompile (See [[#Configuration]])
-
#HEX-Datei in den Mikrocontroller flashen
+
#Flash HEX file into microcontroller using the programmer
-
#Fuses des AVR modifizieren ('''LFuse:''' E0h, '''HFuse''': DDh)
+
#Modify Fuse-bits of AVR ('''LFuse:''' E0h, '''HFuse''': DDh)
-
##Taktquelle auf Ext. Clock stellen (Startup Time 65ms)
+
##Use ext. clock as clock-source (startup-time: 65ms)
-
##Brown Out Detector auf 2,7V einstellen
+
##enable Brown Out Detector using 2.7V as threshold
-
Nach dem Programmiervorgang wird der Mikrocontroller automatisch gestartet und beginnt den ENC28J60 zu initialisieren und seine eigene Taktquelle auf 12,5MHz einzustellen. Ab jetzt sollte die grüne Leuchtdiode an der Netzwerkbuchse dauerhaft leuchten und bei Empfangsaktivität erlischen. Die andere (rote/gelbe) Leuchtdiode leuchtet bei Sendeaktivität.
+
After successfully programming the AVR, it automatically begins to initialize the ENC28J60 and switches to 12.5MHz main-clock. Now the green light of the ethernet should be glowing. This means that the ENC28J60 sensed an ethernet connection. The green light goes off while packets are being received. If packets are being sent, the red light begins to light up.
-
 
+
-
Nachdem an die 2 polige Stiftleiste eine Spannung von etwa 5V - 7V DC angelegt wurde und ein Netzwerkkabel eingesteckt wurde, sollte sich etwas an den Leuchtdioden der Netzwerkbuchse tun.
+
-
eine grüne Leuchtdiode an der Ethernet-Buchse leuchten. Dies bedeutet, dass ein Ethernet Link hergestellt ist. Auf der grünen Leuchtdiode wird außerdem die Empfangsaktivität des Ethernet-Chips, durch ein kurzes Erlischen der Leuchtdiode dargestellt. Die andersfarbige Leuchtdiode an der Buchse leuchtet bei Sendeaktivität.
+
{{Attention
{{Attention
-
|Sollte die Leuchtdioden-Konfiguration nicht zufriedenstellend sein, kann diese im Sourcecode angepasst werden. Siehe {{ProjectLinkFAQ}}.
+
|In case you want to alter the LED configuration, you have to adjust some #defines in the source. See {{ProjectLinkFAQ}}.
}}
}}
-
Sofern die Konfiguration in Schritt 5 nicht verändert wurde, sollte der Server unter der IP-Addresse 192.168.0.55 erreichbar sein. Für einen schnellen Funktionstest kann also das Kommandozeilen-Tool "ping" benutzt werden.
+
If the configuration of step 5 hasn't been altered, the server should be available under the IP-address 192.168.0.55. For a quick function test, you can use the command-line tool "ping" to send out ICMP Echo requests:
ping 192.168.0.93
ping 192.168.0.93
-
===Konfiguration===
+
===Configuration===
-
'''Standardkonfiguration:'''
+
'''Initial configuration:'''
-
*MAC-Adresse: 00:03:6F:55:1C:C2
+
*MAC-address: 00:03:6F:55:1C:C2
-
*IP-Adresse: 192.168.0.93
+
*IP-address: 192.168.0.93
-
*Netzmaske: 255.255.255.0
+
*Netmask: 255.255.255.0
*Gateway: 192.168.0.254
*Gateway: 192.168.0.254
-
*Weberver-Port: 8080
+
*WebServer-Port: 8080
-
Die Konfiguration der MAC-Adresse kann in '''Hardware/Enc28j60.h''' angepasst werden. IP-Adresse, Netzmaske und Gateway lassen sich in '''Main.c''' anpassen und der Webserver-Port kann in '''Net/TcpApps/HttpD.h''' angepasst werden.
+
The mac-address configuration can be altered in the file '''Hardware/Enc28j60.h'''. The IP-address, netmask and gateway can be changed within '''Main.c''' and the TCP-port of the WebServer can be configured in '''Net/TcpApps/HttpD.h'''. After every change you have done, you have to recompile the project. It is necessary to have a working installation of AVR-GCC in order to do this.
-
Nach dem Anpassen muss das Projekt neu kompiliert werden. Hierfür muss eine AVR-GCC Installation (zB WinAVR für Windows) vorhanden sein.
+

Current revision

Features

Contents

Introduction

The MicroWebServer is a small Webserver using the popular ENC28J60 (produced by Microchip) and an ATMega168 AVR (Atmel).

It was designed to act as a platform for developing hardware-drivers for the ENC28J60 which still should be useful afterwards. In order to be useful, the MicroWebServer extends the unused I/O-pins to a 20 pole extension header that can be connected to another circuit board with relays, just to mention one example.

Hardware

Board

As you can see, the board-layout has been kept very common. Therefore it is possible to use this board in a versatile way. Still the board has become very compact by using SMD parts and small isolate values regarding the ground plane. The all-over size of the board measures 38x31mm². The board can be bought at IT-WNS Shop (Germany) either together with the needed electrical components or PCB-only. You can also make the PCB yourself and order the components at some random shop.

Voltage regulator

Among the electrical components there is a 3.3V fixed voltage regulator (LM1117). With an average drawn current of 150mA and with the approximately 1.1V dropout voltage, I have decided to set the mark of maximum input voltage to 7V and the minimum input voltage to 5V. The absolute minimum input voltage is 4.4V.

Attention
The generated 3.3V are also available on the 20 pol extension header. Be sure that you dont draw more than 350mA on this line when you use an input voltage of 5V (Already about 0.6W power dissipation!). If you are even using 7V as input voltage, you shouldn't draw that much current at all.

Ethernet-Jack

The IT-WNS Shop ships different versions of the kit, depending on what ethernet-jack is currently available. Therefore there are two different board-layouts, since the original MagJack SI-60024-F uses another pinout than the Halo FastJack™ HFJ11-2450E-L12RL or ERNI Modular Jack M3D01-203199. Moreover the pinout of the integrated LEDs isn't always the same, so either you accept that you have some swapped colors or you change the initialization word of the ENC28J60 chip, which needs a recompile of the project (See FAQ).

The mentioned ethernet-jacks integrate an isolating ethernet-transformer needed for the electrical isolation according to the ethernet specifications.

Extension header

The MicroWebServer offers a 20 pole extension header to connect the 14 I/Os to external periphery. The remaining 6 pins on the extension header are 2xGND, 2x3.3V and 2xVin. All of the 14 I/Os can be configured to act as an input or output. Some of the pins utilize a special function like for example an integrated I²C module (No integrated pull-ups on board) or a 10-Bit A/D Converter (Reference decoupling capacitor present on board) using a reference voltage of 3.3V or 1.1V integrated. Moreover there are pins having an output-compare function to produce PWM waveforms for example. Also all of the 14 I/Os can trigger a pin-change interrupt.

Software

Network-Stack

The uip-Stack is used to implement the upper network-layers (IP, ARP (Echo), ICMP, UDP and TCP).

Stack-Application

For demonstration purposes there is a usual webserver-application added to the download-package. This application takes place on the top of the stack (according to the OSI layer model). It implements a server for webpages that can be accessed by a regular internet browser. The server currently supports GET and POST request, to configure the 14 I/Os on the extension headers or set the output value of those. (HIGH +3.3V, LOW 0V)

Assembly

Necessary tools

  • Soldering iron (SMD capable)
  • Advanced soldering experience (0805-SMD, TQFP44)
  • Atmel AVR programmer with a 6 pin header and compability for 3.3V target voltage
  • Voltage source of 5V - 7V and at least 150mA

Mounting

  1. lower parts like 0805 capacitors/resistors
  2. ATMega168, ENC28J60 and LM1117
  3. crystal and remaining capacitors
  4. pinheaders
  5. ethernet jack
  • Don't heat up a single part too long
  • Solder carefully without creating short circuits
  • If necessary, use a magnifier or microscope while soldering

Setup

  1. Download sources (Downloads)
  2. Connect to network via RJ45 connector patch cable
  3. Connect voltage source to 2-pin header
  4. Connect programmer to 6-pin header
  5. Optional: Modify sources and recompile (See #Configuration)
  6. Flash HEX file into microcontroller using the programmer
  7. Modify Fuse-bits of AVR (LFuse: E0h, HFuse: DDh)
    1. Use ext. clock as clock-source (startup-time: 65ms)
    2. enable Brown Out Detector using 2.7V as threshold

After successfully programming the AVR, it automatically begins to initialize the ENC28J60 and switches to 12.5MHz main-clock. Now the green light of the ethernet should be glowing. This means that the ENC28J60 sensed an ethernet connection. The green light goes off while packets are being received. If packets are being sent, the red light begins to light up.

Attention
In case you want to alter the LED configuration, you have to adjust some #defines in the source. See FAQ.

If the configuration of step 5 hasn't been altered, the server should be available under the IP-address 192.168.0.55. For a quick function test, you can use the command-line tool "ping" to send out ICMP Echo requests:

ping 192.168.0.93

Configuration

Initial configuration:

  • MAC-address: 00:03:6F:55:1C:C2
  • IP-address: 192.168.0.93
  • Netmask: 255.255.255.0
  • Gateway: 192.168.0.254
  • WebServer-Port: 8080

The mac-address configuration can be altered in the file Hardware/Enc28j60.h. The IP-address, netmask and gateway can be changed within Main.c and the TCP-port of the WebServer can be configured in Net/TcpApps/HttpD.h. After every change you have done, you have to recompile the project. It is necessary to have a working installation of AVR-GCC in order to do this.

Personal tools
In other languages