Sie sind auf Seite 1von 45

MINI PROJECT REPORT

on

ONLINE DEVICE CONTROLLER


Submitted in partial fulfillment of the requirements for the award of the degree of

BACHELOR OF TECHNOLOGY
in
ELECTRONICS ENGINEERING
of the
COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY
by
AGIL FRANCIS
HARRY JOSE M
JIM CHERIAN
under the guidance of

Mr. LIJU PHILIP


Lecturer, Electronics Engineering,
College of Engineering
Chengannur

DEPARTMENT OF ELECTRONICS ENGINEERING,


COLLEGE OF ENGINEERING,
CHENGANNUR, KERALA - 689121.

September 2001
Online Device Controller

ACKNOWLEDGEMENT

This is the age of the Internet and the World Wide Web is becoming a part of the
life of the common man of our country. In this scenario, we have tried to implement the
control of hardware through Internet, a really challenging project. This project would not
have been successfully materialized had it not been for the several people who have
directly and indirectly helped us. We are extremely indebted to all of them and we whole-
heartedly thank everyone for their valuable support.

We are extremely grateful to Mr. P Prathapachandran Nair, our Principal for


providing us with good facilities and a proper environment for developing our project.

We thank Mr. Jyothiraj V P, Head of the Department, Department of Electronics


Engineering for the support and appreciation. We are also grateful to Mr. C V
AnilKumar, our Project Co-ordinator for all the guidance.

Our guide Mr. Liju Philip has been a real help to us during the entire course of
our project and we are highly obliged to him for his valuable suggestions, appraisal and
guidance. We also thank Mr.Gopakumar C, Lecturer and Project Lab In Charge, and
Mr. Sudhin Jacob, Lecturer for the constant support and encouragement for our project.

We are also greatly indebted to Mr. Riyas A, Electronics Engineer, Rubber Board
of India, Kottayam for his critical suggestions and technical advice.

And several of our seniors for their wonderful help rendered and powerful
suggestions in the initial phase of our project, and all our friends, both of Electronics and
Computer Engineering branches, who have been a great help.

We are also very thankful to all those unknown and unseen people who helped us
with valuable information through several discussion boards over the Internet.

We truly admire our parents for their constant encouragement and enduring
support which was inevitable for the success of our ventures.

Last, but not the least, we are thankful to each other in this project group for being
cooperative, patient and hardworking for the successful completion of this project.

Above all, we thank God Almighty for the ever-abiding kind blessings.
1
Online Device Controller

ABSTRACT

The ‘Online Device Controller (ODC) is a multi-channel hardware administration


system that has been developed to enable the control of equipments and appliances from
any part of the world, through the Internet. The concept of ODC is a relatively new one,
and makes use of Common Gateway interface (CGI), a very powerful technique that was
hitherto used solely for e-mail, database access and other ‘soft’ purposes involving
dynamic web page content. But, through this project we have made an attempt to bring a
very powerful but often unknown and underutilised aspect of CGI; the same technique
used to manipulate our e-mail accounts can equally well be applied to access the parallel
port of the web server, and control hardware through it.

Our project, the ‘Online Device Controller’ allows a remote user to login to the
Web server and control the devices connected to the server. Also provided is the feature
to control the same devices locally, through a Cordless Telephone.

The present product offers the facility to remotely control an ON/OFF device and
an Intensity Variable load, through the Internet, and locally through a Cordless telephone
and is a product of paramount significance in office, industrial and household
applications.

2
Online Device Controller

CONTENTS

INTRODUCTION 4

REVIEW 5

The World Wide Web 6


Common Gateway Interface 9
Parallel Port Basics 15
DTMF Dialing System 22
Microcontrollers 24
The Triac 26

THE PROJECT 29

Block Diagram 30
Hardware details 31
Software details 34
Flow Charts 35
Working of the System 41
Result and Discussion 42

CONCLUSION AND FUTURE SCOPE 43

REFERENCES 44

3
Online Device Controller

INTRODUCTION

With the advent of technology, the world has shrunk to a global village. Man has
been looking forward to realise the automation of every process, taking place around him.
But his dream, to extend his control to devices from anywhere in the world still remains
unfulfilled.
Our project envisages the control of equipments from a remote location through
the Internet, or an Intranet. Local control is also available through a dedicated PC and a
Cordless Phone Unit.
This project is suited for Office Automation and Home Automation. The concept
can equally well be extended to Industrial applications where direct human access is
restricted.
Through this project, we strive to make this dream come true…

Salient Features

 Remote access to dedicated devices from anywhere in the world through


the Internet.

 Wide application in industrial, office and domestic automation.

 Secure and reliable.

 Remote control from local station is available.

 Power regulation

 Facility to read the current status of the device is incorporated

4
Online Device Controller

Review

5
Online Device Controller

The World Wide Web

The World Wide Web is the collection of all browsers, servers, files, and browser-
accessible services available through the Internet. Conceived in 1989 by a computer
scientist named Tim Berners-Lee, its original purpose was to facilitate communication
between research scientists. The Web was designed in such a way that documents located
on one computer on the Internet could provide links to documents located on other
computer on the Internet.

A browser is the user’s window to the Web, providing the capability to view Web
documents and access Web-based services and applications. The most popular browsers
are Netscape’s Navigator and Microsoft’s Internet Explorer. Both browsers are
descendants of the Mosaic browser developed at the National Center for Supercomputing
Applications (NCSA). Mosaic’s slick graphical user interface (GUI) transformed the
Web from a research tool to the global publishing medium that it has become today.

Today’s Web browsers extend Mosaic’s GUI features with multimedia


capabilities and with browser programming languages such as Java and JavaScript. In
order to publish a document on the Web, it must be made available to a Web server. Web
servers retrieve Web documents in response to browser requests and forward the
documents to the requesting browsers via the Internet. Web servers also provide
gateways that enable browsers to access Web-related applications as well as other
Internet services, such as Gopher and Wide Area Information Search (WAIS).

