develop by stariya

VIEWS: 5 PAGES: 13

									 MEng Final Year Project                                                                         Page 24
 ‘Remote environmental monitoring/control using the Internet’                                  May 2000



4.3 Development

This section aims to outline the development process followed during the project. Work done in
developing the final solution and tools used in the process are briefly described.



4.3.1 Web Server

Programs used:             Apache HTTP Server Version 1.3.9
Resources used:            Various Online, Books, Apache Documentation
Description:               Installation – Configuration – Running – Test


The most recent version of the Apache HTTP server, Win32 port, was downloaded from the
Apache website: www.apache.org
Supporting documentation was consulted and the server software installed.


After installation, it is necessary to configure the server for desired operation. This involves editing
parameters in some of the configuration files within the Apache ‘conf’ directory as required.


There are lots of other options which can be set before using Apache, although in order to get the
basic HHTP server operation working, only two changes to the httpd.conf file within the ‘conf’
directory of the server installation were required as shown in figure 4.3.


To configure the server for other options such as password protection, other configuration changes
must be made. Details of all options are available from in the Apache HTTP server documentation,
available from the Apache website, as well as in the CD accompanying this report.




 Daniel John McAuley                                                            Queens University Belfast
    MEng Final Year Project                                                                                  Page 25
    ‘Remote environmental monitoring/control using the Internet’                                           May 2000




                   #
                   # ServerAdmin: Your address, where problems with the server should be
                   # e-mailed. This address appears on some server-generated pages, such
                   # as error documents.
                   #
                   ServerAdmin mcauleyj@dnet.co.uk

                   #
                   # ServerName allows you to set a host name which is sent back to clients for
                   # your server if it's different than the one the program would get (i.e., use
                   # "www" instead of the host's real name).
                   #
                   # Note: You cannot just invent host names and hope they work. The name you
                   # define here must be a valid DNS name for your host. If you don't understand
                   # this, ask your network administrator.
                   # If your host doesn't have a registered DNS name, enter its IP address here.
                   # You will have to access it by its address (e.g., http://123.45.67.89/)
                   # anyway, and this will make redirections work in a sensible way.
                   #
                   ServerName 90.0.0.3


                  Figure 4.3 Configuration changes to httpd.conf for Apache set-up.


There are 2 ways Apache can be run:


     As a service
     From a console window


The option to run as a service is only available on Windows NT. This option starts Apache on boot-
up and allows it to continue to run, even when a user is logged off. Multiple instances of the server,
each with different configurations can also be run in this mode.


The console window is the only option available to Windows 95/98 users.


The operating system used in this project was Windows 98SE. Apache was run in a console
window (see figure 4.4), from the apache directory, using the following commands to start and stop
the server:


Start:             apache
Stop:              apache –k shutdown



    Daniel John McAuley                                                                     Queens University Belfast
    MEng Final Year Project                                                                   Page 26
    ‘Remote environmental monitoring/control using the Internet’                            May 2000


These commands can be incorporated as a shortcut, eliminating the need to run a command prompt
to invoke or kill the program.




                              Figure 4.4 Apache 1.3.9 running in console window



Detailed information about running Apache is available in the supporting documentation.[see
www.apache.org or documentation contained in the CD with this report]


Having installed, configured and run Apache, testing its operation involved pointing the browser to
either the host IP address, e.g.


                                                    http://90.0.0.3/


or ‘localhost’ if Apache was running on the same computer:


                                                   http://localhost/


If everything is operational, the response shown in figure 4.5 shown be displayed in the browser.


The operation of the server was verified:


     on the local machine
     over a LAN (10baseT)
     over the Internet (via dial-up-networking)


User HTML documents can then be copied into the server ‘htdocs’ directory or sub-directories,
which will be served by Apache.
    Daniel John McAuley                                                      Queens University Belfast
    MEng Final Year Project                                                                         Page 27
    ‘Remote environmental monitoring/control using the Internet’                                  May 2000




4.3.2 CGI Application Interface successful installation of the Apache HTTP Server
       Figure 4.5 Response indicating

Programs used:                Visual Basic, Visual C++, HyperTerminal, TAL Breakout
Resources used:               Online documentation, tutorials, newsgroups; Books
Description:                  Options – Trial – Simple CGI – Full Implementation


The three programming languages considered for implementing the CGI program were:


     PERL
     Visual Basic
     Visual C/C++
It was realised that, along with the normal CGI requirements for passing variables to/from the Web
server, the final CGI program had to be able to access the serial port of the PC to communicate with
the Control Device.


    Daniel John McAuley                                                            Queens University Belfast
    MEng Final Year Project                                                                      Page 28
    ‘Remote environmental monitoring/control using the Internet’                               May 2000


A brief look into what was involved in implementing serial communications with each language
yielded the following results:


PERL:              Most easily achieved using the ‘Win32::SerialPort’ module.
Visual Basic: Including the ‘MSComm’ control within VB.
Visual C++: Using Windows communication API functions.


