Anda di halaman 1dari 66

Final Year Project Report -2012 Embedded Web Based Monitoring and Control system

Group Members:
Omar Sharif Naveed Asad-u-Allah khan Sami-Ul-Haq Samson Iqbal 08-HITEC-EE-133 08-HITEC-EE-131 08-HITEC-EE-150 08-HITEC-EE-151

Project Advisor: Engr. Zeeshan Ahmed


Lecturer, Department of Electrical Engineering

Department of Electrical Engineering


HITEC University Taxila Cantt Pakistan September 2012

Department of Electrical Engineering


HITEC University Taxila Cantt

The project, Embedded Web Based Monitoring and Control system, Presented by

Naveed Asad-u-Allah khan Omar Sharif Sami-Ul-Haq Samson Iqbal

08-HITEC-EE-131 08-HITEC-EE-133 08-HITEC-EE-150 08-HITEC-EE-151

Under the supervision of their project advisor and approved by the project examination committee, has been accepted by the HITEC University, in partial fulfillment of the requirements for the four year degree of BS (Electrical Engineering)

_________________
Engr. Zeeshan Ahmed (Project Advisor)

___________________
Dr. Fawad Ahmed (Project Co-Advisor)

__________________ (Dr. Jameel Ahmed) Head, Department of Electrical Engineering

ii

In The Name of ALLAH, The most Beneficent And Merciful.

iii

DEDICATION

This project is dedicated to our kind and beloved Teachers, and parents who supported us and made us capable of doing this project by giving their attentions to us.

iv

ACKNOWLEDGMENT

We are thankful to HITEC University for giving us this opportunity to do this project by providing his full support and also providing a working environment.

We would like to thank Sir Zeeshan Ahmed, by helping us in providing all the necessary and helpful material for this project being a kind and helpful advisor.

Secondly, we would like to thank Dr Fawad Ahmed, to give us the idea about this project, and supporting us with their full attention and providing us with solutions to problems and helpful lead to sort out our issues regarding our project.

We would like to thank Sir Fawad Salam Khan who helped us regarding the Ethernet and html programming.

Also we would like to thank Sir Adeel Ahmed in helping us to program PIC Microcontroller.

Table of Contents CHAPTER zero .................................................................................................................................


Certificate .......................................................................................................................................... Dedication ......................................................................................................................................... Acknowledgement ............................................................................................................................ Table of Contents .............................................................................................................................. List of Figures ................................................................................................................................... Abstract .............................................................................................................................................

CHAPTER ONE : Introduction ...................................................................................................... 2 1.1 Introduction of Project .............................................................................................................. 2 1.2 Practical Applications of Project ............................................................................................... 2 1.3 SPI Protocols ............................................................................................................................. 3

CHAPTER TWO : Literature Review ............................................................................................ 4 2.1 Existing system ......................................................................................................................... 4 2.2 Drawbacks of existing Systems ................................................................................................ 4 2.2.1 Slow Working ............................................................................................................... 4 2.2.2 Cost .............................................................................................................................. 4 2.2.3 Inconvenience ............................................................................................................... 4 2.2.4 Energy Loss .................................................................................................................. 4 2.3 Proposed System ...................................................................................................................... 5 2.4 Modules of Project .................................................................................................................... 5 2.4.1 Microcontroller Input and Output ................................................................................. 5 2.4.2 Ethernet Module............................................................................................................ 5 2.4.3 Webpage ...................................................................................................................... 6

CHAPTER THREE: Project Review .......................................................................................... 7 3.1 Project Overview ....................................................................................................................... 7 3.2 Analysis of System ................................................................................................................... 8 3.3 Functional Requirements ......................................................................................................... 8 3.4 System Considerations ............................................................................................................. 8

vi

CHAPTER FOUR : Hardware Design and Implementation of System .................................... 10 4.1 LED Bar graph ........................................................................................................................ 10 4.2 Resistor Networks ................................................................................................................... 10 4.3 Bridge Rectifier ....................................................................................................................... 11 4.4 7805 Voltage Regulator ......................................................................................................... 11 4.5 Diode ....................................................................................................................................... 12 4.6 Relays ...................................................................................................................................... 12 4.7 ULN2003A ............................................................................................................................. 12 4.8 Resistor.................................................................................................................................... 13 4.9 ENC28J60 Ethernet Module .................................................................................................. 13 4.10 LED ...................................................................................................................................... 13 4.11 Oscillator .............................................................................................................................. 13 4.12 Connection Diagram ............................................................................................................ 14 4.13 PCB layout Designing .......................................................................................................... 15 4.14 Hardware Designing ............................................................................................................. 16

CHAPTER FIVE : Microcontroller .............................................................................................. 18 5.1 Introduction to Microcontroller............................................................................................... 18 5.2 Why we have chosen PIC Microcontroller ............................................................................. 18 5.3 Applications of PIC Microcontroller....................................................................................... 18 5.4 Advantages of using PIC Microcontroller ............................................................................. 18 5.5 Datasheet of PIC16F887 Microcontroller .............................................................................. 19 5.6 Pin Diagram of PIC16F887 Microcontroller ......................................................................... 19 5.7 Programming of PIC16F887 Microcontroller ....................................................................... 19 5.7.1 Advantages of MIKRO C .......................................................................................... 20 5.7.2 Analog to digital conversion ...................................................................................... 20 5.7.3 Reset of Microcontroller ............................................................................................ 21 5.7.4 LM 35 Temperature Sensor ....................................................................................... 21

CHAPTER SIX : Webpage Development ..................................................................................... 22 6.1 Designing of Webpage ............................................................................................................ 22 6.1.1 HTML (Hyper Text Markup Language) .................................................................... 22

vii

