Saturday, 31 May 2014

How to generate DISCRETE TIME CONVOLUTION in matlabs,

DISCRETE TIME CONVOLUTION  
n0=0:20;
x=5*(-0.5).^n0;
n1=-10:5;
h=(2/3).^n;
n2=-20:10;
y1=conv(x,h);
y=y1(1:length(n2));
subplot(3,1,1);
stem(n0,x);
xlabel('time(sampled)');
ylabel('magnitude x(n)');
title('input signal');
grid on;
subplot(3,1,2);
stem(n1,h);
xlabel('time(sampled)');
ylabel('magnitude h(n)');
title('transfer function h(n)');
grid on;
subplot(3,1,3);
stem(n2,y);
xlabel('time(sampled)');
ylabel('magnitude y(n)');
title('output signal');
grid on;

Saturday, 24 May 2014

Universal OBD-II Scan Tool

my this article is about a project perform by these group members at university of  engineering and technology which is used to find out that which part of the vehicle is not working , without wasting time in a short time, these students belong to computer system department and perform this project, its detail is given in my previous article,http://mobilezonex.blogspot.com/2014/05/how-to-find-out-fault-in-cars-in-seconds.html
Supervisor:  

Group Members:

Shawkat Ali  
  Amjad Ali   , Dr. Laiq Hassan  
     Saba Kanwal   
       Maria Shoukat   

CONTENTS
OVERVIEW
IMPLEMENTATION
RESULTS
FUTURE WORK

OVERVIEW
On-Board Diagnostics-II. 
Brief history.
Designing such a scanning tool that is compatible with every manufacturer vehicle.
The OBD-II standard connector specifies the type of diagnostic connector and its pin out.



Overview(Conti…)
OBD-II
Design hardware using  STN1110 IC
Interface STN1110 with pc via UART using Max232
Interface with DLC for compatibility with different vehicles
Apply for vehicle telemetry
Vehicle performance optimization






IMPLEMENTATION
Final schematic and design on PCB. 
The schematic was designed using Proteus software. 
Hardware design on Breadboard.
Testing hardware using different OBDII complaint vehicles. 
RESULTS
Proteus PCB design. (Completed) 
Hardware design.      (Completed)
Hardware testing.      (in progress)
ERP module.       (In progress)



Results (Conti…)


Results (Conti…)


Results (Conti…)
Results (Conti…)
FUTURE WORK
Hardware testing. 
ERP module Development & Testing.
Debug the whole project.



        GANTT CHART
Q’s IF ANY?????

Friday, 23 May 2014

NETWORK BASIC COMMANDS

  
Objectives:

Gather information including connection, host name, Layer 2 MAC address and Layer 3 TCP/IP network address information.

Compare network information to other PCs on the network.
Learn to use the TCP/IP Packet Internet Groper (ping) command from a workstation.
Learn to use the Trace Route (tracert) command from a workstation.

Step 1 Connect into the Internet

Establish and verify connectivity to the Internet. This ensures the computer has an IP address.

Step 2 Gather TCP/IP configuration information

Use the Start menu to open the Command Prompt, an MS-DOS-like window. Press Start > Programs > Accessories > Command Prompt

OR
Start > Programs > Command Prompt. OR
Press Start>Run Then type cmd.

The following figure shows the Command screen. Type ipconfig and press the Enter key. The spelling of ipconfig is critical while case is not. It is short for IP Configuration.  i do this task with my friend laptop sufyan and its cmd snip shot is given below



Fig: 1


Fig: 2
This first screen shows the IP address, subnet mask, and default gateway. The IP address and the default gateway should be in the same network or subnet, otherwise this host would not be able to communicate outside the network. In the figure the subnet mask tells us that the first three octets must be the same to be in the same network.

Note: If this computer is on a LAN, the default gateway might not be seen if it is running behind a Proxy Server. Record the following information for this computer.

Step 3 Record the following TCP/IP information for this computer

IP address: 192.168.1.6

Subnet Mask: 255.255.255.0

Default Gateway: 192.168.1.1

Difference between Fig.1 and Fig.2: The features of wireless LAN adaptor, wireless network connection are absent

Step 4 Compare the TCP/IP configuration of this computer to others on the LAN

If this computer is on a LAN, compare the information of several machines.

Are there any similarities? Yes, the Subnet mask and default gateway are similar.

What is similar about the IP addresses? The Network ID is same.

What is similar about the default gateways? Both of the machine's Default Gateway are same.

The IP addresses should share the same network portion. All machines in the LAN should share the same default gateway.
Record a couple of the IP Addresses:

192.168.1.2 , 192.168.1.6
Step 5: Check additional TCP/IP configuration information

To see detailed information, type ipconfig /all and press Enter. The figure shows the detailed IP configuration screen.


Fig.3: Command Screen for ipconfig /all