The earliest Web servers were developed by CERN and NCSA. These servers
were the mainstay of the Web throughout its earlier years. Lately, Commercial Web
servers, developed by Netscape, Microsoft, and other companies, have become
increasingly popular on the Web. These servers are designed for higher performance and
to facilitate the development of complex Web applications.

6
Online Device Controller

Because the Web uses the Internet as its communication medium, it must follow
Internet communication protocols. The Internet’s Transmission Control Protocol (TCP)
and Internet Protocol (IP) enable worldwide connectivity between browsers and servers.
In addition to using the TCP/IP protocols for communication across the Internet, the Web
also uses its own protocol, called the HyperText Transfer Protocol (HTTP), for
exchanges between browsers and servers.

The HyperText Transfer Protocol (HTTP)

HTTP is the protocol used for communication between browsers and web servers.
HTTP uses a request/response model of communication. A browser establishes a
connection with a server and sends URL requests to the server. The server processes the
browser’s request and sends a response back to the browser.

A browser connects with the Web server by establishing a TCP connection at port
80 of the server. (This is the default port until another is specified in the URL) This port
is the default address at which web servers “listen” for browser requests. Once a
connection has been established a browser sends a request to the server. This request
specifies a request method, the URL of the document, program or other resource being
requested, the HTTP version being used by the browser, and other information related to
the request.

Several request methods are available. GET, HEAD, and POST are the most
commonly used ones.

The GET method is used to retrieve the information contained at the specified
URL. This method may also be used to submit data collected in an HTML form or to
invoke a Common Gateway Interface (CGI) program. When the server processes a GET
request, it delivers the requested information (if it can be found). The server inserts at the

7
Online Device Controller

front of the information an HTTP header that provides data about the server, identifies
any errors that occurred in processing the request, and describes the type of information
being returned as a result.

The HEAD method is similar to the GET method except that when a Web server
processes a HEAD request, it only returns the HTTP header data and not the information
that was the object of the request. The HEAD method is used to retrieve the information
about a URL without actually obtaining the information addressed by the URL.

The POST method is used to inform the server that the information appended to
the request is to be sent to the specified URL. The POST method is typically used to send
form data and other information to Common Gateway Interface (CGI) programs. The
Web server responds to a POST request by sending back header data followed by any
information generated by the CGI program as the result of processing the request.

The current version of HTTP is HTTP 1.1. It incorporates performance, security


and other improvements to the original HTTP 1. A new version of HTTP, referred to as
HTTP-NG, is currently being defined. (The NG stands for “Next Generation”.) The goal
of HTTP-NG is to simplify the HTTP protocol and make it more extensible.

Hyper Text Markup Language

The Hyper Text Markup Language, or HTML, originally developed by Tim


Berners Lee at CERN is the lingua franca of the Web. It is used to create Web pages and
uses ordinary ASCII text files to represent Web pages. The files consist of the text to be
displayed and the tags that specify how the text is to be displayed.

The use of tags to define the elements of a Web document is referred to as


markup. A tag is usually enclosed in angle brackets, and most tags come in pairs, with an
opening and a closing tag. The closing tag is the same as the opening tag but starts with a

8
Online Device Controller

forward slash. For example, the following line from an HTML file shows the text of a
title between the appropriate title tags.

<TITLE>Welcome to the Control Menu of Online Device Controller</TITLE>

A browser interprets these tags and displays only the text within the tags
appropriately. There are different tags used to identify headings, paragraphs or hyperlinks
and also, to insert images, forms, multimedia objects etc.

Common Gateway Interface (CGI)

The Common Gateway Interface (CGI) is a standard that specifies how external
programs may be used by Web servers. Programs that adhere to the Common Gateway
Interface standard are referred to as CGI programs. CGI programs may be used to process
data submitted with forms, to perform database searches, and to support other types of
Web applications such as clickable image maps.

Where HTML gives the World Wide Web its look, CGI makes it functional. It is
a ‘Common Gateway” between the web server and applications that can be useful to the
server, but doesn’t run as a part of it. In technical terms, a gateway is an interface or an
application that allows two systems to pass information between them. The CGI does the
same function in the context of a Web server and Web client (Web browser). The server
does not know Perl or C. But by means of CGI, it can handle requests from “clients” or
visitors to the Web page, allow execution of the required application programs and pass
the results back. In fact, CGI is the only way the server can communicate with these other
applications, such as a database or even the parallel port of the machine.

A browser request for the URL of a CGI program comes about as the result of a
user clicking a link or submitted a form. The browser uses HTTP to make the request.
When a Web server receives the request, the Web server executes the CGI program and

9
Online Device Controller

also passes it any data that was submitted by the browser. When the CGI program
performs its processing, it usually generates data in the form a Web page, which it returns
via the Web server to the requesting browser.

The CGI standard specifies how data may be passed from Web servers to CGI
programs and how data should be returned from CGI programs to the web server.

Working of CGI

CGI programs also referred to as CGI scripts are the external programs, which are
a standard interface for communication between Web servers and external programs. The
CGI specification identifies how data is to be passed from a Web server to a CGI
program and back.

The following points summarise how CGI works

 A browser requests a CGI program by specifying the CGI program’s URL. The
request arises as the result of the user submitting a form or clicking a link. The browser
may insert into the URL a query string or extra path information

 When a Web server receives a URL request it determines whether the URL refers
to CGI program, Most Web servers identify CGI programs by the path in which they are

10
Online Device Controller

located or by the file name extensions. For example, all files in the path /cgi-bin/ or with
the extensions .CGI or .PL could be CGI programs.

 When a Web server identifies a request for a CGI program it executes the CGI
program as a separate process and passes any data included in the URL of the program.

 The CGI program performs its processing and then returns its output to the Web