6.1.2 Java Script ................................................................................................................... 22 6.2 Getting started with HTML ................................................................................................... 22 6.3 Using Hyper Text to add structures to webpage .................................................................... 22 6.4 Using a server to Host your page ............................................................................................ 23 6.5 How to create and view an HTML document ........................................................................ 23 6.6 Basic HTML Document Format ............................................................................................. 23 6.7 URL (Uniform Resource Location) ....................................................................................... 24 Code Loaded for HTML Page ...................................................................................................... 24 CHAPTER SEVEN : Ethernet Port ............................................................................................. 25 7.1 Ethernet Port .......................................................................................................................... 25 7.2 Types of Ethernet Port ............................................................................................................ 26 7.3 What is a Packet ...................................................................................................................... 26 7.4 Ethernet Protocols and Protocol Specifications ..................................................................... 27 7.5 Relationship Between Ethernet and TCP/IP .......................................................................... 27 7.6 Seven Layer Model (OSI) ....................................................................................................... 28 7.7 How Encapsulation Works ..................................................................................................... 29 7.8 Control information typically takes one of two forms ............................................................ 29 7.9 Application layer ..................................................................................................................... 29 7.10 Presentation layer .................................................................................................................. 30 7.11 Session Layer ....................................................................................................................... 30 7.12 Transport Layer .................................................................................................................... 30 7.13 Network Layer ..................................................................................................................... 30 7.14 Data link Layer ..................................................................................................................... 30 7.15 ENC28J60 Working Logic ................................................................................................... 31 7.16 Calculations for IP address ................................................................................................... 31 Microcontroller Programming code ............................................................................................. 32

CHAPTER Eight : Recommendations for future work ............................................................. 33 Conclusion ...................................................................................................................................... 34

Appendix A : .................................................................................................................................. 35 Code for HTML webpage ............................................................................................................ 35

viii

Appendix B : .................................................................................................................................. 37 Code for Microcontroller .............................................................................................................. 37

Appendix C : .................................................................................................................................... 41 Datasheet for PIC16F887 Microcontroller ................................................................................... 41 Special features of PIC16F887 Microcontroller (for programming) ........................................... 45 ADC (Analog to Digital Converter) of PIC16F887 Microcontroller ........................................... 48 ULN2003A Datasheet .................................................................................................................. 50 ENC285J60 Datasheet .................................................................................................................. 53

References ........................................................................................................................................ 55

ix

List of Figures
Figure 1.1 Figure 3.1 Figure 4.1 Figure 4.2 Figure 4.3 Figure 4.4 Figure 4.5 Figure 4.6 Figure 4.7 Figure 4.8 Figure 4.9 Figure 4.10 Figure 4.11 SPI Protocol Project Overview LED Bar graph Resistor Network Bridge Rectifier 7805 Voltage Regulator Diode Relay ULN2003A ENC28J60 Circuit Connection Diagram PCB Layout Hardware Design 4 8 11 11 12 12 13 13 13 14 14 15 15

Embedded Web Based Monitoring and Control system


ABSTRACT
Embedded web based monitoring and control system provides the robust solution for communication and control over electronic devices , The idea was to design and develop such a system that will convert a manually controlled home or industrial system in the smart home and industrial system that will be controlled from any place on the earth using internet weather its a GPRS link based or Wired DSL or any other source of internet and as well as from local area network (LAN) .It can also be controlled with only one computer that is independent and has no LAN network . This system enables user to get the status of all the devices in home or industry (that are connected to this system) it also saves a lot of electrical energy and it will also provide a great control over the devices even if the user is at any location far away from his system but internet connection will be required .

In this project we are able to control all our household and industrial electric and electronic devices by using this advance and modern technology .our project aims to remotely control our home appliances like ACs, Fans, Refrigerators, TVs, water pumps, lights and our industrial machinery and other important appliances also the complex operational devices such as Security systems, sensors, cameras, door locks, etc

This project report describes the design, analysis and implementation of home/industrial automation by using internet, by simply connecting our cell phones to internet and entering internet address of our web page and accessing the given controls.

xi

xii

Final Year Project Report -2012

Chapter 1

1.1 Introduction of the project: Human being is the most beloved and unique creation of Almighty Allah and he has given the power to think and research over the whole universe. Now as the human is growing age by age and centuries by centuries, he is being advanced and modernized. Human being is trying to create different type of easy ways or ways of relaxation to fulfill tasks. As the world is becoming globalized, every field of life is becoming auto mobilized. Man is replacing human labor or human force by machinery and circuits. The initialization of this project is also related to such type of thing. In this project a system is tried to be invented or manufactured which is fully automatic and trying to reduce human force. Now the basic concept of this project is to transmit data through static IP upon web server, by using the Ethernet Module and PIC Microcontroller general board and some other devices. The input can be analog or digital example of sensors is smoke sensor, heat sensor etc. The output of the sensor is taken as an input of the Microcontroller and is converted into digital signals. Above given detail clears the whole idea of this project. Lets suppose this system is installed in an organization and one can monitor and manage the whole activities by just a single Static IP. Example can be taken as the security camera or sensor can be directly monitored and controlled by a single control room and the control room can be accessed from anywhere in the world. This is the beauty of the system that if we use a wireless router or a switch to broadcast the data over the wireless LAN to make it easily accessible and this way we will be able to use as many devices as we want.

1.2

Practical application of this project

All the data/sensors and actuator of any organization can be monitored and controlled from the web page. All we have to do is to install our devices on all machines that are to be controlled and get them organized. Particular or specific phenomena such as security system, Electrical control etc., can also be monitored and controlled through this embedded system.

HITEC University Taxila Cantt

Final Year Project Report -2012

1.3 SPI Protocols:


SPI is he quick way to communicate between two digital devices. SPI is a specific protocol for four lines. A clock signal (SCLK) sent from master to slave and the entire signal is synchronous to that signal A slave signal for each slave SS used to select the slave of the master. Data line from Master to Slave is called MOSI (master out-slave in) Data line from slaves to master is called MISO (master in-slave out) The main advantage or the beauty of this project or interface is that it has two same lines for data in and out from the Microcontroller, when we have to transmit or receive data for specific device we simply enable that device for data by giving signal to chip select of that device.

Fig 1.1

SPI protocol
http://en.wikipedia.org/wiki/File:SPI_three_slaves.svg