The host name, including the computer name and NetBIOS name should be displayed. Also, the DHCP server address, if used, and the date the IP lease starts and ends should be displayed. Look over the information. Entries for the DNS, used in name resolution servers, may also be present. The previous figure reveals that the router is performing both DHCP and DNS services for this network. This would likely be a small office or home office (SOHO) or small branch office implementation.

Notice the Physical Address (MAC) and the NIC model (Description).

(74-DE-2B-72-91-1E) and (Bluetooth Device <Personal Area Network>)Write down the IP addresses of any servers listed:

(192.168.1.2), (192.168.1.6) (192.168.1.102)

Write down the computer Host Name:
Sufiyan

Write down the Host Names of a couple other computers:

(HASHIM ELAHI),  (monA).

Do all of the servers and workstations share the same network portion of the IP address as the student workstation?  Yes

It would not be unusual for some or all of the servers and workstations to be in another network. It means that the computer default gateway is going to forward requests to the other network.

Step 6 Close the screen

Close the screen when finished examining network settings.
Repeat the previous steps as necessary. Make sure that it is possible to return to and interpret this screen.


Based on observations, what can be deduced about the following results taken from two computers connected to one switch?

Computer 1

IP Address: 192.168.1.2
Subnet Mask: 255.255.255.
Default Gateway: 192.168.1.1

Computer 2
IP Address: 192.168.1.6
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1

Computer 3
IP Address: 192.168.1.3
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1

Should they be able to talk to each other?

______________________________________________________________________________

Are they all on the same network? Why or why not?
Yes, to make sure that the IP address should be close enough.2. Using “ping” and “tracert “

Objective

Learn to use the TCP/IP Packet Internet Groper (ping) command.

Learn to use the Trace Route (tracert) command.
Observe name resolution occurrences using WINS and/or DNS servers.

Background

This lab assumes the use of any version of Windows. This is a non-destructive lab and can be done on any machine without concern of changing the system configuration.

Ideally, this lab is performed in a LAN environment that connects to the Internet. It can be done from a single remote connection via a modem or DSL-type connection. The student will need the IP addresses that were recorded in the previous part of the lab.

PING Command SET:

Ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] -t ==> repetitive.

-n ==> number of echo to be sent
-l ==> sending buffer size [Max: 65500 bytes] -f ==> don’t fragment.
-r count ==> record route for count hops [3rd layer device] -j ==> loose source route
-k ==> strict source route -i TTL ==> time to live

-v TOS ==> Type of Service


Example:

Ping -t -l 60000 192.168.230.1 -f -l 1000

-l 1000
To see the difference between fragmenting and non-fragmenting, use -f

ping -r 3 192.168.230.1

Step 1 Establish and verify connectivity to the Internet

This ensures the computer has an IP address.

Step 2 Access the command prompt

As accessed in previous part of the lab.
Step 3 ping the IP address of another computer

Ping 192.168.1.2

In the window, type ping, a space, and the IP address of a computer recorded in the previous lab. The following figure shows the successful results of ping to this IP address. Ping uses the ICMP echo reply feature to test physical connectivity. Since ping reports on four attempts, it gives an indication of the reliability of the connection. Look over the results and verify that the ping was successful. Is the ping successful?

Step 4 ping the IP address of the default gateway
Ping 192.168.1.1


Try to ping the IP address of the default gateway if one was listed in the last exercise. If the ping is successful, it means there is physical connectivity to the router on the local network and probably the rest of the world.

Step 5 ping the IP address of a DHCP or DNS servers

Try to ping the IP address of any DHCP and/or DNS servers listed in the last exercise. If this works for both server and they are not in the network, what does this indicate?
No idea.


Was the ping successful? NO

Step 6 ping the Loopback IP address of this computer

Type the following command: ping 127.0.0.1

The 127.0.0.0 network is reserved for loopback testing. If the ping is successful, then TCP/IP is properly installed and functioning on this computer.


Was the ping successful? YES

Step 7t ping the hostname of another compuer

Try to ping the hostname of the computer that was recorded in the previous lab.

Step 8 ping the hostname of another computer using

Try to ping repetitively, the hostname of the computer

How can we stop the ping: CTL+C


Step 9 ping the Yahoo web site

Type the following command: ping www.yahoo.com
 The first output line shows the Fully Qualified Domain Name (FQDN) followed by the IP    address. A Domain Name Service (DNS) server somewhere in the network was able to resolve the name to an IP address. DNS servers resolve domain names, not hostnames, to IP addresses.
Without this name resolution, the ping would have failed because TCP/IP only understands valid IP addresses. It would not be possible to use the web browser without this name resolution.
With DNS, connectivity to computers on the Internet can be verified using a familiar web address, or domain name, without having to know the actual IP address. If the nearest DNS server does not know the IP address, the server asks a DNS server higher in the Internet structure.

What is the IP Address of www.yahoo.com: 46.228.47.115

How much time did our ping took to reach www.yahoo.com: 286Ms


Tracert Command SET:

tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name

-d ==> do not resolve address to hostname.

-h maximum_hops ==> maximum number of Hosts to Search for Target -j host-list ==> loose source router along host-list
-w timeout ==> wait timeout milliseconds for each reply

Step 10 Trace the route to the Yahoo web site

Type tracert www.yahoo.com and press Enter.


Tracert is TCP/IP abbreviation for trace route. The preceding figure shows the successful result when running tracert from Bavaria in Germany. The first output line shows the FQDN followed by the IP address. Therefore, a DNS server was able to resolve the name to an IP address. Then there are listings of all routers the tracert requests had to pass through to get to the destination. tracert uses the same echo requests and replies as the ping command but in a slightly different way. Observe that tracert actually contacted each router three times. Compare the results to determine the consistency of the route. Notice in the above example that there were relatively long delays after router 11 and 13, possibly due to congestion. The main thing is that there seems to be relatively consistent connectivity. Each router represents a point where one network connects to another network and the packet was forwarded through.

What is the difference between the following commands?

Tracert www.yahoo.com
Tracert –h 20 www.yahoo.com


Tracert shows how much HOPS  the desired location is away, and Tracer -h20 declares the location which is at 20 hops distance away.Step 11 Trace a local host name or IP address
Tracert 192.168.1.1

Count the number of Hops: 30 Hops

Simulation of Line Coding Schemes in Matlab


Objectives
How to write Matlab code that encodes a digital data into digital signal?
Study sample Matlab program for unipolar NRZ, NRZ-L, and Bipolar AMI
Program Code
Unipolar NRZ
 A positive voltage represents a binary 1, and zero volts indicates a binary 0. It is the simplest line code.
% Unipolar NRZ
clc
message = [0 1 1 0 1 0 1];
data = [0 0 1 0 1 0 0 0 1 0 0 0 1 0];
i = 1 : 7;
j = 1.99 : 7.99;
time = [ ];
for k = 1 : 7
time = [time i(k), j(k)];
end
% Digital Signal Generation:
signal = [ ];
for t=1:2:13
    if (data(t) == 0)
        signal (t : t+1) = 0;
    else
        signal (t : t+1) = -1;
    end
end
subplot(2,1,1);
plot (time, signal)      % Plotting PCM Signal
xlabel ('Time (t)')
ylabel ('Amplitude (A)')
title('Digital Signal')

Simulation Results
 
NRZ-L
In this encoding schemes, 0 is represented by +ve volt and 1 is represented by negative volt.
Program Code
% NRZ-L
 
message = [0 1 0 1 1 1 0 0 1 1 1 1 ];
data = message;
i = 1:length(messgae);
j=1.99:length(message+0.99);
time = []
for (k = 1 : length(message))
    time= [time i(k) j(k)]
end
 
% Generating signal 
signal = [];
N = length(data);
for (t=1:2:N)
    if(data(t)==1)
        signal(t:t+1)=1;
    else
        signal(t:t+1)=-1;
    end
end
% display the signal
 
figure(1);
plot(time,signal,'linewidth',2)
title('NRZ-LZ')
xlabel('time')
ylabel('voltage level')
 
axis([1 8 -0.5 1.5 ])

Simulation Results
 


 
Pseudo Ternary Encoding
A multilevel binary encoding that complements the bipolar-AMI encoding: binary 1 is represented by a lack of pulse, and a binary 0 is represented by a positive or a negative pulse. The binary 0 pulses must alternate in polarity.

Program Code
clc
message = [0 1 1 0 1 1 1 0 0 0 1];   
data = zeros(1,2*length(message)-1);           
data (1 : 2 : end) = message;
i = 1 : 11;
j = 1.99 : 11 + 0.99;
time = [ ];
for (k = 1 : length(message));
    time = [time i(k), j(k)];   
end
% Gnerating Signal
signal = [ ];            
n = length(data);
prebit = 1;
for t = 1 : 2 : n                  
    if (data(t) == 0)
        signal(t : t+1) = 0;
    else if (data(t) == 1 & prebit == 1)
            signal (t : t+1) = 1;
            prebit = -1;
        else
            signal (t : t+1) = -1;
            prebit = 1;
        end
    end
end
subplot(2,1,1)
plot (time, signal)            % Plotting …
title ('Digital Signal')
xlabel ('Time')
ylabel ('Amplitude')
 

 

Thursday, 22 May 2014

Simulation of line coding scheme in Matlab


Manchester Coding Scheme:
Program :
data=[ 1 0 1 0 1 0  ];

i=1:length(data);
j=1.49:length(data)+0.49;
I=1.50:length(data)+0.50;
J=1.99:length(data)+0.99;
N=length(data);
time=[];
for k=1:length(data);
time=[time i(k),j(k),I(k),J(k)];
end

signal=[];
a=1;
prebit=1;

for t=1:length(data);
  