server. The conventions defined by the CGI specification determine how CGI programs
receive data from and return data to Web servers.

Getting Data from the Web Server

When a CGI program is executed, one of its first tasks is to determine what data
was passed to it by the Web Server. This data may be passed in the following ways:

 Command-line Arguments
 Environment Variables
 The program’s standard input stream

Command-line arguments and the standard input stream are supported by almost
all programming languages. Environment variables are less commonly used outside the
Web applications.

11
Online Device Controller

Environment Variables

Environment Variables are the primary mechanism by which web servers


communicate with CGI programs. All CGI programs can receive data from Web Servers
via environment variables.

Environment variables are variables that are external to a program’s execution.


They are used to define the environment in which a program executes. The following
table identifies some commonly used environment variables defined by CGI version 1.1.

Environment Variable Description


AUTH_TYPE The authentication scheme used to validate the user
requesting access to a Web page.
CONTENT_LENGTH The number of characters that have been passed via
standard input.
CONTENT_TYPE The MIME type associated with the data variable via
standard input
PATH_INFO The extra path information added to the URL of the
CGI program

12
Online Device Controller

PATH_TRANSLATED The full path name that was translated from the URL
by the Web server.
QUERY_STRING The query string portion of the URL.
REMOTE_ADDR The IP address of the host associated with the
requesting browser
REMOTE_HOST The name of the host associated with the requesting
browser.
REMOTE_USER The name of the user associated with the requesting
browser.
REQUEST_METHOD The method associated with the browser request:
GET, POST, HEAD and so on.
SCRIPT_NAME The path and name of the CGI program.
SERVER_NAME The name of the Web server host.
SERVER_PORT The HTTP port number (usually 80) used by the
Web server.
SERVER_PROTOCOL The name and version of the protocol used by the
requesting browser to submit the request.

These environment variables are available to all CGI programs regardless of


whether the CGI program was executed as the result of a command line argument based
query, a form submission, or the clicking of a hyperlink. Many programming languages
provide special mechanisms for accessing environment variables. For example, C
provides the getenv( ) library function and Perl provides the $ENV array.

Reading Query String Data

When data is passed to a CGI program via the QUERY_STRING environment


variable, the data is encoded using the following conventions. These coding conventions
are referred to as URL coding.

13
Online Device Controller

 Spaces are replaced by plus (+) signs.


 Other characters may be replaced by character codes of the form %xx (with the
xx being replaced by two hexadecimal digits). For example, %2a is used to encode a plus
sign.

CGI programs must decode the data passed via the QUERY_STRING variable.
This is accomplished by replacing plus signs with spaces, and sequences of the form %xx
with their character equivalent. This decoding is known as URL decoding.

Sending Data back to the Web Server

A CGI program returns data to the requesting browser via the Web server. In all
cases, it returns the data by writing it to the standard output stream. The output of the
CGI program must begin with a header line, followed by a blank line, and ten by the data
to be displayed by the browser. The header line usually consists of a Content-type
header that specifies the MIME type of the data returned by the CGI program. In most
cases, the MIME type will be text/html, as shown in the following example.

Content type: text/html


<HTML>
<HEAD>
<TITLE>Online Device Controller-- Request Confirmation
</TITLE>
</HEAD>
<BODY>
<H1>Hi Your request has been processed. Please wait for the Control Menu
to load in a few seconds….
</H1>
</BODY>
</HTML>

14
Online Device Controller

Parallel Port Basics

A PC Parallel Port (Printer Port) is an inexpensive and yet powerful platform for
implementing projects dealing with the control of real world peripherals. The printer
port provides eight TTL outputs, five inputs and four bidirectional leads and it provides a
very simple means to use the PC interrupt structure.

The Parallel Port is the most commonly used port for interfacing home made
projects. This port will allow the input of up to 9 bits or the output of 12 bits at any one
given time, thus requiring minimal external circuitry to implement many simpler tasks.
The port is composed of 4 control lines, 5 status lines and 8 data lines. It's found
commonly on the back of the PC as a D-Type 25 Pin female connector. There may also
be a D-Type 25 pin male connector. This will be a serial RS-232 port and thus, is a totally
incompatible port.

Newer Parallel Port’s are standardized under the IEEE 1284 standard first
released in 1994. This standard defines 5 modes of operation, which are as follows,
1. Compatibility Mode.
2. Nibble Mode.
3. Byte Mode.
4. EPP Mode (Enhanced Parallel Port).
5. ECP Mode (Extended Capabilities Port).

The most widely used mode is the Compatibility mode or "Centronics Mode" as it
is commonly known, which can only send data in the forward direction at a typical speed
of 50 Kbytes per second but can be as high as 150+ Kbytes a second.

15
Online Device Controller

Port Assignments

Each printer port consists of three port addresses; Data, Status and Control port.
These addresses are in sequential order. That is, if the Data port is at address 0x0378, the
corresponding Status port is at 0x0379 and the Control port is at 0x037A.

Address Notes
Used for parallel ports which were incorporated into
video cards and now, commonly an option for Ports
3BCh – 3BFh
controlled by BIOS. – Doesn’t support ECP addresses.
378h – 37Fh
Usual Address for LPT 1
278h – 27Fh
Usual Address for LPT 2

Port Addresses

Please refer to the figures titled Pin Assignments and Port Assignments. These
two figures illustrate the pin assignments on the 25-pin connector and the bit assignments
on the three ports.

Hardware Properties

The "Pin Outs" of the D-Type 25 Pin connector and the Centronics 34 Pin
connector are as shown in the table. The D-Type 25 pin connector is the most common
connector found on the Parallel Port of the computer, while the Centronics Connector is
commonly found on printers.

The IEEE 1284 standard however specifies 3 different connectors for use with the
Parallel Port. The first one, 1284 Type A is the D-Type 25 connector found on the back
of most computers. The 2nd is the 1284 Type B which is the 36 pin Centronics Connector
found on most printers. IEEE 1284 Type C however, is a 36 conductor connector like the
Centronics, but smaller. This connector is claimed to have a better clip latch, better

