Wednesday, June 8, 2011

wireless sensor network project


INTELLIGENT SPEED PREVENTION USING
WIRELESS SENSOR NETWORKS




Abstract:


In present world, where accidents have become more a day to day happening .It is high time that we come up with a plan to suppress it down. Our paper concentrates on how these daunting accidents which has great toll on valuable lives be curtailed .In India; we don’t have a complicated system which could facilitate to control the accidents. So we have a taken an initiative to control the dreadful accidents, which is at soaring rates at present by means of this paper.
 Our paper is about the prevention of accidents in case of bent roads where most accidents is suspected to happen as in this case vehicle on one side  ignorant about the vehicle coming on the other side. In this paper, we instill awareness in the driver of vehicle coming on one side of the road about the speed and type of other side vehicle of a bent road and make him cautious about the dangers befall him.  
In this paper we have used wireless sensors to demonstrate our idea. Wireless Sensors being a novel concept we really suppose this will help us to transcend our idea. We really presume that this paper will really help in reducing the atrocious accidents which takes a heavy toll on lives.

Scope:
This project been implemented in bent roads where accidents are common will greatly help in preventing the accidents in a great way.

IMPLEMENTATION:
BASIC DIAGRAM:





 SENSOR NODE HARDWARE
 Sensor node a part of the wireless sensor, which consists of a processor,
·        A radio and processor,
·        A magnetometer,
·        A battery and
·         A cover for protection from the vehicles.


The processor and the radio are located in MICA2DOT, the latest family of Berkeley motes .The microprocessor is Atmel ATmega128L with 128kB of programmable memory and 512kB of data flash memory.
It runs TinyOS, an operating system developed at UC Berkeley, from its internal flash memory.
TinyOS enables the single processor board to run the sensor processing and the radio Communication simultaneously.
The radio is ChipCon CC1000 916MHz, frequency shift keying (FSK) RF transceiver, capable
of delivering up to 40kbps. The RF transmit power can be changed in software.
        There are two HMC1051Z magnetic sensors, based on anisotropic magneto resistive (AMR) sensor technology. To receive one sample, the magnetometer is active for 0.9 msec and the energy spent for taking one sample is 0.9μJ. The magnetometer is turned off between samples for energy conservation.
  The battery is Tadiran Lithium TL5135, with 1.7Ah capacity in a compact size. The
entire unit is encased in a Smart Stud cover, designed to be placed on pavement and able to withstand 16,000 lbs. So the node is protected and can be glued on anywhere on the pavement.
                                                                                                    
                                                                 
SENSOR NODE BASIC  DIAGRAM




GATEWAY NODE:

In a communications network, a network node equipped for interfacing with another network node.
In this case Gateway Node is used to receive the signals from the sensor node on one side of the road and to transmit the signal to the sensor node on the other side of the road.It is simply a node
Which can receive the signal from one side and transmit the data to the other side.
We program the gateway node using netc in tinyos according to our need.

ACTUATOR:


The actuator receive signal from the sensor node about the type and speed of the vehicle coming on the other side. The microprocessor processes the data and it switches on a corresponding relay based on the information supplied by the sensor node.
For ex:  a lorry or heavy locomotive coming a red light will be switched on making the driver cautious about the presence of a heavy locomotive on the other side.
VEHICLE DETECTION:




The sensor detects distortions of the Earth’s field caused by a large ferrous object like a vehicle.
Such a vehicle can be modeled by a composite of many dipole magnets. Since

the distortion depends on the ferrous material, its size and orientation, a magnetic signature is induced  corresponding to the vehicle’s shape and configuration.


Based on the distortions produced in the sensor we may detect the speed and the type of vehicle.


These distortions are processed by the processor and based on the magnitude the type of vehicle is found out.
Speed detection:
                                                     
                     VEHICLE             A                  B
                                                     SENSOR
                                                       NODE
                                                     
                             
To detect the speed of the vehicle the time when sensor node A and node B suffers distortions
is processed by the  processor in the GATEWAY node and the speed is found out by the simple formulae
    

 Since the distance between the sensor node A and sensor node B is constant and