if(data(t)==0)
    signal(a:a+1)=1;
    signal(a+2:a+3)=-1;
      
elseif(data(t)==1)
    signal(a:a+1)=-1;
    signal(a+2:a+3)=1;
    
   
end
   
a=a+4;

end

plot(time,signal,'linewidth',4);
xlabel('time')
ylabel('signal')





Simulation Results









Differential Manchester Coding Scheme :
Program :
data=[ 1 0 1 0 1 0  ];

i=1:length(data);
j=1.49:length(data)+0.49;
I=1.50:length(data)+0.50;
J=1.99:length(data)+0.99;
N=length(data);
time=[];
for k=1:length(data);
time=[time i(k),j(k),I(k),J(k)]; %Time vector
end

signal=[];
a=1;
prebit=1;

%Signal Generation
for t=1:length(data);
    if(data(t)==0 && prebit==1)
        signal(a:a+1)=-1;
        signal(a+2:a+3)=1;
        prebit=1;
    elseif(data(t)==0 && prebit==-1)
        signal(a:a+1)=1;
        signal(a+2:a+3)=-1;
        prebit=-1;
    elseif(data(t)==1 && prebit==-1)
        signal(a:a+1)=-1;
        signal(a+2:a+3)=1;
        prebit=1;
    elseif(data(t)==1 && prebit==1) 
        signal(a:a+1)=1;
        signal(a+2:a+3)=-1;
        prebit=-1;

end
           a=a+4;
end
plot(time,signal,'linewidth',4); %Plot signal
title('Differential Manchester');
xlabel('Time');
ylabel('Differential Manchester');

%constellation diagram
   M = 4;
x = [0:M-1];
scatterplot(modulate(modem.pskmod(M),x));

Simulation Results :


  

Implementing  BPSK , QPSK and MFSK in Matlab

Program Code For BPSK 
clc;
clear all;
message=[1 1 0 0 1 0];
f_one=1.5;
fs=1000;% frequency
t=[0:1/fs:1];
A=5;
x=A*cos(2*pi*f_one*t+pi); %binary 0
y=A*cos(2*pi*f_one*t); %binary 1
time=t;
for i=1:length(message)-1;
    time=[time i+t];
end
%ask signal logic
ask_signal=[];
for i=1:length(message);
   if(message(i)==0)
       ask_signal=[ask_signal x];
   else
       ask_signal=[ask_signal y];
   end
end
   
plot(time,ask_signal,'linewidth',2);
xlabel('no of bits per second')
ylabel('signal value')

%constellation diagram BPSK
M = 2;
x = [0:M-1];
scatterplot(modulate(modem.pskmod(M),x));

Simulation :



  


Programme Code For MFSK :
clc; %clears the command window
clear all; %clears the workspace
message=[1 1 0 0 1 0 1 0 0]; %binary input is
                                                 
if (rem(length(message),3)~=0)     %for don’t care bits
    display('Error in Message'); 
end
f_one=1;
fs=1000; %frequency
t=[0:2/fs:1];
A=5;
w=A*cos(2*pi*f_one*t); %binary 000   (1 Hz)
x=A*cos(4*pi*f_one*t); %binary 001   (2 Hz)
y=A*cos(6*pi*f_one*t); %binary 010   (3 Hz)
z=A*cos(8*pi*f_one*t); %binary 011   (4 hz)
W=A*cos(10*pi*f_one*t);%binary 100   (5 Hz)
X=A*cos(12*pi*f_one*t);%binary 101   (6 Hz)
Y=A*cos(14*pi*f_one*t);%binary 110   (7 Hz)
Z=A*cos(16*pi*f_one*t);%binary 111   (8 Hz)
time=t;
for i=1:(length(message)/3)-1;
    time=[time i+t];
end
%ask signal logic
ask_signal=[];
for i=1:3:length(message);
   if(message(i)==0 && message(i+1)==0 && message(i+2)==0)
       ask_signal=[ask_signal y];
   elseif(message(i)==0 && message(i+1)==0 && message(i+2)==1)
       ask_signal=[ask_signal z];
   elseif(message(i)==0 && message(i+1)==1 && message(i+2)==0)
       ask_signal=[ask_signal x];
   elseif(message(i)==0 && message(i+1)==1 && message(i+2)==1)
       ask_signal=[ask_signal w];
   elseif(message(i)==1 && message(i+1)==0 && message(i+2)==0)
       ask_signal=[ask_signal W];
   elseif(message(i)==1 && message(i+1)==0 && message(i+2)==1)
       ask_signal=[ask_signal X];
   elseif(message(i)==1 && message(i+1)==1 && message(i+2)==0)
       ask_signal=[ask_signal Y];
   elseif(message(i)==1 && message(i+1)==1 && message(i+2)==1)
       ask_signal=[ask_signal Z];
   end
end
   %figure
   plot(time,ask_signal,'linewidth',2);
   xlabel('no of bits per second');
   ylabel('signal value');
    