16
Online Device Controller

electrical properties and is easier to assemble. 1284 Type C connectors are yet to be
implemented in present day applications.

Pin No (D- Pin No SPP Signal Direction Register Hardware


Type 25) (Centronics) In/Out Inverted
1 1 nStrobe In/Out Control Yes
2 2 Data 0 Out Data
3 3 Data 1 Out Data
4 4 Data 2 Out Data
5 5 Data 3 Out Data
6 6 Data 4 Out Data
7 7 Data 5 Out Data
8 8 Data 6 Out Data
9 9 Data 7 Out Data
10 10 nAck In Status
11 11 Busy In Status Yes
12 12 Paper-Out In Status
Paper End
13 13 Select In Status
14 14 nAuto-Linefeed In/Out Control Yes
15 32 nError/ nFault In Status
16 31 nInitialise In/Out Control
17 36 nSelect-Printer In/Out Control Yes
nSelect-In
18 - 25 19 - 30 Ground GND

Pin Assignments of the D-Type 25 Pin Parallel Port Connector

Software Registers - Standard Parallel Port (SPP)

Port Assignments

17
Online Device Controller

The base address, usually called the Data Port or Data Register is simply used for
outputting data on the Parallel Port's data lines (Pins 2-9). This register is normally a
write only port. If we read from the port, we should get the last byte sent. However if the
port is bi-directional, then Read and Write Operations can be performed on the Data
Register and we can receive data on this address.

The Status Port (Base address + 1) is a read only port. Any data written to this
port will be ignored. The Status Port is made up of 5 input lines (Pins 10,11,12,13 & 15),
an IRQ status bit and two reserved bits. There are five status leads from the printer.
(BUSY, /ACK, PE (Paper Empty), SELECT, /ERROR). These are available at the 5 most
significant bits of the Status port. Of these, the BUSY pin is hardware-inverted and
typically this bit is inverted in the software application program to comply with the “True
Positive Logic”.

The Control Port (Base address + 2) was intended as a write only port. When a
printer is attached to the Parallel Port, four "controls" are used. These are Strobe, Auto
Linefeed, Initialize and Select Printer, all of which are inverted except Initialize.
However these four outputs can also be used for inputs. If the computer has placed a pin
high (e.g. +5v) and the device wanted to take it low, we would effectively short out the
port, causing a conflict on that pin. Therefore these lines are "open collector" outputs (or
open drain for CMOS devices). This means that it has two states: - a low state (0 V) and a
high impedance state (open circuit).

Normally the Printer Card will have internal pull-up resistors, but as we expect,
not all will. Some may just have open collector outputs, while others may even have
normal totem pole outputs. In order to make the device work correctly on as many Printer
Ports as possible, we can use an external resistor as well. If there is already an internal
resistor, then it will act in Parallel with it, or if they are Totem pole outputs, the resistor
will act as a load. An external 4.7k resistor can be used to pull the pin high.
18
Online Device Controller

The 4 pins of the Control Port can be used for bi-directional data transfer.
However the Control Port must be set to xxxx0100 to be able to read data, that is all pins
to be +5v at the port so that it can be pulled down to GND (logic 0). Bits 4 & 5 are
internal controls. Bit 4 will enable the IRQ. In the Standard & Bi-directional (SPP) Mode
of the Parallel port, Bit 5 will enable the Bi-directional port. In this case, we can use the 8
Data bits (DATA0-7) for input also. This mode is only possible if the card of the PC
supports the feature. Bits 6 & 7 are reserved.

At a minimum, there are 12 outputs; eight on the Data Port and four on the lower
nibble of the Control Port. There are five inputs, on the highest five bits of the Status
Port. Three output bits on the Control Port and one input on the Status Port are inverted
by the hardware, but this is easily handled by using the Exclusive-OR function to
selectively invert bits.

Using the Parallel Port's IRQ

A hardware interrupt is a capability where a hardware event causes the software


to stop whatever it is doing and to be redirected to a function to handle the interrupt.
When done, the program picks up where it left off. Aside from losing time in executing
the interrupt service routine, the operation of the main program remains unaffected by the
interrupt. Interrupts are good when interfacing monitoring devices where we don't know
when it is going to be activated. Indeed, it's more efficient to have an interrupt request
rather than have the software poll the ports regularly to see if something has changed.
The same technique may be adapted to exerting interrupts directly on the ISA bus.

The Parallel Port's interrupt request is normally IRQ5 or IRQ7 but may be
something else if these are in use. It may also be possible that the interrupts are totally
disabled on the card, if the card was only used for printing. The Parallel Port interrupt can
be disabled and enabled using bit 4 of the control register, Enable IRQ Via Ack Line.

19
Online Device Controller

Once enabled, an interrupt will occur upon a low to high transition (rising edge) of the
/ACK.

Interrupt Handler Table

The original 8088 PC design provided for up to 256 interrupts (0x00 - 0xff). This
includes both hardware and software interrupts. Each of these 256 interrupt types has four
bytes in a table beginning at memory location 0x00000. These 1024 bytes (256x4)
constitute the Interrupt Vector Table. These four bytes contain the address of where the
PC is to go to when an interrupt occurs. Most of the table is loaded when we boot up the
machine. The table may be added to or entries modified when various applications are
run.

The eight hardware interrupts beginning at INT 0x08 were reserved by IBM for
interrupt expansion, commonly known as IRQ0 - IRQ7; IRQ 0 corresponds to INT 8;
IRQ 1 corresponds to INT 9, etc. Typically, the Parallel Port uses the Interrupt Request
IRQ7.

Modifying the Interrupt Handler Table