The time when sensor node A and sensor node B suffer distortions, this information is send to the GATEWAY Node which calculates the time difference and calculates the speed of the vehicle using the formulae specified above. This information is then send to the sensor Node on the other side which excites the actuator which switches on a particular light based on the speed and type of vehicle.




The following graph shows the excitation in the output of the node A and node B when a vehicles passes across

Likewise the speed is detected and the type of vehicle is also detected and consequently a particular output signal is triggered by the actuator based on the data supplied to it.

 COMMUNICATION PROTOCOL

Since the communication is wireless it is must to write protocol to control the communication between the sensor nodes and the GATEWAY Nodes.
In a sensor node, battery energy is mostly consumed by the radio. Therefore, the networks


Communication protocol, which determines how the radios are operated, has a decisive influence
on battery lifetime. Existing MAC protocols fall into one of two categories: random
Access and time division multiple access (TDMA).
In this paper we use random access  since the information must be passed to the gate way node whenever there is a vehicle.But at other times it is said to be inactive state on the verge of conserving power.Once the information passed to the gateway node ,this information is processed and  passed on to the sensor node located on the other side of the road which as a result produces the output signal.

Salient Features:


  • The process is wireless so no need of placing wires under the ground.
  • Till date in india we don’t have a complicated system to curb down the accidents.
  • This can be installed in every bent roads where accidents are frequent.
  • There is no need of maintenance since the work can be automated with the help of protocols and programs written in Netc in TinyOS environment.
  • This will greatly help in reducing the soaring accident rates .



FUTURE ENHANCEMENTS:


·         This paper can be extended so that vehicles may receive the signals directly from the sensor node than viewing as signal on the side of the road.
·         A camera can also be embedded on the bottom of the road so that the reg no of the vehicle can be picturised and corresponding speed can be stored in the database along with it.
·         It can be also extended to be used for overspeed prevention by informing the traffic department about the vehicle no which have exceeded the speed limit of that locality.


REFERENCES:
BOOKS:
1.       Networking Wireless Sensors 
                    by Bhaskar Krishnamachari

2.       Wireless Sensors and Instruments: Networks, Design, and Applications
by Halit Eren

WEB LINKS:
1.      en.wikipedia.org/wiki/Wireless_Sensor_Networks

2.      www.xbow.com/

3.     http://www.sensorsmag.com/articles/0499/0499_10/main.shtml


SOFTWARE USED:
1.      NETC IN TINYOS ENVIRONMENT

I Posted it  just to give a idea regarding the sensor network projects.Ki ndly don't imitate it in any of the paper presentations.
I am always open to comments.Kindly comment in case you want to ask something regarding this paper.
Tell me your comments about this paper

Monday, June 6, 2011

perl oo

perl Object Oriented:
There are many chances that you may get confused with Perl Object Programming

To make the point clear let us first look at references at Perl

@friends = ("Rachael","Phoebs");
%animals = ('donald' => 'duck','mickey' => 'mouse' );


To intiaize  references to a variable use:
In case of array:
$ref  = \@friends
In case of hashes
ref = \%animals;
In case of sub-routine:
$ref=\&whoami;

Print ref ;   ---> to see refernce value

To access elements through references

print $$ref[0]  - it prints Rachael
print  $$ref{ 'mickey'}   - > it prints mouse


Having a basic idea of reference  will help you to use object oriented programming.

In perl ,object is a reference that belongs to a specific package.


method - used to associate a reference with a specific package is referred as "blessing"

constructor is merely a sub-routine that returns a reference to something blessed into a class.


To invoke the constructor in perl you can use:

$bob = Easterbunny::new();
$bob = new Easterbunny;
$bob=Easterbunny - > new();

bless function is used to change the datatype of the anonymous hash to $class.

An anonymous hash is used to hold the properties of the classs.

some key items to remember:
1)All objects are anonymous hashes which not strictly true,perhaps it should be.
2)bless function changes the data type of the anonymous hashes.
3)objects can belong to only one class at a time.
5)the -> operator is  used to call a method.


to demonstrate the bless function changes the datatype of the class:

#!/usr/bin/perl
$foo = {};
$fooref = \$ref;
print (" datatype of \$foo is " .ref($foo) . "\n");   ---> Hash here
bless ($foo,"Bar"); 
print ("datatype of \$foo is " ref($foo) ."\n");  ---->Bar here after blessing with the Bar class

