1、The quality for spreading spectrum of DSSS: Anti-interference Multiple addressCDMA (Code Division Multiple Address): Because of the advantages of DSSS, such as the anti-jamming capability, low probability of interception, multiple access capability and so on, it has been widely applied for secure co
2、mmunications and mobile communications known as Code Division Multiple Access System. Code Division Multiple Address System can be realized by taking advantage of the orthognality of the PN sequence. Basic Requirement In this experiment, the following items need to be done: Write a program to genera
3、te the m sequence with 0 0 0 0 1 0 1 0 1 0 0 0 1 0 1 Draw the autocorrelation of the generated m-sequence Build up a simulation system of the given figure with the data rate 1bit/s, spreading gain 64 and the carrier frequency 128Hz. Experiment Procedure The code for generating the m-sequence is as f
4、ollowing: function mseq = mseries (coefficients); len = length (coefficients) ; L = 2len - 1 ; %the length of the shift register registers =zeros(1,len-1),1 ; %the initial content of the shift register mseq (1)= registers (len) ; for i = 2 :L newregisters(1)= mod(sum(coefficients.*registers),2); for
5、 j=2:len, newregisters(j)=registers(j-1); end; registers = newregisters; mseq(i) = registers(len); end we save this piece of code as a function, then type stem(mseries(0 0 0 0 1 0 1 0 1 0 0 0 1 0 1) and we get the follwoing graph: Draw the autocorrelation of the generated m-sequence The following co
6、de is used to manipulate the correlation of two signals: function r=coorr(seq1,seq2) if nargin=1 seq2=seq1; N=length(seq1); for k=-N+1:-1 seq2_shift=seq2(k+N+1:N) seq2(1:k+N); r(N+k)=seq1*seq2_shift; for k=0:N-1 seq2_shift=seq2(k+1:k); Input the following code, then we can get the following graph: m
7、seq= 0 0 0 0 1 0 1 0 1 0 0 0 1 0 1; ind1=find(mseq=0); mseq(ind1)=-1; r1=coorr(mseq, mseq); N=length(mseq); axis =-N+1:N-1; plot(axis,r1) xlabel( k); ylabel( R(k) title( The autocorrelation of M-sequence 1. Generation of the original data: % SYSTEM REQUIRMENTS %data bit rate : 1 bit/s %carrier frequ
8、ency: 128Hz %spread gain: 64 clc; clear all; close all; % First of all we need to generate the original data % by using Randn() function, standard normal distribution % and we set the original data to be of 1s and -1s data_length=20; % sdefine the length of each users original data numOfUser = 4; %
9、specify the number of the users sumLength = numOfUser*data_length; % the overall data length is 20*4 d = zeros(numOfUser,data_length); % 4*20 double matrix of all zeros randn(state,sum(100*clock); % make the seed of the function different each time for i=1:numOfUser d(i,:) = sign(randn(1,data_length
10、); % 1*20 double matrix dd = d(1,:d(2,:d(3,:d(4,:) % 20*4 double matrix % Generate the orthorgnal 4 ordered Walsh code % Where 4 represent the number of users walshCode = hadamard(numOfUser); % call the function hadamard(), walshCode is 4*4 matrix walshCode = walshCode/2; % normalisition w is s = dd
11、*walshCode; %Coding: dd is of the size 20*4; walshCode is of the size 4*4 %s is of the size 20*4 cdmData = reshape(s,1,4*data_length); % cdmDatas size:1*80 sumLength % set sampling frequency to be % fs = 128*8=1024Hz i.e.8sample/T data(1+(i-1)*1024):i*1024)=cdmData(i); % fs/f=1024 samples % END of s
12、tep 1.We have generated the original data sequence d of length % equals to 20*numOfUser*1024=819202. Generate the PN sequence g = 41889; % G = 1010001110100001 b14=b13*b9*b8*b7*b5*b0 state =16385 ;% state=100000000000001 140after the first 1 PNlength=64*sumLength; %PN frequency is 64Hz, 64Hz/1Hz = 6
13、4. x_code=sign(mgen(g,state,PNlength)-0.5); %turn -1s & 1s PNlength PNcode(1+(i-1)*16):i*16)=x_code(i); %16 samples per PNcode % then we generate a sequence of PNcode with the length 64*20*16 = % length(d)3. Spectrum Spreading fmodSig=data.*PNcode; %PNcode: frequency spreading code % fmodSig: freque
14、ncy modulated signal by PNcode4. BPSK Modulation % carrier frequency: 128Hz cosin signallength(data)/8 AI=1; % the amplitude of the carrier signal dt=2/3; n=0:dt/7:dt; %8 samples per Period of Carrier cI=AI*cos(2*pi*n*1.5); modSig(1+(i-1)*8):i*8)=fmodSig(1+(i-1)*8):i*8).*cI; % Adding Noise % AWGN ch
15、annel adding noise to the signal EsNodB = 0:8; sigma = zeros(1,length(EsNodB); for k=1:length(EsNodB) sigma(k) = sqrt( 10.(-EsNodB(k)/10)/2 ); modSigWithNoise = modSig + sigma(k)*randn(1,length(modSig); % EsNodB = 4; % sigma = sqrt( 10.(-EsNodB/10)/2 ); % modSigWithNoise = modSig + sigma*randn(1,len
16、gth(modSig);5. BPSK demodulation %8 samples per Carrier Period demodSig(1+(i-1)*8):i*8)=modSigWithNoise(1+(i-1)*8):6. Frequency demodulation fdemodSig=demodSig.*PNcode;7. Received data RecovData=zeros(1,length(fdemodSig); value=zeros(1,length(fdemodSig)/1024); avg=zeros(1,length(fdemodSig)/1024); fo
17、r j=1:(length(fdemodSig)/1024) avg(j) = 2*sum(fdemodSig(1+(j-1)*1024: j*1024)/1024; %*! integral of sin or cos function need a % multiplication of 2 value(j) = round(avg(j); RecovData(1+(j-1)*1024:j*1024)=value(j); End8. Make judgments. %.Demultiplexing v = reshape(value,4,20); % 4*20 rd = v*walshCo
18、de; % 20*4 matrix rd = rd % 4*20 matrix9. Calculate the error rate of the whole process error = sum(sum(abs(v-s)/2); errorRate = 100*error/sumLength; disp(The error rate of this process is: disp(errorRate);10. Demultiplexing Conclusion Through the simulation of system with and without noise, with an
19、d without spreading spectrum, we can see that if the Es/No is equal, the bit error rate of the system with spreading spectrum is better than the one without spreading spectrum. DSSS has high quality of anti-interference. The DS signal has very wide spectrum, a small fraction of fading could not influence much for the whole signal. DSSS has good ability of multiple addressing.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1