Assume, we are going to use IRQ 7. When an IRQ 7 interrupt occurs, our
program must proceed to our Interrupt Service Routine, a function that we define. For
this, we must first modify the interrupt handler table. Initially we must read the present
value in the table, save it, perform the required operations and restore the original value
when our ISR terminates.

Masking

The programmer can mask or temporarily disable specific interrupts. In the


present context, we must set the interrupt mask such that IRQ 7 is enabled. Port 0x21 is
associated with the interrupt mask. To enable a particular IRQ (say, IRQ 7), write a zero
to that bit location. However, the other bits must not be altered. Prior to exiting from the

20
Online Device Controller

program, the user should return the system to its original state; by setting the altered bit
(bit 7) of the interrupt mask to logic one and restoring the interrupt vector.

If the IRQ Enable output is at logic one, an interrupt occurs on a negative going
transition on the /ACK input. Thus, in addition to setting the mask to entertain interrupts
from IRQ 7, we must also set IRQ Enable to a logic one.

Interrupt Service Routine

 Disable any further interrupts.


 Set Interrupt Mask to disable IRQ 7 interrupts.
 Set a variable such that in returning to the main program there is an indication that
an interrupt has occurred.
 Indicate to the PC that the interrupt was processed
 Enable all interrupts.
 Execute the required tasks of the ISR
 Disable all interrupts
 Set Interrupt Mask to enable IRQ 7 interrupts.
 Enable all interrupts.

21
Online Device Controller

DTMF Dialing System

To speed up the dialing procedure and to make it more reliable, the DTMF dialing
system is used. In this system, digits are transmitted as two tones simultaneously. This
explains the name "Dual Tone Multi Frequency". It is also known as DTMF dialing or mf
dialing. The tone frequencies are selected to avoid harmonic interference from speech
signals. There are eight frequencies defined in the DTMF system: four in a low frequency
group (679-941 Hz) and four in a high frequency group (1209-1633Hz).

A valid digit is defined as one of the low frequency group together with one tone
out of the high frequency group. In total, there are sixteen combinations possible but we
use only the digits 0-9. The maximum dialing speed with a DTMF system is typically 7
digits per second, i.e., a tone burst of 70 ms. With the pulse dialing system, the speed
varies between 1.1 to 0.56 digits per second. The DTMF is therefore ten times faster. The
major application for DTMF is low speed data transfer.

Generation of DTMF

1209 Hz 1336 Hz 1477 Hz 1633 Hz


1
2 3 A
697 Hz
4 5 6 B
770 Hz
7 8 9 C
852 Hz
* 0 # D
941 Hz

22
Online Device Controller

Two tunable oscillators, one for the low frequency group and one for the high
frequency group can be used to generate DTMF tones as shown in the figure above.

However, due to accurate frequency demand, ICs were put together with a crystal
oscillator and two synthesisers, which generate the DTMF tone digitally. Although, it
cannot synthesize the exact DTMF frequency, an inexpensive crystal has turned out to be
the most popular type of DTMF synthesizer clock that generates a frequency of
3579545Hz and can be divided down to the DTMF frequencies with only a small error.

Tone Details
The exchange will use standard DTMF frequencies for the calling number on the
line. The duration of the digit shall be 50 ms each.

Interface to the Telephone Line

The DTMF tones generated by the DTMF dialer must applied to the telephone
line respecting the AAC and DC requirements of the PTT. Most bipolar DTMF dialers
incorporate an on chip line interface. This approach results in very simple and efficient
circuit designs. The DTMF dialer is powered from the speech circuit peripheral supply
point. The DTMF tones are transmitted to the telephone line via the speech circuit line
interface. The mute signal generated by the DTMF dialer, controls the speech circuit and
determines when to transmit speech and DTMF signals. The switch over from speech
mode to dialing mode can be realized without noticeable audible clicks.

If the speech circuit passes part of the signals on its DTMF input to the earpiece
output, a confidence tone will be introduced. This approach is called the common line
interface architecture because both the speech and dialing parts of telephone are
connected to the by the same interface. If an appropriate speech circuit is not available for
interfacing the CMOS DTMF dialer to the telephone line, a separate line interface for the
dialer must be used. This requires a large number of discrete components.

23
Online Device Controller

Microcontrollers

The Microcontroller is another branch in the evolution of microprocessor


technology. Instead of focusing upon larger word widths & address space, the emphasis
here has been upon exceedingly fast real-time control. It has focused upon the integration
of the facilities needed to support fast control into a single chip. Its on chip resources
provide an integrated approach to a variety of real-time control tasks.

Features
The MCS51 architecture consists, of the following features:
 Eight-bit CPU with registers A (Accumulator) and B
 Sixteen-bit Program Counter (PC) and Data Pointer (DPTR)
 Eight-bit Program Status Word (PSW)
 Eight-bit Stack Pointer (SP)
 Internal ROM (8051) or EPROM (8751) or EEPROM (8951)
 Internal RAM of 128 bytes
o Four Register Banks each containing eight registers
o Sixteen bytes, which may be addressed at the bit level
o Eighty bytes of general-purpose data memory
 Thirty-two input/output pins arranged as four 8-bit Ports: P0-P3
 Two 16-bit Timer/Counters: T0 and T1
 Full duplex Serial Data Receiver/Transmitter: SBUF
 Control registers: TCON, TMOD, SCON, PCON, IP, and IE
 Two external and three Interrupt sources
 Oscillator and Clock circuits

24
Online Device Controller

Programming Model

The programming model of the MCS51 shows the MCS51 as a


collection of 8 bit and 16 bit registers and 8 bit memory locations. These registers and
memory locations can be made to operate using the software instructions that are
incorporated as part of the design. The program instructions have to do with the control
of the registers and digital data paths that are physically contained inside the
Microcontroller, as well as memory locations that are physically outside the
Microcontroller. To make a Microcomputer a Microcontroller, several special function
registers must be present. Each register, with the exception of the Program Counter, has
an internal 1-byte address assigned to it. Some registers are both byte addressable and bit
addressable. That is, the entire byte of data at such register addresses may be read or
altered, or individual bits may be read or altered. Software instructions are generally able
to specify a register by its address, its symbolic name, or both.

