This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA

Download & View **4. Pn Sequence Generator.pdf** as PDF for free.

**Words:**989**Pages:**8

Loading documents preview...

Ex. No.4

PSEUDONOISE SEQUENCE GENERATOR Date:

AIM: To generate maximal and non-maximal length PN sequence and verify its properties. REQUIREMENTS: 1. MATLAB 2. PERSONAL COMPUTER ALGORITHM: 1. Start. 2. First get the register length. 3. Find the length of PN sequence using the formula 2m-1 where m is the number of registers. 4. Initialize the PN sequence, with first bit as 1 and others as zero. 5. The XOR operation is performed for first and last bit and other, bits are shifted. 6. Then the balance property is, checked by checking the number of 1’s and 0`s. 7. The run length property is checked by finding the number of consecutive changes between zeros and ones. 8. The autocorrelation property is verified by using checking for agreement and non agreement between bits. 9. Stop. THEORY: In electrical systems voltage and current waveforms are used as signals for collecting, transmitting and processing information as well as for controlling and providing power to a variety of devices. Signals are classified as deterministic and random. Deterministic signals can be described by functions in the usual mathematical sense with time t as the independent variable. In contrast to a deterministic signal, a random signal always has same elements of uncertainty associated with it and hence it is not possible to determine its value with uncertainty at any given point of time.

36

Models in which there are uncertainties and randomness play an important role in the analysis and design of communication systems. These models are used in a variety of applications in which the signals, as well as the system parameters may randomly change. As an example, consider the waveforms that occur in typical communication in which number of terminals are sending information in binary format over using transmission links to a centralcomputer. A transmitter in each link converts the binary data to an electrical waveform. A Pseudo-Noise (PN) code sequence acts as a noise like (but deterministic) carrier used for bandwidth spreading of the signal energy. The PN code sequence is a Pseudo-Noise or Pseudo-Random sequence of l's and O's, but not a real random sequence (because periodic). Random signals cannot be predicted. The autocorrelation of a PN code has properties similar to those of white noise. Properties of PN Sequences 1. Balance Property In each period of sequence the number of binary ones differs from the number of binary zeros by at most one digit. 2. Run-Length Distribution A run is a sequence of a single type of binary digits. Among the runs of ones and zeros in each period it is desirable that about one-half the runs of each type are of length 1, about onefourth are of length 2, one-eighth are of length 3, and so on. 3. Autocorrelation The origin of the name' pseudo-noise is that the digital signal has an autocorrelation function which is very similar to that of a white noise signal. The autocorrelation function for the periodic sequence is defined as the number of agreements less the number of disagreements in a term by term comparison of one full period of the sequence with a cyclic shift of the sequence itself.

37

PROGRAM:clc; clear all; len=input('Enter the length of the sequence:'); disp('Generator poly example[1 0 0 1......1]:'); poly=input('Enter the generate poly:'); disp('Generator poly example[1 0 0 0......0]:'); ini=input('Enter the initial state:'); ff=log2(len+1); %PN SEQUENCE GENERATOR a=zeros(len,ff); a(1,1:ff)=ini; for i=1:(len-1) x=0; for j=2:(ff+1) if (poly(1,j)==1) x=xor(x,a(i,(j-1))); end end a((i+1),1:ff)=circshift(a(i,1:ff),[0 1]); a((i+1),1)=x; end for i=1:len h(1,i)=a(i,ff); end fprintf('The Generated Sequence is \n'); disp(h); %PROPERTIES %BALANCE PROPERTY check=0; one=0; zero=0; for i=1:len if((h(1,i))==0) zero=zero+1; else one=one+1; end end disp('Balance property'); disp('Number of ones'); disp(one); disp('Number of zeros'); disp(zero); 38

if ((one-zero)==1) fprintf('Balance Property is satisfied \n'); else fprintf('Balance Property is not satisfied \n'); check=1; end %AUTO CORRELATION PROPERTY for i=1:len y(i,:)=xor(h,circshift(h,[0,i])); end %disp(y); for i=1:len one=0; zero=0; for j=1:len if((y(i,j))==0) zero=zero+1; else one=one+1; end end z(i,1)=(zero-one); end for i=1:(len-1) g(i,1)=-1; end g(len,1)=len; disp('Auto Correlation Property '); disp(z); if (z==g) fprintf('Auto Correlation Property is satisfied \n\n'); check=3; else fprintf('Auto Correlation Property is not satisfied \n\n'); check=2; end

%RUN PROPERTY runs=((len+1)/2); u=ff; 39

r=zeros(1,u); count=1; for i=1:len-1 if (h(1,i)==h(1,i+1)); count=count+1; else r(1,count)=r(1,count)+1; count=1; end end r(1,count)=r(1,count)+1; s=zeros(1,u); for i=1:(u-1) s(1,i)=runs/(2.^i); end s(1,u)=1; disp('Run Run Length '); for i=1:u fprintf('%d t\t\t\t\t %d \n',r(1,i),i); end if(r==s) fprintf('Run Property is satisfied \n\n'); check=4; else fprintf('Run Property is not satisfied \n\n'); check=2; end if (check==2) disp('The given is not a PN sequence'); else disp('The given is a PN sequence'); end

40

SAMPLE INPUT AND OUTPUT: CASE 1: Enter the length of the sequence:7 Generator poly example: [1 0 0 1......1]: Enter the generate poly: [1 0 1 1 ] Generator poly example: [1 0 0 0......0]: Enter the initial state: [1 0 0] The Generated Sequence is 0

0

1

0

1

1

1

Balance property Number of ones 4 Number of zeros 3 Balance Property is satisfied Auto Correlation Property -1 -1 -1 -1 -1 -1 7 Auto Correlation Property is satisfied Run

Run Length

2

1

1

2

1

3

Run Property is satisfied The given is a PN sequence

41

CASE 2: Enter the lenth of the sequence:15 Generator poly example[1 0 0 1......1]: Enter the generate poly:[1 0 1 1 1] Generator poly example[1 0 0 0......0]: Enter the inital state:[1 0 1 1] The Generated Sequence is 1 1 0 1 0 0 1 1 1 0 Balance property Number of ones 9 Number of zeros 6 Balance Property is not satisfied Auto Correlation Property -1 -1 -1 -5 -1 -1 7 7 -1 -1 -5 -1 -1 -1 15\ Auto Correlation Property is not satisfied Run Run Length 4 1 4 2 1 3 0 4 Run Property is not satisfied

1

The given sequence is not a PN sequence

42

0

0

1

1

EXERCISE: 1. Vary the input sequence 2. Vary the Generator polynomial.

RESULT:

Thus the length of PN sequence and its properties were tested. 43

PSEUDONOISE SEQUENCE GENERATOR Date:

AIM: To generate maximal and non-maximal length PN sequence and verify its properties. REQUIREMENTS: 1. MATLAB 2. PERSONAL COMPUTER ALGORITHM: 1. Start. 2. First get the register length. 3. Find the length of PN sequence using the formula 2m-1 where m is the number of registers. 4. Initialize the PN sequence, with first bit as 1 and others as zero. 5. The XOR operation is performed for first and last bit and other, bits are shifted. 6. Then the balance property is, checked by checking the number of 1’s and 0`s. 7. The run length property is checked by finding the number of consecutive changes between zeros and ones. 8. The autocorrelation property is verified by using checking for agreement and non agreement between bits. 9. Stop. THEORY: In electrical systems voltage and current waveforms are used as signals for collecting, transmitting and processing information as well as for controlling and providing power to a variety of devices. Signals are classified as deterministic and random. Deterministic signals can be described by functions in the usual mathematical sense with time t as the independent variable. In contrast to a deterministic signal, a random signal always has same elements of uncertainty associated with it and hence it is not possible to determine its value with uncertainty at any given point of time.

