Monday, September 6, 2010

Hardware Control via SMS

System Overview
The system consists of two mobile connected by the existing cellular mobile network. One of the mobile is connected to the computer by USB data cable. The computer contains the series of computer program that is capable of retrieving SMS, processing and directing hardware to produce the desired output. The hardware part is connected to the computer by the parallel port.



2.2 Hardware Description:
2.2.1 Mobiles
The basic component of our project starts with two mobiles. These mobiles are used to send and receive SMS through the available cellular network configurations. One of the mobile is connected to the computer through usb data cable. The other is used by the user to send the SMS to the connected mobile. Since the project’s backbone is the SMS, the SMS has to be fed to the computer and this is done by mobile software which will be discussed under software discription portion.

2.2.2 USB data cable
The USB data cable is the connector that connects different hardwares to the computer. In our project, we have used this cable to connect the mobile to the comptuer.

2.2.3 Parallel Port
Another hardware that plays vital role in the project is the parallel port. The primary use of parallel port is to connect printers to computer and is specifically designed for this purpose. Thus it is often called as printer Port. The lines in parallel port connector are divided in to three groups, they are

1) Data lines (data bus)
2) Control lines
3) Status lines
As the name refers, data is transferred over data lines, Control lines are used to control the peripheral and of course, the peripheral returns status signals back computer through Status lines. These lines are connected to Data, Control and Status registers internally. The details of parallel port pin configuration and signal lines are given below

At this stage, we have tried to light on the led. This is at the simplest stage of the project. When successful in this we intend to extend this part and try other circuits. Many other hardware components can be controlled by using parallel port. Upto this moment, we have used 8 output pins of parallel port indivudally or combination of them. The hardware circuit consists leds that are connected through diodes and reistors. Diodes are used to prevent the back-flow of voltage. It prevents the computer from being damaged since diodes allow one directional current/voltage flow. The output can be taken from pins 1-9, 14, 16, 17 of parallel port .The hardware configuration is shown below.
2.2 Software Discription
As already stated that the project is the combination of SMS, computer program and output hardware, software is the soul of the project. There are various steps of program used in the project which are described below:-
2.2.1 Batch file programming
Batch file is a type of file in computer that allows to store dos commands. We took help of it inorder to convert the SMS file type (*.vmg) to the text file (*.txt) where .vmg and .txt are the extension of the file. The batch file runs as an auto executable file (that is this file will be run at the time of computer startup).These extensions help to recognize the format of the file. The batch file was also used to copy the SMS from mobiles’ phone browser folder to the computer’s memory. This was needed because it was almost impossible to operate on the file with the previous SMS type and location of SMS. The code of the program is as follows:-


@echo off
IF EXIST *.vmg (
Del d:\ \ text.txt
Copy *.vmg d:\
Rename d:\<> *.vmg text.txt
Del *.vmg
Del d:\\*.vmg
Autocopy.bat
)
Autocopy.bat

The batch file is named as autocopy.bat. At first the batch file searches if there appears any new message at inbox or not. If the condition satisfies, the previous text message from destined location will be deleted and new .vmg message will be copied to the required location. This SMS will then be renamed as text file. Then it deletes the SMS from the inbox as well as from the location. Now, again the same autocopy.bat file will be executed to continuously search for the SMS.

2.3.2 Turbo C Programming
Normally, data, control and status registers will have following addresses. We need to provide these addresses in program.
Table 2: Registers address
Register
LPT1
Data register (Base Address + 0)
0x378
Status register (Base Address + 1)
0x379
Control register (Base Address + 2)
0x37a


Now we are using eight data resistors for our output, each of which is read as binary value as below.
D7 - “10000000” D6 – “01000000” D5 – “00100000” D1 – “ 00000010”
Similarly, to read D1, D2 and D6 respectively at once: “01000110”
However; with actual programming, this binary value is replaced by equivalent decimal number to perform the required task.

2.3.2.1 Coding for Parallel Output:
Reaching the ports by using a language differ from port to port. Using Windows 98 we can easily reach the ports with a function which is "outportb". However; when upgraded to Windows 2000 this fails because of its kernel. We can not reach the ports directly in NT, 2000 and XP because of their kernel and their printer drivers. For eg. first we made the circuit as in the fig. 4 and then restarted the computer; for Windows 98, there was no light in the circuit but in Win2000 and XP all the 8 lights are on so we know that the signal is coming and the pins are registered by their kernel with the printerdriver.

Since, our operating system will not be windows 98, as it doesn’t support pc-suite, we need to go hardware interferance as in the below flow chart.


So we have to import inpout32.dll to our debug or release directory. It takes two variables which are address and value. If the data ports are set in "0x378" we have to write "888" because "378" Hexadecimal is equal to "888" in decimal.

The below program will function in windows 98:

#include <conio.h>
#include <dos.h>
#define port 0x378 // Port Address
#define data port+0 // Data Port of the parallel cable
void main (void)
{
outportb(data, 255); // For all lights on
outportb(data, 0); // For all lights off
}

However; if the OS is Windows NT or above, first we must interface with the driver as shown in the flow chart. We are currently working with this type of interface to have better idea before we actually implement such type of coding.

So we have to import inpout32.dll to our debug or release directory. It takes two variables which are address and value. If the data ports are set in "0x378" we have to write "888" because "378" Hexadecimal is equal to "888" in decimal.

The below program will function in windows 98:

#include <conio.h>
#include <dos.h>
#define port 0x378 // Port Address
#define data port+0 // Data Port of the parallel cable
void main (void)
{
outportb(data, 255); // For all lights on
outportb(data, 0); // For all lights off
}

However; if the OS is Windows NT or above, first we must interface with the driver as shown in the flow chart. We are currently working with this type of interface to have better idea before we actually implement such type of coding.
Content of message.txt, fetched from the PC-SUITE:


BEGIN:VMSG
VERSION:1.1
X-IRMC-STATUS:READ
X-IRMC-BOX:INBOX
X-NOK-DT:20081215T085618Z
BEGIN:VCARD
VERSION:2.1
N:
TEL:+9779841346181
END:VCARD
BEGIN:VENV
BEGIN:VCARD
VERSION:2.1
N:
TEL:
END:VCARD
BEGIN:VENV
BEGIN:VBODY
Date:15.12.2008 13:56:18
# SWITCH OFF : 1 #
END:VBODY
END:VENV
END:VENV
END:VMSG
The above program will fetch only the required message #SWITCH OFF : 1# from the program and makes the string compare with the already defined strings to make logical operation and hence to direct output.

0 comments:

Post a Comment

Labels

About Me

My photo
I am an electrical and electronics engineering kathmandu university batch 2007
 
ELECTRICAL AND ELECTRONICS PROJECT COLLECTION. Design by Wpthemedesigner. Converted To Blogger Template By Anshul Tested by Blogger Templates.