HITEC University Taxila Cantt

Final Year Project Report -2012

Chapter 2 Literature Review: 2.1 Existing system


We had a visit to FFC (Fuji Fertilizers Company) office situated at Rawalpindi. There a system was installed, accumulating the task to get the values from smoke sensor and transmitting it to the main server room. Our Idea is almost near to that approach. Some of the conventional systems that presently exist in the market for the purpose of transmitting data through (RS 232) serial ports. (Details shown in appendix)

2.2 Drawbacks of existing systems:


There were several draw backs of the existing systems, some of them are:

2.2.1 Slow Working:


Due to serial communication the data transmission was very slow because data was sent packet by packet and one way communication occurring at one time thats why existing systems were working slowly. The maximum baud rate that older system supported was 9600 bauds, but by the use of Ethernet we can have 100MB/SEC speed.

2.2.2 Cost:
Exiting systems were too much costly and due to their high cost range, it was not possible for every forum to install. System installed at FFC was working very good but the total expenditure on that system was about twenty times greater.

2.2.3 Inconvenience:
In this age of science and technology, everything is moving from the manual interfaces because manual tasks are always inconvenient. Same is the case of monitoring and controlling your desired product and project.

2.2.4 Energy loss:


Lets suppose someone forgets to switch off the A.C and the room is empty then its very good to get it monitored and switched off.

HITEC University Taxila Cantt

Final Year Project Report -2012

2.3 Proposed system:


It was desired that a solution should exist that enables a user to get the system remotely monitored and controlled. That system should increase the efficiency, save power, get the transmission speedy and beat the todays world challenges. The basic concept of this project is to transmit data through static IP upon web server, by using the Ethernet port (RJ-45) and PIC Microcontroller. The input can be analog or digital i.e. sensors output example is smoke sensor, heat sensor etc. The output of the sensor is taken as an input of the Microcontroller and processed according to ones requirement, then transmitted that data through Ethernet port to some web server or PC.

2.4 Modules of the project:


Dividing the whole circuitry into modules, we got mainly three modules i.e: Microcontroller Ethernet module Web page Logic Level Shifter IC Power supply Sensors

2.4.1 Microcontroller Analog input and output:


All the PIC microcontrollers have some Analog pins that may be from 2 to 16, the controller which we choose is PIC16F887 and it has 14 analog channels for input, there are many techniques to interface these for external sensors but we are focusing on completely relevant information, we used two LM35 Temperature Sensors directly with analog inputs at AN2 and AN3 and using the Transfer function of the Sensor derived from its information taken from its datasheet that is shown in Appendix C.

2.4.2 Ethernet module:


This module ENC28J60 is used to convert data from SPI format /protocol/interface to Ethernet format/interface or protocol, and similar in reverse order. In fact it takes all the necessary information from the Microcontroller like IP Address, Packet length, Web page etc.

HITEC University Taxila Cantt

Final Year Project Report -2012

2.4.3 Web page:


By using HTML, a page is designed to get the data and store it on some world wide access point so that the data can be accessed, monitored and controlled word widely.

HITEC University Taxila Cantt

Final Year Project Report -2012

Chapter 3

3.1 Project Review


Embedded web-based monitoring and control system means to monitor and control certain system through internet from anywhere in the world. Today with the rapid advancement in technology, it is the need of the time to provide people with latest technology but it must be in purchasing approach of them. This project consist of following modules, o o o o o System to be control PIC Microcontroller Ethernet Module Web-page Sensors and Actuators

Any system that needs to be controlled through internet is connected with PICmicrocontroller and PIC Microcontroller is then connected with Ethernet port of any computer or switch through Ethernet Module. The information sent from Microcontroller, and received at Ethernet port and the packet is finally received by web-page in the form useful information.

Access To system by Single user

Access To system by multiple users

Access To system over internet

HITEC University Taxila Cantt

Final Year Project Report -2012

3.2 Analysis of the system:


Analysis is the engineering task that bridges the interacting entities of the system, analysis enables the engineer to specify functions and performance of system, indicate systems interface with other system elements. We prototyping and object oriented methodology for the analysis of system.

3.3 Functional requirements:


Functional requirements describe the functions or functional behavior of the system, the functions according to the user requirement, how user interacts with the system and how the system behaves with the user.

3.4 System considerations


The following are major considerations that we would see carefully: Remotely monitored Remotely controlled User friendly Reliable Efficient Cost efficient

Flow Chart: The flow chart for the main logic is given below,

HITEC University Taxila Cantt

Final Year Project Report -2012

The flow chart for SPI TCP Function is below:

HITEC University Taxila Cantt

Final Year Project Report -2012

Chapter 4

Hardware Design & Implementation of the system: In this chapter we have covered all the steps that are taken to complete the implementation. Hardware implementation of this project requires the implementation of different modules The main hardware components of our project are as follow. o o o o o o o o Analog Input Microcontroller PIC 16F887 Ethernet module(ENC28J60) Relay Power supply system LED Bar Graph AC/DC Converter Magnetic Contactor For High Current AC

