Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Wednesday 26 March 2014

Simulation of Line coding schemes in Matlab


hi friend my this article is all about Matlab ,which was originally a task given by our teacher in data communication lab and we perform as a team member in class room , at university of engineering a technology, i am sharing with you this task , and will share all other task as soon as we perform it.

Objectives 

To generate unipolar Non-return-to-zero (NRZ) signal.
To generate unipolar signal with two different polarities 0v and 1v.
To generate Bipolar Alternate Mark Inversion (AMI) signal.
To plot pseudoternary signal.

Software:

Matlab (any suitable version)

Introduction:

Line Coding:

Binary data can be transmitted using a number of different types of pulses. The choice of a particular pair of pulses to represent the symbols 1 and 0 is called Line Coding.
Types of Line Coding:

Unipolar Signal:

            Unipolar signal (also called on-off keying, OOK) is the type of line coding in which one binary symbol (representing a 0 for example) is represented by the absence of a pulse (i.e. a SPACE) and the other binary symbol (denoting a 1) is represented by the presence of a pulse (i.e. a MARK).
            There are two common variations of unipolar signal: Non-Return to Zero (NRZ) and Return to Zero (RZ).

Non-return to zero (NRZ):

             In unipolar NRZ the duration of the MARK pulse (Ƭ) is equal to the duration (To) of the symbol slot shown in the figure. It Provide simplicity in implementation, also it does not require a lot of bandwidth for transmission.

          1         0          1           0        1          1          1           1             1       0
      

Return to Zero (RZ):

            In unipolar RZ the duration of the MARK pulse (Ƭ) is less than the duration (To) of the symbol slot as shown in figure. Typically RZ pulses fill only the first half of the time slot, returning to zero for the second half. It provide Presence of a spectral line at symbol rate which can be used as symbol timing clock signal.
  (To)
                     1           0         1           0        1          1          1         0       0        0
   (T)                          1     0         1     0         1       1        0     0    0         0

Polar signal:

           In polar signal a binary 1 is represented by a pulse g1 (t) and a binary 0 by the opposite (or antipodal) pulse g0 (t) = -g1 (t). Polar signal also has NRZ and RZ forms. 


    1            0          1            0            1           1            1          1          1           0

                                    1       0         1        0     1            1             1              1    0

  
                   

                    Polar NRZ and RZ have almost identical spectra to the Unipolar NRZ and RZ.

Bipolar signal:

Bipolar Signalling is also called “alternate mark inversion” (AMI) uses three          voltage levels (+V, 0, -V) to represent two binary symbols. Zeros, as in unipolar, are
Represented by the absence of a pulse and ones (or marks) are represented by
Alternating voltage levels of +V and –V. Like the Unipolar and Polar cases, Bipolar also has NRZ and RZ variations.

  1           0           1         0             1            1           1           1           1       0
                                  1        0        1      0          1        1        1       1        1      0

Pseudoternary signal:

         A pseudoternary signal which is derived from the binary digit signal without change of the line digit rate
NOTE- An alternate mark inversion signal is an example of a pseudoternary signal.


Unipolar NRZ:

Clc
Clear all;
Data=[0 1 1 0 1 0 1];
I=1:7;
J=1.99:7.99;
Time=[ ];
For (k=1:7)
Time=[time i(k) j(k)];
End
a=1;
signal=[ ];
for (t=1:7)
if (data (t)==0)
signal (a:a+1)=0;
else
signal (a:aa+1)=1;

End
a=a+2;
end
figure (1);
plot(time, signal' line width' 2);
title ('digital signal ')
xlable (''time(t) ')
ylabe ('Amplitude (A)')
axis ( [1 8 -0.5 5])



Task 01:
Write Matlab code that generates unipolar signal with following polarities.
0V for binary – 0
-1V for binary -1


NRZ –L
Data=[1 0 0 0  1 1 0 1];
I= 1; length (data);
J=1.99: length (data) + 0.99;
Time= 
% generating signal
Signal= [ ];
N= length (data);
a= 1;
for (t= 1:N);
if data (t)== 1);
signal (a:a+1)=1;
else
signal (a:a+1)=-1;
end
a= a+2;
end
plot;(time, signal 'linewidth'.2);
title('NRZ-L');
Xlable('time');
Ylable('Voltage level');

Task 02:

            Plot NRZ-I signal for the following message
            M= [0 1 0 1 1 1 0 1];
            Bipolar-AMI (Alternate Mark Inversion).
            % generating signal
            Signal= [ ];
            N= length (data);
            a= 1;
            pre-bit= 1;
           for (t= 1:N)
           if (data(t)==1 and pre-bit==1)
           signal (a; a+1) =1;
           pre-bit= -1;
           else
           signal (a:a+1)= -1;
           pre-bit= 1;
           end
           a= a+2;
           end.

          Task 03:

          Data= [0 1 1 1 0]; j = 1.99 : 11 + 0.
 time = [ ]
for (k = 1 : length(message
          Write Matlab Program to plot psuedoternary signal
  Psuedo Ternary Encoding
clcmessage = [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)

time =time i(k), j(k)])]   
end
% Generating 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