% constellation diagram
inphase = [1 1 1 1 1 1 1 1];
quadr = [0 0 0 0 0 0 0 0];
 const = inphase + j*quadr;
scatterplot(const,1,0,'*');
axis([-3 3 -3 3]); 

Simulation :
  




Programme Code For QPSK :

clc; %clears the command window
clear all; %clears the workspace
message=[1 1 0 0 1 0]; %binary input is
                                                 
if (rem(length(message),2)~=0)     %for don’t care bits
    message(1,length(message)+1)=1; 
end
f_one=1.5;
fs=1000; %frequency
t=[0:2/fs:1];
A=5;
w=A*cos(2*pi*f_one*t+pi/4);%binary 11
x=A*cos(2*pi*f_one*t+3*pi/4); %binary 01
y=A*cos(2*pi*f_one*t-3*pi/4); %binary 00
z=A*cos(2*pi*f_one*t-pi/4); %binary 10
time=t;
for i=1:(length(message)/2)-1;
    time=[time i+t];
end
%ask signal logic
ask_signal=[];
for i=1:2:length(message);
   if(message(i)==0 && message(i+1)==0)
       ask_signal=[ask_signal y];
   elseif(message(i)==1 && message(i+1)==0)
       ask_signal=[ask_signal z];
   elseif(message(i)==0 && message(i+1)==1)
       ask_signal=[ask_signal x];
   elseif(message(i)==1 && message(i+1)==1)
       ask_signal=[ask_signal w];

end
end

%figure
plot(time,ask_signal,'linewidth',2);
xlabel('no of bits per second');
ylabel('signal value');
    
% constellation diagram
inphase = [1 -1 1 -1];
quadr = [1 1 -1 -1];
inphase = [inphase; inphase]; inphase = inphase(:);
quadr = [quadr; quadr]; quadr = quadr(:);
const = inphase + j*quadr;
scatterplot(const,1,0,'*');
     
axis([-3 3 -3 3]);


Simulation :
  



how to find out fault in cars in a seconds




Abstract:- 
On-Board Diagnostic System is a new dimension in the field of Automobiles. It is a core element of all the modern day vehicles and can enhance Vehicle’s performance by periodic inspections. OBD-II provides access to data from the engine control unit (ECU) and offers a valuable source of information when troubleshooting problems inside a vehicle. It provides almost complete engine control and also monitors parts of the chassis, body and accessory devices, as well as the diagnostic control network of the car.
Introduction:- 
On-Board Diagnostics, Second Generation (OBD-II) is a set of standards for implementing a computer based system to control emissions from vehicles. It was first introduced in the United States in 1994, and become a requirement on all 1996 and newer US vehicles. Other countries, including Canada, parts of the European Union, Japan, Australia and Brazil adopted similar legislation but some countries like Pakistan still uses older version i.e. OBD-I. A large portion of the modern vehicle fleet supports OBD-II or one of its regional flavors (EOBD, JOBD etc.). Among other things, OBD-II requires that each complaint vehicle be equipped with a standard diagnostic connector (DLC) and describes a standard way of communicating with the vehicle’s computer also known as the ECU (Electronic Control Unit). A wealth of information can be obtained by tapping into the OBD bus, including the status of the malfunction indicator light (MIL), diagnostic trouble codes (DTCs), inspection and maintenance (I/M) information, freeze frames, VIN, Hundreds of real-time parameters, and more.
Objectives:- 
This application can be used to get an idea of how the engine management diagnostic tools work. Machinery health monitoring or engine management components mainly focused on the ECU and a generic scan tool based on OBD-II Protocol.  OBD –II protocol is extensively used to fetch engine parameters. These parameters will be used by the software for tracking and management purposes. Every vehicle used its own specific OBD-II company protocols which only compatible with specific vehicles. 
Now our objective is to put all OBD-II protocols in OBD using STN1110 IC and make such type of algorithm that search a specific protocol which is compatible for every type of vehicle. Further we will design OBD hardware module for it if needed. We will mainly focus on OBD-II protocol. 


Literature Review:-
We did an online survey and found the following topics related to our project.
OBD-II
An OBD-II compliant vehicle can use any of the five communication protocols, i.e. SAE J1850 PWM, SAE J1850 VPM, ISO9141-2 and ISO14230-4 (KWP2000) and since 2003 also ISO 15765-4/SAE J2480. ELM-USB and OBD tester support all of them.
Some models are equipped with SAE J1962 connector, but these cars are NOT OBD-II complaint. Typical examples of such cars are some early VW/Skoda/ seat models, Ford cars with EEC-IV using Ford DCL protocol (e.g. Ford Escort), Nissan EU/Asian models (using Nissan DDL protocol), or some European Hyundai Models.
Determining protocol from OBD-II pinout
As a general rule, we can determine which protocol our vehicle is using by looking at the pin out of the OBD-II connector. The following table shows this.
 