The details of the components used are as follow: 4.1 LED Bar Graph: These are ten individual LED`s, mounted together in a single packing with individual anode and cathode. They have several uses, such as prototyping or finishing products.

Fig 4.1
https://encryptedtbn0.google.com/images?q=tbn:ANd9GcRp_ZFs3gZbqFu1pVRQxtRnJG5JqHuemQNNVFZqaFUyZ KPdfjK2Q

4.2 Resistor Network: These are 330 Ohm resistors mounted together in a single packing, sharing one common terminal as shown in fig 4.2(a).This network works as current limiting resistors for rows of LEDs and two of these can replace 10 individual wire-lead resistors when hooking up our 10 LED bar graph displays. They also work well as pull-down resistors for DIP e switches.

HITEC University Taxila Cantt

10

Final Year Project Report -2012

Fig 4.2(a) Fig4.2 (b)


http://www.sv-components.com/Photos/Resistor%20NW%20SIP.jpg

4.3 Bridge Rectifier: A bridge rectifier is a four diodes device designed in a bridge arrangement to achieve fullwave rectification. This is a widely used configuration, both with individual diodes wired as shown in fig 4.3 (b) and with single component bridges where the diode bridge is wired internally.

Fig 4.3(a)

Fig 4.3(b)

http://media2.rsdelivers.cataloguesolutions.com/LargeProductImages/W7005443-10.jpg

4.4 7805 voltage regulator: L7805 is a three terminal positive voltage regulator. We used this IC to regulate voltage, this regulator provides, voltage regulation and allows current of one ampere to pass if proper heat sink is provided, making it useful in wide range of application and it regulates voltages to 5v DC.

Fig 4.4(a)
http://www.PIClist.com/images/www/hobby_elec/gif/car2_4_22.gif

Fig 4.4(b)

HITEC University Taxila Cantt

11

Final Year Project Report -2012

4.5 Diode (1N4007): The diode made of silicon drops 0.7 Volts across it, so we used two diodes in series to drop 1.4 volts out of 5 volts which is our main regulated supply to obtain 3.6 volts, which is used to provide power to our Ethernet Module. Blocking Voltage range is up to 1000 volt and allows current maximum 1 ampere. Temperature range is -55 to 150 Centigrade.

http://www.hobby-hour.com/electronics/1n4007-diode.gif

4.6 Relay: Relay is electro-mechanical switches that may contain one are more than one switches in a package. And the switches are designed as normal open normal closed and one common point in the circuitry. We used relays in our hardware to drive our respective loads.

http://cantonfair.org/att/images/product/20100731/org_SIiK93eHv60i.jpg

4.7 ULN 2003A: ULN 2003A is a series based resistor for each Darlington pair allowing operation directly with TTL or CMOS operating at a supply voltage of 5 volts. These devices will handle numerous interface needs particularly those beyond the capabilities of standard logic buffer. It is the original high voltage high current Darlington array having output transistors capable of sinking 500 mA and will sustain at least 50 volt in the off state.

http://www.in-car-stuff.com/shop/images/uln2003a_large.jpg

HITEC University Taxila Cantt

12

Final Year Project Report -2012

4.8 Resistors: It is a current limiting device used to limit current and drop the potential. They are available in a wide range of values, and the selection of particular resistor for a particular system depends upon the amount of the current to be limit within that circuit. Therefore we used resistors of 1k Ohm with LED.

http://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Resistor_cropped.jpg/250px-Resistor_cropped.jpg

4.9 ENC28J60: ENC28J60 is a module that is used to transmit data between computers Ethernet port and microcontroller. It actually works as a bridge and provides an interface between these both devices. This module ENC28J60 is used to convert data from SPI format /protocol/interface to Ethernet format/interface/protocol, and similar in reverse order. In fact it takes all the necessary information from the Microcontroller like IP Address, MAC address, Packet length, Web page etc.

WWW.GOOGLE.COM

4.10 LED: LED stands for Light Emitting Diode and it glows only when it is forward biased with in particular range of current and voltage of the LED specification. We used LED in our hardware to show the power on/off status of the system. 4.11 OSCILLATOR The oscillator module has a wide variety of clock sources and selection features allow it to be used in a wide range of applications while maximizing performance and minimizing the power consumption so clock source can be configured from external oscillators.(For details see datasheet of PIC 16F887). There are different types of oscillator, but main are internal and external, these both have wide range of frequencies. The best configuration depends upon users requirement.

HITEC University Taxila Cantt

13

Final Year Project Report -2012

Connection Diagram:

Fig 4.9 Connection Diagram

HITEC University Taxila Cantt

14

Final Year Project Report -2012

PCB LAYOUT DESIGNING:

HITEC University Taxila Cantt

15

Final Year Project Report -2012

Fig 4.10 PCB Layout HARDWARE DESIGNING:

Stage 1:

Fig 4.11 Hardware Design Stage 1

HITEC University Taxila Cantt

16

Final Year Project Report -2012

Stage 2:

Fig 4.11 Hardware Design Stage 2

HITEC University Taxila Cantt

17

Final Year Project Report -2012

Chapter 5

5.1 Introduction to Microcontrollers: Peripheral interface controller, is a compact microcomputer that monitor and control embedded systems such as robots medical devices, mobile radios, home appliances and lot of other devices. A PIC micro-controller constitutes processor, memory, an peripheral just like a computer. PIC microcontrollers are produced by Microchip Technology in Chandler, Arizona.

5.2 Why we have chosen PIC Microcontroller: The PIC microcontrollers Key features include wide availability, low cost, ease of reprogramming with built-in EEPROM (electrically erasable programmable read-only memory). Every PIC microcontroller has a set of registers that also function as RAM (random access memory). Special purpose control registers for on-chip hardware resources are also mapped into the data space.

5.3 Applications of PIC Micro-controller:

Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and other embedded systems.

5.4 Advantages of using PIC Micro-controller:

By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems.

HITEC University Taxila Cantt

18

Final Year Project Report -2012

5.5 Why we used PIC16F887 Microcontroller: It has no major discrimination from other Microcontrollers from PIC16 family. This was available easily in market and its programmer was also available in market, both at low cost. All over this, we had some practice of using it.

5.6 PIN-Diagram OF PIC16F887:

5.7 Programming of Microcontroller: Steps to program Microcontroller are; We programmed PIC16f887 by the using MikroC compiler IDE. We used Genesis G540 burner to burn the program into the memory of Microcontroller. We made burner settings for PIC16f887 according to information given in datasheet, as shown in special features of PIC16f887 in appendix. The settings finally we made for G540 burner is shown in the figure.

HITEC University Taxila Cantt

19

Final Year Project Report -2012

5.7.1 Advantages of MikroC: As mentioned in topic 5.7, we used MikroC IDE Compiler to program micro-controller because of following advantages, It is easy to use IDE due to hardware and software libraries, hardware debugger support. Advanced features of MikroC includes following: It is capable to support over 415 Microcontrollers. Additional tools provided in MikroC made it more users friendly. MikroC contains many libraries that support different hardware and software. Free updates of new compiler versions are easily available to keep the compiler IDE updated.

5.7.2 ADC (Analog to Digital Converter): The process, in which analog values are converted to digital values, is called Analog to Digital Conversion and the device used for this purpose is called Analog to Digital Converter or simply ADC. In other words the process, in which values from continuous domain are converted to discrete values. Further details are provided in the Data sheet in appendix for PIC16f887.

HITEC University Taxila Cantt

20

Final Year Project Report -2012

5.7.3 Reset for Microcontroller:


It is the special function of Micro-controller in which it start working from initial stage after being made for reset. The circuitry required for this purpose is shown below.

5.7.4 Temperature Sensor ( LM35): LM35 is a temperature sensing device that converts temperature into volts as the Voltage increases with the increase in temperature. For increase in every degree centigrade the voltage of 10 mV will change, so if a temperature of One degree will increase, the 10 mV will increase in the output of LM35. Operating voltages of LM35 are 0-5 volts. Further details are given in appendix.

HITEC University Taxila Cantt

21

Final Year Project Report -2012

CHAPTER 6
6.1 Designing of Web-page:
To design web design a web-page, it is important to follow the latest trends. There are many languages that help web designers to build platforms for a variety of tasks. We have used two basic programming languages for web-designing,

HTML JavaScript

6.1.1 HTML, Hypertext Markup Language is the basic language of the web and is used to write and create content for web pages such as content includes text, photos, images, videos, widgets, and other content elements on a web page. 6.1.2 JavaScript It is used by web designers to make web pages more dynamic, more interactive, functional, and computational through the use of forms and other interactive elements.

6.2 Getting started with HTML: HTML is a language in which strings of charter is mixed up with ordinary text so called markup, and used to tell the browser that how to display the page.. Commonly used contents are text, Graphics, Forms, Audio and video files and Interactive games

6.3 Using Hypertext to add structure to web pages: Web page is a collection of text documents. It is the mother language of computer. Now webpage is a collection of instructions that is included along with the content plain in text file page that what the direction of your page.

HITEC University Taxila Cantt

22

Final Year Project Report -2012

6.4 Using a server to host your pages: Webpage is considered to be useless if it is not browsed widely. Now web server is a machine that is connected to the net, having all the essential softwares. To host a page a domain and password is purchased from an organization, providing specific space on main server. Domain holder is the administrator and all the data is stored at that specific space.

6.5 How to create and View an HTML document: Some general steps to create and view an HTML document are as below; To Create HTML Document: First of all to write the document use text editor (Note pad) and save the file as filename.html for example ABC.html at particular location in computer, known as the Document Source. To View HTML Document: Now by staying as Off-Line, open Netscape (or any browser) and switch to Netscape. After that Click on File > Open File and select the ABC.html document that is created recently and HTML page will appear just like any other Web page in Netscape. To Edit HTML Document: To edit HTML document switch to Notepad with the Document Source and after making required changes again save the document. Now again switch back to Netscape and click on RELOAD and view the new edited HTML Document.

6.6 Basic HTML Document Format:

HITEC University Taxila Cantt

23

Final Year Project Report -2012

6.7 URL (Uniform Resource Location): Each web page is composed of large number of source files and number of source files may be in trillions and every source file is linkable. If we know the address of specific file, we can create hyperlink successfully.

I.

Protocol:

This part of link tells about the selection of protocol that must be used by the browser when request is made for link. http:// is the protocol for WebPages. II. Domain:

This is the portion of link that indicates the location to the general website where data is stored and one domain is capable to host millions of files. III. Path:

This portion of file is associated with the path or sequence of files and folders to be followed to access specific file placed at specific location. IV. File name:

The name of the file specifies exactly which file in a directory path the browser should access.

Code loaded for HTML page: (Refer to appendix A)


`

