51016756 online device controller 1

Upload: mnz59

Post on 03-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 51016756 Online Device Controller 1

    1/46

    MINI PROJECT REPORTon

    ONLINE DEVICE CONTROLLERSubmitted in partial fulfillment of the requirements for the award of the degreeofBACHELOR OF TECHNOLOGY

    inELECTRONICS ENGINEERING

    of theCOCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY

    by

    AGIL FRANCIS HARRY JOSE M JIM CHERIANunder the guidance ofMr. LIJU PHILIP Lecturer, Electronics Engineering, College of Engineering Chengannur

    DEPARTMENT OF ELECTRONICS ENGINEERING, COLLEGE OF ENGINEERING, CHENGANNUR, KERALA - 689121.

    September 2001

  • 7/28/2019 51016756 Online Device Controller 1

    2/46

    Online Device Controller

    ACKNOWLEDGEMENTThis is the age of the Internet and the World Wide Web is becoming a part of thelife 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 theseveral people who have directly and indirectly helped us. We are extremely indebted to all of them and we wholeheartedly thank everyone for their valuable support. We are extremely grateful to Mr. P Prathapachandran Nair, our Principal forproviding 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. LijuPhilip 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 severalof 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 forthe 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

  • 7/28/2019 51016756 Online Device Controller 1

    3/46

    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 equallywell 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 Webserver 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 andan Intensity Variable load, through the Internet, and locally through a Cordless telephone and is a product of paramount significance in office, industrial andhousehold applications.

    2

  • 7/28/2019 51016756 Online Device Controller 1

    4/46

    Online Device Controller

    CONTENTSINTRODUCTION REVIEW The World Wide Web Common Gateway Interface Parallel Port Basics DTMF Dialing System Microcontrollers The Triac THE PROJECT Block Diagram Hardware details Software details Flow Charts Working of the System Result and Discussion CONCLUSION AND FUTURE SCOPE REFERENCES 4 5 6 9 15 22 24 26 29 30 31 34 35 41 42 43 44

    3

  • 7/28/2019 51016756 Online Device Controller 1

    5/46

    Online Device Controller

    INTRODUCTIONWith the advent of technology, the world has shrunk to a global village. Man hasbeen 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 theworld still remains unfulfilled. Our project envisages the control of equipmentsfrom 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 issuited 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 FeaturesRemote 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

  • 7/28/2019 51016756 Online Device Controller 1

    6/46

  • 7/28/2019 51016756 Online Device Controller 1

    7/46

    Online Device Controller

    The World Wide WebThe World Wide Web is the collection of all browsers, servers, files, and browseraccessible 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 thatdocuments located on one computer on the Internet could provide links to documents located on other computer on the Internet.

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

    Todays Web browsers extend Mosaics 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 serversretrieve Web documents in response to browser requests and forward the documents to the requesting browsers via the Internet. Web servers also provide gatewaysthat enable browsers to access Web-related applications as well as other Intern

    et services, such as Gopher and Wide Area Information Search (WAIS).

    The earliest Web servers were developed by CERN and NCSA. These servers were themainstay 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 tofacilitate the development of complex Web applications.

    6

  • 7/28/2019 51016756 Online Device Controller 1

    8/46

    Online Device Controller Because the Web uses the Internet as its communicationmedium, it must follow Internet communication protocols. The Internets 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 theHyperText 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 browsers request and sends a response back to the browser.

    A browser connects with the Web server by establishing a TCP connection at port80 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 orother resource being requested, the HTTP version being used by the browser, andother information related to the request.

    Several request methods are available. GET, HEAD, and POST are the most commonlyused 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 GETrequest, it delivers the requested information (if it can be found). The serverinserts at the 7

  • 7/28/2019 51016756 Online Device Controller 1

    9/46

  • 7/28/2019 51016756 Online Device Controller 1

    10/46

    Online Device Controller forward slash. For example, the following line from anHTML file shows the text of a title between the appropriate title tags. Welcome to the Control Menu of Online Device Controller

    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 doesnt 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 (Webbrowser). 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 waythe 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

  • 7/28/2019 51016756 Online Device Controller 1

    11/46

    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 CGICGI 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 serverto a CGI program and back.

    The following points summarise how CGI works

    A browser requests a CGI program by specifying the CGI programs URL. The requestarises 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 toCGI program, Most Web servers identify CGI programs by the path in which they are 10

  • 7/28/2019 51016756 Online Device Controller 1

    12/46

    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 ServerWhen a CGI program is executed, one of its first tasks is to determine what datawas passed to it by the Web Server. This data may be passed in the following ways:

    Command-line Arguments Environment Variables The programs standard input stream

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

    11

  • 7/28/2019 51016756 Online Device Controller 1

    13/46

    Online Device Controller

    Environment Variables

    Environment Variables are the primary mechanism by which web servers communicatewith CGI programs. All CGI programs can receive data from Web Servers via environment variables.

    Environment variables are variables that are external to a programs execution. They are used to define the environment in which a program executes. The followingtable identifies some commonly used environment variables defined by CGI version 1.1.

    Environment VariableAUTH_TYPE

    DescriptionThe 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

  • 7/28/2019 51016756 Online Device Controller 1

    14/46

    Online Device Controller PATH_TRANSLATED The full path name that was translatedfrom the URL by the Web server. QUERY_STRING REMOTE_ADDR The query string portion of the URL. The IP address of the host associated with the requesting browserREMOTE_HOST The name of the host associated with the requesting browser. REMOTE_USER The name of the user associated with the requesting browser. REQUEST_METHODThe method associated with the browser request: GET, POST, HEAD and so on. SCRIPT_NAME SERVER_NAME SERVER_PORT The path and name of the CGI program. The name of the Web server host. 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 basedquery, 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 DataWhen 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

  • 7/28/2019 51016756 Online Device Controller 1

    15/46

    Online Device Controller Spaces are replaced by plus (+) signs. Other charactersmay be replaced by character codes of the form %xx (with the xx being replacedby 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 isaccomplished by replacing plus signs with spaces, and sequences of the form %xxwith their character equivalent. This decoding is known as URL decoding.

    Sending Data back to the Web ServerA CGI program returns data to the requesting browser via the Web server. In allcases, 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 Online DeviceController-- Request Confirmation Hi Your request has been processed. Please wait for the Control Menu to load in a few seconds. 14

  • 7/28/2019 51016756 Online Device Controller 1

    16/46

    Online Device Controller

    Parallel Port BasicsA PC Parallel Port (Printer Port) is an inexpensive and yet powerful platform for implementing projects dealing with the control of real world peripherals. Theprinter 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 onegiven time, thus requiring minimal external circuitry to implement many simplertasks. 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-232port and thus, is a totally incompatible port. Newer Parallel Ports are standardized under the IEEE 1284 standard first released in 1994. This standard defines 5modes 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+ Kbytesa second.

    15

  • 7/28/2019 51016756 Online Device Controller 1

    17/46

    Online Device Controller

    Port AssignmentsEach 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 controlled by BIOS. Doesnt support ECP addresses. Usual Address for LPT 1 Usual Address for LPT 2 Port Addresses

    3BCh 3BFh 378h 37Fh 278h 27Fh

    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 PropertiesThe "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 theParallel 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 havea better clip latch, better

    16

  • 7/28/2019 51016756 Online Device Controller 1

    18/46

    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 (DType 25) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - 25

    Pin No (Centronics) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 32 31 36 19 - 30

    SPP Signal nStrobe Data 0 Data 1 Data 2 Data 3 Data 4 Data 5 Data 6 Data 7 nAckBusy Paper-Out Paper End Select nAuto-Linefeed nError/ nFault nInitialise nSelect-Printer nSelect-In Ground

    Direction In/Out In/Out Out Out Out Out Out Out Out Out In In In In In/Out In In/Out In/Out GND

    Register Control Data Data Data Data Data Data Data Data Status Status Status Status Control Status Control Control

    Hardware Inverted Yes

    Yes

    Yes

    Yes

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

    Software Registers - Standard Parallel Port (SPP)

    Port Assignments 17

  • 7/28/2019 51016756 Online Device Controller 1

    19/46

    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 Operationscan 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 thisport 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 leadsfrom 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 pinis 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, wewould effectively short out the port, causing a conflict on that pin. Thereforethese lines are "open collector" outputs (or open drain for CMOS devices). Thismeans 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 evenhave 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 ifthey are Totem pole outputs, the resistor will act as a load. An external 4.7kresistor can be used to pull the pin high. 18

  • 7/28/2019 51016756 Online Device Controller 1

    20/46

    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. Thismode is only possible if the card of the PC supports the feature. Bits 6 & 7 arereserved.

    At a minimum, there are 12 outputs; eight on the Data Port and four on the lowernibble of the Control Port. There are five inputs, on the highest five bits ofthe 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 IRQA hardware interrupt is a capability where a hardware event causes the softwareto 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 programremains 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 pollthe 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 inuse. 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

  • 7/28/2019 51016756 Online Device Controller 1

    21/46

  • 7/28/2019 51016756 Online Device Controller 1

    22/46

    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 oneand 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 setIRQ Enable to a logic one.

    Interrupt Service RoutineDisable 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 indicationthat 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

  • 7/28/2019 51016756 Online Device Controller 1

    23/46

    Online Device Controller

    DTMF Dialing SystemTo speed up the dialing procedure and to make it more reliable, the DTMF dialingsystem 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 pulsedialing system, the speed varies between 1.1 to 0.56 digits per second. The DTMFis therefore ten times faster. The major application for DTMF is low speed datatransfer.

    Generation of DTMF

    1209 Hz 1 697 Hz 770 Hz 852 Hz 941 Hz 4 7 *

    1336 Hz 2 5 8 0

    1477 Hz 3 6 9 #

    1633 Hz A B C D

    22

  • 7/28/2019 51016756 Online Device Controller 1

    24/46

    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 crystaloscillator 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 onlya small error.

    Tone DetailsThe 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 LineThe 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 thespeech 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 notic

    eable 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

  • 7/28/2019 51016756 Online Device Controller 1

    25/46

    Online Device Controller

    MicrocontrollersThe 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.

    FeaturesThe 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 o o Four Register Banks each containing eight registers Sixteen bytes, which may be addressed at the bit level 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 Controlregisters: TCON, TMOD, SCON, PCON, IP, and IE Two external and three Interruptsources Oscillator and Clock circuits

    24

  • 7/28/2019 51016756 Online Device Controller 1

    26/46

    Online Device Controller

    Programming ModelThe programming model of the MCS51 shows the MCS51 as a collection of 8 bit and16 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 MicrocontrollerThe 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 allthese I/O devices are fabricated within the 8951, they form part of the program

    ming 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 thememory addressing and data lines.

    25

  • 7/28/2019 51016756 Online Device Controller 1

    27/46

    Online Device Controller

    The TriacThe Triac is a three terminal, gated npnp device for controlling ac current in either direction. Originally designated as a bi-directional triode thyristor, itis 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 thepoint 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 800V, respectively.

    Theory of OperationThe 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 liesin 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 risein off-state voltage. These methods of conduction are not employed in normal Tr

    iac 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 sharp26

  • 7/28/2019 51016756 Online Device Controller 1

    28/46

  • 7/28/2019 51016756 Online Device Controller 1

    29/46

    Online Device Controller cycles (one half second). If the Triac is switched on for 15 full cycles during each onehalf-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 arevirtually 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 SwitchingTriac phase-controlled gate circuits allow conduction of load current during a specified portion of each ac half cycle. Simple resistive gate switching circuitscan be employed to trigger the Triac for firing angles up to 90 degree in eachhalf cycle. Resistance-capacitance phase shifting networks are used to delay thefiring 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 onof load current.

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

    28

  • 7/28/2019 51016756 Online Device Controller 1

    30/46

    Online Device Controller

    The Project

    The Project

    29

  • 7/28/2019 51016756 Online Device Controller 1

    31/46

    Online Device Controller

    Block Diagram

    30

  • 7/28/2019 51016756 Online Device Controller 1

    32/46

    Online Device Controller

    Hardware DetailsThe Hardware unit of the system includes the following sections: 1. 2. 3. 4. 5.6. Microcontroller Card DTMF Decoder Card Relay Based ON/OFF Control Card TriacBased Intensity Control Card Status Reading Card Power Supply Card

    Microcontroller CardThe 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, NOTGates 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 Thegate firing pulse for the Triac. The Delayed Steering Output (Pin 15) of the DT

    MF Decoder (MM 8870) is used to Interrupt the PC (IRQ 7) through Pin 10 of the Parallel Port. 31

  • 7/28/2019 51016756 Online Device Controller 1

    33/46

    Online Device Controller

    DTMF Decoder CardThis 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 tothe 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 byIC MM 8870. The reception of a valid DTMF tone generates a pulse at the Pin 15of 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 CardThis 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 CardThe 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

  • 7/28/2019 51016756 Online Device Controller 1

    34/46

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

    Status Reading CardThe 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 CardThe 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 CentreTapped Transformer (230/12-0-12). The Power Supply Card uses 7805, 7812 and 7912Voltage Regulator ICs for proper regulation. To ensure extremely good electricalisolation by the Opto couplers used, the Hardware unit comprises of two similarPower Supply Cards fed by the two secondary of the Transformer.

    33

  • 7/28/2019 51016756 Online Device Controller 1

    35/46

    Online Device Controller

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

    Web InterfaceThis 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 ControlMenu. 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 portwith 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 statusof 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 ProgramsThe 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

  • 7/28/2019 51016756 Online Device Controller 1

    36/46

    Online Device Controller

    Flow ChartsCGI ProgramRead 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 mode requested = Status Read

    N

    Interrupt 8951 MCU and O/P Data through Parallel Port

    y

    C 35

  • 7/28/2019 51016756 Online Device Controller 1

    37/46

    Online Device Controller

    C

    Insert Delay

    Read the Present Status of Devices

    Send valid HTTP Response Header and new Device Status to the Web Browser

    End

    MCU Main ProgramStart

    Initialize SP Timers, Interrupt Fan Mode Register

    8951 Enters into a wait loop, ready to accept interrupts36

  • 7/28/2019 51016756 Online Device Controller 1

    38/46

    Online Device Controller

    Parallel Port Interrupt Service Routine (/INT 0)

    37

  • 7/28/2019 51016756 Online Device Controller 1

    39/46

    Online Device Controller

    Phone

    Initialize Port 2 and Read 4 Bit BCD Code from DTMF Decoder

    Store 4 Bit BCD Code in R5

    Is R5=1 Y Output Data to Port 0

    N

    Is R5=2 Y Set Fan Mode to 0

    N

    Is R5=3 Y Set Fan Mode to 1

    N

    Is R5=4 Y Set Fan Mode to 2

    N

    Is R5=5 Y Set Fan Mode to 3

    N

    Reti

    38

  • 7/28/2019 51016756 Online Device Controller 1

    40/46

    Online Device Controller

    Fan

    Select Lower 3 bits for Mode Selection

    Is A=00h

    N

    Is A=01h

    N

    Is A=02h

    N

    Is A=03h

    N

    Y Set Fan Mode (R6) to 0

    Y Set Fan Mode (R6) to 1

    Y Set Fan Mode (R6) to 2

    Y Set Fan Mode (R6) to 3

    Reti

    Timer 0 Interrupt Service RoutineTimer 0

    Clear P3.1

    Stop Timer 0

    Reti

    39

  • 7/28/2019 51016756 Online Device Controller 1

    41/46

    Online Device Controller

    Zero Crossing Detector Interrupt Service Routine (/INT 1)

    ZCD

    Is Fan Mode =0 Y

    N

    Is Fan Mode =1 Y

    N

    Is Fan Mode =2 Y

    N

    Is Fan Mode =3 Y

    N

    Clear P3.1

    Y

    Set P3.1

    Set P3.1

    Set P3.1

    Initialize Timer 0 to Mode 1

    Initialize Timer 0 to Mode 2

    Initialize Timer 0 to Mode 3

    Loads Count EC78h for a delay of 5ms

    Loads Count D120h for a delay of 12ms

    Loads Count BFC8h for a delay of 19ms

    Clears Overflow Flag, Start Timer

    Clears Overflow Flag, Start Timer

    Clears Overflow Flag, Start Timer

    Reti

    40

  • 7/28/2019 51016756 Online Device Controller 1

    42/46

  • 7/28/2019 51016756 Online Device Controller 1

    43/46

    Online Device Controller

    Result and DiscussionThrough 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 asa whole. In fact, right from the design to the final implementation, we had gonethrough 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 MicrocontrollerEPROM. The Web Interface software and DTMF Interrupt Service software were coded in C and were thoroughly verified. The PCBs for the circuits were designed andetched. 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

  • 7/28/2019 51016756 Online Device Controller 1

    44/46

    Online Device Controller

    Conclusion and Future ScopeThus, 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 Palmtopsmeet 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 byadding several other features specific and relevant to the environment where itis 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 onesimagination. The day is not a distant one, when all devices around us will get linked to the Internet and thats exactly what we are trying to prove through thisproject. Imagine controlling all the gadgets of your home from any corner of theworld, or switching off the fan above your Office desk, even while you are on aflight to New York.

    43

  • 7/28/2019 51016756 Online Device Controller 1

    45/46

    Online Device Controller

    ReferencesBooks [1] [2] [3] Perl, CGI, and JavaScript Complete, BPB Publications, New Delhi,2000 Manger, Jason J., The World Wide Web, Mosaic and More, 1994 Ayala, KennethJ., The 8051 Microcontroller: Architecture, Programming & Applications, PenramInternational Publishing (India), Mumbai, 1996

    Websites [1] [2] [3] [4] [5] [6] [7] http://www.us-epanorama.net http://www.8052.com http://www.w3.org http://www.apache.org http://www.intel.com http://www.acebus.com http://www.google.com

    44

  • 7/28/2019 51016756 Online Device Controller 1

    46/46