The 8951 Microcontroller

The 8951 is a second-generation Microcontroller belonging to the MCS51 family.


Compared to its predecessors, the 8951 provides a significantly more powerful
architecture, a more powerful instruction set, a full serial port and 4KB of internal
EEPROM. Some key product features include sophisticated I/O port capability, 4KB of
EEPROM, 128 bytes of internal RAM, two 16-bit Counter-Timers. Because all these I/O
devices are fabricated within the 8951, they form part of the programming model. The
8951 has an 8-bit ALU. It has 32 I/O lines organised as four 8-bit I/O ports. The 8951 can
also address external memory if there is not enough internal RAM or ROM. When used
to address external memory, two ports provide the memory addressing and data lines.

25
Online Device Controller

The Triac

The Triac is a three terminal, gated npnp device for controlling ac current in either
direction. Originally designated as a bi-directional triode thyristor, it is more commonly
referred to as Triode ac semiconductor (TRIAC).

Either positive or negative gate signals may be used to trigger the Triac into
conduction. This characteristic helps to simplify circuit design. The load or main current
terminals are designated as MT1 and MT2. Usually, MT1 is taken as the point of
reference for voltage and current measurements made and the gate terminal. Maximum
current and offset voltage ratings are of the order of 40 A and 800 V, respectively.

Theory of Operation

The n and p semiconductor sections between MT1 and MT2 can be considered as
parallel npnp and pnpn switches. The Triac is similar to connecting two SCRs in parallel
for bi-directional, or full wave, current conduction. The primary difference between
parallel SCRs and the equivalent switching sections of the Triac lies in the gate structure
and trigger methods.

The Triac can be switched to conduction either by gate triggering or by two other
operating conditions- exceeding the break over voltage rating, or a sharp rise in off-state
voltage. These methods of conduction are not employed in normal Triac operation but
they may be considered as limiting factors in circuit design. As a result, Triacs switched
to conduction by either of these mechanisms will not be damaged, since the Triac merely
switches to the on-state condition. In general, the Triac requires no external over voltage
protection.

However, a snubber network, consisting of a series resistor and capacitor


connected across the MT1 and MT2 terminals, can be used to protect a Triac from sharp
26
Online Device Controller

increases in the off-state voltage. The charging capacitor momentarily places the voltage
across the resistor and the energy contained in the sharply rising portion of the voltage
waveform is dissipated in the resistor. Snubber circuit can also protect the Triac against
voltage transients, which exceed the break over voltage level. The design of snubber
circuits must take into account peak line voltages, load characteristics, and time constant
of the RC network must be small when compared to the ac load conduction time.

Triac Turn On Methods

Triacs may be triggered into conduction by a variety if methods. The particular


application will generally dictate the method if triggering to be employed. The gate
circuits can be designed for static, zero voltage, or phase switching techniques. Each
method offers specific advantages and disadvantages.

Static Switching

Triacs employed in static switching circuits offer many advantages over


mechanical switching using relays or manually operated switches. This electronic
switching eliminates arcing and contact bounce, both of which are problems with moving
physical contacts. These factors result in more reliable operation and virtual elimination of
RFI. A resistor is connected to the gate circuit to limit the gate current and is about 100
ohms.

Zero-Voltage Switching

During zero voltage switching, the Triac conducts for virtually 360° of each cycle,
and full power is delivered to the load. The Triac is triggered at approximately the 0 and
180 degree points in the ac cycle. During power off periods, the Triac is held in a non-
conducting state. The ratio of power-on to power-off intervals determines the average
power applied to the load. The power-control time base may consist of intervals of 30 ac

27
Online Device Controller

cycles (one half second). If the Triac is switched on for 15 full cycles during each one-
half-second interval, the average power being applied to the load is one-half of full power.

Triac zero crossing switching circuits are used in industrial control and related
applications. Like static switching, zero crossing power switching systems are virtually
free of radio frequency interference problems. Another important advantage is the inherent
differential control capability that exists when gradual changes in average power can be
applied to a load.

Phase Control Switching

Triac phase-controlled gate circuits allow conduction of load current during a


specified portion of each ac half cycle. Simple resistive gate switching circuits can be
employed to trigger the Triac for firing angles up to 90 degree in each half cycle.
Resistance-capacitance phase shifting networks are used to delay the firing angle up to
nearly 180-degree.

The performance of phase controlled gate trigger circuits can be greatly improved
by the use of a trigger device. For low voltage levels, the trigger device exhibits high
impedance. Except for a small leakage current, no gate signal is presented to the Triac
during this time. When the applied voltage is increased to the break over level, the trigger
device suddenly latches into conduction. This presents a fast rising trigger signal to the
Triac, resulting in reliable turn on of load current.

Common trigger devices in use today are the diac, unijunction transistors (UJTs)
and special two-transistor configurations usually fabricated as one integrated circuit.

28
Online Device Controller

The Project

The Project

29
Online Device Controller

Block Diagram

30
Online Device Controller

Hardware Details

The Hardware unit of the system includes the following sections:


1. Microcontroller Card
2. DTMF Decoder Card
3. Relay Based ON/OFF Control Card
4. Triac Based Intensity Control Card
5. Status Reading Card
6. Power Supply Card

Microcontroller Card
The Microcontroller Card is the most important section of the ‘Online Device
Controller’ Hardware. This card is designed so as to provide the facility to control
ON/OFF devices and Intensity Variable loads. This Card is divided into the following
sub-sections: Parallel Port Input, DTMF Decoder Input, a 4-to-16 Decoder, NOT Gates
and Connector for interfacing different Loads.