HITEC University Taxila Cantt

24

Final Year Project Report -2012

CHAPTER 7

7.1 Ethernet Port Ethernet is the most common type of connection, computers use in a local area network (LAN). An Ethernet port looks like a regular phone jack, but it is slightly wider. This port can be used to connect your computer to another computer, a local network, or an external DSL or cable modem. Ethernet is the most popular LAN technology in the world. It is an easy, relatively inexpensive way to provide high-performance networking to all different types of computer equipment. Ethernet was invented at Xerox PARC and developed jointly by Digital Equipment Corporation, Intel and Xerox. Introduced in 1980, Ethernet was distinguished by its high speed (10 Mbps), its unusual signaling methodology (the latest version of which is now referred to as Carrier Sense Multiple Access with Collision Detection or CSMA/CD), and by the physical medium on which it operates: a thick, high-quality coaxial cable with a bright yellow braided sheath. Today, the term Ethernet refers to a whole family of closely related protocols characterized by their raw data rates (10 Mbps, 100 Mbps, 1 GBPS or 10 GBPS) and the physical medium on which they operate. Ethernet now runs on a wide variety of physical media. Among the most common are: coaxial cable (thick or thin), many types of copper cable called twisted pair, and several types of fiber-optic cables using a variety of signaling methods and light wavelengths. The CSMA/CD approach is used by any form of Ethernet operating in half-duplex modethat is, the mode in which transmit (Tx) and receive (Rx) signals can be sent on the same wire or data path. In full-duplex mode, transmit and receive signals are separated onto dedicated, one-way channels. This eliminates the need for CSMA/CD, as all the transmissions on a single data path will be coming from a single device. Half-duplex mode is seldom used in versions of Ethernet running on fiber, and is not supported at all in the 10 GBPS standards.

HITEC University Taxila Cantt

25

Final Year Project Report -2012

7.2 Types of Ethernet Port: Two widely-used forms of Ethernet are 10BaseT and 100BaseT. In a 10BaseT Ethernet connection, data transfer speeds can reach 10 mbps (megabits per second) through a copper cable. In a 100BaseT Ethernet connection, transfer speeds can get up to 100 mbps. There is also a new technology called "Gigabit" Ethernet, where data transfer rates peak at 1000 mbps. Now that's fast.