Two utilities for producing CGI programs in Visual Basic and C were also found. These utilities
can be included in the CGI project and help reduce the amount of coding required by providing
common functions required in CGI.


Details of the utilities are as follows:


Visual Basic: VB5-CGI Objects from ‘Easyware’ www.eazyware.com/vb5-cgi/


The VB5-CGI Objects is an extension to Visual Basic which allows you to perform CGI specific
tasks. It is stated that the VB5-CGI objects provide:


     Low-level functionality, like direct access to stdin, stdout, servers environment variables and
      cookie handling.
     Enhanced support for HTML 3.2 authoring.
     Automatic URL-decoding, query string length and submit method limitation.
     Direct form field validation and value retrieval.
     Simple MS-Access (.mdb) database browsing.
     Easy debugging within the Visual Basic IDE.


C:                 CGIC: An ANSI C library for CGI Programming
                   by Thomas Boutell: www.boutell.com/cgic/


CGIC is an ANSI C-language library for the creation of CGI-based World Wide Web applications.
CGIC performs the following tasks:
     Parses form data, correcting for defective and/or inconsistent browsers
     Transparently accepts both GET and POST form data
     Handles line breaks in form fields in a consistent manner

    Daniel John McAuley                                                         Queens University Belfast
    MEng Final Year Project                                                                       Page 29
    ‘Remote environmental monitoring/control using the Internet’                                May 2000


     Provides string, integer, floating-point, and single- and multiple-choice functions to retrieve
      form data
     Provides bounds checking for numeric fields
     Loads CGI environment variables into C strings which are always non-null
     Provides a way to capture CGI situations for replay in a debugging environment




Both these utilities are compatible with the CGI standard, so work with any Web Server which
supports CGI.


More information on these utilities is provided in the CD-ROM.


Given this information on the three languages, it was decided not to use PERL for this application.
This was largely due to the fact that PERL is an interpreted language and would therefore require
the installation of PERL in order to run any programs produced.


Trial CGI programs were produced with Visual Basic and Visual C++ using the two utilities
mentioned. This was to gain experience in CGI programming and to determine which language
would be best suited to implement the final program.


The operation of the two programs produced was fairly simple, providing the following actions:


     Accept user input in the form of a Querystring, from a form submission.
     Configure serial port
     Open the serial port
     Send the Querystring over the serial port
     Close the serial port
     Return HTML with user Querystring displayed


The arrangement used to test the operation of these programs is shown in figure 4.6




    Daniel John McAuley                                                          Queens University Belfast
 MEng Final Year Project                                                                       Page 30
 ‘Remote environmental monitoring/control using the Internet’                                May 2000


         Web Browser

                                                                Server
             FORM



                                                                                  Apache
                                                                                  Test CGI




                                                                           Crossover

                       HyperTerminal                                     Serial Cable




                                          Laptop


                               Figure 4.6 Set-up for CGI test and debug


The test/debug set-up shown in figure 4.6 consists of a PC and laptop/second PC, connected using a
crossover serial cable.


The PC runs Apache and has the desired test CGI program and accompanying HTML form
document located in the appropriate directories of the server (cgi-bin and htdocs respectively). A
Web browser is then used to submit the form with user input to the Web Server and CGI program
as well as observe the HTML response.


The second PC or laptop runs HyperTerminal, which displays data received from the serial port. It
is important that the CGI program and HyperTerminal use the same serial settings.


Figure 4.7 shows the form, HTML response and data received through HyperTerminal, for a
successful execution of the Visual Basic test CGI program.




 Daniel John McAuley                                                          Queens University Belfast
 MEng Final Year Project                                                                    Page 31
 ‘Remote environmental monitoring/control using the Internet’                             May 2000




       FORM




      HTML
    RESPONSE




   SERIAL DATA
    RECEIVED




           Figure 4.7 Screenshots indicating successful test of the Visual Basic test CGI
                                                    program
The CGI program written in C operates in the same manner as the Visual Basic program shown.
Source code for both test CGI programs (VB_CGI.exe and C_CGI.exe) can be found in Appendix 3
as well as on the CD-ROM accompanying this report.


Having implemented test CGI programs in Visual Basic and C (using Visual C++), a decision could
be made regarding the language used to implement the final CGI program.




C was chosen for two main reasons:
 Daniel John McAuley                                                       Queens University Belfast
    MEng Final Year Project                                                                       Page 32
    ‘Remote environmental monitoring/control using the Internet’                                May 2000


     Personal preference and past experience in using the C language
     Ability to compile to standalone executable which does not require runtime DLLs (the VB
      implementation requires VB runtime DLL’s as well as the VB5_CGI DLL’s).


The development of the final CGI program was carried out using Visual C++ and using the
test/debug set-up shown in figure 4.6. The test/debug set-up can be used to monitor the serial output
of the CGI program as well as provide feedback or response data over the serial port via
HyperTerminal. This allowed the development of the CGI program to proceed in parallel with that
of the Control Device, as a working model was not necessary to test the CGI program.


