Online Device Controller
Online Device Controller
Online Device Controller
on
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
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.
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
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 PROJECT 29
Block Diagram 30
Hardware details 31
Software details 34
Flow Charts 35
Working of the System 41
Result and Discussion 42
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
Power regulation
4
Online Device Controller
Review
5
Online Device Controller
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.
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.
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.
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.
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.
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.
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.
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
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.
13
Online Device Controller
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.
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.
14
Online Device Controller
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.
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.
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.
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.
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
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.
21
Online Device Controller
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
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.
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
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
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.
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.
Static Switching
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.
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
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
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.
32
Online Device Controller
at the Triac Gate results in proportional Intensity variation at the Load connected to the
Triac.
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
Decode
Query-String
Is Lamp
N
mode Interrupt 8951 MCU
requested = and O/P Data
Status Read through Parallel Port
C
35
Online Device Controller
Insert Delay
End
Start
Initialize SP
Timers,
Interrupt Fan
Mode Register
36
Online Device Controller
37
Online Device Controller
Phone
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
Clear P3.1
Stop
Timer 0
Reti
39
Online Device Controller
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
Reti
40
Online Device Controller
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
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
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
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