Standard                   Pin 2               Pin 6             Pin 7    Pin 10      Pin 14        Pin 15   
J1850 PWM     must have - -                          must have - -   
J1850 VPW         must have - - - - -   
ISO9141/14230 - -                                  must have - -                          optional   
ISO15765 (CAN) -                   must have - -                        must have -  

 
Figure 1



ECU
In automotive electronics, ECU is a generic term for any embedded system that controls one or more of the electrical system or subsystems in a motor vehicle.
Types of ECU include electronic/engine control module (ECM), powertrain control module (PCM), Transmission Control module (TCM), brake control module (BCM or EBCM), central control module (CCM), central timing module (CTM), general electronic module (GEM), body control module (BCM), suspension control module (SCM). Taken together, these systems are sometimes referred to as the car’s computer.
Some modern motor vehicles have up to 80 ECUs. Managing the increasing complexity and number of ECUs in a vehicle has become a key challenge for original equipment manufacturers (OEMs).
ELM 327
The ELM327 is a programmed microcontroller produced by ELM Electronics for translating the OBD interface found in most modern cars. The ELM327 command protocol is one of the most popular PC to OBD interface standards, and is also implemented by other vendors.
ELM 327
The STN1110 integrated circuit is an OBD to UART interpreter that can be used to convert messages b/w any of the OBD-II protocols currently in use and UART. It is fully compatible with the de-facto industry standard ELM328 command set. Based on a 16-bit processor core, the STN1110 offers more features and better performance than any other ELM327 compatible IC.
Methodology:-
STN1110 is the world’s smallest, lowest cost multiprotocol OBD to UART Interpreter IC.  The main task of our project is to design hardware for STN1110 IC and interface STN1110 with pc and also interface with OBD 2 via Bluetooth or WIFI for checking that it is compatible for different vehicles or not. If it is not computable for our required vehicles then we design hardware and different algorithm for our required vehicles which will search specific protocol for specific vehicle.
 

Application:-
The applications of OBD ranges from simple generic consumer level tools to highly sophisticated original equipment manufacturer (OEM) dealership tools to vehicle telematic devices. A range of rugged hand-held scan tools is available that use OBD as simple fault code readers/reset tool. OBD system can monitor the engine pollutants emission level continuously and show faults timely. Also it can control the vehicles emission level effectively and avoid the higher fuel consumptions and emissions caused by sustained driving of fault vehicles. OBD system provides a convenient means for vehicle maintenance and repair, and the real time data provide related research and analysis with the basis. It has great significance and high application value for improving vehicle maintenance.
Requirements 
Hardware:  Development PC: PC with MS Windows XP or Window 7 or Window 8
Minimum Display Resolution: 1024 * 768 with 16 bit color
Server PC: PC with 1TB hard drive
 ECUs OBD STN 1110 ELM327 some extra hardware.
Software: Assembly language for STN 1110
References:-
project perform by
Shawkat Ali 10PWCSE0868
Saba Kanwal 10PWCSE0860
Amjad Ali 10PWCSE0889
Maria Shaukat 10PWCSE0864


Wednesday, 21 May 2014

Implementing Spread Spectrum Communication in Matlab



DSSS  is  a  wireless  analog  encoding  scheme  based  on  a  technique   spread  spectrum.  
It represents each data bit by multiple bits in the transmitted signal using a chip code/spreading code. The spreading code spreads the signal across a wider frequency band in direct proportion to the length of the chip code. 

Task 1: Study and implement the  matlab functions and show the output:
Hadamard:
This MATLAB function returns the Hadamard matrix of order n.
Syntax:
Hadamard(n) % n n must be an integer and n, n/12 or n/20 must be a power of 2.
Command: Hadamard(4);
Output: 
     1     1     1     1
     1    -1     1    -1
     1     1    -1    -1
     1    -1    -1     1
randperm
It stands for random permutation
Syntax:
P = randperm(n); % returns a row vector containing a random permutation of the integer from 1 to n inclusive.
P= randperm(n,k) % return a row vector containing k unique integers selected randomly from 1 to n inclusive. 
Command: 
randperm(7);
output:  6     3     7     5     1     2     4
Command:
Randperm(7,3);
Output:
                     6     2     7

randint
It generates a matrix of uniformly distributed random integers.
Syntax:
Out= randint % generate either 0 or 1
Out = randint(n) % generate a matrix of order nxn containing randomly 0’s and 1’s.
Out = randint(n,m,range)% generates a matrix of order nxm, if rg is 0 it will generate matrix containing all zeros, otherwise it will have integer containing in the specified range.
Command:   randint(2,2,9)
                  Output:8     4
              4     2
biterr
It computes the number of bit errors and bit error rate(BER).
Syntax:
 [number, ratio]= biterr(x,y) % compare the unsigned binary representation of each element of x matrix with that of y matrix.