The Microcontroller used is Atmel 89C51. The connections to the various Port
pins of the Microcontroller are as mentioned below:
P1.0 to P1.7 – Input Port connected to the Data bits of the Parallel Port
P2.0 to P2.3 – Input Port connected to the BCD Output of DTMF Decoder

P3.2 – /INT0 Interrupt connected to /STROBE pin (Pin 1) of the PC Parallel Port
P3.3 – /INT1 Interrupt connected to the Zero Crossing Detector circuit Output

P0.4 to P0.7 – Outputs the 4-bit ON/OFF Device Code to the 4-to-16 Decoder
P3.1 –The gate firing pulse for the Triac.
The Delayed Steering Output (Pin 15) of the DTMF Decoder (MM 8870) is used
to Interrupt the PC (IRQ 7) through Pin 10 of the Parallel Port.

31
Online Device Controller

DTMF Decoder Card


This Card makes possible the control of Load through the Cordless Phone. This
card includes the DTMF Decoder IC (MM 8870), and a Buffer IC (7407).

The DTMF Decoder IC receives the tone input from the Telephone Line
connected to the Telephone Exchange from the Base Unit of the Cordless Phone. For
each key pressed, the DTMF tone produced is decoded to the corresponding 4-bit BCD
Code by IC MM 8870. The reception of a valid DTMF tone generates a pulse at the Pin
15 of this IC, which is used to interrupt the PC through the Parallel Port pin 10 (/ACK).
Pin 11-14: 4-bit BCD Output
Pin 15: Delayed Steering Output

A 7407 Buffer IC is also used to drive the Decoder output before sending it to the
Microcontroller Input Port.

Relay Based ON/OFF Control Card


This Card includes a D Flip-Flop (CD 4013), Optocoupler (MCT2E), Relay
Driver Circuit and a 12 V single-pole Relay.
The D Flip-Flop is wired as a Toggle Flip-Flop, the output of which toggles for
every rising edge of its Clock input received from the Microcontroller Card. The MCT2E
provides electrical isolation. Each time the device is selected by the Microcontroller, the
Load (say, a Bulb) connected to the Relay toggles between ON and OFF states.

Triac Based Intensity Control Card


The Triac Based Intensity Control Card consists of the Zero Crossing Detector
Circuit and the Triac Based Intensity Control circuit. The Zero Crossing circuit provides
the reference signal for the MCU for generating firing pulses. It includes an Opamp
Comparator receiving 12 V AC supply and a 555 Timer IC wired as a Monoshot. The
Triac circuit makes use of MOC 3021, an opto-isolated Triac Driver IC which is
connected to the gate of the Triac. The variation in Firing Pulses generated by the MCU,

32
Online Device Controller

at the Triac Gate results in proportional Intensity variation at the Load connected to the
Triac.

Status Reading Card


The Status Reading Circuit consists of a Current Transformer, which senses the
current through the Load circuit. The CT produces a very low voltage which is amplified
using an Opamp amplifier (µA 741) and after opto isolation through an MCT2E, is fed to
the PC parallel port input pin. This circuit can sense whether the Load is On or OFF.

Power Supply Card


The Power Supply Card provides the necessary DC voltages +5V, +12V and -12V
required to power the various Cards used in the entire Hardware. This uses a Centre-
Tapped Transformer (230/12-0-12). The Power Supply Card uses 7805, 7812 and 7912
Voltage Regulator ICs for proper regulation.
To ensure extremely good electrical isolation by the Opto couplers used, the
Hardware unit comprises of two similar Power Supply Cards fed by the two secondary of
the Transformer.

33
Online Device Controller

Software Details
The ‘Online Device Controller’ software section mainly comprises the Web
Server Interface software (using CGI) and the Microcontroller programs.

Web Interface

This includes the interface between the hardware to the Internet. This is accomplished by
running a Web Server in a dedicated computer, the parallel port of which is connected to
the ‘Online Device Controller’ Hardware unit. The Web server running is used to execute
CGI programs. The Web server serves the homepage of the ‘Online Device Controller’
Website, when a remote browser requests the homepage at the given URL or IP address.
Initially, a username-password check is done and on success, the present status of devices
is available on the Web page as a Control Menu. In the Control Menu, the user can
change the status of the appliances as desired. The new control information is sent to the
Web server using a GET method, the Web Server passes this information to the CGI
program in the CGI-BIN directory, which checks the present status of devices read
through the Parallel port with the new control signal received, and outputs an appropriate
byte at the Parallel port, after interrupting the 8951 MCU. After a short delay, the new
status of devices is again read and the response is sent back to the Web Browser.

At present, we are offering the Web Interface software that runs on Windows 9x
platform. For this, we used Xitami, a commonly available Web Server for Windows
platform. The CGI programs were coded in the ‘C’ language and the Web pages were
designed using an HTML authoring tool.

Microcontroller Programs

The Microcontroller programs are used to manage the Hardware unit of the
‘Online Device Controller’. Written in the 8051 Assembly language, this includes the
programs to initiliase the Microcontroller, External Interrupt Service Routines, and
programs for timing and firing pulse generation.
34
Online Device Controller

Flow Charts

CGI Program
Read the CGI
Environment

Read the Present


Status of Devices
from Parallel
Port

Decode
Query-String

Store the requested


lamp and Fan Modes

Interrupt the 8951


MCU and output the
new Fan Mode
through Parallel Port

Is Lamp
N
mode Interrupt 8951 MCU
requested = and O/P Data
Status Read through Parallel Port

C
35
Online Device Controller

Insert Delay

Read the Present


Status of Devices

Send valid HTTP


Response Header and
new Device Status to
the Web Browser

End

MCU Main Program

Start

Initialize SP
Timers,
Interrupt Fan
Mode Register

8951 Enters into a wait loop,


ready to accept interrupts

36
Online Device Controller

Parallel Port Interrupt Service Routine (/INT 0)

37
Online Device Controller

Phone