7.3 What is a packet? Information is transmitted on Ethernet network as a packet. A chunk of data is identified and route it to a correct destination by enclosing data in to one or more wrappers. Destination means a particular application on a particular machine. Wrappers consist of headers and trailers, headers define bits of data, and trailer must be at the end of packet. The application generating the data on the sending machine passes the data to a protocol. Protocol stack is to break that data in to small chunks, and each chunk consists of one or more wrappers and allows that packet in to correct destination. Protocol stack passes the packet on Ethernet hardware, the NIC. If the destination of packet is somewhere beyond the local network, the Ethernet header added by the sending machine will point to a router specific destination address.

The router will open the packet, breaks the Ethernet wrapper, read far enough to find the exact destination address and re-wrap it, giving it a new header that will send it on the next hop. Process is reversed at receiving end. NIC reads the packet at receiving end and strips off Ethernet header and pass it to protocol stack.

HITEC University Taxila Cantt

26

Final Year Project Report -2012

The protocol read the received packet/stack and cuts of the header, then sends the packet to the application for which it is addressed and gets assembled.

7.4

Ethernet protocols and Specifications

Ethernet is based on network standards, and network standard includes physical network layer, which specify the sending and receiving of the signal. Protocol specifications are nesting the protocol. The protocol specification is depending upon these standards i.e. 802.3 Ethernet standard and older Ethernet type 2, but mostly protocol stacks are written in type2 standards.

7.5

Relationship between Ethernet and TCP/IP:

Network is composed of many layer and standards that cover physical medium with the addition of some low level things like message collision detection. Ethernet is a physical thing, including with wires and voltages and connectors. IP is just related to the routing of messages. TCP deals with the conversation that has some rules and regulations, that how to communicate with each other and making sure those messages are not dispersed.

HITEC University Taxila Cantt

27

Final Year Project Report -2012

7.6

Seven layer Model:

When we get online or connect to as server, a physical connection allows to connect to the internet through either modem or Ethernet card. The connections are established through a physical modem or through a Ethernet card. A TCP/IP is allowing us to load web sites to IP and pass all the traffic. The Ethernet and modem are functional in two parts. The modem or Ethernet drivers are responsible for hardware communication. The PPP connection also known as dial up networking allows your computer to access the modem. These two components provide the basis of getting a connection to the internet.

The TCP/IP stack allows the machine to get the traffic passed across the link to the internet in a smooth and running manner. The seven OSI layers use for controlling information to communicate with their peer layers in other computer systems. This controlled information consists of specific requests and instructions between peer OSI layers.

HITEC University Taxila Cantt

28

Final Year Project Report -2012

7.7 How Encapsulation Works:

Left side shows the encapsulation as the data comes to lower layers data gets headers from each layer and finally when it is received on other place the data gets encapsulated shown in right side.

7.8

Control information typically takes one of two forms:


Headers passes the data down from upper layers. Trailers are passes the data down from upper layers.

HeaderTrailer-

7.9 Application Layer:


The application layer compares with software applications that implement a communicating component. Application layer include the following functions: Identifying communication partners - The application layer identifies, determines and ensures availability of communication partners for the transmission of data. Determining resource availability - The application layer determine network resources for the requested communication which is available.

HITEC University Taxila Cantt

29

Final Year Project Report -2012

7.10 Presentation Layer: The presentation layer includes a variety of encoding and encryption functions that is applied to the information received after communication through application layer. This function ensures that the information sent from one system that is readable to another system. 7.11 Session Layer: The session layer establishes, and terminates communication sessions between presentation layer entities. A communication session includes service requests and service responses which occur between applications located in different locations. 7.12 Transport Layer:

The transport layer implements reliable work on internet data by transporting it to upper layer. Transport layer functions typically include the following: Flow control - Flow control is responsible for data transmission between devices so that the transmitting device does not send more data at the receiving end. Sliding Window - This function allows the receiving computer to dictate to the receiving end that how many packets are received. Multiplexing - Multiplexing allows data to be transmitted onto a single physical link from several application. Virtual circuit management - Virtual circuits are established and maintained, by the transport layer. The two most important Transport layer protocols are TCP and UDP.

7.13 Network:
The network layer provides route to the functions which allow multiple data links to be merged into an internet work. This is accomplished by the logical addressing of devices. The network layer supports both connection- and connectionless service from higher-layer protocols.

7.14

Data Link:

The data link layer is where the logical information which is transmitted over the physical layer.

HITEC University Taxila Cantt

30

Final Year Project Report -2012

Physical addressing - Physical addressing defines how devices are addressed at the data link layer. Network topology - Data link layer specifications how the devices are connected physically (such as bus and topology). Error notification - Error notification involves alerting upper layer protocols and the errors at receiving end.

7.15 ENC28J60 Working Logic: The working Logic of ENC28J60 is shown in following diagram,

Further details of ENC28J60 are provided in Appendix.

HITEC University Taxila Cantt

31

Final Year Project Report -2012

7.16 Calculation for IP Address: The IP of the device is 182.150.22.16 The IP for the computer is 182.150.22.(15-255) The range of the class is defined as: A- 1-126 B- 128-191 C- 192-223 D- 224-239 We have chosen class B because we designed out device for a large organization.

How to calculate Network Address: 182.150.22.15 Default subnet mask 255.255.0.0 If we used default subnet mask the IP ranges from Network Address to the last useable IP. i.e. 182.150.22.15 Default subnet mask 255.255.0.0 Network address 182.150.0.0 So the last useable IP is 182.150.254

Microcontroller Programming code (complete): (Refer to appendix A)

HITEC University Taxila Cantt

32

Final Year Project Report -2012

CHAPTER 8 Recommendation for future work: Improvements can be made in Microcontroller program and HTML web page to make it more customizable for user and can be made more user friendly. It may have some password protection for security reasons. Special features like login/user names/id, so that the activity of each person can be recorded in log files like data base. We can interface Keypad with the device, so that we can change the MAC address and the IP address on the run time. LCD can also be interfaced with the device, to make it easy for user. IP address and MAC address can be changed directly by interface provided with Keypad and LCD, without connecting the device to a computer machine. Memory card or portable storage can be added externally for HTML pages and other important data like videos, Pictures, audio etc.