[number, ratio]= biterr(x,y,k) % it considers that elements of x and y have k bits.
[number, ratio]= biterr(x,y,k,flg) % flg can be ‘overall’ (element by element comparison), ‘rsow_wise’  (compare nth row of x with nth row of y) and ‘column_wise’. 
[number,ratio, individual]= biterr(….) % individual have dimension greater then that of x and y matrix. Each element of individual represent the difference of bits between the corresponding elements of x and y matrix and number of comparisons.
Command:
[number,ratio,individual] = biterr([0;0;0],randi([0 1],3,5));
Output:
number = 2              1              2              1              1       
                 ratio =  2/3            1/3            2/3            1/3            1/3     
                 individual =0              0              0              1              0       
                     1              0              1              0              1       
                     1              1              1              0              0       
bi2de
convert binary vector to decimal equivalent number.
Syntax:
Bin2de(v)
Command:   v=[1 0 1 0 1]
bi2de(v);
Output= 21
bin2gray
Converts binary integer to corresponding  Gray-encoded integer.
Syntax: 
Y= bin2gray(x,modulation,M)
or 
[y,map]= bin2gray(x,modulation,M) 
Code:
% To Gray encode a vector x with a 16-QAM Gray encoded
 % constellation and return its map, use:
 x=randi([0 5],1,100);
 [y,map] = bin2gray(x,'qam',16);
 % Obtain the symbols for 16-QAM
 hMod = modem.qammod('M', 16);
 symbols = hMod.Constellation;
 % Plot the constellation
 scatterplot(symbols);
 set(get(gca,'Children'),'Marker','d','MarkerFaceColor',...
 'auto'); hold on;
 % Label the constellation points according
 % to the Gray mapping
 for jj=1:16
 text(real(symbols(jj))-0.15,imag(symbols(jj))+0.15,...
 dec2base(map(jj),2,4));
 end
 set(gca,'yTick',(-4:2:4),'xTick',(-4:2:4),...
 'XLim',[-4 4],'YLim',...
 [-4 4],'Box','on','YGrid','on', 'XGrid','on');
Output:


de2bi
It converts decimal number to equivalent binary  vector.
Command: de2bi(3)
Output:  1 0 1
gray2bin
Convert Gray-encoded positive integers to corresponding Gray-decoded integers.
Syntax: 
Y= gray2bin(x,Modulation, M);
or
[Y,map]= gray2bin(x,Modulation,M);
Code:
% To Gray decode a vector x with a 16-QAM Gray encoded
 % constellation and return its map, use:
 x=randi([0 15],1,100);
 [y,map] = gray2bin(x,'qam',16);
 % Obtain the symbols for 16-QAM
 hMod = modem.qammod('M', 16);
 symbols = hMod.Constellation;
 % Plot the constellation
 scatterplot(symbols);
 set(get(gca,'Children'),'Marker','d','MarkerFaceColor','auto');
 hold on;
 % Label the constellation points according
 % to the Gray mapping
 for jj=1:16
  text(real(symbols(jj))-0.15,imag(symbols(jj))+0.15,...
  dec2base(map(jj),2,4));
 end
 set(gca,'yTick',(-4:2:4),'xTick',(-4:2:4),...
  'XLim',[-4 4],'YLim',...
   [-4 4],'Box','on','YGrid','on', 'XGrid','on');

Output:



vec2mat
It converts a vector into matrix.
Command: v=[1 2 3 4 5];
 vec2mat(v);
Output: 1    2    3
               4    5    0

Task 2:  Implement DSSS receiver in Matlab and show the complete results:
Matlab code: 
At transmitter side the data=[1 0 1 1 1 1] was encoded as coded=[1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1];  by  spread  spectrum technique.
Matlab function for receiver side.
coded=[1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1];
ct=hadamard(8);
p=8;
code=ct(p,1:end)';
data=[];
l=length(coded);
for i=1:8:l
    matrix=coded(1,i:i+7);
    original=(matrix*code)/length(code);
    if(original ==-1)
        original=0;
    else
        original=1;
    end
    data=[data original];
    end
Data:    1 0 1 1 1 1
Coded data received from transmitter: 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1
Decoded data at Receiver:  1 0 1 1 1 1
Task 3:  Implement Frequency Hopping Spread Spectrum (FHSS) Transmitter in Matlab and show the complete results.
Frequency-hopping spread spectrum (FHSS) is a method of transmitting radio signals by rapidly switching a carrier among many frequency channels, using a pseudorandom sequence known to both transmitter and receiver. It is used as a multiple access methodin the frequency-hopping code division multiple access (FH-CDMA) scheme
Matlab code for transmitter: 
      clc
clear all
close all 
data=[1 0 1 1 1 1]; 
size=length(data); 
M=2; 
NRZ_signal=[]; %unipolar NRZ signal 
k=[];
for (t=1:size) 
    if (data(t)==0)
        NRZ_signal(t)=-1;
    else
        NRZ_signal(t)=1;
    end
    k=[k NRZ_signal(t)];