Initialize Port 2 and


Read 4 Bit BCD Code
from DTMF Decoder

Store 4 Bit BCD


Code in R5

N N N N N
Is Is Is Is Is
R5=1 R5=2 R5=3 R5=4 R5=5

Y Y Y Y Y

Output Data Set Fan Set Fan Set Fan Set Fan
to Port 0 Mode to 0 Mode to 1 Mode to 2 Mode to 3

Reti

38
Online Device Controller

Fan

Select Lower 3
bits for Mode
Selection

Is N Is N Is N Is N
A=00h A=01h A=02h A=03h

Y Y Y Y

Set Fan Mode Set Fan Mode Set Fan Mode Set Fan Mode
(R6) to 0 (R6) to 1 (R6) to 2 (R6) to 3

Reti

Timer 0 Interrupt Service Routine


Timer 0

Clear P3.1

Stop
Timer 0

Reti
39
Online Device Controller

Zero Crossing Detector Interrupt Service Routine (/INT 1)

ZCD

Is Is Is Is
Fan N Fan N Fan N Fan N
Mode =0 Mode =1 Mode =2 Mode =3

Y Y Y Y

Clear P3.1 Set P3.1 Set P3.1 Set P3.1


Y

Initialize Timer 0 Initialize Timer 0 Initialize Timer 0


to Mode 1 to Mode 2 to Mode 3

Loads Count Loads Count Loads Count


EC78h for a D120h for a BFC8h for a
delay of 5ms delay of 12ms delay of 19ms

Clears Overflow Clears Overflow Clears Overflow


Flag, Start Timer Flag, Start Timer Flag, Start Timer

Reti

40
Online Device Controller

Working of the System

A typical scheme of the working of the system can be described as follows.

A remote user can log in from any location in the world to the homepage of the
Web server through the Internet/Intranet via a Web Browser. This request is processed by
the CGI and after security check, the user is presented with the current status of
equipments. Now he can control the equipments as required and he can send the
information through a form or menu. According to the control information received, the
CGI executes the required programs to read/write data to the parallel port (LPT1).

Local control is made possible with a Cordless telephone. The PC and phone
produces their own interrupts. When a key on the keypad is pressed, the arrival of a new
valid DTMF tone will interrupt the PC using the PC Parallel port (using IRQ 7). The
DTMF tone generated from the telephone line is decoded by the DTMF Decoder which
produces the corresponding 4 bit BCD code output which is read by the Microcontroller.
The Microcontroller 89C51 reads the appropriate control signal when interrupted by the
PC (through /INT0 pin of the Microcontroller). This is processed and is sent to the output
port, and to the devices. ON/OFF devices are controlled through the Relay Based Control
circuit and Intensity Variable Loads are controlled via the Triac Based Circuit. The firing
pulse for the Triac is generated by the 8951. To synchronize the firing pulse with the AC
cycle, a Zero Crossing Detector circuit is also used which is connected to another
interrupt pin (/INT1) of the Microcontroller.

After executing the control signals, the actual status of the equipments are read by
sensing the load current by means of a Current Transformer, is fed back through Status
Reading circuit and is read through the input pins of the PC Parallel Port.

Finally, the remote user will receive back the confirmation message that the status
of the devices has been changed as per the control signal sent by him. This completes the
cycle of events.
41
Online Device Controller

Result and Discussion

Through this project, the ‘Online Device Controller’ we are sure that we have
been able to accomplish a good task, something which will be useful to the society as a
whole. In fact, right from the design to the final implementation, we had gone through
several steps, and each of these was completed satisfactorily. After the initial design of
the circuits, these were assembled on the Breadboard and verified at the labs. The
Microcontroller program was developed using a software simulator, the Acebus 8051
IDE and the program was loaded into the Microcontroller EPROM. The Web Interface
software and DTMF Interrupt Service software were coded in C and were thoroughly
verified. The PCBs for the circuits were designed and etched. A user friendly and
pleasing Front Panel and Cabinet was designed and obtained. The entire hardware was
assembled. The software was checked on real time and the entire system was again
verified. The final product the ‘Online Device Controller’ is thus made available as a
finished product. The approximate cost of the entire product (on developmental stage) is
Rs.3000/-.

42
Online Device Controller

Conclusion and Future Scope

Thus, the ‘Online Device Controller (ODC) as implemented through our project
has emerged as a valuable product useful for several applications, ranging from Industrial
Control applications to Office Administration and even for domestic purposes. In this
world of Convergence, where everything from Cell phones to Palmtops meet the Internet,
we feel proud that our project has added a small drop to a big ocean.

The present system is presented as a general purpose one and can be enhanced by
adding several other features specific and relevant to the environment where it is to be
installed. This will bring greater and efficient utilization of the system. The project can be
very well implemented in Industrial applications if slightly more complicated Status
Reading Circuit and Automatic Control Loop is added. A Telephone based control from
Remote locations is also feasible with slight additions in hardware and software.

The possibilities offered by this system for the future, is limited only by one’s
imagination. The day is not a distant one, when all devices around us will get linked to
the Internet and that’s exactly what we are trying to prove through this project. Imagine
controlling all the gadgets of your home from any corner of the world, or switching off
the fan above your Office desk, even while you are on a flight to New York….

43
Online Device Controller

References

Books

[1] Perl, CGI, and JavaScript Complete, BPB Publications, New Delhi, 2000

[2] Manger, Jason J., The World Wide Web, Mosaic and More, 1994

[3] Ayala, Kenneth J., The 8051 Microcontroller: Architecture, Programming


& Applications, Penram International Publishing (India), Mumbai, 1996

Websites

[1] http://www.us-epanorama.net

[2] http://www.8052.com

[3] http://www.w3.org

[4] http://www.apache.org

[5] http://www.intel.com

[6] http://www.acebus.com

[7] http://www.google.com

44

Das könnte Ihnen auch gefallen