36

Models in which there are uncertainties and randomness play an important role in the analysis and design of communication systems. These models are used in a variety of applications in which the signals, as well as the system parameters may randomly change. As an example, consider the waveforms that occur in typical communication in which number of terminals are sending information in binary format over using transmission links to a centralcomputer. A transmitter in each link converts the binary data to an electrical waveform. A Pseudo-Noise (PN) code sequence acts as a noise like (but deterministic) carrier used for bandwidth spreading of the signal energy. The PN code sequence is a Pseudo-Noise or Pseudo-Random sequence of l's and O's, but not a real random sequence (because periodic). Random signals cannot be predicted. The autocorrelation of a PN code has properties similar to those of white noise. Properties of PN Sequences 1. Balance Property In each period of sequence the number of binary ones differs from the number of binary zeros by at most one digit. 2. Run-Length Distribution A run is a sequence of a single type of binary digits. Among the runs of ones and zeros in each period it is desirable that about one-half the runs of each type are of length 1, about onefourth are of length 2, one-eighth are of length 3, and so on. 3. Autocorrelation The origin of the name' pseudo-noise is that the digital signal has an autocorrelation function which is very similar to that of a white noise signal. The autocorrelation function for the periodic sequence is defined as the number of agreements less the number of disagreements in a term by term comparison of one full period of the sequence with a cyclic shift of the sequence itself.