end
rand_freq=[2 3 4 5 6 7 8 9];
chip=8;
r=randperm(chip);
t=[];
bpsk_datasig=[];
for b=1:length(k)
   f=rand_freq(r(b));
    fs=50;
    t1=b-1:1/fs:b;
    t2=0:1/fs:1;
    x=cos(2*pi*f*t2);
    y=sin(2*pi*f*t2);
    t=[t t1];
     if (k(b)==1) 
            a=x; 
        else
            a=y;
        end
 bpsk_datasig=[bpsk_datasig a];
end
plot([1:length(bpsk_datasig)], abs(fft(bpsk_datasig)));

capturing data through ethereal


Ethereal:
Ethereal is a network packet analyzer, which captures network packets and displays that packet data detailed as possible. In fact, it’s kind of a measuring tool that tries to measure what is going inside a network cable. It can be downloaded from www.ethereal.org
download ethereal

 Few main uses of Ethereal can be 
1. Network administrators can use it to troubleshoot network problems 
2. Network security engineers use it to examine security problems. 
3. Developers use it to debug protocol implementation. 
4. And we students will learn the basics of computer networks with its help. 

Task 02:
Capture data on the network using all the three auto-stop features i.e:





a) Packets-Based:
No of data packets captured =35 



b) Size-Based: Data captured about 1Mbytes.


  

c) Time Based : Data captured for 30 seconds is ;

  
Task 02: Filter on the capturing process on the basis of ;
Distination IP :
   

Port number : port (80)

  
Task 3 :
SMTP Protocol :

  
Findings:
Packet size = 423 bytes
Header size = 20 bytes
Checksum value = 0x2498 [validation disabled]
Time with refrence to the first packet = 0.12393000 sec
Source IP Address = 82.178.158.19
Destination IP Address = 10.110.160.100
Source MAC address = 7c:ad:74:e4:f6:d0
Destination MAC address = o8:ed:b9:86:6d:
Note, to view the image it is better to download it first.

Introduction to Ethereal

Objectives

What is ethereal and why we study it?
How does ethereal works and what are its main features?
Introduction to ethereal interface and its menu items

Ethereal 

Ethereal is the network packet analyzer, which captures network packets and displays that packet data as detailed as possible. It is kind of measuring tool that tries to measure what is going inside a network cable.

Why Study Ethereal ?

Study of ethereal is important because being a student of data communications one must know how information is transferred between functional units by means of data transmission according to a protocol .Also it helps in knowing how information is transferred in computer networks.

Uses of Ethereal

Network administrator can use it to troubleshoot network problems
Network security engineers use it to examine security problems
Developers use it to debug protocol implementation






Task 1
a)Find the available interfaces on the computer and the IP assigned to each interface.

 

b)Capture packets on a particular interface,find out what protocols have been used,and save them in a file.
Captured the Microsoft interface whose IP Address is 192.168.1.2.
The following are the protocols used:
1)TCP
2)UDP
3)ARP
4)RUDP
 

c) State your findings
The findings are:
1 ) Data can be captured from the wire from a live network connection.
2) Data display can be refined using a display filter.
3) You can capture, filter, and analyze data your network adapter sees -- nothing more and nothing less. Typically it is used to examine what data is being sent to and from your machine. If there's strange network activity going on, wireshark will certainly tell you about it. In that sense, it is a security tool. It's also valuable for debugging software you write yourself that works over the network. 

Thursday, 15 May 2014

Home Automation using GSM and Arduino :






Main purpose is to provide the user with comfort and access to control his devices from anywhere in the world.
  The user can control his home appliances like air conditioners, fans, lights or music systems etc from anywhere in the world by just sending  a simple pre-defined SMS command to a particular number, user received the acknowledgement for his action. User can check the status whether his device is on or off at that moment. 

Automatic gates for his house or garage, IR motion sensors or smoke or fire alarms can also be added to alert the user in case of any emergency situations by SMS  and by using  GPS  it can send  SOS message to rescue teams with exact location. 

Spy Car controlled by Pc :






Radio frequency is used, through pc you establish a connection using hyper terminal and serial cable. And then through hyper terminal you can control the car`s direction and motion.
   Wireless camera is attached to the infront of this car, for spying or monitoring purposes, and an integrated mic is also located inside the camera module, so you can watch and hear the surrounding by an AV receiver.


GSM modem can be introduced and we can control its direction through sms commands, GPS for tracking , different sensors like temperature , smoke radiations etc . an android app can also be developed to control its direction and motion and even watch the video being captured by the wireless camera on the car.

Tiniest Drill

This drill is about the smallest i have ever seen. The word drill in this case is a bit of a hyperbole as it doesn’t actually do any drilling. It will however spin the drill bit upon pressing the trigger, and that’s close enough for us. Plus, who’s ever heard of a drill you can wear as a pendant? That’s pretty sweet!