Documente Academic
Documente Profesional
Documente Cultură
1
Acknowledgement
I would like to express my gratitude to all those who gave me the possibility to complete this
project. I want to thank Mr. Satyadev Vyas ( Head Of Department, Electronics and
Communication Engineering)(inhouse supervisor) encouraged us to go ahead with my project
subject
2
Certificate page3
Synopsis Of the Project
Name
Main project
3. Theoretical background
4. Definition of problem
6. System planning
Annexure
3. List of tables,figures
4
MAIN REPORT
I like my xerox laser printer because it is reliable and prints in good quality. However normally I
print a couple of pages in a row and then for a long time nothing. The printer will go into sleep
mode after 15 minutes but until then it has a loud fan an consumes a lot of power. I could walk to
the printer, switch it on, go back to the computer, print, walk back to the printer and switch it off
but it would be much nicer if one could switch on/off the printer remotely.
Preparing fresh coffee for the break while you are giving a presentation
This is an idea which a customer had who bought the kit at shop.tuxgraphics.org.
You attach a coffee machine to the avr web server and fill the coffee machine with water, coffee
powder,... Now you can give a nice and inspiring presentation to your customers. Shortly before
the end of your presentation you can switch on the coffee machine directly from your computer
and without leaving the room. .... and you can serve fresh coffee for the break.
With a network enabled microcontroller such as our avr web server you can of course control
anything from anywhere in the world if you connect this device to the internet.
5
Mobile phones have these days integrated web browsers. In other words you don't even need a
computer to switch on/off a coffee machine, control the heating in your house,...
All DSL routers include these days already a firewall and something called NAT (network
address translation). This NAT feature allows you to use the internet from several computers at
the same time. Inside you network you use a private address range (e.g 192.168.0.1 up to
192.168.0.254) while your internet service provider has actually given you only a single public
address e.g 216.109.112.2. The translation (NAT) between private and public addresses is
possible because udp/tcp uses also two (client and server) 16 bit numbers called port numbers for
each connection.
Theoretical Background :
To make webserver the Ethernet should be interface with microcontroller. Here I have used the
microchip’s Ethernet controller enc28j60.
The ENC28J60 from Microchip is a fantastic chip. It has Tx/Rx, MAC and PHY in one small
chip. There are very few external parts. Basically just a crystal and an Ethernet transformer, aka
magnetics. All this comes in an convenient 28-pin DIP package. Easy to solder and perfect for
hobby applications.
The ENC28J60 requires a transformer with a turn ratio of 1:1 certified for 10base-T. There are
some very nice RJ45 connectors called "Magjack" which have already integrated magnetics and
optionally integrated LEDs. In addition you need a small filter coil. A 5mm ferrite bead with 5-7
turns of thin wire seems to work well.
Here I have used the ATMEL’s atmega32 which is the brain of this whole server system.(see
Further details in circuit section)
6
Definition of Problem :
Systems Planning :
Step8: connect board through Ethernet jack with pc & check it on web browser
Methodology :
Step1:
7
Hardwares Used :
1 FERIT 10μH
1 IC1 ATmega32
1 IC2 LM 7805
1 IC3 LM 317
1 IC4 MAX232
1 IC5 ENC28J60-DIL
1 J1 MEB 8P
1 JP2, JP3 1 X 06
1 L1 10μH
1 LED1, LED2, LED3 LED3MM
1 PROG ML10
1 Q1 16Mhz
1 Q2 25Mhz
1 R1 10k
1 R2 470 Ohm
1 R3 270 Ohm
1 R4 1.5 k ohms
1 R5 33k Ohms
2 R6, R7 180 ohms
1 R8 2,7 k Ohm
4 R9, R10, R11, R12 50 ohms
1 TR FB2201
1 X1(instead of this I have used magjack with 2.1 mm jack socket
Inbuilt Ethernet transformer)
1 10baseT magjack stewart connector SI-52008-F-jack magjack
1 X2 SUB-D09F
8
Introduction to the ENC28J60 Ethernet
controller
9
The ENC28J60 from Microchip is a fantastic chip. It has Tx/Rx, MAC and PHY in one small
chip. There are very few external parts. Basically just a crystal and an Ethernet transformer, aka
magnetics. All this comes in an convenient 28-pin DIP package. Easy to solder and perfect for
hobby applications.
The ENC28J60 requires a transformer with a turn ratio of 1:1 certified for 10base-T. There are
some very nice RJ45 connectors called "Magjack" which have already integrated magnetics and
optionally integrated LEDs. In addition you need a small filter coil. A 5mm ferrite bead with 5-7
turns of thin wire seems to work well.
10
SPI Interface with Clock Speeds Up to 20 MHz
Buffer
Auto-Increment
Features
Packets
- Multicast address
- Broadcast address
- Magic Packetô
11
INTRODUCTION TO ATMEL ATMEGA32 MICROCONTROLLER:
Features
8-bit Microcontroller
12
– On-chip 2-cycle Multiplier
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interfa
• Peripheral Features
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
• 8 Single-ended Channels
13
• 2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Stan
• Operating Voltages
• Speed Grades
– Active: 0.6 mA
14
The block diagram
15
16
Ethernet rj45 jack with inbuilt Ethernet transformer “magjack” :
Here the magjack is shown in fig so that there is no need to connect Ethernet transformer with
enc28j60 everything is in the magjack.
Schematic:
17
19
SPI –serial peripheral interface
Features :
20
• Full-duplex, Three-wire Synchronous Data Transfer
The Serial Peripheral Interface (SPI) allows high-speed synchronous data transfer between the
21
The interconnection between Master and Slave CPUs with SPI is shown in Figure. The sys-
tem consists of two Shift Registers, and a Master clock generator. The SPI Master initiates the
communication cycle when pulling low the Slave Select SS pin of the desired Slave. Master and
Slave prepare the data to be sent in their respective Shift Registers, and the Master generates
the required clock pulses on the SCK line to interchange data. Data is always shifted from Mas-
22
ter to Slave on the Master Out – Slave In, MOSI, line, and from Slave to Master on the Master In
– Slave Out, MISO, line. After each data packet, the Master will synchronize the Slave by
pulling
When configured as a Master, the SPI interface has no automatic control of the SS line. This
must be handled by user software before communication can start. When this is done, writing a
byte to the SPI Data Register starts the SPI clock generator, and the hardware shifts the eight
bits into the Slave. After shifting one byte, the SPI clock generator stops, setting the end of
Transmission Flag (SPIF). If the SPI Interrupt Enable bit (SPIE) in the SPCR Register is set, an
interrupt is requested. The Master may continue to shift the next byte by writing it into SPDR, or
signal the end of packet by pulling high the Slave Select, SS line. The last incoming byte will be
When configured as a Slave, the SPI interface will remain sleeping with MISO tri-stated as long
as the SS pin is driven high. In this state, software may update the contents of the SPI Data
Register, SPDR, but the data will not be shifted out by incoming clock pulses on the SCK pin
until the SS pin is driven low. As one byte has been completely shifted, the end of Transmission
Flag, SPIF is set. If the SPI Interrupt Enable bit, SPIE, in the SPCR Register is set, an interrupt
is requested. The Slave may continue to place new data to be sent into SPDR before reading
the incoming data. The last incoming byte will be kept in the Buffer Register for later use.
23
Software code :
#include <avr/io.h>
#include "config.h"
#include "usart.h"
#include "networkcard/enc28j60.h"
#include "networkcard/rtl8019.h"
#include "stack.h"
#include "timer.h"
#include "wol.h"
#include "httpd.h"
#include "cmd.h"
#include "telnetd.h"
#include "ntp.h"
#include "base64.h"
#include "http_get.h"
#include "lcd.h"
#include "udp_lcd.h"
#include "analog.h"
#include "camera/cam.h"
#include "camera/servo.h"
#include "sendmail.h"
#include <avr/eeprom.h>
#include "dhcpc.h"
#include "dnsc.h"
int main(void)
{
DDRA = OUTA;
DDRC = OUTC;
DDRD = OUTD;
unsigned long a;
#if USE_SERVO
servo_init ();
#endif //USE_SERVO
#if USE_ADC
ADC_Init();
#endif
usart_write("\n\rSystem Ready\n\r");
usart_write("Compiliert am "__DATE__" um "__TIME__"\r\n");
usart_write("Compiliert mit GCC Version "__VERSION__"\r\n");
for(a=0;a<1000000;a++){asm("nop");};
stack_init();
httpd_init();
telnetd_init();
24
#if USE_SER_LCD
udp_lcd_init();
lcd_init();
lcd_clear();
back_light = 1;
lcd_print(0,0,"System Ready");
#endif
ETH_INT_ENABLE;
sei();
#if USE_CAM
#if USE_SER_LCD
lcd_print(1,0,"CAMERA INIT");
#endif //USE_SER_LCD
for(a=0;a<2000000;a++){asm("nop");};
cam_init();
max_bytes = cam_picture_store(CAM_RESOLUTION);
#if USE_SER_LCD
back_light = 0;
lcd_print(1,0,"CAMERA READY");
#endif //USE_SER_LCD
#endif //USE_CAM
#if USE_DHCP
dhcp_init();
if ( dhcp() == 0)
{
save_ip_addresses();
}
else
{
usart_write("DHCP fail\r\n");
read_ip_addresses(); //get from EEPROM
}
#endif //USE_DHCP
#if USE_DNS
usart_write("DNS %1i.%1i.%1i.%1i\r\n", dns_server_ip[0],
dns_server_ip[1], dns_server_ip[2], dns_server_ip[3]);
#endif //USE_DNS
#if USE_NTP
#if USE_DNS
dns_init();
if ( dns_resolve("1.de.pool.ntp.org") == 0) //resolve NTP server
{
for (unsigned char count = 0; count<4; count++)
25
{
eeprom_busy_wait ();
eeprom_write_byte((unsigned char *)(NTP_IP_EEPROM_STORE +
count),dns_resolved_ip[count]);
}
}
else
{
usart_write("DNS Err.\r\n");
}
#endif //USE_DNS
ntp_init();
for(a=0;a<1000000;a++){asm("nop");};
ntp_request();
if ( ntp() != 0 )
{
usart_write("NTP Err.\r\n");
}
else
{
command_time();
}
#endif //USE_NTP
#if USE_WOL
wol_init();
#endif //USE_WOL
#if USE_MAIL
mail_client_init();
#endif //USE_MAIL
while(1)
{
#if USE_ADC
ANALOG_ON;
#endif
eth_get_data();
/ if (usart_status.usart_ready){
usart_write("\r\n");
if(extract_cmd(&usart_rx_buffer[0]))
{
usart_write("Ready\r\n\r\n");
}
else
{
usart_write("ERROR\r\n\r\n");
}
usart_status.usart_ready =0;
}
26
#if GET_WEATHER
http_request ();
#endif
#if USE_MAIL
if (mail_enable == 1)
{
mail_enable = 0;
mail_send();
}
#endif //USE_MAIL
#if USE_DHCP
if ( dhcp() != 0) //check for lease timeout
{
usart_write("dhcp lease renewal failed\r\n");
RESET();
}
#endif //USE_DHCP
if(ping.result)
{
usart_write("Get PONG:
%i.%i.%i.%i\r\n",ping.ip1[0],ping.ip1[1],ping.ip1[2],ping.ip1[3]);
ping.result = 0;
}
}//while (1)
return(0);
}
27
Headerfiles:
Httpd.h
#ifndef _HTTPD_H
#define _HTTPD_H
#define HTTPD_PORT 80
#define MAX_VAR_ARRAY 10
#define CONVERSION_BUFFER_LEN 10
#define HTTP_DEBUG(...)
//1
#define TEXT_PLAIN 0
#define TEXT_HTML 1
#define TEXT_HTML_AUTH 2
#define TEXT_CSS 3
#define IMAGE_JPEG 4
#define IMAGE_GIF 5
typedef struct
} WEBPAGE_ITEM;
struct http_table
PGM_P old_page_pointer ;
PGM_P new_page_pointer ;
#if USE_CAM
#endif //USE_CAM
};
//2
#endif //_HTTPD_H
Usart.h:
#ifndef _UART_H
#define _UART_H
#define USART_ECHO 1
#define BUFFER_SIZE 50
char usart_rx_buffer[BUFFER_SIZE];
char *rx_buffer_pointer_in;
char *rx_buffer_pointer_out;
struct {
}usart_status ;
/*
#ifndef SYSCLK
#endif //SYSCLK
*/
//Anpassen der seriellen Schnittstellen Register wenn ein ATMega128 benutzt wird
#endif
#endif
#endif
#endif
//----------------------------------------------------------------------------
void usart_init(unsigned long baudrate);
//----------------------------------------------------------------------------
#endif //_UART_H
This is the small low power embedded system so it is made with the purpose of continuous
running so there is very less maintenance needed. It is a very low power and cheap system.
Enc28j60 of Rs.600
Atmega32 of Rs120
Magjack of Rs 450
Step1: make schematic and layout using eagle cad software and get pcb
I have used stk500 programmer and avr studio 4 with winavr for programming and development.
Annexure :
Brief background of the organization where the student has developed the project:
References :
--Bibliography
TCP/IP Lean: Web Servers for Embedded Systems
By: Jeremy Bentham
--websites
http://www.tuxgraphics.org/
http://www.electronicfr.com/
http://ulrichradig.de/