37

PROGRAM:clc; clear all; len=input('Enter the length of the sequence:'); disp('Generator poly example[1 0 0 1......1]:'); poly=input('Enter the generate poly:'); disp('Generator poly example[1 0 0 0......0]:'); ini=input('Enter the initial state:'); ff=log2(len+1); %PN SEQUENCE GENERATOR a=zeros(len,ff); a(1,1:ff)=ini; for i=1:(len-1) x=0; for j=2:(ff+1) if (poly(1,j)==1) x=xor(x,a(i,(j-1))); end end a((i+1),1:ff)=circshift(a(i,1:ff),[0 1]); a((i+1),1)=x; end for i=1:len h(1,i)=a(i,ff); end fprintf('The Generated Sequence is \n'); disp(h); %PROPERTIES %BALANCE PROPERTY check=0; one=0; zero=0; for i=1:len if((h(1,i))==0) zero=zero+1; else one=one+1; end end disp('Balance property'); disp('Number of ones'); disp(one); disp('Number of zeros'); disp(zero); 38

if ((one-zero)==1) fprintf('Balance Property is satisfied \n'); else fprintf('Balance Property is not satisfied \n'); check=1; end %AUTO CORRELATION PROPERTY for i=1:len y(i,:)=xor(h,circshift(h,[0,i])); end %disp(y); for i=1:len one=0; zero=0; for j=1:len if((y(i,j))==0) zero=zero+1; else one=one+1; end end z(i,1)=(zero-one); end for i=1:(len-1) g(i,1)=-1; end g(len,1)=len; disp('Auto Correlation Property '); disp(z); if (z==g) fprintf('Auto Correlation Property is satisfied \n\n'); check=3; else fprintf('Auto Correlation Property is not satisfied \n\n'); check=2; end

%RUN PROPERTY runs=((len+1)/2); u=ff; 39

r=zeros(1,u); count=1; for i=1:len-1 if (h(1,i)==h(1,i+1)); count=count+1; else r(1,count)=r(1,count)+1; count=1; end end r(1,count)=r(1,count)+1; s=zeros(1,u); for i=1:(u-1) s(1,i)=runs/(2.^i); end s(1,u)=1; disp('Run Run Length '); for i=1:u fprintf('%d t\t\t\t\t %d \n',r(1,i),i); end if(r==s) fprintf('Run Property is satisfied \n\n'); check=4; else fprintf('Run Property is not satisfied \n\n'); check=2; end if (check==2) disp('The given is not a PN sequence'); else disp('The given is a PN sequence'); end

40

SAMPLE INPUT AND OUTPUT: CASE 1: Enter the length of the sequence:7 Generator poly example: [1 0 0 1......1]: Enter the generate poly: [1 0 1 1 ] Generator poly example: [1 0 0 0......0]: Enter the initial state: [1 0 0] The Generated Sequence is 0

0

1

0

1

1

1

Balance property Number of ones 4 Number of zeros 3 Balance Property is satisfied Auto Correlation Property -1 -1 -1 -1 -1 -1 7 Auto Correlation Property is satisfied Run

Run Length

2

1

1

2

1

3

Run Property is satisfied The given is a PN sequence

41

CASE 2: Enter the lenth of the sequence:15 Generator poly example[1 0 0 1......1]: Enter the generate poly:[1 0 1 1 1] Generator poly example[1 0 0 0......0]: Enter the inital state:[1 0 1 1] The Generated Sequence is 1 1 0 1 0 0 1 1 1 0 Balance property Number of ones 9 Number of zeros 6 Balance Property is not satisfied Auto Correlation Property -1 -1 -1 -5 -1 -1 7 7 -1 -1 -5 -1 -1 -1 15\ Auto Correlation Property is not satisfied Run Run Length 4 1 4 2 1 3 0 4 Run Property is not satisfied

1

The given sequence is not a PN sequence

42

0

0

1

1

EXERCISE: 1. Vary the input sequence 2. Vary the Generator polynomial.

RESULT:

Thus the length of PN sequence and its properties were tested. 43