The final design and implementation of the CGI program is discussed in Chapter 5.



4.3.3 Control Device Development

Programs used:                MPLAB, CCS PIC-C PCM compiler, TAL Breakout,
                              EasyPC, HyperTerminal
Resources used:               PIC Millennium Development Kit, Datasheets, Online resources,
                              CCS Example programs
Description:                  Familiarisation – Development Kit Configuration – Embedded Software –
                              Sensor Integration – Final Design & Construction


Development of the Control Device initially involved becoming familiar with the requirements of
the chosen PIC microcontroller, the PIC16F876.
Datasheets, various online and written resources, as well as University staff were consulted to gain
knowledge on the hardware implementation and software programming of PIC devices.


A block design of what was required for the control device was constructed, as shown in figure 4.8.




    Daniel John McAuley                                                          Queens University Belfast
 MEng Final Year Project                                                                     Page 33
 ‘Remote environmental monitoring/control using the Internet’                              May 2000




                       Power                           Clk              Sensors            To other
                                                                                           sensors




                                                  PIC16F876




  To PC                Serial                        Inputs             Outputs
Serial Port


                           Figure 4.8 Block design of Control Device hardware

The basic circuit structure was implemented on the PIC Millennium Development Board, as shown
in figure 4.9. As the picture shows, the kit contains a PCB with a wide range of components and
peripherals built in, for example LCD display, keypad, seven segment displays, serial connectors,
breadboard, switches and LED’s. It provides an ideal environment for the rapid construction of PIC
related projects.




                            Figure 4.9 PIC Millennium Development Board


With the prototype circuit implemented on the development board, work could progress on the


embedded software for the microcontroller.
 Daniel John McAuley                                                        Queens University Belfast
 MEng Final Year Project                                                                       Page 34
 ‘Remote environmental monitoring/control using the Internet’                                May 2000


The embedded software development followed the cycle shown in figure 4.10.




                                                                  DESIGN
                                     DESIGN ERROR




                                                                WRITE CODE
                                     CODING ERROR




                   DETERMINE ERROR
                                                                 COMPILE
                           SOURCE                  ERROR


                                                                       SUCCESS




                                                                PROGRAM PIC
                                                   ERROR


                                                                       SUCCESS




                                                                TEST/DEBUG
                                                   ERROR


                                                                       SUCCESS




                                                                  FINISH



                            Figure 4.10 PIC Software Development Cycle


Tools used in each stage of the software development cycle are summarised in table 4.1 next:




 Daniel John McAuley                                                          Queens University Belfast
 MEng Final Year Project                                                                          Page 35
 ‘Remote environmental monitoring/control using the Internet’                                   May 2000


  Development Stage                                                Tools Used
Write Code                     Text Editor within MPLAB
Compile                        CCS Pic-C PWM compiler, integrated with MPLAB
Program PIC                    PICSTART Plus Programmer + Integrated MPLAB interface
Test & Debug                   One or both of the following set-ups;
                               1. HyperTerminal with Development Board connected direct to PC
                                   serial port (figure 4.11 ‘a’)
                               2. Using TAL Breakout to use a PC as a serial communications
                                   analyser (figure 4.11 ‘b’)

                   Table 4.1 Summary of tools used in PIC software development




          HyperTerminal


 (a)
                                                                                PIC Development
                                              Serial port                            Board
                                                   1


          LAPTOP



          HyperTerminal                     TAL Breakout


 (b)
                                                                                PIC Development
                                                                                     Board
                            Serial port                         Serial port
                                 1                                   2


          LAPTOP                            PC AS SERIAL
                                             ANALYSER

                 Figure 4.11 Test and Debug set-ups used in project development


The development board, software and test tools were used to develop the final embedded software
for the PIC16F876.
Initial test programs were written to gain experience in specific areas of the microcontroller (e.g.
the on board USART, I/O etc). Following this, individual modules (e.g. the serial communication
protocol employed between the control device and PC, or the integration of the chosen temperature
 Daniel John McAuley                                                             Queens University Belfast
 MEng Final Year Project                                                                        Page 36
 ‘Remote environmental monitoring/control using the Internet’                                  May 2000


sensor (DS1820), were developed using these tools and techniques. Finally, the overall embedded
code, described in Chapter 5, was produced by integration of required modules.


Other tools used in the project include ‘Designworks Lite’ for schematic entry and ‘Easy PC’ for
PCB layout.




4.3.4 User Interface

The user interface development involved completing tutorials in the use of HTML and Flash, as
well as creating sample pages to gain experience.


The interface used for the project contains both HTML and Flash content. A detailed description of
what was involved in using these is outside the scope of this project and will not be given.
Additional information regarding the use of HTML and Flash is easily obtained at various locations
on-line if required.




 Daniel John McAuley                                                          Queens University Belfast

								
To top