HITEC University Taxila Cantt

33

Final Year Project Report -2012

Conclusion:

Embedded Web Based Monitoring and Control system has been taken into a new dimension. We have clearly demonstrated that tiny circuitry with a huge scope of research has given birth to a new era of endless possibilities. The Embedded Web Based Monitoring and Control system is suitable for a real time monitoring and control system. We feel that our product is completely sound, and has great market value. The advantage of our product is that it is economical and no one in Pakistan is offering such system at low cost. Our project includes Ethernet and web page which are becoming part of everyday life and routine.

HITEC University Taxila Cantt

34

Final Year Project Report -2012

Appendix A : Code for HTML Web Page:

const char

*indexPage =

// Change the IP address of the page to be refreshed

"<meta http-equiv=\"refresh\" content=\"3;url=http://182.150.22.16\">\ <HTML><HEAD></HEAD><BODY>\ <h2>Umer Sharif Naveed Khan Samson Iqbal Sami ul haq</h2>\

<a href=/>Reload</a>\ <script src=/s></script>\ <table><tr><td valign=top><table border=1 style=\"font-size:20px ;font-family: terminal ;\">\ <tr><th colspan=2>ADC</th></tr>\ <tr><td>Temprature Value</td><td><script>document.write(AN2)</script></td></tr>\ <tr><td>Light Intensity</td><td><script>document.write(AN3)</script></td></tr>\ </table></td><td><table border=1 style=\"font-size:20px ;font-family: terminal ;\">\ <tr><th colspan=2>Buttons</th></tr>\ <script>\ var str,i;\ str=\"\";\ for(i=0;i<8;i++)\ {str+=\"<tr><td bgcolor=pink>BUTTON #\"+i+\"</td>\";\ if(PORTB&(1<<i)){str+=\"<td bgcolor=red>ON\";}\ else {str+=\"<td bgcolor=#ccbbcc>OFF\";}\ str+=\"</td></tr>\";}\ document.write(str) ;\ </script>\ ";

HITEC University Taxila Cantt

35

Final Year Project Report -2012

const char

*indexPage2 = "</table></td><td>\

<table border=1 style=\"font-size:20px ;font-family: terminal ;\">\ <tr><th colspan=3>Lights</th></tr>\ <script>\ var str,i;\ str=\"\";\ for(i=0;i<8;i++)\ {str+=\"<tr><td bgcolor=yellow>LED #\"+i+\"</td>\";\ if(PORTD&(1<<i)){str+=\"<td bgcolor=red>ON\";}\ else {str+=\"<td bgcolor=#cccccc>OFF\";}\ str+=\"</td><td><a href=/t\"+i+\">Toggle</a></td></tr>\";}\ document.write(str) ;\ </script>\ </table></td></tr></table>\ Total HTTP request #<script>document.write(REQ)</script></BODY></HTML>\ "; // these both pages will be concatenated when they reach to the browser.

HITEC University Taxila Cantt

36

Final Year Project Report -2012

Appendix B :

Microcontroller Programming code (complete):

#define Spi_Ethernet_HALFDUPLEX #define Spi_Ethernet_FULLDUPLEX

0x00 0x01

#define PCS SPI_Ethernet_putConstString #define PS SPI_Ethernet_putString sfr sbit SPI_Ethernet_Rst at RC0_bit; sfr sbit SPI_Ethernet_CS at RC1_bit; sfr sbit SPI_Ethernet_Rst_Direction at TRISC0_bit; sfr sbit SPI_Ethernet_CS_Direction at TRISC1_bit; const unsigned char httpHeader[] = "HTTP/1.1 200 OK\nContent-type: " ; // HTTP header const unsigned char httpMimeTypeHTML[] = "text/html\n\n" ; const unsigned char httpMimeTypeScript[] = "text/plain\n\n" ; unsigned char httpMethod[] = "GET /"; // HTML MIME type // TEXT MIME type

HTML Code is to be written here that is shown in Appendix A.

unsigned char MacAdr[6] = {0x01, 0x33, 0x78, 0x15, 0x9e, 0x2d} ; // my MAC address unsigned char IpAdr[4] = {182, 150, 22, 16} ; unsigned char GREQ[15] ; unsigned char Variable[30] ; unsigned long httpCounter = 0 ; // my IP address // HTTP request buffer // buffer for dynamicresponse // counter of HTTP requests