output :

datatype of $foo is Hash
datatype of $foo is  Bar

adding values into INC perl

@INC array is actually array element the perl program will search for the perl modules in the program.


PERL5LIB="/usr/home";
export PERL5LIB:

This will add the path "/usr/home" to the first element of the @INC array.

To remove the content set by PERL5LIB simply use

unset PERL5LIB;


There is also a other way:
add this line before the use module lines

use lib "/usr/home";

This will also add the path to "/usr/home" temporarily to the INC path for this particular program.

perl string compare

To compare striings in perl use this simple example


#!/usr/bin/perl
#here eq must be used if you use "=" it will always return a positive value
if ( $dd eq "hello" )
{
       print "it is equal");
}
else
{
      print "it is not equal"
}

Also refer to the perl comparison  in the site for better understanding
http://linux-forum-karthik.blogspot.com/2011/06/comparison-in-perl.html

Sunday, June 5, 2011

Rsync using ssh in Linux

Rsync is mainly used for backup operations.It can be used also transfer the file from one place to another.
Just like rcp or rsh.
Only difference in this case is it  just copies the difference between the target and destination file.If some data is missing in the destination file  that alone is copied instead of the copying the complete data
It syncs the file between the two locations.
There are also many options available that control  the transfer.

For simple backup:
This option can be used
Here i am trying to transfer the file from /home/karthik  to /mnt/usb

/usr/bin/rsync -au /home/karthik  /mnt/usb
-u - in this case the file if exits in destination it will not be overritten.
-a-  in this case the data is sent in archive mode.

Rsync can be also be used to transfer the file to the remote server.

rsync -avz karthik@192.168.200.10:/var/lib/rpm /root/temp
z- enables compression

Rsync using ssh 
can also be made to use secure shell for transfer :
For this we need to use -e option:

rsync -avz -e ssh karthik@192.168.200.10:/var/lib/rpm /root/temp
-e specifies th remote shell to transfer.

Rsync is a effective command to perform the sync of files with many options available:

Some of the useful options are:

-r - to recursively transfer the files.
-z-to compress the files
-q-to quiet mode
-o - to preserve the owner information in the transfer
-g - to preserve group
-p - to preserve permissions of the file.
--timeout - to specify the time out information for the rsync to happen.
--rsync_path - this is used to the rsync comaand path in the remote shell.
 --delete - to delete the files in the destination if the files are not present in the target.
-d -directory structure is only modified in the destination not the file.
-v  - verbose
--progress-  to view the progress of the files.

Another example:

/bin/rsync -tzqogp -e ssh -o BatchMode=yes --rsync-path=/usr/bin/rsync --timeout=30 /home/kkk /home/fff   karthik@12.33.44.44:/home/karthik/
Here the files /home/kkk and /home/fff are transferred from the local server  to the remote server's directory /home/karthik/  in BatchMode using the ssh secure shell.

Thursday, June 2, 2011

Linux Tips


Steps for resizing the PC partition in Linux

To view the partitions:

df -ah
Now umount the filesystem using the command given below:

umount /dev/sda1
Perform a check on the file system

e2fsck -f /usr/sda1
Now resize with

resize2fs /usr/sda1 60M
resize is a tool to perform partition.

--------------------------------------------------------------------
To get our public IP in Linux:
curl -s karthik.com
karthik.com is the host name

----------------------------------------------------------------------
Finding Open Sockets in Linux

lsof

use  lsof -i  also

To list all open internet files,use this command:
lsof -i -U

You can also get very specific about ports .We have to use the following command:

lsof -i TCP:3386


To look at UDP ports as follows:
lsof -i UDP:1812

Monday, May 30, 2011

sed quit operator and seq operator

The seq operator in shell is to generate sequential numbers.As you can see.


 acer@ubuntu:~$ seq 10
1
2
3
4
5
6
7
8
9
10
And the quit operator in sed is mainly used to quit when aa particular match or substitution occurs.


acer@ubuntu:~$ seq 10 | sed '4 q'
1
2
3
4
acer@ubuntu:~$

As you may see from the above example the ouput is stopped once the match occurs.