X hits on this document

PDF document

DigitalCommons@University of Nebraska - Lincoln - page 66 / 69

143 views

0 shares

0 downloads

0 comments

66 / 69

Appendix B Matlab Code

%Casey Deyle %Version 1 - proving underlying Direct Sequence Spread Spectrum works %by comparing to BPSK system %Version 2 - Implementing selfencoded spread spectrum on top of Spread %Spectrum %Version 3 - Adding the Jamming signal %Version 4 - Adding selfencoded spread spectrum to jamming and jamming

%

each chip instead of each bit

%Version 5 - Adding irative detector to the self-encoded spread spectrum

%Version 8 - Final clear;

%------------------- Declaring Varibles -----------------------------------

figure; ch_bt=32; % Set the chips/bit increment = 1; %How much you increment the SNR in the loop Max_Eb_No_db=20; %Max SNR, changes graph window as well Bits2Tx = 100000; %How many Bits to transmit BER = zeros(1,floor(Max_Eb_No_db/increment)); %empty BER Eb_No = zeros(1,floor(Max_Eb_No_db/increment)); %empty Eb/No temp = zeros(1,ch_bt); b = zeros(1,ch_bt+1);

jdcnt = [1] ; %jdc=.02; % Set the jamming duty cycle (percent) 20% =

.2, 100%=1, etc.

for z=1:length(jdcnt) jdc = jdcnt(z);

%------------------- Setup ------------------------------------------------ %figure; %crates new figure

arraycounter = 0; %initialize to 0

%for display in Matlab window fprintf('Chips per bit = %g\tBits Transmitted = %g\n',ch_bt,Bits2Tx); fprintf('Max Eb_No = %gdb\tIncrements = %gdb\n',Max_Eb_No_db,increment); fprintf('Jamming Duty Cycle = %g percent\n',jdc*100);

for SNR1=0:increment:Max_Eb_No_db arraycounter = arraycounter+1; Eb_No(arraycounter) = SNR1; fprintf('SNR: %g (',SNR1); %for display in Matlab window SNR = 10*log10(ch_bt)-SNR1; %Adjusts for Processing Gain data_reg_ct = ch_bt+1; data_reg = zeros(ch_bt+1, ch_bt); spread_reg = zeros(ch_bt+1, ch_bt); %--------- Generate the initial bit pattern used for spreading ---- s sig=2.*round(rand(1,ch bt))-1; %random # 1 or -1

_

_

%------------------ ds_sig=s_sig; Errors = 0; BitsTx = 0; hardbit = 0; hardbit1 = 0; %------------------

Set the initial despreading signal -----------

  • -------

    Start Transmitting Bits ----------------

while (BitsTx<Bits2Tx)

57

Document info
Document views143
Page views143
Page last viewedSat Dec 03 03:00:36 UTC 2016
Pages69
Paragraphs1770
Words13793

Comments