unsigned int SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqPacketlength) { unsigned int Packetlength = 0 ; unsigned int i ; // my reply Packetlength

// general purpose integer

HITEC University Taxila Cantt

37

Final Year Project Report -2012

if(localPort != 80) { return(0) ; }

// I listen only to web request on port 80

// get 10 first bytes only of the request, the rest does not matter here for(i = 0 ; i < 10 ; i++) { GREQ[i] = 0 ; if(memcmp(GREQ, httpMethod, 5)) { httpCounter++ ; if(GREQ[5] == 's') { browsers Packetlength = PCS(httpHeader) ; // HTTP header // with text MIME type return(0) ; } // one more request done // if request is s, store dynamic data in transmit buffer // only GET method is supported here GREQ[i] = SPI_Ethernet_getByte() ; }

// the text string replied by this request can be interpreted as javascript statements by

Packetlength += PCS(httpMimeTypeScript) ;

IntToStr(ADC_Read(2), Variable) ; Packetlength += PCS("var AN2=") ; Packetlength += PS(Variable) ; Packetlength += PCS(";") ; IntToStr(ADC_Read(3), Variable) ; Packetlength += PCS("var AN3=") ; Packetlength += PS(Variable) ; Packetlength += PCS(";") ;

Packetlength += PCS("var PORTB=") ; IntToStr(PORTB, Variable) ; Packetlength += PS(Variable) ; Packetlength += PCS(";") ;

HITEC University Taxila Cantt

38

Final Year Project Report -2012

Packetlength += PCS("var PORTD=") ; IntToStr(PORTD, Variable) ; Packetlength += PS(Variable) ; Packetlength += PCS(";") ;

IntToStr(httpCounter, Variable) ; Packetlength += PCS("var REQ=") ; Packetlength += PS(Variable) ; Packetlength += PCS(";") ; else if(GREQ[5] == 't') comes after { }

// if request path name starts with t, toggle PORTD (LED) bit number that // for bit mask

unsigned char BM = 0 ;

if(isdigit(GREQ[6])) // if 0 <= bit number <= 9, bits 8 & 9 does not exist but does not matter { BM = GREQ[6] - '0' ; BM = 1 << BM ; PORTD ^= BM ; } } // what do to by default // HTTP header // with HTML MIME type // convert ASCII to integer // create bit mask // toggle PORTD with xor operator

if(Packetlength == 0) { Packetlength = PCS(httpHeader) ;

Packetlength += PCS(httpMimeTypeHTML) ; Packetlength += PCS(indexPage) ; Packetlength += PCS(indexPage2) ; }

// HTML page first part // HTML page second part

return(Packetlength) ; // return to the library with the number of bytes to transmit } unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqPacketlength) { return(0) ; // UDP is not used here but its necessary to return some value }

HITEC University Taxila Cantt

39

Final Year Project Report -2012

void main() { ANSEL = 0x0C ; C1ON_bit = 0; C2ON_bit = 0; PORTA = 0 ; TRISA = 0xff ; ANSELH = 0; PORTB = 0 ; TRISB = 0xff ; // set PORTB as input for buttons // set PORTA as input for ADC // Configure other AN pins as digital I/O // AN2 and AN3 convertors will be used // Disable comparators

PORTD = 0 ; TRISD = 0 ; SPI1_Init(); SPI_Ethernet_Init(MacAdr, IpAdr, Spi_Ethernet_FULLDUPLEX) ; while(1) // do forever // set PORTD as output

{ SPI_Ethernet_doPacket() ; // process incoming Ethernet packet } }

HITEC University Taxila Cantt

40

Final Year Project Report -2012

Appendix C: Data sheet of PIC 16F887 Microcontroller:

HITEC University Taxila Cantt

41

Final Year Project Report -2012

HITEC University Taxila Cantt

42

Final Year Project Report -2012

HITEC University Taxila Cantt

43

Final Year Project Report -2012

HITEC University Taxila Cantt

44

Final Year Project Report -2012

SPECIAL FEATURES OF THE CPU The PIC16F882/883/884/886/887 have a host of features intended to maximize system reliability, minimize cost through elimination of external components, provide power-saving features and offer code protection. These features are: Reset - Power-on Reset (POR) - Power-up Timer (PWRT) - Oscillator Start-up Timer (OST) - Brown-out Reset (BOR) Interrupts Watchdog Timer (WDT) Oscillator selection Sleep Code protection ID Locations In-Circuit Serial Programming Low-voltage In-Circuit Serial Programming The PIC16F882/883/884/886/887 have two timers that offer necessary delays on power-up. One is the Oscillator Start-up Timer (OST), intended to keep the chip in Reset until the crystal oscillator is stable. The other is the Power-up Timer (PWRT), which provides a fixed delay of 64 ms (nominal) on power-up only, designed to keep the part in Reset while the power supply stabilizes. There is also circuitry to reset the device if a brown-out occurs, which can use the Power-up Timer to provide at least a 64 ms Reset. With these three functions-on-chip, most applications need no external Reset circuitry. The Sleep mode is designed to offer a very low-current Power-Down mode. The user can wake-up from Sleep through: External Reset Watchdog Timer Wake-up An interrupt Several oscillator options are also made available to allow the part to fit the application. The INTOSC option saves system cost while the LP crystal option saves power. A set of Configuration bits are used to select various options (see Register 14-3).

HITEC University Taxila Cantt

45

Final Year Project Report -2012

HITEC University Taxila Cantt

46

Final Year Project Report -2012

HITEC University Taxila Cantt

47

Final Year Project Report -2012

ADC (Analog to Digital Conversion):

HITEC University Taxila Cantt

48

Final Year Project Report -2012

ADC CONVERSION PROCEDURE:

HITEC University Taxila Cantt

49

Final Year Project Report -2012

ULN 2003A:

HITEC University Taxila Cantt

50

Final Year Project Report -2012

HITEC University Taxila Cantt

51

Final Year Project Report -2012

HITEC University Taxila Cantt

52

Final Year Project Report -2012

HITEC University Taxila Cantt

53

Final Year Project Report -2012

HITEC University Taxila Cantt

54

Final Year Project Report -2012

References: TCP/IP protocol suite, fourth edition by behrouz A.forouzan. Computer Networking, third edition by james F.Kourose and keith W.Rose HTLM4 for dummies, fourth edition by Natanya Pitts PIC Microcontroller and embedded system, by Muhammad Ali Mazidi, Rolin D.Mckinlay and Danny Causey www.google.com www.wikipedia.com www.yahooanswers.com http://en.wikipedia.org/wiki/File:SPI_three_slaves.svg http://www.sv-components.com/Photos/Resistor%20NW%20SIP.jpg http://media2.rsdelivers.cataloguesolutions.com/LargeProductImages/W700544310.jpg .http://www.in-car-stuff.com/shop/images/uln2003a_large.jpg http://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Resistor_cropped.jpg/ 250px-Resistor_cropped.jpg https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcRp_ZFs3gZbqFu1pVRQxtRnJG5JqHuemQNNVFZqaFUyZKPdfjK2Q http://www.PIClist.com/images/www/hobby_elec/gif/car2_4_22.gif http://www.hobby-hour.com/electronics/1n4007-diode.gif http://cantonfair.org/att/images/product/20100731/org_SIiK93eHv60i.jpg

HITEC University Taxila Cantt

55

Anda mungkin juga menyukai