Moi University Faculty of Technology Department of Electrical and Communications Engineering Control and Monitoring of Non-computing Devices Over The Internet and The GSM Cellular Network COURSE: ELC 590-Engineering Project II NAME: Makau Thomas Mulei –EC/14/98 SUPERVISORS: Dr. Marcel Odhiambo PhD and Dr. George Kamuncha PhD This report is submitted in partial fulfillment for the award of the degree of Bachelor of Technology in Electrical and Communications Engineering of Moi University PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Moi University Faculty of Technology Department of Electrical and Communications Engineering
Control and Monitoring of Non-computing Devices Over The Internet and The GSM Cellular Network
COURSE: ELC 590-Engineering Project II NAME: Makau Thomas Mulei –EC/14/98 SUPERVISORS: Dr. Marcel Odhiambo PhD and Dr. George Kamuncha PhD
This report is submitted in partial fulfillment for the award of the degree of Bachelor of Technology in Electrical and Communications Engineering of
Moi University
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
1.1 PREAMBLE ----------------------------------------------------------------------------------1 1.1.1 MOTIVATION ------------------------------------------------------------------------------1 1.1.2 PROJECT AIM AND OBJECTIVES---------------------------------------------------------1 1.1.2.1 The local Objectives:------------------------------------------------------------------1 1.1.2.2 The global objectives: ----------------------------------------------------------------1
2 CHAPTER TWO: LITERATURE REVIEW ----------------------------------------3
2.1 WEB-BASED CONTROL -------------------------------------------------------------------3 2.1.1 THE INTERNET ----------------------------------------------------------------------------4 2.1.1.1 Web Servers ----------------------------------------------------------------------------5 2.1.2 RELATIONAL DATABASE SYSTEMS ----------------------------------------------------5 2.1.3 OSI REFERENCE MODEL ----------------------------------------------------------------6 2.1.3.1 Types And Sources Of Network Threats----------------------------------------- 11 2.1.3.2 Protecting a Network Using Firewalls ------------------------------------------- 12 2.2 THE GLOBAL SYSTEM FOR MOBILE COMMUNICATIONS (GSM)----------------15 2.2.1 ARCHITECTURE OF THE GSM NETWORK -------------------------------------------- 15 2.2.2 SHORT MESSAGE SERVICE (SMS) ---------------------------------------------------18 2.3 SOFTWARE DEVELOPMENT ------------------------------------------------------------23 2.3.1 APPLICATION DEVELOPMENT CYCLE -------------------------------------------------23
3.1 PROBLEM ANALYSIS -------------------------------------------------------------------- 27 3.2 PROJECT CHALLENGES----------------------------------------------------------------- 28 3.3 PROPOSED SOLUTION ------------------------------------------------------------------- 28 3.4 THE CONTROL AND MONITORING SYSTEM ----------------------------------------- 29
4 CHAPTER FOUR: SYSTEM DESIGN --------------------------------------------- 33
4.1 WEB SERVER ----------------------------------------------------------------------------- 33 4.1.1 APACHE WEB SERVER ----------------------------------------------------------------- 33 4.1.2 MICROSOFT INTERNET INFORMATION SERVER (IIS)-------------------------------33 4.1.3 XITAMI WEB SERVER ------------------------------------------------------------------ 34 4.1.4 SCRIPTING -------------------------------------------------------------------------------35 4.1.4.1 How PHP is installed ---------------------------------------------------------------36 4.2 DATABASE SERVER ---------------------------------------------------------------------- 37 4.2.1 MICROSOFT SQL ----------------------------------------------------------------------- 37 4.2.2 ORACLE----------------------------------------------------------------------------------38 4.2.3 MYSQL----------------------------------------------------------------------------------38 4.2.3.1 Installing MySQL ------------------------------------------------------------------- 39
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
4.2.3.2 Creating the database ---------------------------------------------------------------40 4.3 OPEN DATA BASE CONNECTIVITY (ODBC) DATA ACCESS ENGINE ------------ 41 4.4 USER INTERFACE ------------------------------------------------------------------------ 42 4.4.1 DESIGNING THE WEB INTERFACE-----------------------------------------------------43 4.5 SOFTWARE DESIGN---------------------------------------------------------------------- 45 4.6 SOFTWARE CODING --------------------------------------------------------------------- 49 4.6.1 THE SPLASH SCREEN ------------------------------------------------------------------- 50 4.6.2 MOBILE PHONE ACCESS PROGRAM ---------------------------------------------------50 4.6.3 DATABASE ACCESS PROGRAM --------------------------------------------------------51 4.7 REMOTE COMPUTER INTERFACE -----------------------------------------------------52 4.7.1 SERIAL INTERFACE --------------------------------------------------------------------- 52 4.7.2 PARALLEL INTERFACE ----------------------------------------------------------------- 53 4.7.3 PORT ACCESS --------------------------------------------------------------------------- 54 4.8 SWITCHING INTERFACE CIRCUIT -----------------------------------------------------54 4.8.1 CIRCUIT OPERATION ------------------------------------------------------------------- 55 4.8.2 MONITORING CIRCUITS----------------------------------------------------------------56
5 CHAPTER FIVE: TESTS AND RESULTS ---------------------------------------- 59
5.1 CIRCUIT TESTING ------------------------------------------------------------------------ 59 5.1.1 BURN-IN TEST--------------------------------------------------------------------------- 59 5.2 PROGRAM TESTING---------------------------------------------------------------------- 59 5.3 SYSTEM TESTING ------------------------------------------------------------------------ 60 5.3.1 WEB CONTROL -------------------------------------------------------------------------- 61 5.3.2 TEXT MESSAGE (SMS) CONTROL-----------------------------------------------------61 5.3.3 WEB THEN SMS TEXT CONTROL -----------------------------------------------------62
6.1 COST ANALYSIS -------------------------------------------------------------------------- 64 6.1.1 SYSTEM LEARNING AND DESIGN ------------------------------------------------------64 6.1.2 RETURN ON INVESTMENT -------------------------------------------------------------65 6.1.3 TO INSTALL OR NOT?------------------------------------------------------------------- 66
7 CHAPTER SEVEN: CONCLUSION AND RECOMMENDATIONS-------- 68
9.1 APPENDIX I -------------------------------------------------------------------------------73 9.2 APPENDIX II ------------------------------------------------------------------------------ 78
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Operations: These are the actions used to define the structures or manipulate data between
the structures. SELECT statements or CREATE statements are examples of operations
in Oracle and MySQL.
Integrity rules: These govern the kinds of actions allowed on data and the database
structure. Integrity rules protect the data and the structure of the database. The primary
keys and foreign keys are examples of integrity rules in Oracle and MySQL.
2.1.3 OSI Reference Model The Open Systems Interconnection1 (OSI) reference model is a conceptual blueprint of
how communications should take place. It addresses all the processes required for
effective communication and divides these processes into logical groupings called layers.
When a communication system is designed in this manner, it’s known as layered
architecture.
The main advantages of a layered approach to WAN2 design are as follows:
q Dividing the complex network operation into more manageable layers
q Changing one layer without having to change all layers. This allows application
developers to specialize in design and development.
q Defining the standard interface for the “plug-and-play” multivendor integration
The OSI has seven levels on which the different equipment belongs to. These are:
Layer 7: The Application layer provides the software for network services such as file
transfer, remote login, remote execution, e-mail and etc. It provides the interface
between the user programs and the network. “What the user runs”
Layer 6: The Presentation layer converts outbound data from a machine specific format
to an international standard format and vice versa. “Translator”
Layer 5: The Session layer allows the setup and termination of communication path, and
synchronizes the dialog between the two systems. “Terminal emulator”
Layer 4: The Transport layer provides reliable flow of datagrams between the sender and
receiver, and ensures that the data arrives at the correct destination. “Software error
correction”
1 The OSI Reference model was designed by the International Standards Organization (ISO) 2 The Internet can be considered as a Wide Area Network (WAN) covering the whole world
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Layer 3: The Network layer decides the path that will be taken through the network. It
provides packet addressing which will alert computers on the network as to where to
route the users data. “Addressing schemes”
Layer 2: The Data link layer provides reliable, error free media access for data
transmission. It produces the frame around data. “Hardware error correction”
Layer 1: The Physical layer establishes the actual physical connection (cable) between the
network and the computer equipment. The functions provided at this level include the
type of signaling (what represents a bit 0, what represents a 1), cable length
specifications, and connector size, etc. “Cable”
Application
Presentation
Session
Transport
Network
Data link
Physical
Fig 2.1: The OSI reference model
Internet Protocol (IP) addressing
Internet nodes are uniquely identified by an Internet protocol (IP) address. An Internet
node can be a router, hub, gateway, server or a desktop computer that is connected to
the Internet.
An IP address consists of 32 bits of information. These bits are divided into four
sections, referred to as octets or bytes, each containing 1 byte (8 bits).
One can depict an IP address using one of three methods:
q Dotted-decimal, as in 172.16.30.56
q Binary, as in 10101100.00010000.00011110.00111000
q Hexadecimal, as in 82 39 1E 38
All these examples represent the same IP address. Although hexadecimal is not used
as often as dotted-decimal or binary when IP addressing is discussed.
File, print, database and application services Data encryption, compression and translation services Dialog Control End-to-End Connection Routing Framing Physical topology
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
DoS (Denial-of-Service) attacks are probably the nastiest, and most difficult to address.
These are the nastiest, because they're very easy to launch, difficult (sometimes
impossible) to track, and it isn't easy to refuse the requests of the attacker, without also
refusing legitimate requests for service.
The premise of a DoS attack is simple: send more requests to the machine than it can
handle. There are toolkits available in the market that make this a simple matter of
running a program and telling it which host to blast with requests. The attacker's
program simply makes a connection on some service port, perhaps forging the packet's
header information that says where the packet came from, and then dropping the
connection. If the host is able to answer 20 requests per second, and the attacker is
sending 50 per second, obviously the host will be unable to service all of the attacker's
requests, much less any legitimate requests (hits on the web site running there, for
example).
Such attacks were fairly common in late 1996 and early 1997, but are now becoming less
popular. 3
Some things that can be done to reduce the risk of being stung by a denial of service
attack include:
q Not running the visible-to-the-world servers4 at a level too close to full capacity.
q Using packet filtering to prevent obviously forged packets from entering into
your network address space5.
q Obviously forged packets would include those that claim to come from your own
hosts, addresses reserved for private networks as defined in RFC 1918
[Moskowitz et al 1991], and the loopback network (127.0.0.0).
q Keeping up-to-date on security-related patches for your hosts' operating systems.
Unauthorized Access
“Unauthorized access” is a very high-level term that can refer to a number of different
sorts of attacks. The goal of these attacks is to access some resource that a machine
3 In 1999 a DoS attack brought the Internet to a standstill when an attacker attacked yahoo.com, amazon.com, deutschebank.de and hsbc.com 4 These include mail, HTTP and FTP servers. 5 Ingress (in bound) and Egress (out bound) packet filtering can be applied on Internet gateways
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
The MM function is in charge of all the aspects related with the mobility of the user,
specially the location management and the authentication and security.
Location management: When a mobile station is powered on, it performs a location update
procedure by indicating its IMSI to the network. The first location update procedure is
called the IMSI attach procedure. The mobile station also performs location updating, in
order to indicate its current location, when it moves to a new Location Area or a
different PLMN. This location-updating message is sent to the new MSC/VLR, which
gives the location information to the subscriber's HLR. If the mobile station is
authorized in the new MSC/VLR, the subscriber's HLR cancels the registration of the
mobile station with the old MSC/VLR. A location updating is also performed
periodically. If after the updating time period, the mobile station has not registered, it is
then deregistered.
When a mobile station is powered off, it performs an IMSI detach procedure in order to
tell the network that it is no longer connected.
Authentication and security: The authentication procedure involves the SIM card and the
Authentication Center. A secret key, stored in the SIM card and the AuC, and a ciphering
algorithm called A3 are used in order to verify the authenticity of the user. The mobile
station and the AuC compute a SRES using the secret key, the algorithm A3 and a
random number generated by the AuC. If the two computed SRES are the same, the
subscriber is authenticated. The different services to which the subscriber has access are
also checked.
Another security procedure is to check the equipment identity. If the IMEI number of
the mobile is authorized in the EIR, the mobile station is allowed to connect the
network.
In order to assure user confidentiality, the user is registered with a Temporary Mobile
Subscriber Identity (TMSI) after its first location update procedure.
2.2.2 Short Message Service (SMS) Short Message Service (SMS) messages are 160 character text messages, sent using a
SDCCH 7(slow speed data channel) from a mobile phone handset to another handset.
7 This means that they can be sent at the same time as a fax or data call, but also means that they can be a little slow because of the limited bandwidth available to carry them.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
The Data Coding Scheme (DCS) parameter is used for several purposes, including the
following:
q Indicate the form in which the short message text (user data) is encoded, be it the
GSM 7-bit default alphabet, 16-bit text or binary.
q Specify short message classes, which tell the mobile phone how to deal with the
short message. For example, the Data Coding Scheme flag is used to indicate
whether to store the short message in the SimCard or memory, send it directly to
the display or to Terminal Equipment attached to the mobile phone.
q Allow a receiving Short Message Entity to display an icon associated with a short
message, such as an email or voice mail icon.
q Indicate that a short message is compressed.
Protocol Identifier (PID)
Another flag that is used for a wide variety of purposes is the Protocol Identifier (PID).
The PID determines how the short message should be handled by the receiving entity or
the SMS Center. Uses of the Protocol Identifier include:
Routing short messages to the correct outbound interface: This is useful when several interfaces
share the same numbering plan (e.g. PSTN fax and voice). Use of the Protocol Identifier
indicates to the SMS Center where to send the short message to maximize the likelihood
that it is successfully delivered to its intended Destination Address.
Routing by Protocol Identifier is, for example, used in the provision of SMS to Fax
services, through which a mobile phone user can send a short message to a fax machine.
The SMS Center recognizes that the Protocol Identifier indicates an SMS to Fax message
and routes the short message to the module within the SMS Center that incorporates fax
outdial, or an SMS to Fax platform resident outside the SMS Center itself.
Indicating that a mobile phone receiving a short message should check to see if a short
message of the same type is currently stored and if so replace it with the new one.
Reply Path
The Reply Path allows a user to indicate to the receiver that a reply to the short message
is requested. When the recipient chooses to reply to a short message, the SMSC Address
8 The Data Coding Scheme values are described in GSM 03.38. How or if they are supported depends on the specific mobile phone. Network support of the DCS parameter also varies- application developers and users have to check with their network operator to see which if any uses of the DCS are allowed.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
The GSM Network This is the wireless cellular phone network that is currently provided by Safaricom and
Kencell Communications Ltd. The user of the system can use the GSM network as a
backup of the Internet (incase Internet fails) or when the user is out of reach of an
Internet connected computer. To control say the lights, the user sends a SMS to his
home phone with the message ‘lights on’, to switch them off, he/she sends ‘lights off’.
The system is in such a way that it will only act on the message if it comes from a
particular phone number to prevent malicious interference. This is done by accessing the
phone software by use of the communications port through activeX controls that we are
currently developing. The activeX components will not only be able to read the message
received but also get the International Mobile Equipment Identification (IMEI) number
of the phone that sent the message, this additional feature will enhance security by
preventing phone number spoofing.13
Application switching software This is software that shall be running on the remote computer to which devices are
connected to, its main duty is to interface the switching circuits to the rest of the system
and get data from the mobile phone. It shall be executing commands from the user that
have been stored in a predefined data format in the database. This software shall also
make it possible to perform locally all the services that can be done remotely mainly for
troubleshooting purposes.
The software shall also interpret data from the devices and post it to the database from
which the user interface shall output the device status to the user of the system.14
Device interface This is an electronic circuit that interfaces the devices being monitored and controlled to
the rest of the system. This device shall have a port that connects to the computer
through which data shall flow to and from the circuits. It shall also gather device status
information, digitize it and send it to the rest of the system.
Devices These are the main focus of the system, they are the devices to be monitored and
controlled, and they include any non-computing electrical or electronic device or system
13 This is similar to IP address spoofing used in Denial of Service Attacks (DoS) on Computer networks 14 This is where closed loop feedback comes in to the system.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
doc_root = <the document root folder of the Xitami Web server> extension_dir = <the PHP install directory> register_globals = On The document root folder is where the WebPages that the server will serve are placed.
The full path of the location is entered here e.g. C:\Webpages.
The PHP install directory is the folder in which we installed the PHP engine e.g.
C:\program files\php
After this is done and saved, we restart the Xitami web server by clicking the back arrow
on the web browser to the server configuration main page and clicking on the ‘restart
server’ button.
4.2 Database Server A database server is a program that can store large amounts of information in an
organized format that is easily accessible from scripting languages like PHP. The database
server’s work is to store data about the status of the devices we are controlling and
monitoring.
There are several types of commercial and freeware database servers in the market today
such as Microsoft SQL, Oracle, and MySQL etc.
4.2.1 Microsoft SQL This is one of the most versatile servers on the market, its ability to allocate separate
CPU threads for each connection makes it fast and efficient.
Advantages of MS SQL are:
q It can handle very many connections at a time
q Issues separate CPU threads per connection making it fast
q Has good security features
Its disadvantages are:
q Can only run in Microsoft NT based operating systems such as windows NT4,
2000, XP
q Needs a license from Microsoft making it expensive
q Needs powerful hardware to run
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Once the server is up and running, we create a database in the server. Before this is done
we must login using the credentials we set by typing the following in the command
prompt:
mysql -h 127.0.0.1 -u root -p The ‘-p’ argument will make the server ask for the users password that we shall enter.
Once inside, we can proceed to create the databases which we shall call ‘rock’.
mysql> create database rock; (Every MySQL statement must end with a semi-colon)
Once the database is created we have to tell MySQL that we need to use it, this is done
by typing the line:
mysql> use rock; We then proceed to create a table that shall consist of columns of the items we are
controlling and monitoring, in this case we choose, The Gate, lights, Fridge, and a boiler.
These form part of the possible devices we want to control.
The table (which we call master) is created by typing on the MySQL command prompt as
follows:
mysql> CREATE TABLE master ( -> ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Gate char(3), -> Lights char(3), -> Fan char(3), -> Boiler char(3), ->); The first line says that we want to create a new table called master.
The second line says that we want a column called ID that will contain an integer (INT).
The rest of this line deals with special details for this column. First, this column is not
allowed to be left blank (NOT NULL). Next, if we don't specify any value in particular
when adding a new entry to the table, MySQL should pick a value that is one more than
the highest value in the table so far (AUTO_INCREMENT). Finally, this column is to act
as a unique identifier for entries in this table, so all values in this column must be unique
(PRIMARY KEY).
The third, fourth fifth and sixth line say that we want to create columns called Gate,
Lights, Fan, Boiler that will contain three character long values (char (3)). The last
line closes the whole process by ending with a semi-colon.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
To view the contents of the table we have just created we type mysql> DESCRIBE master; The result of this command is displayed in the table below. +----------+---------+------+-----+------------+ | Field | Type | Null | Key | Default | +----------+---------+------+-----+------------+ | ID | int(11) | | PRI | NULL | | Gate | char(3) | | | | | Lights | char(3) | | | | | Fridge | char(3) | | | | | Boiler | char(3) | | | | +----------+---------+------+-----+------------+ 5 rows in set Table 4.0: Command prompt output for the command: Describe master This confirms that the table was created with the properties we defined. These are the
devices that we wish to remotely control, we have entered then into a database so as to
store any information relating to their status (on/off). It is from this database that all
other software modules will get or post information.
The database is now ready for use.
4.3 Open Data Base Connectivity (ODBC) data access engine The ODBC data access engine is used to connect ODBC-aware data access components
to a MySQL server. For MySQL, MyODBC engine is used.
MyODBC is a 32-bit ODBC (2.50) level 0 (with level 1 and level 2 features) driver for
connecting an ODBC-aware application to MySQL. MyODBC works on Windows95,
Windows98, NT, and on most Unix/Linux platforms. The ODBC aware component
used in Delphi programming need to use a DSN entry that is created as follows:
q Open the Control Panel on the Windows machine.
q Double-click the ODBC Data Sources 32 bits icon.
q Click the tab User DSN.
q Click the button Add.
q Select MySQL in the screen Create New Data Source and click the Finish button.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Collect user input; Post user input to database table;
If no Do nothing;
Interface Refresh time out? Yes
Read database table; Format data from database Output formatted data to user interface;
Close database connection; No Do nothing and wait for refresh time out
End The other software is the activeX component that connects to the mobile handset
through the serial communications port (COM 1). The code is written with the
understanding that when a phone sends am SMS, it send it together with the SMS center
number, Phones IMEI and the user data. Its pseudo code is shown below:
Start Connect to phone If connection failed then Alert user Else continue
Read phones’ SMS inbox If Short message received
Check source phone number and IMEI number If source phone number and IMEI number are correct then Update database with message value Send confirmation to user
Else do nothing End The software flowchart for the user input process is as shown in figure 4.0:
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
off, lights off. The program is case insensitive so the ‘LIGHTS ON’ is the same
as ‘Lights on’ or ‘LiGhTS oN’
q Using case of switching in the program flow, it will update the desired
column in the MySQL database so that if the message contains the key words
‘lights on’, the program will update the lights column in the database with the
word ‘ON’ if the key words were ‘lights off’ the it will update the lights column
with the word ‘OFF’ and so on.
q Once the desired device is switched, the phone access program sends back a
confirmation text message (SMS) to the sender confirming that the desired device
has been switched on or off.16
The full program code for the phone access software is found in appendix VI
4.6.3 Database access program This is the main program in the system. It is responsible for getting user input data from
the database and acting on it appropriately so that if a user wished to switch on the fan,
the use information which was saved on the database is read by this program which then
proceeds to output data signals on the parallel port which will activate the device
switching circuits to switch on the fan.
The Data Controls page of the Component palette in the Delphi programming interface
provides a set of data-aware controls that represent data from fields in a database record,
and, if the dataset allows it, enable users to edit that data and post changes back to the
database. By placing data controls onto the forms in our database access application,
were able to build a database application’s User Interface (UI) so that information is
visible and accessible to users and the PHP scripts
Data controls connect to datasets by using a data source. A data source component (
TDataSource) acts as a conduit between the control and a dataset containing data. Each
data-aware control must be associated with a data source component to have data to
display and manipulate. Similarly, all datasets must be associated with a data source
component in order for their data to be displayed and manipulated in data-aware controls
on a form.
16 This is subject to the availability of airtime credit on the remote phone. The confirmation SMS is charged as a normal SMS based on the network provider’s existing tariffs at the time of sending
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
4.7.2 Parallel Interface In a parallel interface, there are as many data lines as the size of data rate being
transferred so that for transfer of one byte per second then there will be eight data lines
(a data line for each bit). This has the advantage of speed especially over short distances.
In this project we intend to output a three-bit signal (in Parallel) and also receive bit
values from the monitoring circuits hence a parallel port is needed or a parallel to serial
(shift) converter if we are to use the serial port provided by the computer.
The above hurdle can be overcome by making use of the fact that the 25-pin serial port
has two independent channels, which give a total of 8 inputs and seven outputs with the
rest of the signal pins use for timing, grounding and power.
Because of the many output and input pins available in the parallel interface, we shall use
it in the project.
Pin No Signal Type RS232-C Signal Designation Modified Use in This Project
1 Ground Protective Ground 2 Data Data Transmit (Tx) Switching Bit3 out (LSB) 3 Data Data Receive (Rx) Switching Bit2 out 4 Control Request To Send (RTS) Switching Bit1 out (MSB) 5 Control Clear To Send (CTS) Bit Input from Transducer 6 Control Data Set Ready (DSR) Bit Input from Transducer 7 Ground Signal Ground 8 Control Received signal detector (RSD) 9 Reserved for testing 10 Reserved for testing 11 Not Assigned 12 Control Secondary RSD Bit Input from Transducer 13 Control Secondary CTS Bit input from Transducer 14 Data Secondary Tx 15 Timing Transmitted Signal Timing 16 Data Secondary RX 17 Timing Receiver Signal Timing 18 Not Assigned 19 Control Secondary RTS 20 Control Data Terminal ready 21 Control Signal Quality detector 22 Control Ring Indicator 23 Control Data Signal Rate Selector 24 Timing Transmitted signal timing 25 Not Assigned
Table 4.1: Comparison of RS 232 and our modified pin usage table
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
So when the user selects to switch on the device B, 011 is output on the port and the
fourth pin on the decoder is active low, it this that is buffered and inverted to switch on
the transistor which then switches the motor driver IC and the motor runs.
q To switch off the device B, a binary value of 100 is output on the port and this
signal is similarly used as the one above but this time it resets the flip-flop and
the device is shut down.
Electronic workbench software was used to design and simulate the circuit using the
chosen components. After few modifications, the simulation worked as expected.
The circuit in figure 4.2 below shows the switching/control circuit that was simulated
where the device has been represented by a 240Volts incandescent light bulb although it
could be a motor, heater etc.
Fig 4.2: Diagram for the control circuit as viewed in the Electronics workbench simulator. The rest of the devices can be connected in a similar manner as shown by the connection
of a light bulb. The pin-to-pin connection table of the various integrated circuit (IC)
chips is found in the appendix.
4.8.2 Monitoring Circuits The monitoring circuit should be able to monitor the device status by observing one key
parameter of the device and send an electrical signal to a specified pin on the parallel
port. The device monitoring software (which constantly observes this pin) will be able to
Parallel Port
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
6.1.2 Return on Investment For any system to be adopted, it must have a good return on investment. For
demonstration purposes, we will use a two-year return on investment model for a system
that that is controlling a remote critical system such as an oilrig in southern Sudan via
Internet using a VSAT link17. This model is consistent with expected parameters for a
piece of critical remote equipment and uses approximate operational parameters from
the example presented. Following ISO standards, the table for cost analysis is show
below for our system. The currency used is in US dollars (USD):
Cost of Down Time USD/Hour $50 Downtime (without monitoring) Hrs/Year 168 $8,400 Downtime (with monitoring) Hrs/Year 24 $1,200 Cost of Service visit $150 Frequency of Service visit (No monitoring) Days 7 Frequency of Service visit (With monitoring) Days 14 Cost of Service (No monitoring) USD/Year $7,821 Cost of Service (With monitoring) USD/Year $3,910 Installation Cost $1,250 Monthly expense $130 Annual software license& maintenance $0 Cost Saving per year 1 $8,300 Cost Saving per year 2 $9,550 Total cost saving for the two years $17,850 Simple return on investment for the two years 1193.58% Table 6.0: Return on Investment Data for the Web-based/GSM remote monitoring system
The return on investment for the first two years is more than 1000%. The return is very
high because the upfront design and installation expenses are low this in turn produces a
very high return as per percentage of investment.
The next analysis compares the system we have designed with what is there on the
market that is non-web based or mobile phone controlled systems that heavily rely on
onsite control. This system yields a marginal simple return on investment for the first
two years.
17 The war and instability in this region would make remote oilrig monitoring and control a viable option to multinational oil companies as compared to sending staff there. This system would also find wide use in Iraq where insecurity has increased in the last few months
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Cost of Down Time USD/Hour $50 Downtime (without monitoring) Hrs/Year 168 $8,400 Downtime (with monitoring) Hrs/Year 24 $1,200 Cost of Service visit $150 Frequency of Service visit (No monitoring) Days 7 Frequency of Service visit (With monitoring) Days 14 Cost of Service (No monitoring) USD/Year $7,821 Cost of Service (With monitoring) USD/Year $3,910 Installation Cost $7,500 Monthly expense $100 Annual software license& maintenance $2,000 Cost Saving per year 1 $2,410 Cost Saving per year 2 $7,910 Total cost saving for the two years $10,320 Simple return on investment for the two years 35.81% Table 6.1: Return on Investment Data for on-site control and monitoring system
Downtime is a general term used to describe a system that is out of control. In this oilrig
example, it may mean that the pump has stopped, in environmental applications; it could
refer to a process that is out of regulatory compliance. The oilrig example is such that
downtime alone justifies a complete monitoring and control system. In general, the
maintenance visit costs will more frequently dominate. In the case of actual deployment
of the system for example, a saving of 24 hours of downtime per year would yield a
payback of over 1000% during the first year alone.
6.1.3 To install or not? The decision of whether to install the system or not in any industrial setting can be
clouded in uncertainty of whether the system will make any cost saving or improve
productivity; we have simplified decision-making by the following steps:
q Compute the monthly cost savings if this system is implemented.
q Compute the monthly cost for the remote monitoring system.
q Subtract the monthly cost of the remote monitoring system fro the monthly
savings
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
The Remote PC interface which has access to the www. The panel on the right shows the device status; currently the gate is open as indicated by the light green icon. This interface also read the phone memory in the background.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
9.2 Appendix II The main Initialization program that calls the other units program Rock; uses Forms, Mainfrm in 'Mainfrm.pas' {RockForm}, DMfrm in 'DMfrm.pas' {DM: TDataModule}, Aboutfrm in 'Aboutfrm.pas' {AboutForm}, UnitD in 'UnitD.pas' {PhoneForm}; PassDlg in 'PassDlg.pas' {PasswordDlg} ; {$R *.RES} Var Splash : TAboutForm; begin Application.Initialize; Splash:=TAboutForm.Create(Nil); Splash.OKBtn.Visible :=False; Splash.Show; Splash.Update ; Application.Title:='Remote Web-Based Control Interface'; Application.CreateForm(TRockForm, RockForm); Application.CreateForm(TPasswordDlg, PasswordDlg); Application.CreateForm(TDM, DM); Application.CreateForm(TAboutForm, AboutForm); Splash.Hide; Splash.Free; Application.Run; end.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Procedure TRockForm.UpdateDevs; Var I : Integer; PortData: Integer; Begin For I:= 0 To DM.RockQry.RecordCount Do Begin PortData:=0; If DM.RockQry.Fields[3].AsString = 'On' Then PortData:=(PortData Or 16); If DM.RockQry.Fields[6].AsString = 'On' Then PortData:=(PortData Or 32); SendData(LPT1,16) WritePort(LPT1,PortData); End; Function TRockForm.ReadPort(PortNo:Word):Word; Var PortStat : Word; Begin PortStat:=PortNo+1; Asm Mov Dx,PortStat In Ax,Dx Mov PortStatus,Ax End ; Result:=PortStatus; End; Procedure TRockForm.WritePort(PortNo:Word;Data:Byte); Begin Asm Mov Dx, PortNo Mov Al, Data Out Dx, Al End
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
End; Procedure TRockForm.UpdateList; Var I :Integer; Begin If DM.RockQry.RecordCount > 0 Then Begin DM.RockQry.Last ; For I:= 1 To 8 Do Begin If DM.RockQry.Fields[I].AsString = 'On' Then Begin DeviceList.Items[I-1].ImageIndex := 1; DeviceList.Items[I-1].SelectedIndex := 1; End Else Begin DeviceList.Items[I-1].ImageIndex := 0; DeviceList.Items[I-1].SelectedIndex := 0; End; End; DeviceList.Refresh ; DeviceList.Update ; DeviceList.Invalidate; End; End; Function TRockForm.CheckUpdate:Boolean; Var Cnt1,Cnt2:Integer; Begin
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
Begin Index:=3; Flag:=True; End Else If InMsg=ComArray[2] Then Begin Index:=3; Flag:=False; End Else If InMsg=ComArray[3] Then Begin Index:=6; Flag:=True; End Else If InMsg=ComArray[4] Then Begin Index:=6; Flag:=False; End Else Begin ShowMessage('Invalid Command : ' + InMsg); Exit; End; DM.RockQry.Last; For I:=1 To 8 Do Begin Devs[I]:= DM.RockQry.Fields[I].AsString; End; If Flag Then Devs[Index] := 'On' Else Devs[Index] := 'Off'; With DM.TempTable Do Begin Open; Insert; For I:=1 To 8 Do Fields[I].AsString := Devs[I]; Fields[9].AsDateTime:=Now; Post;
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
end; procedure TDM.DataModuleCreate(Sender: TObject); begin Rock.Open ; end; procedure TDM.RockWillConnect(Connection: TADOConnection; var ConnectionString, UserID, Password: WideString; var ConnectOptions: TConnectOption; var EventStatus: TEventStatus); begin UserID:=''; Password:=''; If PasswordDlg.ShowModal=mrOK Then Begin UserID:=PasswordDlg.UserName.Text; Password:=PasswordDlg.Password.Text; End Else Begin ShowMessage('Database Login Aborted !'); Abort; End; end; procedure TDM.RockAfterConnect(Sender: TObject); begin SnoopTable.Open ; RockQry.Open ; RockForm.Timer1.Enabled:=True; end; procedure TDM.RockQryAfterOpen(DataSet: TDataSet); begin end.
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
begin MsgNumCB.Items.Add(IntTostr(Index)); BusyMsgL.Caption := IntToStr(MsgNumCB.Items.count); end end; StBar.Panels[3].text := 'Message arrived'; end; procedure TPhoneForm.ReadMsg_BtnClick(Sender: TObject); begin LoadMessage(StrToInt(MsgNumCB.text)); end; procedure TPhoneForm.DelMsg_BtnClick(Sender: TObject); var s : string; i : integer; begin try if SMS1.DeleteSMSMessage(StrToInt(MsgNumCB.text)) then begin MsgNumCB.Items.Delete(MsgNumCB.ItemIndex); StBar.Panels[3].text := 'Message deleted'; s := BusyMsgL.Caption; i := StrToInt(s); if i > 0 then begin Dec(i); s := IntToStr(i); BusyMsgL.Caption := s; end; MsgNumCB.text := ''; end else StBar.Panels[3].text := 'Message NOT deleted'; except end; end; procedure TPhoneForm.GetInbox_BtnClick(Sender: TObject); var count, busy : integer; Locations : string; begin GetInbox_Btn.Enabled := false; SMS1.GetInboxInfo(Count, Busy, Locations); TotalMsgL.Caption := IntToStr(Count); BusyMsgL.Caption := IntToStr(Busy); MsgNumCB.Clear;
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
MsgNumCB.Items.CommaText := Locations; if MsgNumCB.Items.Count > 0 then begin MsgNumCB.ItemIndex := 0; MsgNumCBChange(Self); end; GetInbox_Btn.Enabled := true; end; procedure TPhoneForm.SendMsgBtnClick(Sender: TObject); var Res : boolean; begin if SendSMSCE.text <> '' then SMS1.SetSMSCNumber(SendSMSCE.text); StBar.Panels[3].text := 'Sending message...'; Case MsgTypeCB.ItemIndex of 0: Res := sms1.SendSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, UnicodeChB.Checked, nil); 1: Res := sms1.SendUnicodeSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, nil); 2: Res := sms1.SendSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, UnicodeChB.Checked, SendPic); 3: if sms1.CheckRTTTL(SendtextE.text) = 0 then Res := sms1.SendRingtone(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked) else Res := false; 4: Res := sms1.SendOperatorLogo(SendToE.text, MCCE.Value, MNCE.Value, StrToInt(SendValidE.text), NRepChB.Checked, SendPic); 5: Res := sms1.SendCLILogo(SendToE.text, StrToInt(SendValidE.text), NRepChB.Checked, SendPic); 6: Res := sms1.SendFlashMessage(SendToE.text, SendTextE.text, StrToInt(SendValidE.text),NRepChB.checked); Else Res := false; end; if Res then StBar.Panels[3].text := 'Message sent' else StBar.Panels[3].text := 'Message NOT sent'; end; procedure TPhoneForm.Button7Click(Sender: TObject); begin
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
1. Database connection PHP Script <? function db_connect($UserName,$Password) { $dbcon = @mysql_connect('localhost', $UserName, $Password); if (!$dbcon) return false; if (! @mysql_select_db("rock") ) return false; return $dbcon; } ?>
2. PHP script to get data from database to web browser <?php require_once("dbcon.php"); $dbcnx = db_connect('php','phpman'); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } $ourqry="SELECT * FROM Master"; $Result =mysql_query($ourqry); $rowcnt=mysql_num_rows($Result); $fldcnt=mysql_num_fields($Result); printf("<center><h3>Device History </h3></center>"); echo "<table border=1 align='center'>"; for ($k=0 ;$k < $fldcnt; $k++) {
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
2. Database modification and exception handling page HTML and PHP code <html> <head> <title>ELC 590 Project Exception page</title> <link rel="stylesheet" type="text/css" href="./css/main.css"> </head> <body> <?php require_once("dbcon.php"); $dbcnx = db_connect($User,$Passwd); // login with username "guest" and password "mypass" to local serve if (!$dbcnx) { echo( "<P Class=Shout>Unable to connect to the " . "database server at this time.<BR><BR> Please Check That : <ul> <li>The Database Server Is Up & Running. <li>Your Username and Password are Properly Spelt. <li>Your CAPSLOCK is set Correctly. <li>Your Keyboard is Working :-) </ul></P>" ); exit(); } @$upquery= sprintf("INSERT INTO Master (Gate,Heater,Lights,TV,Fridge,Fan,Music,Alarm) Values ( '%s','%s','%s','%s','%s','%s','%s','%s')",$Gate? 'On':'Off',$Heater? 'On':'Off',$Lights? 'On':'Off', $TV? 'On':'Off',$Fridge? 'On':'Off',$Fan? 'On':'Off',$Music? 'On':'Off',$Alarm? 'On':'Off'); //printf($upquery); if (mysql_query($upquery)) { printf("<center><p class=info> Update Was Successful. <p> Click <A href='showdata.php'>Here </A> to view Records</center>");
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
6. Jscript code that runs the status bar text var SysStr = "ELC 590:Final Year Project 2004 :" var StatStr = "(C)Tom Makau and Prashnat Kumar. All Rights Reserved. EMail: [email protected], [email protected] "; defaultStatus = StatStr; var DeptStr = "Department Of Electrical And Communications Engineering. "; var FactStr = "Faculty of Technology."; var UniStr = "Moi University."; var MyArray= new array(SysStr,DeptStr,FactStr,UniStr,StatStr); var CharInd = 1; var ArrInd = 0; function Init() { setInterval("Animate()",50); } function Animate() { defaultStatus = MyArray[ArrInd].substr(0,CharInd) ; if (CharInd++ >MyArray[ArrInd].length) { CharInd = 1; if (ArrInd++ > 3 ) ArrInd = 0 ; } } function fade(orb,stat) { if(stat==1) { orb.bgColor="ffeeaa"; } else { orb.bgColor="#ffffcc"; } }
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com
74LS04 Pins 74LS76 Pins OUTPUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A V O O P Pin 15 high = A is On A U K P’ K Pin 15 low = A is Off B O V O P Pin 11 high = B is On B U K P’ K Pin 11 low = B is Off C V O’ O’ Q Pin 15’ high=C is on C U’ K’ Q’ K’ Pin 15’ low =C is off
Table 3.0 Pin connection table for the control circuit
PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com